@ledgerhq/device-management-kit-devtools-rozenite 0.0.0-develop-20260507002614 → 0.0.0-develop-20260508002748

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -522,7 +522,7 @@ Details
522
522
 
523
523
  ${(function(o){switch(o.kind){case wa.method:return`[class: "${o.targetClass.name}", method: "${o.method.toString()}"]`;case wa.parameter:return`[class: "${o.targetClass.name}", index: "${o.index.toString()}"]`;case wa.property:return`[class: "${o.targetClass.name}", property: "${o.property.toString()}"]`}})(i)}`,{cause:n})}throw n}function Fj(e,t){return(r,n,i)=>{try{i===void 0?(function(o,s){const u=Kv(o,s);return(c,f)=>{Lu(c.constructor,kd,Md,y_(u(c),f))}})(e,t)(r,n):typeof i=="number"?(function(o,s){const u=Kv(o,s);return(c,f,d)=>{if(!(function(g,h){return typeof g=="function"&&h===void 0})(c,f))throw new Aa(vo.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.
524
524
  Found @inject decorator at method "${f?.toString()??""}" at class "${c.constructor.name}"`);Lu(c,kd,Md,(function(g,h){return y=>{const m=y.constructorArguments[h];return y.constructorArguments[h]=g(m),y}})(u(c),d))}})(e,t)(r,n,i):(function(o,s){const u=Kv(o,s);return(c,f,d)=>{if(!(function(g){return g.set!==void 0})(d))throw new Aa(vo.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.
525
- Found @inject decorator at method "${f.toString()}" at class "${c.constructor.name}"`);Lu(c.constructor,kd,Md,y_(u(c),f))}})(e,t)(r,n,i)}catch(o){Lj(r,n,i,o)}}}function Kv(e,t){return r=>{const n=t(r);return i=>(n(i),e(i))}}function tt(e){return Fj(Dj(ec.singleInjection,e),Pj)}(function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"})(wa||(wa={}));const b_="@inversifyjs/core/classIsInjectableFlagReflectKey",Nj=[Array,BigInt,Boolean,Function,Number,Object,String];function jj(e){const t=pb(e,"design:paramtypes");t!==void 0&&Lu(e,kd,Md,(function(r){return n=>(r.forEach(((i,o)=>{var s;n.constructorArguments[o]!==void 0||(s=i,Nj.includes(s))||(n.constructorArguments[o]=(function(u){return{isFromTypescriptParamType:!0,kind:ec.singleInjection,name:void 0,optional:!1,tags:new Map,value:u}})(i))})),n)})(t))}function Et(e){return t=>{(function(r){if(pb(r,b_)!==void 0)throw new Aa(vo.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${r.name}"`);$j(r,b_,!0)})(t),jj(t)}}var S_;(function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection"})(S_||(S_={}));var w_;(function(e){e[e.singleMandatory=0]="singleMandatory",e[e.singleOptional=1]="singleOptional",e[e.multipleMandatory=2]="multipleMandatory",e[e.multipleOptional=3]="multipleOptional",e[e.length=4]="length"})(w_||(w_={}));let zj=class{constructor(t,r,n,i,o){this.deviceModel=t,this.serviceUuid=r,this.writeUuid=n,this.writeCmdUuid=i,this.notifyUuid=o}},Us=class{id;productName;usbProductId;bootloaderUsbProductId;usbOnly;memorySize;getBlockSize;masks;bluetoothSpec;constructor(t){this.id=t.id,this.productName=t.productName,this.usbProductId=t.usbProductId,this.bootloaderUsbProductId=t.bootloaderUsbProductId,this.usbOnly=t.usbOnly,this.memorySize=t.memorySize,this.getBlockSize=t.getBlockSize,this.masks=t.masks,this.bluetoothSpec=t.bluetoothSpec}};var Bj=Object.defineProperty,Vj=(e,t,r)=>t in e?Bj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hj=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Uj=(e,t,r)=>Vj(e,t+"",r);let rs=class{getAllDeviceModels(){return Object.values(rs.deviceModelByIds)}getDeviceModel(t){return rs.deviceModelByIds[t.id]}filterDeviceModels(t){return this.getAllDeviceModels().filter(r=>Object.entries(t).every(([n,i])=>r[n]===i))}getBluetoothServicesInfos(){return Object.values(rs.deviceModelByIds).reduce((t,r)=>{const{bluetoothSpec:n}=r;return n?{...t,...n.reduce((i,o)=>({...i,[o.serviceUuid]:new zj(r,o.serviceUuid,o.writeUuid,o.writeCmdUuid,o.notifyUuid)}),{})}:t},{})}getBluetoothServices(){return Object.values(rs.deviceModelByIds).map(t=>(t.bluetoothSpec||[]).map(r=>r.serviceUuid)).flat().filter(t=>!!t)}};Uj(rs,"deviceModelByIds",{[Yt.NANO_S]:new Us({id:Yt.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>i_.lt(i_.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[Yt.NANO_SP]:new Us({id:Yt.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[Yt.NANO_X]:new Us({id:Yt.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"}]}),[Yt.STAX]:new Us({id:Yt.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"}]}),[Yt.FLEX]:new Us({id:Yt.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"}]}),[Yt.APEX]:new Us({id:Yt.APEX,productName:"Ledger Nano Gen5",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"}]})}),rs=Hj([Et()],rs);let Wj=class{statusCode;data;constructor({statusCode:t,data:r}){this.statusCode=t,this.data=r}};const qj=5,Ja=1,xy=2,ll=2,Ey=2,Fr=[];for(let e=0;e<256;++e)Fr.push((e+256).toString(16).slice(1));function Gj(e,t=0){return(Fr[e[t+0]]+Fr[e[t+1]]+Fr[e[t+2]]+Fr[e[t+3]]+"-"+Fr[e[t+4]]+Fr[e[t+5]]+"-"+Fr[e[t+6]]+Fr[e[t+7]]+"-"+Fr[e[t+8]]+Fr[e[t+9]]+"-"+Fr[e[t+10]]+Fr[e[t+11]]+Fr[e[t+12]]+Fr[e[t+13]]+Fr[e[t+14]]+Fr[e[t+15]]).toLowerCase()}let Yv;const Xj=new Uint8Array(16);function Kj(){if(!Yv){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yv=crypto.getRandomValues.bind(crypto)}return Yv(Xj)}const Yj=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),x_={randomUUID:Yj};function $p(e,t,r){if(x_.randomUUID&&!e)return x_.randomUUID();e=e||{};const n=e.random||(e.rng||Kj)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Gj(n)}const as={getLastBytesFrom(e,t){return e.slice(-t)},getFirstBytesFrom(e,t){return e.slice(0,t)},bytesToNumber(e){return e.reduce((t,r,n)=>t+r*Math.pow(256,e.length-1-n),0)},numberToByteArray(e,t){return new Uint8Array(t).map((r,n)=>e>>8*(t-1-n)&255)}},E_=2,Qv=800;let C_=class{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}},Qj=class{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}},__=class{_tag="ReceiverApduError";originalError;constructor(t){this.originalError=new Error(t??"Unable to parse apdu")}},R_=class{_tag="DeviceSessionNotFound";originalError;constructor(t){this.originalError=t??new Error("Device session not found")}},PI=class{_header;_data;constructor({header:t,data:r}){this._header=t,this._data=r}toString(){return JSON.stringify({header:this._header.toString(),data:Ju(this._data)},null,2)}getRawData(){const t=this._header.getRawData(),r=new Uint8Array(t.length+this._data.length);return r.set(t,0),r.set(this._data,t.length),r}getHeader(){return this._header}getData(){return this._data}},kI=class{_uuid;_channel;_headTag;_index;_length;_dataLength;constructor({uuid:t,dataSize:r,index:n,headTag:i,length:o,channel:s}){this._uuid=t,this._dataLength=r,this._index=n,this._headTag=i,this._length=o,this._channel=s}getDataLength(){return this._dataLength.map(t=>as.bytesToNumber(t))}setDataSize(t){return this._dataLength=t,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:t=>[...t],Nothing:()=>[]}),...this._headTag,...this._index,...this._dataLength.caseOf({Just:t=>[...t],Nothing:()=>[]})])}};const Er={LoggerPublisherServiceFactory:Symbol.for("LoggerPublisherServiceFactory")};var Jj=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Zj=(e,t)=>(r,n)=>t(r,n,e);let O_=class{_channel;_logger;_pendingFrames;constructor({channel:t=Cn.zero()},r){this._channel=t,this._logger=r("ApduReceiverService"),this._pendingFrames=[]}handleFrame(t){return this.getFrameFromBytes(t).map(r=>{if(this._pendingFrames.push(r),!this._pendingFrames[0])return Gt;const n=this._pendingFrames[0].getHeader().getDataLength();return this.getCompleteFrame(n)})}getCompleteFrame(t){return t.chain(r=>{if(!this.isComplete(r))return this._logger.debug("frame is not complete, waiting for more"),Gt;const n=as.getFirstBytesFrom(this.concatFrames(this._pendingFrames),r),i=as.getFirstBytesFrom(n,n.length-E_),o=as.getLastBytesFrom(n,E_);return this._pendingFrames=[],ln(new Wj({data:i,statusCode:o}))})}getFrameFromBytes(t){const r=this._channel.caseOf({Just:()=>xy,Nothing:()=>0}),n=t.slice(r,r+Ja),i=t.slice(r+Ja,r+Ja+ll),o=i.reduce((h,y)=>h+y,0)===0;if(!o&&this._pendingFrames.length===0)return Qr(new __);const s=r+Ja+ll,u=o?Ey:0;if(t.length<r+Ja+ll+u)return Qr(new __("Unable to parse header from apdu"));const c=o?ln(t.slice(s,s+u)):Gt,f=s+u,d=t.slice(f),g=new PI({header:new kI({uuid:$p(),channel:this._channel,dataSize:c,headTag:n,index:i,length:r+Ja+ll+u}),data:d});return Jr(g)}isComplete(t){return this._pendingFrames.reduce((r,n)=>r+n.getData().length,0)>=t}concatFrames(t){return t.reduce((r,n)=>Uint8Array.from([...r,...n.getData()]),new Uint8Array(0))}};O_=Jj([Et(),Zj(1,tt(Er.LoggerPublisherServiceFactory))],O_);var ez=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},tz=(e,t)=>(r,n)=>t(r,n,e);let T_=class{_frameSize;_channel;_padding;_logger;constructor({frameSize:t,channel:r=Cn.zero(),padding:n=!1},i){this._frameSize=t,this._channel=r,this._padding=n,this._logger=i("DefaultApduSenderService")}getFrames(t){const r=[];let n=0,i=this.getFrameAtIndex(t,n);for(;i.isRight();)r.push(i.extract()),n+=1,i=this.getFrameAtIndex(t,n).mapLeft(o=>(o instanceof C_||this._logger.error("Error while parsing frame",{data:{error:o}}),o));return r}getFrameAtIndex(t,r){const n=this.getFrameHeaderFrom(r,t.length),i=r===0?0:r*this._frameSize-this.getHeaderSizeSumFrom(r);if(i>=t.length)return Qr(new C_);if(n.getLength()>this._frameSize)return Qr(new Qj);const o=this._frameSize-n.getLength(),s=t.slice(i,i+this._frameSize-n.getLength()),u=this._padding?new Uint8Array(o).fill(0):new Uint8Array(s.length<o?s.length:o);u.set(s,0);const c=new PI({header:n,data:u});return Jr(c)}getFrameHeaderFrom(t,r){const n=new kI({uuid:$p(),channel:this._channel.map(i=>as.getLastBytesFrom(i,xy)),headTag:new Uint8Array([qj]),index:as.numberToByteArray(t,ll),length:this.getFrameHeaderSizeFromIndex(t),dataSize:Cn.zero()});return t===0&&n.setDataSize(Cn.of(as.numberToByteArray(r,Ey))),n}getHeaderSizeSumFrom(t){let r=this.getFrameHeaderSizeFromIndex(0),n=1;for(;n<t;)r+=this.getFrameHeaderSizeFromIndex(n),n+=1;return r}getFrameHeaderSizeFromIndex(t){return this._channel.caseOf({Just:()=>xy,Nothing:()=>0})+ll+Ja+(t===0?Ey:0)}};T_=ez([Et(),tz(1,tt(Er.LoggerPublisherServiceFactory))],T_);const Cy={LocalConfigDataSource:Symbol.for("LocalConfigDataSource"),RemoteConfigDataSource:Symbol.for("RemoteConfigDataSource"),ConfigService:Symbol.for("ConfigService")},fn={ApduSenderServiceFactory:Symbol.for("ApduSenderServiceFactory"),ApduReceiverServiceFactory:Symbol.for("ApduReceiverServiceFactory"),DeviceSessionService:Symbol.for("DeviceSessionService")},$_={ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase")},Ap={ManagerApiService:Symbol.for("ManagerApiService"),ManagerApiDataSource:Symbol.for("ManagerApiDataSource"),DmkConfig:Symbol.for("ManagerApiDmkConfig")},Ia={DmkConfig:Symbol.for("TransportDmkConfig"),TransportService:Symbol.for("TransportService"),TransportsInput:Symbol.for("TransportsInput")};var rz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},A_=(e,t)=>(r,n)=>t(r,n,e);let I_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("SendCommandUseCase")}async execute({sessionId:t,command:r,abortTimeout:n}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:async i=>await i.sendCommand(r,n),Left:i=>{throw this._logger.error("Error getting session",{data:{error:i}}),i}})}};I_=rz([Et(),A_(0,tt(fn.DeviceSessionService)),A_(1,tt(Er.LoggerPublisherServiceFactory))],I_);var nz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let P_=class{execute=vi.fn(()=>"stub")};P_=nz([Et()],P_);var iz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},k_=(e,t)=>(r,n)=>t(r,n,e);let M_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("ExecuteDeviceActionUseCase")}execute({sessionId:t,deviceAction:r}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:n=>n.executeDeviceAction(r),Left:n=>{throw this._logger.error("Error getting session",{data:{error:n}}),n}})}};M_=iz([Et(),k_(0,tt(fn.DeviceSessionService)),k_(1,tt(Er.LoggerPublisherServiceFactory))],M_);function oz(e){return typeof e=="object"&&e!==null&&"version"in e&&"name"in e&&typeof e.version=="string"&&typeof e.name=="string"}let D_=class{constructor(t){this.err=t,this.originalError=t}_tag="ApiCallError";originalError},az=class{constructor(t){this.err=t,this.originalError=t}_tag="ParseResponseError";originalError},MI=class{constructor(t){this.err=t,this.originalError=t}_tag="JSONParseError";originalError},sz=class{constructor(t){this.err=t,this.originalError=t}_tag="ReadFileError";originalError};const lz="@ledgerhq/device-management-kit",uz="0.0.0-develop-20260507002614",L_={name:lz,version:uz};var cz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};const fz={name:L_.name,version:L_.version},dz=()=>JSON.stringify(fz);let F_=class{getConfig(){return Wn.encase(()=>dz()).mapLeft(t=>new sz(t)).chain(t=>Wn.encase(()=>{const r=JSON.parse(t);if(oz(r))return r;throw new Error("Invalid config file")}).mapLeft(r=>new MI(r)))}};F_=cz([Et()],F_);var pz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let N_=class{getConfig(){return Wn.of({name:"DeviceSDK",version:"0.0.0-stub.1"})}};N_=pz([Et()],N_);var hz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let j_=class{async getConfig(){const t=await this._callApi();if(t.isLeft())return Qr(new D_(t.extract()));if(!t.extract().ok)return Qr(new D_(new Error("response not ok")));const r=await t.extract().json();return r.isLeft()?Qr(new MI):r.chain(n=>this._parseResponse(n)).map(n=>n)}_parseResponse(t){const{name:r,version:n}=t;return!r||!n?Qr(new az):Wn.of({name:r,version:n})}_callApi(){return new Promise(t=>{t(Wn.of({ok:!0,json:async()=>new Promise(r=>{r(Wn.of({name:"DeviceSDK",version:"0.0.0-fake.1",yolo:"yolo"}))})}))})}};j_=hz([Et()],j_);var gz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let z_=class{async getConfig(){return new Promise(t=>t(Wn.of({name:"DeviceSDK",version:"0.0.0-fake.2"})))}};z_=gz([Et()],z_);var vz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Jv=(e,t)=>(r,n)=>t(r,n,e);let B_=class{_local;_remote;_logger;constructor(t,r,n){this._local=t,this._remote=r,this._logger=n("config")}async getDmkConfig(){const t=this._local.getConfig().ifLeft(r=>{this._logger.error("Local config not available",{data:{error:r}})});if(t.isRight()){const r=t.extract();return this._logger.info("Local config available",{data:{config:r}}),r}return this._remote.getConfig().then(r=>r.mapLeft(n=>(this._logger.error("Local config available",{data:{error:n}}),{name:"DeadDmk",version:"0.0.0-dead.1"})).extract())}};B_=vz([Et(),Jv(0,tt(Cy.LocalConfigDataSource)),Jv(1,tt(Cy.RemoteConfigDataSource)),Jv(2,tt(Er.LoggerPublisherServiceFactory))],B_);var mz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},yz=(e,t)=>(r,n)=>t(r,n,e);let V_=class{_configService;constructor(t){this._configService=t}async getDmkVersion(){return(await this._configService.getDmkConfig()).version}};V_=mz([Et(),yz(0,tt(Cy.ConfigService))],V_);const bz={DeviceModelDataSource:Symbol.for("DeviceModelDataSource")};var Sz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},H_=(e,t)=>(r,n)=>t(r,n,e);let U_=class{constructor(t,r){this._sessionService=t,this._logger=r("DisableDeviceSessionRefresherUseCase")}_logger;execute({sessionId:t,blockerId:r}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:n=>{throw this._logger.error("Error getting device session",{data:{error:n}}),n},Right:n=>n.disableRefresher(r)})}};U_=Sz([Et(),H_(0,tt(fn.DeviceSessionService)),H_(1,tt(Er.LoggerPublisherServiceFactory))],U_);var wz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},xz=(e,t)=>(r,n)=>t(r,n,e);let W_=class{_sessions;_sessionsSubject;_logger;constructor(t){this._sessions=[],this._sessionsSubject=new dI,this._logger=t("DeviceSessionService")}get sessionsObs(){return this._sessionsSubject.asObservable()}addDeviceSession(t){return this._sessions.find(r=>r.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){const r=this._sessions.find(n=>n.id===t);return r?(r.close(),this._sessions=this._sessions.filter(n=>n.id!==t),this._logger.info("DeviceSession removed",{data:{sessionId:t}}),this):(this._logger.warn("DeviceSession not found",{data:{sessionId:t}}),this)}getDeviceSessionById(t){return Cn.fromNullable(this._sessions.find(r=>r.id===t)).toEither(new R_)}getDeviceSessionsByDeviceId(t){return Cn.fromPredicate(({length:r})=>r>0,this._sessions.filter(r=>r.connectedDevice.id===t)).toEither(new R_)}getDeviceSessions(){return this._sessions}};W_=wz([Et(),xz(0,tt(Er.LoggerPublisherServiceFactory))],W_);var Ez=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},q_=(e,t)=>(r,n)=>t(r,n,e);let G_=class{_sessionService;_transportService;constructor(t,r){this._sessionService=t,this._transportService=r}execute(){const t=this._sessionService.getDeviceSessions();for(const r of t)this._transportService.closeConnection(r.connectedDevice),this._sessionService.removeDeviceSession(r.id)}};G_=Ez([Et(),q_(0,tt(fn.DeviceSessionService)),q_(1,tt(Ia.TransportService))],G_);var Cz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},X_=(e,t)=>(r,n)=>t(r,n,e);let K_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("GetDeviceSessionStateUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:r=>{throw this._logger.error("Error getting session device",{data:{error:r}}),r},Right:r=>r.state})}};K_=Cz([Et(),X_(0,tt(fn.DeviceSessionService)),X_(1,tt(Er.LoggerPublisherServiceFactory))],K_);var _z=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Y_=(e,t)=>(r,n)=>t(r,n,e);let Q_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("UnsafeBypassIntentQueueUseCase")}execute({sessionId:t,bypass:r}){this._sessionService.getDeviceSessionById(t).caseOf({Left:n=>{throw this._logger.error("Error getting session",{data:{error:n}}),n},Right:n=>{this._logger.warn(`UNSAFE: ${r?"Enabling":"Disabling"} intent queue bypass for session ${t}`),n._unsafeBypassIntentQueue(r)}})}};Q_=_z([Et(),Y_(0,tt(fn.DeviceSessionService)),Y_(1,tt(Er.LoggerPublisherServiceFactory))],Q_);function Rz(e){return`[will send APDU] ~...> ${Ju(e,!1)}`}function Oz(e){return`[exchange] <= ${Ju(e.data,!1)}${Ju(e.statusCode,!1)}`}const _y=1e3,Zv=1e3,Tz={isRefresherDisabled:!1,pollingInterval:1e3};var ur=(e=>(e.NEW_STATE="NEW_STATE",e.REFRESH_NEEDED="REFRESH_NEEDED",e.COMMAND_SUCCEEDED="COMMAND_SUCCEEDED",e.DEVICE_STATE_UPDATE_BUSY="DEVICE_STATE_UPDATE_BUSY",e.DEVICE_STATE_UPDATE_LOCKED="DEVICE_STATE_UPDATE_LOCKED",e.DEVICE_STATE_UPDATE_CONNECTED="DEVICE_STATE_UPDATE_CONNECTED",e.DEVICE_STATE_UPDATE_UNKNOWN="DEVICE_STATE_UPDATE_UNKNOWN",e))(ur||{});let $z=class{_eventEmitter=new Dl;listen(){return this._eventEmitter.asObservable()}dispatch(t){this._eventEmitter.next(t)}},Az=class{constructor(t,r){this.loggerModuleFactory=t,this.sessionEventDispatcher=r,this._logger=this.loggerModuleFactory("IntentQueueService")}_logger;_queue=[];_isProcessing=!1;_currentSubscription=null;enqueue(t){this._logger.debug("Enqueueing intent",{data:{type:t.type}});const r=new Dl,n={intent:t,subject:r,isCancelled:!1};this._queue.push(n);const i=()=>{this._logger.debug("Cancelling intent",{data:{type:t.type}}),n.isCancelled=!0,this._queue[0]===n&&this._currentSubscription?(this._currentSubscription.unsubscribe(),this._currentSubscription=null,r.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue()):(!this._isProcessing||this._queue[0]!==n)&&r.complete()};return this._isProcessing||this._processQueue(),{observable:r.asObservable().pipe(hj(()=>{this._logger.debug("Intent observable finalized",{data:{type:t.type}})})),cancel:i}}_processQueue(){if(this._isProcessing)return;if(this._queue.length===0){this.sessionEventDispatcher.dispatch({eventName:ur.NEW_STATE});return}this.sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_BUSY}),this._isProcessing=!0;const t=this._queue[0];if(t.isCancelled){this._logger.debug("Skipping cancelled intent",{data:{type:t.intent.type}}),t.subject.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue();return}this._logger.debug("Processing intent",{data:{type:t.intent.type}}),this._currentSubscription=t.intent.execute().subscribe({next:r=>{t.isCancelled||t.subject.next(r)},error:r=>{t.isCancelled||t.subject.error(r),this._onIntentComplete()},complete:()=>{t.isCancelled||t.subject.complete(),this._onIntentComplete()}})}_onIntentComplete(){this._logger.debug("Intent completed"),this._currentSubscription=null,this._queue.shift(),this._isProcessing=!1,this._processQueue()}},Iz=class{constructor(t,r){this._refresher=r,this._logger=t("refresher-service")}_refresherBlockers=new Set;_logger;disableRefresher(t){const r=`${t}-${$p()}`;this.addRefresherBlocker(r),this._logger.debug("Refresher disabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}});let n=!1;return()=>{n||(n=!0,this.removeRefresherBlocker(r),this._logger.debug("Refresher re-enabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}}))}}addRefresherBlocker(t){const r=this._refresherBlockers.size;this._refresherBlockers.add(t),r===0&&this._refresher.stop()}removeRefresherBlocker(t){const r=this._refresherBlockers.size;this._refresherBlockers.delete(t),r>0&&this._refresherBlockers.size===0&&this._refresher.start()}},Pz=class{constructor(t,r,n,i){this.connectedDevice=r,this._sessionEventDispatcher=n,this._sendCommandFunction=i,this._logger=t("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(t){return this._logger.error("Error while pinging device",{data:{error:t}}),null}}mapEventAction=async t=>{switch(t.eventName){case ur.REFRESH_NEEDED:return await this.ping();default:return null}};async mapDevicePingAction(t){switch(t){case Yt.NANO_S:{const r=async()=>{const o=await this._sendCommandFunction(new dC,Qv);return this._sendCommandFunction(new S4,Qv),o},n=new Promise(o=>{setTimeout(()=>o(null),_y*2+100)}),i=await Promise.race([r(),n]);return i?this._sessionEventDispatcher.dispatch({eventName:ur.COMMAND_SUCCEEDED,eventData:i}):this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_LOCKED}),i}default:{const r=await this._sendCommandFunction(new dC,Qv);return this._sessionEventDispatcher.dispatch({eventName:ur.COMMAND_SUCCEEDED,eventData:r}),r}}}unsubscribe(){this._subscription.unsubscribe()}},kz=class{constructor(t,r,n,i){this._sessionEventDispatcher=n,this._refresherOptions=r,this._logger=t("device-session-refresher"),this._connectedDeviceID=i.deviceModel.id}_refresherSubscription;_refresherOptions;_logger;_connectedDeviceID;startRefresher(){if(this._refresherOptions.isRefresherDisabled||this._refresherSubscription)return;const t=this.getValidPollingInterval(this._refresherOptions,this._logger)*2,r=this._sessionEventDispatcher.listen().pipe(p_(n=>n.eventName===ur.DEVICE_STATE_UPDATE_BUSY||n.eventName===ur.NEW_STATE),$a(n=>n.eventName===ur.DEVICE_STATE_UPDATE_BUSY),vj(!1),dj());this._refresherSubscription=uj(0,t).pipe(mj(r),h_(([n,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),p_(([n,i])=>!i),h_(()=>this._sessionEventDispatcher.dispatch({eventName:ur.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=(t,r)=>{const{pollingInterval:n}=t;switch(this._connectedDeviceID){case Yt.NANO_S:{const i=_y*2;return n!==void 0&&n<i?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${i}`),i):n??i}default:return n!==void 0&&n<Zv?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${Zv}`),Zv):n??_y}}},Mz=class{constructor(t,r,n,i,o){this._sessionEventDispatcher=r,this._connectedDevice=n,this._deviceState=i,this.setDeviceSessionState=o,this._subscription=this._sessionEventDispatcher.listen().subscribe(s=>this.mapEventAction(s)),this._logger=t("device-session-state-handler")}_subscription;_logger;_pendingDeviceStatus=uo.BUSY;_updateDeviceState(t){const r=this._parseDeviceStatus(t);if(r){const{sessionStateType:n,deviceStatus:i,currentApp:o}=r,s=this._deviceState.getValue();s.sessionStateType===Zu.Connected?this.setDeviceSessionState({sessionStateType:n,deviceStatus:i,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o,installedApps:[],isSecureConnectionAllowed:!1}):this.setDeviceSessionState({...s,sessionStateType:n,deviceStatus:i,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o})}}mapEventAction=t=>{const{eventName:r}=t;switch(r){case ur.COMMAND_SUCCEEDED:return this._updateDeviceState(t.eventData);case ur.DEVICE_STATE_UPDATE_BUSY:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:uo.BUSY});case ur.DEVICE_STATE_UPDATE_LOCKED:this._pendingDeviceStatus=uo.LOCKED;return;case ur.DEVICE_STATE_UPDATE_CONNECTED:this._pendingDeviceStatus=uo.CONNECTED;return;case ur.NEW_STATE:{const n=this._pendingDeviceStatus;return this._pendingDeviceStatus=uo.BUSY,this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:n})}case ur.DEVICE_STATE_UPDATE_UNKNOWN:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:uo.BUSY});case ur.REFRESH_NEEDED:return;default:{const n=r;throw new Error(`Unhandled context type ${n}`)}}};_parseDeviceStatus(t){return B3(t)?{sessionStateType:Zu.ReadyWithoutSecureChannel,deviceStatus:uo.CONNECTED,currentApp:{name:t.data.name,version:t.data.version}}:(this._logger.debug("Error while parsing APDU response",{data:{parsedResponse:t}}),null)}unsubscribe(){this._subscription.unsubscribe()}},Dz=class{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new $z;_bypassIntentQueue=!1;constructor({connectedDevice:t,id:r=$p()},n,i,o,s,u=c=>new Az(n,c)){this._id=r,this._connectedDevice=t,this._loggerModuleFactory=n,this._logger=n("device-session"),this._managerApiService=i,this._intentQueueService=u(this._sessionEventDispatcher),this._secureChannelService=o,this._refresherOptions={...Tz,...s},this._deviceState=new F4({sessionStateType:Zu.Connected,deviceStatus:uo.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new Pz(n,t,this._sessionEventDispatcher,(c,f)=>this.sendCommand(c,f)),this._deviceSessionRefresher=new kz(n,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new Mz(n,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new Iz(n,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(t){throw this._logger.error("Error while initialising session",{data:{error:t}}),t}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(t){this._deviceState.next(t)}sendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(t,r):this._internalSendApdu(t,r)}_internalSendApdu(t,r){const n=r.abortTimeout,i=Date.now(),{observable:o,cancel:s}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>wl((async()=>{const c=Date.now()-i;return await this._unsafeInternalSendApdu(t,{isPolling:r.isPolling,triggersDisconnection:r.triggersDisconnection,abortTimeout:n?n-c:void 0})})())}),u=n?o.pipe(f_({each:n,with:()=>{throw s(),new yj}})):o;return c_(u)}async _unsafeInternalSendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug(Rz(t)),(await this._connectedDevice.sendApdu(t,r.triggersDisconnection,r.abortTimeout)).ifRight(n=>{this._logger.debug(Oz(n)),Y1.isLockedDeviceResponse(n)?this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(t,r){return this._logger.debug(`[sendCommand] ${t.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(t,r):this._internalSendCommand(t,r)}_internalSendCommand(t,r){const n=Date.now(),{observable:i,cancel:o}=this._intentQueueService.enqueue({type:"send-command",execute:()=>wl((async()=>{const u=Date.now()-n;return await this._unsafeInternalSendCommand(t,r?r-u:void 0)})())}),s=r?i.pipe(f_({each:r,with:()=>{throw o(),new bj}})):i;return c_(s)}async _unsafeInternalSendCommand(t,r){const n=t.getApdu();return(await this._unsafeInternalSendApdu(n.getRawApdu(),{isPolling:!1,triggersDisconnection:t.triggersDisconnection??!1,abortTimeout:r})).caseOf({Left:i=>{throw this._logger.error("[sendCommand] error",{data:{err:i}}),i},Right:i=>{const o=t.parseResponse(i,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(t){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(t):this._internalExecuteDeviceAction(t)}_internalExecuteDeviceAction(t){let r;const{observable:n,cancel:i}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:o,cancel:s}=this._unsafeInternalExecuteDeviceAction(t);return r=s,o}});return{observable:n,cancel:()=>{r?.(),i()}}}_unsafeInternalExecuteDeviceAction(t){const{observable:r,cancel:n}=t._execute({sendApdu:async i=>this._unsafeInternalSendApdu(i),sendCommand:async i=>this._unsafeInternalSendCommand(i),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:r,cancel:n}}close(){this._updateDeviceStatus(uo.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(t){return this._refresherService.disableRefresher(t)}_unsafeBypassIntentQueue(t){this._bypassIntentQueue=t}_updateDeviceStatus(t){const r=this._deviceState.getValue();this._deviceState.next({...r,deviceStatus:t})}};const hb={SecureChannelService:Symbol.for("SecureChannelService"),SecureChannelDataSource:Symbol.for("SecureChannelDataSource"),DmkConfig:Symbol.for("SecureChannelDmkConfig")};var Lz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},mu=(e,t)=>(r,n)=>t(r,n,e);let J_=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(t,r,n,i,o){this._sessionService=r,this._transportService=t,this._loggerFactory=n,this._logger=n("ConnectUseCase"),this._managerApi=i,this._secureChannel=o}handleDeviceDisconnect(t){this._sessionService.getDeviceSessionsByDeviceId(t).ifRight(r=>{r.forEach(n=>{this._sessionService.removeDeviceSession(n.id),this._logger.info("Session removed",{data:{deviceId:t,sessionId:n.id}})})})}async execute({device:t,sessionRefresherOptions:r}){const n=this._transportService.getTransport(t.transport),i="sessionId"in t?t.sessionId:void 0;return gt.liftEither(n.toEither(new db(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:t.id,onDisconnect:s=>this.handleDeviceDisconnect(s)})).ifLeft(o=>{this._logger.error("Error connecting to device")}).map(async o=>{const s=new Dz({connectedDevice:o,id:i},this._loggerFactory,this._managerApi,this._secureChannel,r);return this._sessionService.addDeviceSession(s),await s.initialiseSession(),s.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};J_=Lz([Et(),mu(0,tt(Ia.TransportService)),mu(1,tt(fn.DeviceSessionService)),mu(2,tt(Er.LoggerPublisherServiceFactory)),mu(3,tt(Ap.ManagerApiService)),mu(4,tt(hb.SecureChannelService))],J_);var Fz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},em=(e,t)=>(r,n)=>t(r,n,e);let Z_=class{_transportService;_sessionService;_logger;constructor(t,r,n){this._sessionService=r,this._transportService=t,this._logger=n("DisconnectUseCase")}async execute({sessionId:t}){return this._logger.debug("Disconnecting from device",{data:{test:this._sessionService.getDeviceSessions().map(r=>r.id)}}),gt(async({liftEither:r})=>{const n=await r(this._sessionService.getDeviceSessionById(t).ifLeft(s=>{this._logger.error("Device session not found",{data:{sessionId:t,error:s}})})),i=n.connectedDevice.transport,o=await r(this._transportService.getTransport(i).toEither(new db(new Error("Unknown transport"))));n.close(),this._sessionService.removeDeviceSession(t),await o.disconnect({connectedDevice:n.connectedDevice})}).caseOf({Left:r=>{throw this._logger.error("Error disconnecting from device",{data:{error:r}}),r},Right:()=>{}})}};Z_=Fz([Et(),em(0,tt(Ia.TransportService)),em(1,tt(fn.DeviceSessionService)),em(2,tt(Er.LoggerPublisherServiceFactory))],Z_);let gb=class{id;sessionId;modelId;name;type;transport;constructor({transportConnectedDevice:{id:t,deviceModel:{id:r,productName:n},type:i,transport:o,name:s},sessionId:u}){this.id=t,this.sessionId=u,this.modelId=r,this.name=s??n,this.type=i,this.transport=o}};var Nz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},eR=(e,t)=>(r,n)=>t(r,n,e);let tR=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("GetConnectedDeviceUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:r=>new gb({sessionId:r.id,transportConnectedDevice:r.connectedDevice}),Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r}})}};tR=Nz([Et(),eR(0,tt(fn.DeviceSessionService)),eR(1,tt(Er.LoggerPublisherServiceFactory))],tR);var jz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},rR=(e,t)=>(r,n)=>t(r,n,e);let nR=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("ListConnectedDeviceUseCase")}execute(){return this._logger.info("Listing connected devices"),this._sessionService.getDeviceSessions().map(t=>new gb({transportConnectedDevice:t.connectedDevice,sessionId:t.id}))}};nR=jz([Et(),rR(0,tt(fn.DeviceSessionService)),rR(1,tt(Er.LoggerPublisherServiceFactory))],nR);var zz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},iR=(e,t)=>(r,n)=>t(r,n,e);let oR=class{_transports;_transportService;_logger;constructor(t,r){this._transports=t.getAllTransports(),this._transportService=t,this._logger=r("ListenToAvailableDevicesUseCase")}mapTransportDiscoveredDeviceToDiscoveredDevice(t){const r=new tI({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:r,transport:t.transport,name:t.name||r.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"),wl([[]]);if(!t){this._logger.info("Discovering all available transports");const r=this._transports.map((n,i)=>n.listenToAvailableDevices().pipe($a(o=>({index:i,arr:o}))));return cj(...r).pipe(gj((n,{index:i,arr:o})=>(n[i]=o,n),{}),$a(n=>Object.values(n).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`),TI([])),Just:r=>r.listenToAvailableDevices().pipe($a(n=>n.map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))})}};oR=zz([Et(),iR(0,tt(Ia.TransportService)),iR(1,tt(Er.LoggerPublisherServiceFactory))],oR);var Bz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},aR=(e,t)=>(r,n)=>t(r,n,e);let sR=class{constructor(t,r){this._sessionService=t,this._logger=r("ListenToConnectedDeviceUseCase")}_logger;execute(){return this._logger.info("Observe connected devices"),this._sessionService.sessionsObs.pipe($a(t=>new gb({transportConnectedDevice:t.connectedDevice,sessionId:t.id})))}};sR=Bz([Et(),aR(0,tt(fn.DeviceSessionService)),aR(1,tt(Er.LoggerPublisherServiceFactory))],sR);var Vz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},tm=(e,t)=>(r,n)=>t(r,n,e);let lR=class{constructor(t,r,n){this.connectUseCase=t,this.disconnectUseCase=r,this._logger=n("ReconnectUseCase")}_logger;async execute({device:t,sessionRefresherOptions:r}){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:r})}};lR=Vz([Et(),tm(0,tt($_.ConnectUseCase)),tm(1,tt($_.DisconnectUseCase)),tm(2,tt(Er.LoggerPublisherServiceFactory))],lR);var Hz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Uz=(e,t)=>(r,n)=>t(r,n,e);let uR=class{constructor(t){this._transportService=t}mapDiscoveredDevice(t){const r=new tI({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:r,transport:t.transport,name:t.name||r.name,rssi:t.rssi}}execute({transport:t}={}){if(!t){const r=this._transportService.getAllTransports();return TI(...r).pipe(fb(n=>n.startDiscovering().pipe($a(i=>this.mapDiscoveredDevice(i)))))}return this._transportService.getTransport(t).caseOf({Just:r=>r.startDiscovering().pipe($a(n=>this.mapDiscoveredDevice(n))),Nothing:()=>{throw new db(new Error("Unknown transport"))}})}};uR=Hz([Et(),Uz(0,tt(Ia.TransportService))],uR);var Wz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},cR=(e,t)=>(r,n)=>t(r,n,e);let fR=class{constructor(t,r){this.transportService=t,this._logger=r("StopDiscoveringUseCase")}_logger;async execute(){this._logger.debug("Stopping discovering devices");for(const t of this.transportService.getAllTransports())await t.stopDiscovering()}};fR=Wz([Et(),cR(0,tt(Ia.TransportService)),cR(1,tt(Er.LoggerPublisherServiceFactory))],fR);var Ru=(e=>(e[e.Fatal=0]="Fatal",e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Info=3]="Info",e[e.Debug=4]="Debug",e))(Ru||{});let qz=class{format(t){return Array.isArray(t)?t.map(r=>`[${r}]`).join(" "):`[${t}]`}};function Ry(e,t){if(typeof e=="bigint")return e.toString();if(Array.isArray(e))return t.has(e)?"[Circular]":(t.add(e),e.map(r=>Ry(r,t)));if(e!==null&&typeof e=="object"){if(t.has(e))return"[Circular]";t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=Ry(i,t);return r}return e}function Gz(e){const t=new WeakSet;t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=Ry(i,t);return r}var Xz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let dR=class{subscribers;tag;tagFormatter;constructor(t,r,n=new qz){this.subscribers=t,this.tag=r,this.tagFormatter=n}_log(t,r,n){const i=n?.data?Gz(n.data):void 0,o=n?.tag??this.tag,s=this.tagFormatter.format(o);this.subscribers.forEach(u=>{const c={timestamp:n?.timestamp??Date.now(),tag:s,data:i};u.log(t,r,c)})}info(t,r){this._log(Ru.Info,t,r)}warn(t,r){this._log(Ru.Warning,t,r)}debug(t,r){this._log(Ru.Debug,t,r)}error(t,r){this._log(Ru.Error,t,r)}};dR=Xz([Et()],dR);let tc=class extends Error{status;statusText;responseBody;isTimeout;isAbort;cause;constructor(t){super(t.message),this.name="DmkNetworkClientError",this.status=t.status,this.statusText=t.statusText,this.responseBody=t.responseBody,this.isTimeout=t.isTimeout??!1,this.isAbort=t.isAbort??!1,this.cause=t.cause}};const Kz="application/json";function Yz(e,t){if(!t)return e;const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function Qz(e){const t=[];for(const[r,n]of Object.entries(e))n!=null&&t.push(`${encodeURIComponent(r)}=${encodeURIComponent(String(n))}`);return t.join("&")}function Jz(e){const{url:t,params:r,baseUrl:n}=e,i=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:n?Yz(n,t):t,o=r?Qz(r):"";if(o.length===0)return new URL(i);const s=i.includes("?")?"&":"?";return new URL(`${i}${s}${o}`)}function Zz(e,t){const r=t.toLowerCase();return Object.keys(e).some(n=>n.toLowerCase()===r)}function e8(e){return!!(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<"u"&&e instanceof Blob||typeof FormData<"u"&&e instanceof FormData||typeof URLSearchParams<"u"&&e instanceof URLSearchParams||typeof ReadableStream<"u"&&e instanceof ReadableStream)}function t8(e){const{method:t,body:r,defaultHeaders:n,perRequestHeaders:i}=e,o={...n,...i};return r===void 0||t==="GET"||t==="HEAD"?{body:void 0,headers:o}:e8(r)?{body:r,headers:o}:(Zz(o,"content-type")||(o["Content-Type"]=Kz),{body:JSON.stringify(r),headers:o})}function r8(e){const{timeoutMs:t,externalSignal:r}=e,n=t&&t>0?AbortSignal.timeout(t):void 0;return n&&r?AbortSignal.any([r,n]):n??r}async function n8(e,t){switch(t){case"void":return;case"text":return await e.text();case"blob":return await e.blob();case"arrayBuffer":return await e.arrayBuffer();case"json":default:{const r=await e.text();if(r.length===0)return;try{return JSON.parse(r)}catch(n){throw new tc({message:"Failed to parse JSON response body",status:e.status,statusText:e.statusText,responseBody:r,cause:n})}}}}async function i8(e){try{return await e.text()}catch{return}}function o8(e){const{cause:t,externalSignal:r,timeoutMs:n}=e,i=!!(n&&n>0);if(t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")){const o=r?.aborted??!1,s=!o&&(t.name==="TimeoutError"||i);return new tc({message:s?"Request timed out":"Request aborted",isTimeout:s,isAbort:o,cause:t})}return new tc({message:t instanceof Error?t.message:"Network request failed",cause:t})}let a8=class{baseUrl;defaultHeaders;fetchImpl;constructor(t={}){this.baseUrl=t.baseUrl,this.defaultHeaders=t.headers??{},this.fetchImpl=t.fetch}getFetch(){return this.fetchImpl??globalThis.fetch.bind(globalThis)}get(t,r){return this.request({...r,method:"GET",url:t}).then(n=>n.data)}post(t,r,n){return this.request({...n,method:"POST",url:t,body:r}).then(i=>i.data)}put(t,r,n){return this.request({...n,method:"PUT",url:t,body:r}).then(i=>i.data)}patch(t,r,n){return this.request({...n,method:"PATCH",url:t,body:r}).then(i=>i.data)}delete(t,r){return this.request({...r,method:"DELETE",url:t}).then(n=>n.data)}head(t,r){return this.request({...r,method:"HEAD",url:t,responseType:"void"}).then(()=>{})}async request(t){const r=Jz({url:t.url,params:t.params,baseUrl:this.baseUrl}),{body:n,headers:i}=t8({method:t.method,body:t.body,defaultHeaders:this.defaultHeaders,perRequestHeaders:t.headers}),o=r8({timeoutMs:t.timeoutMs,externalSignal:t.signal}),s=t.throwOnHttpError??!0,u=t.responseType??"json";let c;try{c=await this.getFetch()(r.toString(),{method:t.method,headers:i,body:n,signal:o})}catch(f){throw o8({cause:f,externalSignal:t.signal,timeoutMs:t.timeoutMs})}if(!c.ok&&s){const f=await i8(c);throw new tc({message:`HTTP error ${c.status} ${c.statusText}`.trim(),status:c.status,statusText:c.statusText,responseBody:f})}return{data:await n8(c,u),status:c.status,statusText:c.statusText,headers:c.headers,ok:c.ok}}};var Ou=(e=>(e.currency="currency",e.plugin="plugin",e.tool="tool",e.swap="swap",e))(Ou||{});const s8=1,l8="0";let ep=class{constructor(t){this.error=t,this.originalError=t}_tag="FetchError";originalError};var Tu=(e=>(e.currency="currency",e.plugin="plugin",e.tool="tool",e.swap="swap",e))(Tu||{}),u8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},c8=(e,t)=>(r,n)=>t(r,n,e);const Vo=e=>e instanceof tc&&e.cause!==void 0?new ep(e.cause):new ep(e);let pR=class{http;_provider=s8;_firmwareDistributionSalt=l8;constructor({managerApiUrl:t,provider:r,firmwareDistributionSalt:n}){this.http=new a8({baseUrl:t}),this._provider=r,this._firmwareDistributionSalt=n}setProvider(t){this._provider===t||t<1||(this._provider=t)}getProvider(){return this._provider}getAppList(t){const{targetId:r,firmwareVersionName:n}=t;return gt(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:n}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(Vo)}getMcuList(){return gt(()=>this.http.get("/mcu_versions")).chain(t=>this.mapMcuDtoToMcu(t)).mapLeft(Vo)}getDeviceVersion(t){const{targetId:r}=t;return gt(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(n=>this.mapDeviceVersionDto(n)).mapLeft(Vo)}getFirmwareVersion(t){const{deviceId:r,version:n}=t;return gt(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:n,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(Vo)}getFirmwareVersionById(t){return gt(()=>this.http.get(`/firmware_final_versions/${t}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(Vo)}getOsuFirmwareVersion(t){const{deviceId:r,version:n}=t;return gt(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:n,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(Vo)}getLatestFirmwareVersion(t){const r="34.27.0",{currentFinalFirmwareId:n,deviceId:i}=t;return gt(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:n,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(o=>this.mapLatestFirmwareDto(o)).mapLeft(Vo)}getAppsByHash(t){const{hashes:r}=t;return gt(()=>this.http.post("/v2/apps/hash",r)).chain(n=>this.mapNullableApplicationDtoToApplication(n)).mapLeft(Vo)}getLanguagePackages(t){const{deviceId:r,currentFinalFirmwareId:n}=t;return gt(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:n}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(Vo)}mapAppTypeDtoToAppType(t){if(t===null)return null;switch(t){case Tu.currency:return Ou.currency;case Tu.plugin:return Ou.plugin;case Tu.tool:return Ou.tool;case Tu.swap:return Ou.swap}}mapApplicationDtoToApplication(t){return gt(()=>Promise.resolve(t.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(t){return gt(()=>Promise.resolve(t.map(r=>r===null?null:this.mapApplicationDto(r))))}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)}`);const{applicationType:r,hash:n,perso:i,firmware:o,firmwareKey:s,delete:u,deleteKey:c,...f}=t;return{...f,hash:n,perso:i,firmware:o,firmwareKey:s,delete:u,deleteKey:c,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(t){return gt(()=>Promise.resolve(t.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name}})))}mapDeviceVersionDto(t){return gt(()=>{if(typeof t!="object"||typeof t.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(t)}`);const r={id:t.id};return Promise.resolve(r)})}mapFinalFirmwareDto(t){return gt(()=>{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)}`);const r={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(r)})}mapLatestFirmwareDto(t){return gt(()=>{if(t.result!=="success"||!t.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${t.result}`);const r=t.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>this.mapOsuFirmwareDto(r))}mapOsuFirmwareDto(t){return gt(()=>{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)}`);const r={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(r)})}mapLanguagesDtoToLanguages(t){return gt(()=>Promise.resolve(t.map(r=>this.mapLanguageDto(r))))}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}}};pR=u8([Et(),c8(0,tt(Ap.DmkConfig))],pR);var f8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},d8=(e,t)=>(r,n)=>t(r,n,e);let hR=class{constructor(t){this.dataSource=t}getAppList(t){const r={targetId:t.targetId.toString(),firmwareVersionName:t.seVersion};return this.dataSource.getAppList(r)}getDeviceVersion(t){const r={targetId:t.targetId.toString()};return this.dataSource.getDeviceVersion(r)}getFirmwareVersion(t,r){const n={version:t.seVersion,deviceId:r.id};return this.dataSource.getFirmwareVersion(n)}getOsuFirmwareVersion(t,r){const n={version:t.seVersion,deviceId:r.id};return this.dataSource.getOsuFirmwareVersion(n)}getLatestFirmwareVersion(t,r){const n={currentFinalFirmwareId:t.id,deviceId:r.id};return this.dataSource.getLatestFirmwareVersion(n)}getNextFirmwareVersion(t){return this.dataSource.getFirmwareVersionById(t.nextFinalFirmware)}getLanguagePackages(t,r){const n={deviceId:t.id,currentFinalFirmwareId:r.id};return this.dataSource.getLanguagePackages(n)}getMcuList(){return this.dataSource.getMcuList()}getAppsByHash(t){const r={hashes:t};return gt(async({fromPromise:n,throwE:i})=>{if(r.hashes.length===0)return[];try{return await n(this.dataSource.getAppsByHash(r))}catch(o){return o instanceof ep?i(o):i(new ep(o))}})}};hR=f8([Et(),d8(0,tt(Ap.ManagerApiDataSource))],hR);var p8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},gR=(e,t)=>(r,n)=>t(r,n,e);let vR=class{constructor(t,r){this.sessionService=t,this.managerApiDataSource=r}execute(t){for(const r of this.sessionService.getDeviceSessions()){const n=r.getDeviceSessionState();n.sessionStateType!==Zu.Connected&&r.setDeviceSessionState({...n,firmwareUpdateContext:void 0,installedApps:[],appsUpdates:void 0,catalog:void 0})}this.managerApiDataSource.setProvider(t)}};vR=p8([Et(),gR(0,tt(fn.DeviceSessionService)),gR(1,tt(Ap.ManagerApiDataSource))],vR);var Ya={},$u={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var h8=$u.exports,mR;function g8(){return mR||(mR=1,(function(e,t){(function(r){var n=t&&!t.nodeType&&t,i=e&&!e.nodeType&&e,o=typeof self=="object"&&self;(o.global===o||o.window===o||o.self===o)&&(r=o);var s,u=2147483647,c=36,f=1,d=26,g=38,h=700,y=72,m=128,S="-",b=/^xn--/,C=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,$={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=c-f,_=Math.floor,A=String.fromCharCode,O;function I(U){throw new RangeError($[U])}function L(U,D){for(var P=U.length,G=[];P--;)G[P]=D(U[P]);return G}function F(U,D){var P=U.split("@"),G="";P.length>1&&(G=P[0]+"@",U=P[1]),U=U.replace(x,".");var Z=U.split("."),te=L(Z,D).join(".");return G+te}function W(U){for(var D=[],P=0,G=U.length,Z,te;P<G;)Z=U.charCodeAt(P++),Z>=55296&&Z<=56319&&P<G?(te=U.charCodeAt(P++),(te&64512)==56320?D.push(((Z&1023)<<10)+(te&1023)+65536):(D.push(Z),P--)):D.push(Z);return D}function z(U){return L(U,function(D){var P="";return D>65535&&(D-=65536,P+=A(D>>>10&1023|55296),D=56320|D&1023),P+=A(D),P}).join("")}function B(U){return U-48<10?U-22:U-65<26?U-65:U-97<26?U-97:c}function j(U,D){return U+22+75*(U<26)-((D!=0)<<5)}function N(U,D,P){var G=0;for(U=P?_(U/h):U>>1,U+=_(U/D);U>T*d>>1;G+=c)U=_(U/T);return _(G+(T+1)*U/(U+g))}function X(U){var D=[],P=U.length,G,Z=0,te=m,K=y,ye,ae,be,he,xe,Se,Oe,Ee,_e;for(ye=U.lastIndexOf(S),ye<0&&(ye=0),ae=0;ae<ye;++ae)U.charCodeAt(ae)>=128&&I("not-basic"),D.push(U.charCodeAt(ae));for(be=ye>0?ye+1:0;be<P;){for(he=Z,xe=1,Se=c;be>=P&&I("invalid-input"),Oe=B(U.charCodeAt(be++)),(Oe>=c||Oe>_((u-Z)/xe))&&I("overflow"),Z+=Oe*xe,Ee=Se<=K?f:Se>=K+d?d:Se-K,!(Oe<Ee);Se+=c)_e=c-Ee,xe>_(u/_e)&&I("overflow"),xe*=_e;G=D.length+1,K=N(Z-he,G,he==0),_(Z/G)>u-te&&I("overflow"),te+=_(Z/G),Z%=G,D.splice(Z++,0,te)}return z(D)}function q(U){var D,P,G,Z,te,K,ye,ae,be,he,xe,Se=[],Oe,Ee,_e,$e;for(U=W(U),Oe=U.length,D=m,P=0,te=y,K=0;K<Oe;++K)xe=U[K],xe<128&&Se.push(A(xe));for(G=Z=Se.length,Z&&Se.push(S);G<Oe;){for(ye=u,K=0;K<Oe;++K)xe=U[K],xe>=D&&xe<ye&&(ye=xe);for(Ee=G+1,ye-D>_((u-P)/Ee)&&I("overflow"),P+=(ye-D)*Ee,D=ye,K=0;K<Oe;++K)if(xe=U[K],xe<D&&++P>u&&I("overflow"),xe==D){for(ae=P,be=c;he=be<=te?f:be>=te+d?d:be-te,!(ae<he);be+=c)$e=ae-he,_e=c-he,Se.push(A(j(he+$e%_e,0))),ae=_($e/_e);Se.push(A(j(ae,0))),te=N(P,Ee,G==Z),P=0,++G}++P,++D}return Se.join("")}function M(U){return F(U,function(D){return b.test(D)?X(D.slice(4).toLowerCase()):D})}function J(U){return F(U,function(D){return C.test(D)?"xn--"+q(D):D})}if(s={version:"1.4.1",ucs2:{decode:W,encode:z},decode:X,encode:q,toASCII:J,toUnicode:M},n&&i)if(e.exports==n)i.exports=s;else for(O in s)s.hasOwnProperty(O)&&(n[O]=s[O]);else r.punycode=s})(h8)})($u,$u.exports)),$u.exports}var rm,yR;function Ll(){return yR||(yR=1,rm=TypeError),rm}const v8={},m8=Object.freeze(Object.defineProperty({__proto__:null,default:v8},Symbol.toStringTag,{value:"Module"})),y8=M1(m8);var nm,bR;function Ip(){if(bR)return nm;bR=1;var e=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&e?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=e&&t&&typeof t.get=="function"?t.get:null,n=e&&Map.prototype.forEach,i=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=i&&o&&typeof o.get=="function"?o.get:null,u=i&&Set.prototype.forEach,c=typeof WeakMap=="function"&&WeakMap.prototype,f=c?WeakMap.prototype.has:null,d=typeof WeakSet=="function"&&WeakSet.prototype,g=d?WeakSet.prototype.has:null,h=typeof WeakRef=="function"&&WeakRef.prototype,y=h?WeakRef.prototype.deref:null,m=Boolean.prototype.valueOf,S=Object.prototype.toString,b=Function.prototype.toString,C=String.prototype.match,x=String.prototype.slice,$=String.prototype.replace,T=String.prototype.toUpperCase,_=String.prototype.toLowerCase,A=RegExp.prototype.test,O=Array.prototype.concat,I=Array.prototype.join,L=Array.prototype.slice,F=Math.floor,W=typeof BigInt=="function"?BigInt.prototype.valueOf:null,z=Object.getOwnPropertySymbols,B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,j=typeof Symbol=="function"&&typeof Symbol.iterator=="object",N=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===j||!0)?Symbol.toStringTag:null,X=Object.prototype.propertyIsEnumerable,q=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(V){return V.__proto__}:null);function M(V,ee){if(V===1/0||V===-1/0||V!==V||V&&V>-1e3&&V<1e3||A.call(/e/,ee))return ee;var Re=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof V=="number"){var le=V<0?-F(-V):F(V);if(le!==V){var fe=String(le),ve=x.call(ee,fe.length+1);return $.call(fe,Re,"$&_")+"."+$.call($.call(ve,/([0-9]{3})/g,"$&_"),/_$/,"")}}return $.call(ee,Re,"$&_")}var J=y8,U=J.custom,D=Oe(U)?U:null,P={__proto__:null,double:'"',single:"'"},G={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};nm=function V(ee,Re,le,fe){var ve=Re||{};if($e(ve,"quoteStyle")&&!$e(P,ve.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if($e(ve,"maxStringLength")&&(typeof ve.maxStringLength=="number"?ve.maxStringLength<0&&ve.maxStringLength!==1/0:ve.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=$e(ve,"customInspect")?ve.customInspect:!0;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if($e(ve,"indent")&&ve.indent!==null&&ve.indent!==" "&&!(parseInt(ve.indent,10)===ve.indent&&ve.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if($e(ve,"numericSeparator")&&typeof ve.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Me=ve.numericSeparator;if(typeof ee>"u")return"undefined";if(ee===null)return"null";if(typeof ee=="boolean")return ee?"true":"false";if(typeof ee=="string")return lt(ee,ve);if(typeof ee=="number"){if(ee===0)return 1/0/ee>0?"0":"-0";var ze=String(ee);return Me?M(ee,ze):ze}if(typeof ee=="bigint"){var Je=String(ee)+"n";return Me?M(ee,Je):Je}var Ze=typeof ve.depth>"u"?5:ve.depth;if(typeof le>"u"&&(le=0),le>=Ze&&Ze>0&&typeof ee=="object")return K(ee)?"[Array]":"[Object]";var et=se(ve,le);if(typeof fe>"u")fe=[];else if(Qe(fe,ee)>=0)return"[Circular]";function Nt(er,_r,Fe){if(_r&&(fe=L.call(fe),fe.push(_r)),Fe){var Zn={depth:ve.depth};return $e(ve,"quoteStyle")&&(Zn.quoteStyle=ve.quoteStyle),V(er,Zn,le+1,fe)}return V(er,ve,le+1,fe)}if(typeof ee=="function"&&!ae(ee)){var ct=qe(ee),pt=Y(ee,Nt);return"[Function"+(ct?": "+ct:" (anonymous)")+"]"+(pt.length>0?" { "+I.call(pt,", ")+" }":"")}if(Oe(ee)){var bt=j?$.call(String(ee),/^(Symbol\(.*\))_[^)]*$/,"$1"):B.call(ee);return typeof ee=="object"&&!j?dt(bt):bt}if(Ge(ee)){for(var ht="<"+_.call(String(ee.nodeName)),mt=ee.attributes||[],_t=0;_t<mt.length;_t++)ht+=" "+mt[_t].name+"="+Z(te(mt[_t].value),"double",ve);return ht+=">",ee.childNodes&&ee.childNodes.length&&(ht+="..."),ht+="</"+_.call(String(ee.nodeName))+">",ht}if(K(ee)){if(ee.length===0)return"[]";var jt=Y(ee,Nt);return et&&!ne(jt)?"["+pe(jt,et)+"]":"[ "+I.call(jt,", ")+" ]"}if(be(ee)){var ar=Y(ee,Nt);return!("cause"in Error.prototype)&&"cause"in ee&&!X.call(ee,"cause")?"{ ["+String(ee)+"] "+I.call(O.call("[cause]: "+Nt(ee.cause),ar),", ")+" }":ar.length===0?"["+String(ee)+"]":"{ ["+String(ee)+"] "+I.call(ar,", ")+" }"}if(typeof ee=="object"&&Ae){if(D&&typeof ee[D]=="function"&&J)return J(ee,{depth:Ze-le});if(Ae!=="symbol"&&typeof ee.inspect=="function")return ee.inspect()}if(Ne(ee)){var dr=[];return n&&n.call(ee,function(er,_r){dr.push(Nt(_r,ee,!0)+" => "+Nt(er,ee))}),$t("Map",r.call(ee),dr,et)}if(Ve(ee)){var mr=[];return u&&u.call(ee,function(er){mr.push(Nt(er,ee))}),$t("Set",s.call(ee),mr,et)}if(je(ee))return Dt("WeakMap");if(Ce(ee))return Dt("WeakSet");if(Ke(ee))return Dt("WeakRef");if(xe(ee))return dt(Nt(Number(ee)));if(Ee(ee))return dt(Nt(W.call(ee)));if(Se(ee))return dt(m.call(ee));if(he(ee))return dt(Nt(String(ee)));if(typeof window<"u"&&ee===window)return"{ [object Window] }";if(typeof globalThis<"u"&&ee===globalThis||typeof self<"u"&&ee===self)return"{ [object globalThis] }";if(!ye(ee)&&!ae(ee)){var Cr=Y(ee,Nt),Pr=q?q(ee)===Object.prototype:ee instanceof Object||ee.constructor===Object,kr=ee instanceof Object?"":"null prototype",pr=!Pr&&N&&Object(ee)===ee&&N in ee?x.call(Pe(ee),8,-1):kr?"Object":"",hn=Pr||typeof ee.constructor!="function"?"":ee.constructor.name?ee.constructor.name+" ":"",Ht=hn+(pr||kr?"["+I.call(O.call([],pr||[],kr||[]),": ")+"] ":"");return Cr.length===0?Ht+"{}":et?Ht+"{"+pe(Cr,et)+"}":Ht+"{ "+I.call(Cr,", ")+" }"}return String(ee)};function Z(V,ee,Re){var le=Re.quoteStyle||ee,fe=P[le];return fe+V+fe}function te(V){return $.call(String(V),/"/g,"&quot;")}function K(V){return Pe(V)==="[object Array]"&&(!N||!(typeof V=="object"&&N in V))}function ye(V){return Pe(V)==="[object Date]"&&(!N||!(typeof V=="object"&&N in V))}function ae(V){return Pe(V)==="[object RegExp]"&&(!N||!(typeof V=="object"&&N in V))}function be(V){return Pe(V)==="[object Error]"&&(!N||!(typeof V=="object"&&N in V))}function he(V){return Pe(V)==="[object String]"&&(!N||!(typeof V=="object"&&N in V))}function xe(V){return Pe(V)==="[object Number]"&&(!N||!(typeof V=="object"&&N in V))}function Se(V){return Pe(V)==="[object Boolean]"&&(!N||!(typeof V=="object"&&N in V))}function Oe(V){if(j)return V&&typeof V=="object"&&V instanceof Symbol;if(typeof V=="symbol")return!0;if(!V||typeof V!="object"||!B)return!1;try{return B.call(V),!0}catch{}return!1}function Ee(V){if(!V||typeof V!="object"||!W)return!1;try{return W.call(V),!0}catch{}return!1}var _e=Object.prototype.hasOwnProperty||function(V){return V in this};function $e(V,ee){return _e.call(V,ee)}function Pe(V){return S.call(V)}function qe(V){if(V.name)return V.name;var ee=C.call(b.call(V),/^function\s*([\w$]+)/);return ee?ee[1]:null}function Qe(V,ee){if(V.indexOf)return V.indexOf(ee);for(var Re=0,le=V.length;Re<le;Re++)if(V[Re]===ee)return Re;return-1}function Ne(V){if(!r||!V||typeof V!="object")return!1;try{r.call(V);try{s.call(V)}catch{return!0}return V instanceof Map}catch{}return!1}function je(V){if(!f||!V||typeof V!="object")return!1;try{f.call(V,f);try{g.call(V,g)}catch{return!0}return V instanceof WeakMap}catch{}return!1}function Ke(V){if(!y||!V||typeof V!="object")return!1;try{return y.call(V),!0}catch{}return!1}function Ve(V){if(!s||!V||typeof V!="object")return!1;try{s.call(V);try{r.call(V)}catch{return!0}return V instanceof Set}catch{}return!1}function Ce(V){if(!g||!V||typeof V!="object")return!1;try{g.call(V,g);try{f.call(V,f)}catch{return!0}return V instanceof WeakSet}catch{}return!1}function Ge(V){return!V||typeof V!="object"?!1:typeof HTMLElement<"u"&&V instanceof HTMLElement?!0:typeof V.nodeName=="string"&&typeof V.getAttribute=="function"}function lt(V,ee){if(V.length>ee.maxStringLength){var Re=V.length-ee.maxStringLength,le="... "+Re+" more character"+(Re>1?"s":"");return lt(x.call(V,0,ee.maxStringLength),ee)+le}var fe=G[ee.quoteStyle||"single"];fe.lastIndex=0;var ve=$.call($.call(V,fe,"\\$1"),/[\x00-\x1f]/g,At);return Z(ve,"single",ee)}function At(V){var ee=V.charCodeAt(0),Re={8:"b",9:"t",10:"n",12:"f",13:"r"}[ee];return Re?"\\"+Re:"\\x"+(ee<16?"0":"")+T.call(ee.toString(16))}function dt(V){return"Object("+V+")"}function Dt(V){return V+" { ? }"}function $t(V,ee,Re,le){var fe=le?pe(Re,le):I.call(Re,", ");return V+" ("+ee+") {"+fe+"}"}function ne(V){for(var ee=0;ee<V.length;ee++)if(Qe(V[ee],`
525
+ Found @inject decorator at method "${f.toString()}" at class "${c.constructor.name}"`);Lu(c.constructor,kd,Md,y_(u(c),f))}})(e,t)(r,n,i)}catch(o){Lj(r,n,i,o)}}}function Kv(e,t){return r=>{const n=t(r);return i=>(n(i),e(i))}}function tt(e){return Fj(Dj(ec.singleInjection,e),Pj)}(function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"})(wa||(wa={}));const b_="@inversifyjs/core/classIsInjectableFlagReflectKey",Nj=[Array,BigInt,Boolean,Function,Number,Object,String];function jj(e){const t=pb(e,"design:paramtypes");t!==void 0&&Lu(e,kd,Md,(function(r){return n=>(r.forEach(((i,o)=>{var s;n.constructorArguments[o]!==void 0||(s=i,Nj.includes(s))||(n.constructorArguments[o]=(function(u){return{isFromTypescriptParamType:!0,kind:ec.singleInjection,name:void 0,optional:!1,tags:new Map,value:u}})(i))})),n)})(t))}function Et(e){return t=>{(function(r){if(pb(r,b_)!==void 0)throw new Aa(vo.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${r.name}"`);$j(r,b_,!0)})(t),jj(t)}}var S_;(function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection"})(S_||(S_={}));var w_;(function(e){e[e.singleMandatory=0]="singleMandatory",e[e.singleOptional=1]="singleOptional",e[e.multipleMandatory=2]="multipleMandatory",e[e.multipleOptional=3]="multipleOptional",e[e.length=4]="length"})(w_||(w_={}));let zj=class{constructor(t,r,n,i,o){this.deviceModel=t,this.serviceUuid=r,this.writeUuid=n,this.writeCmdUuid=i,this.notifyUuid=o}},Us=class{id;productName;usbProductId;bootloaderUsbProductId;usbOnly;memorySize;getBlockSize;masks;bluetoothSpec;constructor(t){this.id=t.id,this.productName=t.productName,this.usbProductId=t.usbProductId,this.bootloaderUsbProductId=t.bootloaderUsbProductId,this.usbOnly=t.usbOnly,this.memorySize=t.memorySize,this.getBlockSize=t.getBlockSize,this.masks=t.masks,this.bluetoothSpec=t.bluetoothSpec}};var Bj=Object.defineProperty,Vj=(e,t,r)=>t in e?Bj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hj=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Uj=(e,t,r)=>Vj(e,t+"",r);let rs=class{getAllDeviceModels(){return Object.values(rs.deviceModelByIds)}getDeviceModel(t){return rs.deviceModelByIds[t.id]}filterDeviceModels(t){return this.getAllDeviceModels().filter(r=>Object.entries(t).every(([n,i])=>r[n]===i))}getBluetoothServicesInfos(){return Object.values(rs.deviceModelByIds).reduce((t,r)=>{const{bluetoothSpec:n}=r;return n?{...t,...n.reduce((i,o)=>({...i,[o.serviceUuid]:new zj(r,o.serviceUuid,o.writeUuid,o.writeCmdUuid,o.notifyUuid)}),{})}:t},{})}getBluetoothServices(){return Object.values(rs.deviceModelByIds).map(t=>(t.bluetoothSpec||[]).map(r=>r.serviceUuid)).flat().filter(t=>!!t)}};Uj(rs,"deviceModelByIds",{[Yt.NANO_S]:new Us({id:Yt.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>i_.lt(i_.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[Yt.NANO_SP]:new Us({id:Yt.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[Yt.NANO_X]:new Us({id:Yt.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"}]}),[Yt.STAX]:new Us({id:Yt.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"}]}),[Yt.FLEX]:new Us({id:Yt.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"}]}),[Yt.APEX]:new Us({id:Yt.APEX,productName:"Ledger Nano Gen5",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"}]})}),rs=Hj([Et()],rs);let Wj=class{statusCode;data;constructor({statusCode:t,data:r}){this.statusCode=t,this.data=r}};const qj=5,Ja=1,xy=2,ll=2,Ey=2,Fr=[];for(let e=0;e<256;++e)Fr.push((e+256).toString(16).slice(1));function Gj(e,t=0){return(Fr[e[t+0]]+Fr[e[t+1]]+Fr[e[t+2]]+Fr[e[t+3]]+"-"+Fr[e[t+4]]+Fr[e[t+5]]+"-"+Fr[e[t+6]]+Fr[e[t+7]]+"-"+Fr[e[t+8]]+Fr[e[t+9]]+"-"+Fr[e[t+10]]+Fr[e[t+11]]+Fr[e[t+12]]+Fr[e[t+13]]+Fr[e[t+14]]+Fr[e[t+15]]).toLowerCase()}let Yv;const Xj=new Uint8Array(16);function Kj(){if(!Yv){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yv=crypto.getRandomValues.bind(crypto)}return Yv(Xj)}const Yj=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),x_={randomUUID:Yj};function $p(e,t,r){if(x_.randomUUID&&!e)return x_.randomUUID();e=e||{};const n=e.random||(e.rng||Kj)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Gj(n)}const as={getLastBytesFrom(e,t){return e.slice(-t)},getFirstBytesFrom(e,t){return e.slice(0,t)},bytesToNumber(e){return e.reduce((t,r,n)=>t+r*Math.pow(256,e.length-1-n),0)},numberToByteArray(e,t){return new Uint8Array(t).map((r,n)=>e>>8*(t-1-n)&255)}},E_=2,Qv=800;let C_=class{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}},Qj=class{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}},__=class{_tag="ReceiverApduError";originalError;constructor(t){this.originalError=new Error(t??"Unable to parse apdu")}},R_=class{_tag="DeviceSessionNotFound";originalError;constructor(t){this.originalError=t??new Error("Device session not found")}},PI=class{_header;_data;constructor({header:t,data:r}){this._header=t,this._data=r}toString(){return JSON.stringify({header:this._header.toString(),data:Ju(this._data)},null,2)}getRawData(){const t=this._header.getRawData(),r=new Uint8Array(t.length+this._data.length);return r.set(t,0),r.set(this._data,t.length),r}getHeader(){return this._header}getData(){return this._data}},kI=class{_uuid;_channel;_headTag;_index;_length;_dataLength;constructor({uuid:t,dataSize:r,index:n,headTag:i,length:o,channel:s}){this._uuid=t,this._dataLength=r,this._index=n,this._headTag=i,this._length=o,this._channel=s}getDataLength(){return this._dataLength.map(t=>as.bytesToNumber(t))}setDataSize(t){return this._dataLength=t,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:t=>[...t],Nothing:()=>[]}),...this._headTag,...this._index,...this._dataLength.caseOf({Just:t=>[...t],Nothing:()=>[]})])}};const Er={LoggerPublisherServiceFactory:Symbol.for("LoggerPublisherServiceFactory")};var Jj=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Zj=(e,t)=>(r,n)=>t(r,n,e);let O_=class{_channel;_logger;_pendingFrames;constructor({channel:t=Cn.zero()},r){this._channel=t,this._logger=r("ApduReceiverService"),this._pendingFrames=[]}handleFrame(t){return this.getFrameFromBytes(t).map(r=>{if(this._pendingFrames.push(r),!this._pendingFrames[0])return Gt;const n=this._pendingFrames[0].getHeader().getDataLength();return this.getCompleteFrame(n)})}getCompleteFrame(t){return t.chain(r=>{if(!this.isComplete(r))return this._logger.debug("frame is not complete, waiting for more"),Gt;const n=as.getFirstBytesFrom(this.concatFrames(this._pendingFrames),r),i=as.getFirstBytesFrom(n,n.length-E_),o=as.getLastBytesFrom(n,E_);return this._pendingFrames=[],ln(new Wj({data:i,statusCode:o}))})}getFrameFromBytes(t){const r=this._channel.caseOf({Just:()=>xy,Nothing:()=>0}),n=t.slice(r,r+Ja),i=t.slice(r+Ja,r+Ja+ll),o=i.reduce((h,y)=>h+y,0)===0;if(!o&&this._pendingFrames.length===0)return Qr(new __);const s=r+Ja+ll,u=o?Ey:0;if(t.length<r+Ja+ll+u)return Qr(new __("Unable to parse header from apdu"));const c=o?ln(t.slice(s,s+u)):Gt,f=s+u,d=t.slice(f),g=new PI({header:new kI({uuid:$p(),channel:this._channel,dataSize:c,headTag:n,index:i,length:r+Ja+ll+u}),data:d});return Jr(g)}isComplete(t){return this._pendingFrames.reduce((r,n)=>r+n.getData().length,0)>=t}concatFrames(t){return t.reduce((r,n)=>Uint8Array.from([...r,...n.getData()]),new Uint8Array(0))}};O_=Jj([Et(),Zj(1,tt(Er.LoggerPublisherServiceFactory))],O_);var ez=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},tz=(e,t)=>(r,n)=>t(r,n,e);let T_=class{_frameSize;_channel;_padding;_logger;constructor({frameSize:t,channel:r=Cn.zero(),padding:n=!1},i){this._frameSize=t,this._channel=r,this._padding=n,this._logger=i("DefaultApduSenderService")}getFrames(t){const r=[];let n=0,i=this.getFrameAtIndex(t,n);for(;i.isRight();)r.push(i.extract()),n+=1,i=this.getFrameAtIndex(t,n).mapLeft(o=>(o instanceof C_||this._logger.error("Error while parsing frame",{data:{error:o}}),o));return r}getFrameAtIndex(t,r){const n=this.getFrameHeaderFrom(r,t.length),i=r===0?0:r*this._frameSize-this.getHeaderSizeSumFrom(r);if(i>=t.length)return Qr(new C_);if(n.getLength()>this._frameSize)return Qr(new Qj);const o=this._frameSize-n.getLength(),s=t.slice(i,i+this._frameSize-n.getLength()),u=this._padding?new Uint8Array(o).fill(0):new Uint8Array(s.length<o?s.length:o);u.set(s,0);const c=new PI({header:n,data:u});return Jr(c)}getFrameHeaderFrom(t,r){const n=new kI({uuid:$p(),channel:this._channel.map(i=>as.getLastBytesFrom(i,xy)),headTag:new Uint8Array([qj]),index:as.numberToByteArray(t,ll),length:this.getFrameHeaderSizeFromIndex(t),dataSize:Cn.zero()});return t===0&&n.setDataSize(Cn.of(as.numberToByteArray(r,Ey))),n}getHeaderSizeSumFrom(t){let r=this.getFrameHeaderSizeFromIndex(0),n=1;for(;n<t;)r+=this.getFrameHeaderSizeFromIndex(n),n+=1;return r}getFrameHeaderSizeFromIndex(t){return this._channel.caseOf({Just:()=>xy,Nothing:()=>0})+ll+Ja+(t===0?Ey:0)}};T_=ez([Et(),tz(1,tt(Er.LoggerPublisherServiceFactory))],T_);const Cy={LocalConfigDataSource:Symbol.for("LocalConfigDataSource"),RemoteConfigDataSource:Symbol.for("RemoteConfigDataSource"),ConfigService:Symbol.for("ConfigService")},fn={ApduSenderServiceFactory:Symbol.for("ApduSenderServiceFactory"),ApduReceiverServiceFactory:Symbol.for("ApduReceiverServiceFactory"),DeviceSessionService:Symbol.for("DeviceSessionService")},$_={ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase")},Ap={ManagerApiService:Symbol.for("ManagerApiService"),ManagerApiDataSource:Symbol.for("ManagerApiDataSource"),DmkConfig:Symbol.for("ManagerApiDmkConfig")},Ia={DmkConfig:Symbol.for("TransportDmkConfig"),TransportService:Symbol.for("TransportService"),TransportsInput:Symbol.for("TransportsInput")};var rz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},A_=(e,t)=>(r,n)=>t(r,n,e);let I_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("SendCommandUseCase")}async execute({sessionId:t,command:r,abortTimeout:n}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:async i=>await i.sendCommand(r,n),Left:i=>{throw this._logger.error("Error getting session",{data:{error:i}}),i}})}};I_=rz([Et(),A_(0,tt(fn.DeviceSessionService)),A_(1,tt(Er.LoggerPublisherServiceFactory))],I_);var nz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let P_=class{execute=vi.fn(()=>"stub")};P_=nz([Et()],P_);var iz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},k_=(e,t)=>(r,n)=>t(r,n,e);let M_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("ExecuteDeviceActionUseCase")}execute({sessionId:t,deviceAction:r}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:n=>n.executeDeviceAction(r),Left:n=>{throw this._logger.error("Error getting session",{data:{error:n}}),n}})}};M_=iz([Et(),k_(0,tt(fn.DeviceSessionService)),k_(1,tt(Er.LoggerPublisherServiceFactory))],M_);function oz(e){return typeof e=="object"&&e!==null&&"version"in e&&"name"in e&&typeof e.version=="string"&&typeof e.name=="string"}let D_=class{constructor(t){this.err=t,this.originalError=t}_tag="ApiCallError";originalError},az=class{constructor(t){this.err=t,this.originalError=t}_tag="ParseResponseError";originalError},MI=class{constructor(t){this.err=t,this.originalError=t}_tag="JSONParseError";originalError},sz=class{constructor(t){this.err=t,this.originalError=t}_tag="ReadFileError";originalError};const lz="@ledgerhq/device-management-kit",uz="0.0.0-develop-20260508002748",L_={name:lz,version:uz};var cz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};const fz={name:L_.name,version:L_.version},dz=()=>JSON.stringify(fz);let F_=class{getConfig(){return Wn.encase(()=>dz()).mapLeft(t=>new sz(t)).chain(t=>Wn.encase(()=>{const r=JSON.parse(t);if(oz(r))return r;throw new Error("Invalid config file")}).mapLeft(r=>new MI(r)))}};F_=cz([Et()],F_);var pz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let N_=class{getConfig(){return Wn.of({name:"DeviceSDK",version:"0.0.0-stub.1"})}};N_=pz([Et()],N_);var hz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let j_=class{async getConfig(){const t=await this._callApi();if(t.isLeft())return Qr(new D_(t.extract()));if(!t.extract().ok)return Qr(new D_(new Error("response not ok")));const r=await t.extract().json();return r.isLeft()?Qr(new MI):r.chain(n=>this._parseResponse(n)).map(n=>n)}_parseResponse(t){const{name:r,version:n}=t;return!r||!n?Qr(new az):Wn.of({name:r,version:n})}_callApi(){return new Promise(t=>{t(Wn.of({ok:!0,json:async()=>new Promise(r=>{r(Wn.of({name:"DeviceSDK",version:"0.0.0-fake.1",yolo:"yolo"}))})}))})}};j_=hz([Et()],j_);var gz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let z_=class{async getConfig(){return new Promise(t=>t(Wn.of({name:"DeviceSDK",version:"0.0.0-fake.2"})))}};z_=gz([Et()],z_);var vz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Jv=(e,t)=>(r,n)=>t(r,n,e);let B_=class{_local;_remote;_logger;constructor(t,r,n){this._local=t,this._remote=r,this._logger=n("config")}async getDmkConfig(){const t=this._local.getConfig().ifLeft(r=>{this._logger.error("Local config not available",{data:{error:r}})});if(t.isRight()){const r=t.extract();return this._logger.info("Local config available",{data:{config:r}}),r}return this._remote.getConfig().then(r=>r.mapLeft(n=>(this._logger.error("Local config available",{data:{error:n}}),{name:"DeadDmk",version:"0.0.0-dead.1"})).extract())}};B_=vz([Et(),Jv(0,tt(Cy.LocalConfigDataSource)),Jv(1,tt(Cy.RemoteConfigDataSource)),Jv(2,tt(Er.LoggerPublisherServiceFactory))],B_);var mz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},yz=(e,t)=>(r,n)=>t(r,n,e);let V_=class{_configService;constructor(t){this._configService=t}async getDmkVersion(){return(await this._configService.getDmkConfig()).version}};V_=mz([Et(),yz(0,tt(Cy.ConfigService))],V_);const bz={DeviceModelDataSource:Symbol.for("DeviceModelDataSource")};var Sz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},H_=(e,t)=>(r,n)=>t(r,n,e);let U_=class{constructor(t,r){this._sessionService=t,this._logger=r("DisableDeviceSessionRefresherUseCase")}_logger;execute({sessionId:t,blockerId:r}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:n=>{throw this._logger.error("Error getting device session",{data:{error:n}}),n},Right:n=>n.disableRefresher(r)})}};U_=Sz([Et(),H_(0,tt(fn.DeviceSessionService)),H_(1,tt(Er.LoggerPublisherServiceFactory))],U_);var wz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},xz=(e,t)=>(r,n)=>t(r,n,e);let W_=class{_sessions;_sessionsSubject;_logger;constructor(t){this._sessions=[],this._sessionsSubject=new dI,this._logger=t("DeviceSessionService")}get sessionsObs(){return this._sessionsSubject.asObservable()}addDeviceSession(t){return this._sessions.find(r=>r.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){const r=this._sessions.find(n=>n.id===t);return r?(r.close(),this._sessions=this._sessions.filter(n=>n.id!==t),this._logger.info("DeviceSession removed",{data:{sessionId:t}}),this):(this._logger.warn("DeviceSession not found",{data:{sessionId:t}}),this)}getDeviceSessionById(t){return Cn.fromNullable(this._sessions.find(r=>r.id===t)).toEither(new R_)}getDeviceSessionsByDeviceId(t){return Cn.fromPredicate(({length:r})=>r>0,this._sessions.filter(r=>r.connectedDevice.id===t)).toEither(new R_)}getDeviceSessions(){return this._sessions}};W_=wz([Et(),xz(0,tt(Er.LoggerPublisherServiceFactory))],W_);var Ez=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},q_=(e,t)=>(r,n)=>t(r,n,e);let G_=class{_sessionService;_transportService;constructor(t,r){this._sessionService=t,this._transportService=r}execute(){const t=this._sessionService.getDeviceSessions();for(const r of t)this._transportService.closeConnection(r.connectedDevice),this._sessionService.removeDeviceSession(r.id)}};G_=Ez([Et(),q_(0,tt(fn.DeviceSessionService)),q_(1,tt(Ia.TransportService))],G_);var Cz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},X_=(e,t)=>(r,n)=>t(r,n,e);let K_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("GetDeviceSessionStateUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:r=>{throw this._logger.error("Error getting session device",{data:{error:r}}),r},Right:r=>r.state})}};K_=Cz([Et(),X_(0,tt(fn.DeviceSessionService)),X_(1,tt(Er.LoggerPublisherServiceFactory))],K_);var _z=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Y_=(e,t)=>(r,n)=>t(r,n,e);let Q_=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("UnsafeBypassIntentQueueUseCase")}execute({sessionId:t,bypass:r}){this._sessionService.getDeviceSessionById(t).caseOf({Left:n=>{throw this._logger.error("Error getting session",{data:{error:n}}),n},Right:n=>{this._logger.warn(`UNSAFE: ${r?"Enabling":"Disabling"} intent queue bypass for session ${t}`),n._unsafeBypassIntentQueue(r)}})}};Q_=_z([Et(),Y_(0,tt(fn.DeviceSessionService)),Y_(1,tt(Er.LoggerPublisherServiceFactory))],Q_);function Rz(e){return`[will send APDU] ~...> ${Ju(e,!1)}`}function Oz(e){return`[exchange] <= ${Ju(e.data,!1)}${Ju(e.statusCode,!1)}`}const _y=1e3,Zv=1e3,Tz={isRefresherDisabled:!1,pollingInterval:1e3};var ur=(e=>(e.NEW_STATE="NEW_STATE",e.REFRESH_NEEDED="REFRESH_NEEDED",e.COMMAND_SUCCEEDED="COMMAND_SUCCEEDED",e.DEVICE_STATE_UPDATE_BUSY="DEVICE_STATE_UPDATE_BUSY",e.DEVICE_STATE_UPDATE_LOCKED="DEVICE_STATE_UPDATE_LOCKED",e.DEVICE_STATE_UPDATE_CONNECTED="DEVICE_STATE_UPDATE_CONNECTED",e.DEVICE_STATE_UPDATE_UNKNOWN="DEVICE_STATE_UPDATE_UNKNOWN",e))(ur||{});let $z=class{_eventEmitter=new Dl;listen(){return this._eventEmitter.asObservable()}dispatch(t){this._eventEmitter.next(t)}},Az=class{constructor(t,r){this.loggerModuleFactory=t,this.sessionEventDispatcher=r,this._logger=this.loggerModuleFactory("IntentQueueService")}_logger;_queue=[];_isProcessing=!1;_currentSubscription=null;enqueue(t){this._logger.debug("Enqueueing intent",{data:{type:t.type}});const r=new Dl,n={intent:t,subject:r,isCancelled:!1};this._queue.push(n);const i=()=>{this._logger.debug("Cancelling intent",{data:{type:t.type}}),n.isCancelled=!0,this._queue[0]===n&&this._currentSubscription?(this._currentSubscription.unsubscribe(),this._currentSubscription=null,r.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue()):(!this._isProcessing||this._queue[0]!==n)&&r.complete()};return this._isProcessing||this._processQueue(),{observable:r.asObservable().pipe(hj(()=>{this._logger.debug("Intent observable finalized",{data:{type:t.type}})})),cancel:i}}_processQueue(){if(this._isProcessing)return;if(this._queue.length===0){this.sessionEventDispatcher.dispatch({eventName:ur.NEW_STATE});return}this.sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_BUSY}),this._isProcessing=!0;const t=this._queue[0];if(t.isCancelled){this._logger.debug("Skipping cancelled intent",{data:{type:t.intent.type}}),t.subject.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue();return}this._logger.debug("Processing intent",{data:{type:t.intent.type}}),this._currentSubscription=t.intent.execute().subscribe({next:r=>{t.isCancelled||t.subject.next(r)},error:r=>{t.isCancelled||t.subject.error(r),this._onIntentComplete()},complete:()=>{t.isCancelled||t.subject.complete(),this._onIntentComplete()}})}_onIntentComplete(){this._logger.debug("Intent completed"),this._currentSubscription=null,this._queue.shift(),this._isProcessing=!1,this._processQueue()}},Iz=class{constructor(t,r){this._refresher=r,this._logger=t("refresher-service")}_refresherBlockers=new Set;_logger;disableRefresher(t){const r=`${t}-${$p()}`;this.addRefresherBlocker(r),this._logger.debug("Refresher disabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}});let n=!1;return()=>{n||(n=!0,this.removeRefresherBlocker(r),this._logger.debug("Refresher re-enabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}}))}}addRefresherBlocker(t){const r=this._refresherBlockers.size;this._refresherBlockers.add(t),r===0&&this._refresher.stop()}removeRefresherBlocker(t){const r=this._refresherBlockers.size;this._refresherBlockers.delete(t),r>0&&this._refresherBlockers.size===0&&this._refresher.start()}},Pz=class{constructor(t,r,n,i){this.connectedDevice=r,this._sessionEventDispatcher=n,this._sendCommandFunction=i,this._logger=t("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(t){return this._logger.error("Error while pinging device",{data:{error:t}}),null}}mapEventAction=async t=>{switch(t.eventName){case ur.REFRESH_NEEDED:return await this.ping();default:return null}};async mapDevicePingAction(t){switch(t){case Yt.NANO_S:{const r=async()=>{const o=await this._sendCommandFunction(new dC,Qv);return this._sendCommandFunction(new S4,Qv),o},n=new Promise(o=>{setTimeout(()=>o(null),_y*2+100)}),i=await Promise.race([r(),n]);return i?this._sessionEventDispatcher.dispatch({eventName:ur.COMMAND_SUCCEEDED,eventData:i}):this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_LOCKED}),i}default:{const r=await this._sendCommandFunction(new dC,Qv);return this._sessionEventDispatcher.dispatch({eventName:ur.COMMAND_SUCCEEDED,eventData:r}),r}}}unsubscribe(){this._subscription.unsubscribe()}},kz=class{constructor(t,r,n,i){this._sessionEventDispatcher=n,this._refresherOptions=r,this._logger=t("device-session-refresher"),this._connectedDeviceID=i.deviceModel.id}_refresherSubscription;_refresherOptions;_logger;_connectedDeviceID;startRefresher(){if(this._refresherOptions.isRefresherDisabled||this._refresherSubscription)return;const t=this.getValidPollingInterval(this._refresherOptions,this._logger)*2,r=this._sessionEventDispatcher.listen().pipe(p_(n=>n.eventName===ur.DEVICE_STATE_UPDATE_BUSY||n.eventName===ur.NEW_STATE),$a(n=>n.eventName===ur.DEVICE_STATE_UPDATE_BUSY),vj(!1),dj());this._refresherSubscription=uj(0,t).pipe(mj(r),h_(([n,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),p_(([n,i])=>!i),h_(()=>this._sessionEventDispatcher.dispatch({eventName:ur.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=(t,r)=>{const{pollingInterval:n}=t;switch(this._connectedDeviceID){case Yt.NANO_S:{const i=_y*2;return n!==void 0&&n<i?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${i}`),i):n??i}default:return n!==void 0&&n<Zv?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${Zv}`),Zv):n??_y}}},Mz=class{constructor(t,r,n,i,o){this._sessionEventDispatcher=r,this._connectedDevice=n,this._deviceState=i,this.setDeviceSessionState=o,this._subscription=this._sessionEventDispatcher.listen().subscribe(s=>this.mapEventAction(s)),this._logger=t("device-session-state-handler")}_subscription;_logger;_pendingDeviceStatus=uo.BUSY;_updateDeviceState(t){const r=this._parseDeviceStatus(t);if(r){const{sessionStateType:n,deviceStatus:i,currentApp:o}=r,s=this._deviceState.getValue();s.sessionStateType===Zu.Connected?this.setDeviceSessionState({sessionStateType:n,deviceStatus:i,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o,installedApps:[],isSecureConnectionAllowed:!1}):this.setDeviceSessionState({...s,sessionStateType:n,deviceStatus:i,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o})}}mapEventAction=t=>{const{eventName:r}=t;switch(r){case ur.COMMAND_SUCCEEDED:return this._updateDeviceState(t.eventData);case ur.DEVICE_STATE_UPDATE_BUSY:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:uo.BUSY});case ur.DEVICE_STATE_UPDATE_LOCKED:this._pendingDeviceStatus=uo.LOCKED;return;case ur.DEVICE_STATE_UPDATE_CONNECTED:this._pendingDeviceStatus=uo.CONNECTED;return;case ur.NEW_STATE:{const n=this._pendingDeviceStatus;return this._pendingDeviceStatus=uo.BUSY,this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:n})}case ur.DEVICE_STATE_UPDATE_UNKNOWN:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:uo.BUSY});case ur.REFRESH_NEEDED:return;default:{const n=r;throw new Error(`Unhandled context type ${n}`)}}};_parseDeviceStatus(t){return B3(t)?{sessionStateType:Zu.ReadyWithoutSecureChannel,deviceStatus:uo.CONNECTED,currentApp:{name:t.data.name,version:t.data.version}}:(this._logger.debug("Error while parsing APDU response",{data:{parsedResponse:t}}),null)}unsubscribe(){this._subscription.unsubscribe()}},Dz=class{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new $z;_bypassIntentQueue=!1;constructor({connectedDevice:t,id:r=$p()},n,i,o,s,u=c=>new Az(n,c)){this._id=r,this._connectedDevice=t,this._loggerModuleFactory=n,this._logger=n("device-session"),this._managerApiService=i,this._intentQueueService=u(this._sessionEventDispatcher),this._secureChannelService=o,this._refresherOptions={...Tz,...s},this._deviceState=new F4({sessionStateType:Zu.Connected,deviceStatus:uo.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new Pz(n,t,this._sessionEventDispatcher,(c,f)=>this.sendCommand(c,f)),this._deviceSessionRefresher=new kz(n,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new Mz(n,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new Iz(n,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(t){throw this._logger.error("Error while initialising session",{data:{error:t}}),t}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(t){this._deviceState.next(t)}sendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(t,r):this._internalSendApdu(t,r)}_internalSendApdu(t,r){const n=r.abortTimeout,i=Date.now(),{observable:o,cancel:s}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>wl((async()=>{const c=Date.now()-i;return await this._unsafeInternalSendApdu(t,{isPolling:r.isPolling,triggersDisconnection:r.triggersDisconnection,abortTimeout:n?n-c:void 0})})())}),u=n?o.pipe(f_({each:n,with:()=>{throw s(),new yj}})):o;return c_(u)}async _unsafeInternalSendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug(Rz(t)),(await this._connectedDevice.sendApdu(t,r.triggersDisconnection,r.abortTimeout)).ifRight(n=>{this._logger.debug(Oz(n)),Y1.isLockedDeviceResponse(n)?this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:ur.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(t,r){return this._logger.debug(`[sendCommand] ${t.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(t,r):this._internalSendCommand(t,r)}_internalSendCommand(t,r){const n=Date.now(),{observable:i,cancel:o}=this._intentQueueService.enqueue({type:"send-command",execute:()=>wl((async()=>{const u=Date.now()-n;return await this._unsafeInternalSendCommand(t,r?r-u:void 0)})())}),s=r?i.pipe(f_({each:r,with:()=>{throw o(),new bj}})):i;return c_(s)}async _unsafeInternalSendCommand(t,r){const n=t.getApdu();return(await this._unsafeInternalSendApdu(n.getRawApdu(),{isPolling:!1,triggersDisconnection:t.triggersDisconnection??!1,abortTimeout:r})).caseOf({Left:i=>{throw this._logger.error("[sendCommand] error",{data:{err:i}}),i},Right:i=>{const o=t.parseResponse(i,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(t){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(t):this._internalExecuteDeviceAction(t)}_internalExecuteDeviceAction(t){let r;const{observable:n,cancel:i}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{const{observable:o,cancel:s}=this._unsafeInternalExecuteDeviceAction(t);return r=s,o}});return{observable:n,cancel:()=>{r?.(),i()}}}_unsafeInternalExecuteDeviceAction(t){const{observable:r,cancel:n}=t._execute({sendApdu:async i=>this._unsafeInternalSendApdu(i),sendCommand:async i=>this._unsafeInternalSendCommand(i),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:i=>(this.setDeviceSessionState(i),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:r,cancel:n}}close(){this._updateDeviceStatus(uo.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(t){return this._refresherService.disableRefresher(t)}_unsafeBypassIntentQueue(t){this._bypassIntentQueue=t}_updateDeviceStatus(t){const r=this._deviceState.getValue();this._deviceState.next({...r,deviceStatus:t})}};const hb={SecureChannelService:Symbol.for("SecureChannelService"),SecureChannelDataSource:Symbol.for("SecureChannelDataSource"),DmkConfig:Symbol.for("SecureChannelDmkConfig")};var Lz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},mu=(e,t)=>(r,n)=>t(r,n,e);let J_=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(t,r,n,i,o){this._sessionService=r,this._transportService=t,this._loggerFactory=n,this._logger=n("ConnectUseCase"),this._managerApi=i,this._secureChannel=o}handleDeviceDisconnect(t){this._sessionService.getDeviceSessionsByDeviceId(t).ifRight(r=>{r.forEach(n=>{this._sessionService.removeDeviceSession(n.id),this._logger.info("Session removed",{data:{deviceId:t,sessionId:n.id}})})})}async execute({device:t,sessionRefresherOptions:r}){const n=this._transportService.getTransport(t.transport),i="sessionId"in t?t.sessionId:void 0;return gt.liftEither(n.toEither(new db(new Error("Unknown transport")))).chain(async o=>o.connect({deviceId:t.id,onDisconnect:s=>this.handleDeviceDisconnect(s)})).ifLeft(o=>{this._logger.error("Error connecting to device")}).map(async o=>{const s=new Dz({connectedDevice:o,id:i},this._loggerFactory,this._managerApi,this._secureChannel,r);return this._sessionService.addDeviceSession(s),await s.initialiseSession(),s.id}).caseOf({Left:o=>{throw o},Right:o=>o})}};J_=Lz([Et(),mu(0,tt(Ia.TransportService)),mu(1,tt(fn.DeviceSessionService)),mu(2,tt(Er.LoggerPublisherServiceFactory)),mu(3,tt(Ap.ManagerApiService)),mu(4,tt(hb.SecureChannelService))],J_);var Fz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},em=(e,t)=>(r,n)=>t(r,n,e);let Z_=class{_transportService;_sessionService;_logger;constructor(t,r,n){this._sessionService=r,this._transportService=t,this._logger=n("DisconnectUseCase")}async execute({sessionId:t}){return this._logger.debug("Disconnecting from device",{data:{test:this._sessionService.getDeviceSessions().map(r=>r.id)}}),gt(async({liftEither:r})=>{const n=await r(this._sessionService.getDeviceSessionById(t).ifLeft(s=>{this._logger.error("Device session not found",{data:{sessionId:t,error:s}})})),i=n.connectedDevice.transport,o=await r(this._transportService.getTransport(i).toEither(new db(new Error("Unknown transport"))));n.close(),this._sessionService.removeDeviceSession(t),await o.disconnect({connectedDevice:n.connectedDevice})}).caseOf({Left:r=>{throw this._logger.error("Error disconnecting from device",{data:{error:r}}),r},Right:()=>{}})}};Z_=Fz([Et(),em(0,tt(Ia.TransportService)),em(1,tt(fn.DeviceSessionService)),em(2,tt(Er.LoggerPublisherServiceFactory))],Z_);let gb=class{id;sessionId;modelId;name;type;transport;constructor({transportConnectedDevice:{id:t,deviceModel:{id:r,productName:n},type:i,transport:o,name:s},sessionId:u}){this.id=t,this.sessionId=u,this.modelId=r,this.name=s??n,this.type=i,this.transport=o}};var Nz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},eR=(e,t)=>(r,n)=>t(r,n,e);let tR=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("GetConnectedDeviceUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:r=>new gb({sessionId:r.id,transportConnectedDevice:r.connectedDevice}),Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r}})}};tR=Nz([Et(),eR(0,tt(fn.DeviceSessionService)),eR(1,tt(Er.LoggerPublisherServiceFactory))],tR);var jz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},rR=(e,t)=>(r,n)=>t(r,n,e);let nR=class{_sessionService;_logger;constructor(t,r){this._sessionService=t,this._logger=r("ListConnectedDeviceUseCase")}execute(){return this._logger.info("Listing connected devices"),this._sessionService.getDeviceSessions().map(t=>new gb({transportConnectedDevice:t.connectedDevice,sessionId:t.id}))}};nR=jz([Et(),rR(0,tt(fn.DeviceSessionService)),rR(1,tt(Er.LoggerPublisherServiceFactory))],nR);var zz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},iR=(e,t)=>(r,n)=>t(r,n,e);let oR=class{_transports;_transportService;_logger;constructor(t,r){this._transports=t.getAllTransports(),this._transportService=t,this._logger=r("ListenToAvailableDevicesUseCase")}mapTransportDiscoveredDeviceToDiscoveredDevice(t){const r=new tI({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:r,transport:t.transport,name:t.name||r.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"),wl([[]]);if(!t){this._logger.info("Discovering all available transports");const r=this._transports.map((n,i)=>n.listenToAvailableDevices().pipe($a(o=>({index:i,arr:o}))));return cj(...r).pipe(gj((n,{index:i,arr:o})=>(n[i]=o,n),{}),$a(n=>Object.values(n).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`),TI([])),Just:r=>r.listenToAvailableDevices().pipe($a(n=>n.map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))})}};oR=zz([Et(),iR(0,tt(Ia.TransportService)),iR(1,tt(Er.LoggerPublisherServiceFactory))],oR);var Bz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},aR=(e,t)=>(r,n)=>t(r,n,e);let sR=class{constructor(t,r){this._sessionService=t,this._logger=r("ListenToConnectedDeviceUseCase")}_logger;execute(){return this._logger.info("Observe connected devices"),this._sessionService.sessionsObs.pipe($a(t=>new gb({transportConnectedDevice:t.connectedDevice,sessionId:t.id})))}};sR=Bz([Et(),aR(0,tt(fn.DeviceSessionService)),aR(1,tt(Er.LoggerPublisherServiceFactory))],sR);var Vz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},tm=(e,t)=>(r,n)=>t(r,n,e);let lR=class{constructor(t,r,n){this.connectUseCase=t,this.disconnectUseCase=r,this._logger=n("ReconnectUseCase")}_logger;async execute({device:t,sessionRefresherOptions:r}){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:r})}};lR=Vz([Et(),tm(0,tt($_.ConnectUseCase)),tm(1,tt($_.DisconnectUseCase)),tm(2,tt(Er.LoggerPublisherServiceFactory))],lR);var Hz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Uz=(e,t)=>(r,n)=>t(r,n,e);let uR=class{constructor(t){this._transportService=t}mapDiscoveredDevice(t){const r=new tI({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:r,transport:t.transport,name:t.name||r.name,rssi:t.rssi}}execute({transport:t}={}){if(!t){const r=this._transportService.getAllTransports();return TI(...r).pipe(fb(n=>n.startDiscovering().pipe($a(i=>this.mapDiscoveredDevice(i)))))}return this._transportService.getTransport(t).caseOf({Just:r=>r.startDiscovering().pipe($a(n=>this.mapDiscoveredDevice(n))),Nothing:()=>{throw new db(new Error("Unknown transport"))}})}};uR=Hz([Et(),Uz(0,tt(Ia.TransportService))],uR);var Wz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},cR=(e,t)=>(r,n)=>t(r,n,e);let fR=class{constructor(t,r){this.transportService=t,this._logger=r("StopDiscoveringUseCase")}_logger;async execute(){this._logger.debug("Stopping discovering devices");for(const t of this.transportService.getAllTransports())await t.stopDiscovering()}};fR=Wz([Et(),cR(0,tt(Ia.TransportService)),cR(1,tt(Er.LoggerPublisherServiceFactory))],fR);var Ru=(e=>(e[e.Fatal=0]="Fatal",e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Info=3]="Info",e[e.Debug=4]="Debug",e))(Ru||{});let qz=class{format(t){return Array.isArray(t)?t.map(r=>`[${r}]`).join(" "):`[${t}]`}};function Ry(e,t){if(typeof e=="bigint")return e.toString();if(Array.isArray(e))return t.has(e)?"[Circular]":(t.add(e),e.map(r=>Ry(r,t)));if(e!==null&&typeof e=="object"){if(t.has(e))return"[Circular]";t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=Ry(i,t);return r}return e}function Gz(e){const t=new WeakSet;t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=Ry(i,t);return r}var Xz=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i};let dR=class{subscribers;tag;tagFormatter;constructor(t,r,n=new qz){this.subscribers=t,this.tag=r,this.tagFormatter=n}_log(t,r,n){const i=n?.data?Gz(n.data):void 0,o=n?.tag??this.tag,s=this.tagFormatter.format(o);this.subscribers.forEach(u=>{const c={timestamp:n?.timestamp??Date.now(),tag:s,data:i};u.log(t,r,c)})}info(t,r){this._log(Ru.Info,t,r)}warn(t,r){this._log(Ru.Warning,t,r)}debug(t,r){this._log(Ru.Debug,t,r)}error(t,r){this._log(Ru.Error,t,r)}};dR=Xz([Et()],dR);let tc=class extends Error{status;statusText;responseBody;isTimeout;isAbort;cause;constructor(t){super(t.message),this.name="DmkNetworkClientError",this.status=t.status,this.statusText=t.statusText,this.responseBody=t.responseBody,this.isTimeout=t.isTimeout??!1,this.isAbort=t.isAbort??!1,this.cause=t.cause}};const Kz="application/json";function Yz(e,t){if(!t)return e;const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function Qz(e){const t=[];for(const[r,n]of Object.entries(e))n!=null&&t.push(`${encodeURIComponent(r)}=${encodeURIComponent(String(n))}`);return t.join("&")}function Jz(e){const{url:t,params:r,baseUrl:n}=e,i=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:n?Yz(n,t):t,o=r?Qz(r):"";if(o.length===0)return new URL(i);const s=i.includes("?")?"&":"?";return new URL(`${i}${s}${o}`)}function Zz(e,t){const r=t.toLowerCase();return Object.keys(e).some(n=>n.toLowerCase()===r)}function e8(e){return!!(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<"u"&&e instanceof Blob||typeof FormData<"u"&&e instanceof FormData||typeof URLSearchParams<"u"&&e instanceof URLSearchParams||typeof ReadableStream<"u"&&e instanceof ReadableStream)}function t8(e){const{method:t,body:r,defaultHeaders:n,perRequestHeaders:i}=e,o={...n,...i};return r===void 0||t==="GET"||t==="HEAD"?{body:void 0,headers:o}:e8(r)?{body:r,headers:o}:(Zz(o,"content-type")||(o["Content-Type"]=Kz),{body:JSON.stringify(r),headers:o})}function r8(e){const{timeoutMs:t,externalSignal:r}=e,n=t&&t>0?AbortSignal.timeout(t):void 0;return n&&r?AbortSignal.any([r,n]):n??r}async function n8(e,t){switch(t){case"void":return;case"text":return await e.text();case"blob":return await e.blob();case"arrayBuffer":return await e.arrayBuffer();case"json":default:{const r=await e.text();if(r.length===0)return;try{return JSON.parse(r)}catch(n){throw new tc({message:"Failed to parse JSON response body",status:e.status,statusText:e.statusText,responseBody:r,cause:n})}}}}async function i8(e){try{return await e.text()}catch{return}}function o8(e){const{cause:t,externalSignal:r,timeoutMs:n}=e,i=!!(n&&n>0);if(t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")){const o=r?.aborted??!1,s=!o&&(t.name==="TimeoutError"||i);return new tc({message:s?"Request timed out":"Request aborted",isTimeout:s,isAbort:o,cause:t})}return new tc({message:t instanceof Error?t.message:"Network request failed",cause:t})}let a8=class{baseUrl;defaultHeaders;fetchImpl;constructor(t={}){this.baseUrl=t.baseUrl,this.defaultHeaders=t.headers??{},this.fetchImpl=t.fetch}getFetch(){return this.fetchImpl??globalThis.fetch.bind(globalThis)}get(t,r){return this.request({...r,method:"GET",url:t}).then(n=>n.data)}post(t,r,n){return this.request({...n,method:"POST",url:t,body:r}).then(i=>i.data)}put(t,r,n){return this.request({...n,method:"PUT",url:t,body:r}).then(i=>i.data)}patch(t,r,n){return this.request({...n,method:"PATCH",url:t,body:r}).then(i=>i.data)}delete(t,r){return this.request({...r,method:"DELETE",url:t}).then(n=>n.data)}head(t,r){return this.request({...r,method:"HEAD",url:t,responseType:"void"}).then(()=>{})}async request(t){const r=Jz({url:t.url,params:t.params,baseUrl:this.baseUrl}),{body:n,headers:i}=t8({method:t.method,body:t.body,defaultHeaders:this.defaultHeaders,perRequestHeaders:t.headers}),o=r8({timeoutMs:t.timeoutMs,externalSignal:t.signal}),s=t.throwOnHttpError??!0,u=t.responseType??"json";let c;try{c=await this.getFetch()(r.toString(),{method:t.method,headers:i,body:n,signal:o})}catch(f){throw o8({cause:f,externalSignal:t.signal,timeoutMs:t.timeoutMs})}if(!c.ok&&s){const f=await i8(c);throw new tc({message:`HTTP error ${c.status} ${c.statusText}`.trim(),status:c.status,statusText:c.statusText,responseBody:f})}return{data:await n8(c,u),status:c.status,statusText:c.statusText,headers:c.headers,ok:c.ok}}};var Ou=(e=>(e.currency="currency",e.plugin="plugin",e.tool="tool",e.swap="swap",e))(Ou||{});const s8=1,l8="0";let ep=class{constructor(t){this.error=t,this.originalError=t}_tag="FetchError";originalError};var Tu=(e=>(e.currency="currency",e.plugin="plugin",e.tool="tool",e.swap="swap",e))(Tu||{}),u8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},c8=(e,t)=>(r,n)=>t(r,n,e);const Vo=e=>e instanceof tc&&e.cause!==void 0?new ep(e.cause):new ep(e);let pR=class{http;_provider=s8;_firmwareDistributionSalt=l8;constructor({managerApiUrl:t,provider:r,firmwareDistributionSalt:n}){this.http=new a8({baseUrl:t}),this._provider=r,this._firmwareDistributionSalt=n}setProvider(t){this._provider===t||t<1||(this._provider=t)}getProvider(){return this._provider}getAppList(t){const{targetId:r,firmwareVersionName:n}=t;return gt(()=>this.http.get("/v2/apps/by-target",{params:{target_id:r,provider:this._provider,firmware_version_name:n}})).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(Vo)}getMcuList(){return gt(()=>this.http.get("/mcu_versions")).chain(t=>this.mapMcuDtoToMcu(t)).mapLeft(Vo)}getDeviceVersion(t){const{targetId:r}=t;return gt(()=>this.http.get("/get_device_version",{params:{target_id:r,provider:this._provider}})).chain(n=>this.mapDeviceVersionDto(n)).mapLeft(Vo)}getFirmwareVersion(t){const{deviceId:r,version:n}=t;return gt(()=>this.http.get("/get_firmware_version",{params:{device_version:r,version_name:n,provider:this._provider}})).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(Vo)}getFirmwareVersionById(t){return gt(()=>this.http.get(`/firmware_final_versions/${t}`)).chain(r=>this.mapFinalFirmwareDto(r)).mapLeft(Vo)}getOsuFirmwareVersion(t){const{deviceId:r,version:n}=t;return gt(()=>this.http.get("/get_osu_version",{params:{device_version:r,version_name:n,provider:this._provider}})).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(Vo)}getLatestFirmwareVersion(t){const r="34.27.0",{currentFinalFirmwareId:n,deviceId:i}=t;return gt(()=>this.http.get("/get_latest_firmware",{params:{current_se_firmware_final_version:n,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:r}})).chain(o=>this.mapLatestFirmwareDto(o)).mapLeft(Vo)}getAppsByHash(t){const{hashes:r}=t;return gt(()=>this.http.post("/v2/apps/hash",r)).chain(n=>this.mapNullableApplicationDtoToApplication(n)).mapLeft(Vo)}getLanguagePackages(t){const{deviceId:r,currentFinalFirmwareId:n}=t;return gt(()=>this.http.get("/language-packages",{params:{device_version:r,current_se_firmware_final_version:n}})).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(Vo)}mapAppTypeDtoToAppType(t){if(t===null)return null;switch(t){case Tu.currency:return Ou.currency;case Tu.plugin:return Ou.plugin;case Tu.tool:return Ou.tool;case Tu.swap:return Ou.swap}}mapApplicationDtoToApplication(t){return gt(()=>Promise.resolve(t.map(r=>this.mapApplicationDto(r))))}mapNullableApplicationDtoToApplication(t){return gt(()=>Promise.resolve(t.map(r=>r===null?null:this.mapApplicationDto(r))))}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)}`);const{applicationType:r,hash:n,perso:i,firmware:o,firmwareKey:s,delete:u,deleteKey:c,...f}=t;return{...f,hash:n,perso:i,firmware:o,firmwareKey:s,delete:u,deleteKey:c,applicationType:this.mapAppTypeDtoToAppType(r)}}mapMcuDtoToMcu(t){return gt(()=>Promise.resolve(t.map(r=>{if(typeof r!="object"||typeof r.id!="number"||typeof r.name!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(r)}`);return{id:r.id,name:r.name}})))}mapDeviceVersionDto(t){return gt(()=>{if(typeof t!="object"||typeof t.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(t)}`);const r={id:t.id};return Promise.resolve(r)})}mapFinalFirmwareDto(t){return gt(()=>{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)}`);const r={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(r)})}mapLatestFirmwareDto(t){return gt(()=>{if(t.result!=="success"||!t.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${t.result}`);const r=t.se_firmware_osu_version;return Promise.resolve(r)}).chain(r=>this.mapOsuFirmwareDto(r))}mapOsuFirmwareDto(t){return gt(()=>{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)}`);const r={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(r)})}mapLanguagesDtoToLanguages(t){return gt(()=>Promise.resolve(t.map(r=>this.mapLanguageDto(r))))}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}}};pR=u8([Et(),c8(0,tt(Ap.DmkConfig))],pR);var f8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},d8=(e,t)=>(r,n)=>t(r,n,e);let hR=class{constructor(t){this.dataSource=t}getAppList(t){const r={targetId:t.targetId.toString(),firmwareVersionName:t.seVersion};return this.dataSource.getAppList(r)}getDeviceVersion(t){const r={targetId:t.targetId.toString()};return this.dataSource.getDeviceVersion(r)}getFirmwareVersion(t,r){const n={version:t.seVersion,deviceId:r.id};return this.dataSource.getFirmwareVersion(n)}getOsuFirmwareVersion(t,r){const n={version:t.seVersion,deviceId:r.id};return this.dataSource.getOsuFirmwareVersion(n)}getLatestFirmwareVersion(t,r){const n={currentFinalFirmwareId:t.id,deviceId:r.id};return this.dataSource.getLatestFirmwareVersion(n)}getNextFirmwareVersion(t){return this.dataSource.getFirmwareVersionById(t.nextFinalFirmware)}getLanguagePackages(t,r){const n={deviceId:t.id,currentFinalFirmwareId:r.id};return this.dataSource.getLanguagePackages(n)}getMcuList(){return this.dataSource.getMcuList()}getAppsByHash(t){const r={hashes:t};return gt(async({fromPromise:n,throwE:i})=>{if(r.hashes.length===0)return[];try{return await n(this.dataSource.getAppsByHash(r))}catch(o){return o instanceof ep?i(o):i(new ep(o))}})}};hR=f8([Et(),d8(0,tt(Ap.ManagerApiDataSource))],hR);var p8=(e,t,r,n)=>{for(var i=t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},gR=(e,t)=>(r,n)=>t(r,n,e);let vR=class{constructor(t,r){this.sessionService=t,this.managerApiDataSource=r}execute(t){for(const r of this.sessionService.getDeviceSessions()){const n=r.getDeviceSessionState();n.sessionStateType!==Zu.Connected&&r.setDeviceSessionState({...n,firmwareUpdateContext:void 0,installedApps:[],appsUpdates:void 0,catalog:void 0})}this.managerApiDataSource.setProvider(t)}};vR=p8([Et(),gR(0,tt(fn.DeviceSessionService)),gR(1,tt(Ap.ManagerApiDataSource))],vR);var Ya={},$u={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var h8=$u.exports,mR;function g8(){return mR||(mR=1,(function(e,t){(function(r){var n=t&&!t.nodeType&&t,i=e&&!e.nodeType&&e,o=typeof self=="object"&&self;(o.global===o||o.window===o||o.self===o)&&(r=o);var s,u=2147483647,c=36,f=1,d=26,g=38,h=700,y=72,m=128,S="-",b=/^xn--/,C=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,$={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=c-f,_=Math.floor,A=String.fromCharCode,O;function I(U){throw new RangeError($[U])}function L(U,D){for(var P=U.length,G=[];P--;)G[P]=D(U[P]);return G}function F(U,D){var P=U.split("@"),G="";P.length>1&&(G=P[0]+"@",U=P[1]),U=U.replace(x,".");var Z=U.split("."),te=L(Z,D).join(".");return G+te}function W(U){for(var D=[],P=0,G=U.length,Z,te;P<G;)Z=U.charCodeAt(P++),Z>=55296&&Z<=56319&&P<G?(te=U.charCodeAt(P++),(te&64512)==56320?D.push(((Z&1023)<<10)+(te&1023)+65536):(D.push(Z),P--)):D.push(Z);return D}function z(U){return L(U,function(D){var P="";return D>65535&&(D-=65536,P+=A(D>>>10&1023|55296),D=56320|D&1023),P+=A(D),P}).join("")}function B(U){return U-48<10?U-22:U-65<26?U-65:U-97<26?U-97:c}function j(U,D){return U+22+75*(U<26)-((D!=0)<<5)}function N(U,D,P){var G=0;for(U=P?_(U/h):U>>1,U+=_(U/D);U>T*d>>1;G+=c)U=_(U/T);return _(G+(T+1)*U/(U+g))}function X(U){var D=[],P=U.length,G,Z=0,te=m,K=y,ye,ae,be,he,xe,Se,Oe,Ee,_e;for(ye=U.lastIndexOf(S),ye<0&&(ye=0),ae=0;ae<ye;++ae)U.charCodeAt(ae)>=128&&I("not-basic"),D.push(U.charCodeAt(ae));for(be=ye>0?ye+1:0;be<P;){for(he=Z,xe=1,Se=c;be>=P&&I("invalid-input"),Oe=B(U.charCodeAt(be++)),(Oe>=c||Oe>_((u-Z)/xe))&&I("overflow"),Z+=Oe*xe,Ee=Se<=K?f:Se>=K+d?d:Se-K,!(Oe<Ee);Se+=c)_e=c-Ee,xe>_(u/_e)&&I("overflow"),xe*=_e;G=D.length+1,K=N(Z-he,G,he==0),_(Z/G)>u-te&&I("overflow"),te+=_(Z/G),Z%=G,D.splice(Z++,0,te)}return z(D)}function q(U){var D,P,G,Z,te,K,ye,ae,be,he,xe,Se=[],Oe,Ee,_e,$e;for(U=W(U),Oe=U.length,D=m,P=0,te=y,K=0;K<Oe;++K)xe=U[K],xe<128&&Se.push(A(xe));for(G=Z=Se.length,Z&&Se.push(S);G<Oe;){for(ye=u,K=0;K<Oe;++K)xe=U[K],xe>=D&&xe<ye&&(ye=xe);for(Ee=G+1,ye-D>_((u-P)/Ee)&&I("overflow"),P+=(ye-D)*Ee,D=ye,K=0;K<Oe;++K)if(xe=U[K],xe<D&&++P>u&&I("overflow"),xe==D){for(ae=P,be=c;he=be<=te?f:be>=te+d?d:be-te,!(ae<he);be+=c)$e=ae-he,_e=c-he,Se.push(A(j(he+$e%_e,0))),ae=_($e/_e);Se.push(A(j(ae,0))),te=N(P,Ee,G==Z),P=0,++G}++P,++D}return Se.join("")}function M(U){return F(U,function(D){return b.test(D)?X(D.slice(4).toLowerCase()):D})}function J(U){return F(U,function(D){return C.test(D)?"xn--"+q(D):D})}if(s={version:"1.4.1",ucs2:{decode:W,encode:z},decode:X,encode:q,toASCII:J,toUnicode:M},n&&i)if(e.exports==n)i.exports=s;else for(O in s)s.hasOwnProperty(O)&&(n[O]=s[O]);else r.punycode=s})(h8)})($u,$u.exports)),$u.exports}var rm,yR;function Ll(){return yR||(yR=1,rm=TypeError),rm}const v8={},m8=Object.freeze(Object.defineProperty({__proto__:null,default:v8},Symbol.toStringTag,{value:"Module"})),y8=M1(m8);var nm,bR;function Ip(){if(bR)return nm;bR=1;var e=typeof Map=="function"&&Map.prototype,t=Object.getOwnPropertyDescriptor&&e?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=e&&t&&typeof t.get=="function"?t.get:null,n=e&&Map.prototype.forEach,i=typeof Set=="function"&&Set.prototype,o=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=i&&o&&typeof o.get=="function"?o.get:null,u=i&&Set.prototype.forEach,c=typeof WeakMap=="function"&&WeakMap.prototype,f=c?WeakMap.prototype.has:null,d=typeof WeakSet=="function"&&WeakSet.prototype,g=d?WeakSet.prototype.has:null,h=typeof WeakRef=="function"&&WeakRef.prototype,y=h?WeakRef.prototype.deref:null,m=Boolean.prototype.valueOf,S=Object.prototype.toString,b=Function.prototype.toString,C=String.prototype.match,x=String.prototype.slice,$=String.prototype.replace,T=String.prototype.toUpperCase,_=String.prototype.toLowerCase,A=RegExp.prototype.test,O=Array.prototype.concat,I=Array.prototype.join,L=Array.prototype.slice,F=Math.floor,W=typeof BigInt=="function"?BigInt.prototype.valueOf:null,z=Object.getOwnPropertySymbols,B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,j=typeof Symbol=="function"&&typeof Symbol.iterator=="object",N=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===j||!0)?Symbol.toStringTag:null,X=Object.prototype.propertyIsEnumerable,q=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(V){return V.__proto__}:null);function M(V,ee){if(V===1/0||V===-1/0||V!==V||V&&V>-1e3&&V<1e3||A.call(/e/,ee))return ee;var Re=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof V=="number"){var le=V<0?-F(-V):F(V);if(le!==V){var fe=String(le),ve=x.call(ee,fe.length+1);return $.call(fe,Re,"$&_")+"."+$.call($.call(ve,/([0-9]{3})/g,"$&_"),/_$/,"")}}return $.call(ee,Re,"$&_")}var J=y8,U=J.custom,D=Oe(U)?U:null,P={__proto__:null,double:'"',single:"'"},G={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};nm=function V(ee,Re,le,fe){var ve=Re||{};if($e(ve,"quoteStyle")&&!$e(P,ve.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if($e(ve,"maxStringLength")&&(typeof ve.maxStringLength=="number"?ve.maxStringLength<0&&ve.maxStringLength!==1/0:ve.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Ae=$e(ve,"customInspect")?ve.customInspect:!0;if(typeof Ae!="boolean"&&Ae!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if($e(ve,"indent")&&ve.indent!==null&&ve.indent!==" "&&!(parseInt(ve.indent,10)===ve.indent&&ve.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if($e(ve,"numericSeparator")&&typeof ve.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Me=ve.numericSeparator;if(typeof ee>"u")return"undefined";if(ee===null)return"null";if(typeof ee=="boolean")return ee?"true":"false";if(typeof ee=="string")return lt(ee,ve);if(typeof ee=="number"){if(ee===0)return 1/0/ee>0?"0":"-0";var ze=String(ee);return Me?M(ee,ze):ze}if(typeof ee=="bigint"){var Je=String(ee)+"n";return Me?M(ee,Je):Je}var Ze=typeof ve.depth>"u"?5:ve.depth;if(typeof le>"u"&&(le=0),le>=Ze&&Ze>0&&typeof ee=="object")return K(ee)?"[Array]":"[Object]";var et=se(ve,le);if(typeof fe>"u")fe=[];else if(Qe(fe,ee)>=0)return"[Circular]";function Nt(er,_r,Fe){if(_r&&(fe=L.call(fe),fe.push(_r)),Fe){var Zn={depth:ve.depth};return $e(ve,"quoteStyle")&&(Zn.quoteStyle=ve.quoteStyle),V(er,Zn,le+1,fe)}return V(er,ve,le+1,fe)}if(typeof ee=="function"&&!ae(ee)){var ct=qe(ee),pt=Y(ee,Nt);return"[Function"+(ct?": "+ct:" (anonymous)")+"]"+(pt.length>0?" { "+I.call(pt,", ")+" }":"")}if(Oe(ee)){var bt=j?$.call(String(ee),/^(Symbol\(.*\))_[^)]*$/,"$1"):B.call(ee);return typeof ee=="object"&&!j?dt(bt):bt}if(Ge(ee)){for(var ht="<"+_.call(String(ee.nodeName)),mt=ee.attributes||[],_t=0;_t<mt.length;_t++)ht+=" "+mt[_t].name+"="+Z(te(mt[_t].value),"double",ve);return ht+=">",ee.childNodes&&ee.childNodes.length&&(ht+="..."),ht+="</"+_.call(String(ee.nodeName))+">",ht}if(K(ee)){if(ee.length===0)return"[]";var jt=Y(ee,Nt);return et&&!ne(jt)?"["+pe(jt,et)+"]":"[ "+I.call(jt,", ")+" ]"}if(be(ee)){var ar=Y(ee,Nt);return!("cause"in Error.prototype)&&"cause"in ee&&!X.call(ee,"cause")?"{ ["+String(ee)+"] "+I.call(O.call("[cause]: "+Nt(ee.cause),ar),", ")+" }":ar.length===0?"["+String(ee)+"]":"{ ["+String(ee)+"] "+I.call(ar,", ")+" }"}if(typeof ee=="object"&&Ae){if(D&&typeof ee[D]=="function"&&J)return J(ee,{depth:Ze-le});if(Ae!=="symbol"&&typeof ee.inspect=="function")return ee.inspect()}if(Ne(ee)){var dr=[];return n&&n.call(ee,function(er,_r){dr.push(Nt(_r,ee,!0)+" => "+Nt(er,ee))}),$t("Map",r.call(ee),dr,et)}if(Ve(ee)){var mr=[];return u&&u.call(ee,function(er){mr.push(Nt(er,ee))}),$t("Set",s.call(ee),mr,et)}if(je(ee))return Dt("WeakMap");if(Ce(ee))return Dt("WeakSet");if(Ke(ee))return Dt("WeakRef");if(xe(ee))return dt(Nt(Number(ee)));if(Ee(ee))return dt(Nt(W.call(ee)));if(Se(ee))return dt(m.call(ee));if(he(ee))return dt(Nt(String(ee)));if(typeof window<"u"&&ee===window)return"{ [object Window] }";if(typeof globalThis<"u"&&ee===globalThis||typeof self<"u"&&ee===self)return"{ [object globalThis] }";if(!ye(ee)&&!ae(ee)){var Cr=Y(ee,Nt),Pr=q?q(ee)===Object.prototype:ee instanceof Object||ee.constructor===Object,kr=ee instanceof Object?"":"null prototype",pr=!Pr&&N&&Object(ee)===ee&&N in ee?x.call(Pe(ee),8,-1):kr?"Object":"",hn=Pr||typeof ee.constructor!="function"?"":ee.constructor.name?ee.constructor.name+" ":"",Ht=hn+(pr||kr?"["+I.call(O.call([],pr||[],kr||[]),": ")+"] ":"");return Cr.length===0?Ht+"{}":et?Ht+"{"+pe(Cr,et)+"}":Ht+"{ "+I.call(Cr,", ")+" }"}return String(ee)};function Z(V,ee,Re){var le=Re.quoteStyle||ee,fe=P[le];return fe+V+fe}function te(V){return $.call(String(V),/"/g,"&quot;")}function K(V){return Pe(V)==="[object Array]"&&(!N||!(typeof V=="object"&&N in V))}function ye(V){return Pe(V)==="[object Date]"&&(!N||!(typeof V=="object"&&N in V))}function ae(V){return Pe(V)==="[object RegExp]"&&(!N||!(typeof V=="object"&&N in V))}function be(V){return Pe(V)==="[object Error]"&&(!N||!(typeof V=="object"&&N in V))}function he(V){return Pe(V)==="[object String]"&&(!N||!(typeof V=="object"&&N in V))}function xe(V){return Pe(V)==="[object Number]"&&(!N||!(typeof V=="object"&&N in V))}function Se(V){return Pe(V)==="[object Boolean]"&&(!N||!(typeof V=="object"&&N in V))}function Oe(V){if(j)return V&&typeof V=="object"&&V instanceof Symbol;if(typeof V=="symbol")return!0;if(!V||typeof V!="object"||!B)return!1;try{return B.call(V),!0}catch{}return!1}function Ee(V){if(!V||typeof V!="object"||!W)return!1;try{return W.call(V),!0}catch{}return!1}var _e=Object.prototype.hasOwnProperty||function(V){return V in this};function $e(V,ee){return _e.call(V,ee)}function Pe(V){return S.call(V)}function qe(V){if(V.name)return V.name;var ee=C.call(b.call(V),/^function\s*([\w$]+)/);return ee?ee[1]:null}function Qe(V,ee){if(V.indexOf)return V.indexOf(ee);for(var Re=0,le=V.length;Re<le;Re++)if(V[Re]===ee)return Re;return-1}function Ne(V){if(!r||!V||typeof V!="object")return!1;try{r.call(V);try{s.call(V)}catch{return!0}return V instanceof Map}catch{}return!1}function je(V){if(!f||!V||typeof V!="object")return!1;try{f.call(V,f);try{g.call(V,g)}catch{return!0}return V instanceof WeakMap}catch{}return!1}function Ke(V){if(!y||!V||typeof V!="object")return!1;try{return y.call(V),!0}catch{}return!1}function Ve(V){if(!s||!V||typeof V!="object")return!1;try{s.call(V);try{r.call(V)}catch{return!0}return V instanceof Set}catch{}return!1}function Ce(V){if(!g||!V||typeof V!="object")return!1;try{g.call(V,g);try{f.call(V,f)}catch{return!0}return V instanceof WeakSet}catch{}return!1}function Ge(V){return!V||typeof V!="object"?!1:typeof HTMLElement<"u"&&V instanceof HTMLElement?!0:typeof V.nodeName=="string"&&typeof V.getAttribute=="function"}function lt(V,ee){if(V.length>ee.maxStringLength){var Re=V.length-ee.maxStringLength,le="... "+Re+" more character"+(Re>1?"s":"");return lt(x.call(V,0,ee.maxStringLength),ee)+le}var fe=G[ee.quoteStyle||"single"];fe.lastIndex=0;var ve=$.call($.call(V,fe,"\\$1"),/[\x00-\x1f]/g,At);return Z(ve,"single",ee)}function At(V){var ee=V.charCodeAt(0),Re={8:"b",9:"t",10:"n",12:"f",13:"r"}[ee];return Re?"\\"+Re:"\\x"+(ee<16?"0":"")+T.call(ee.toString(16))}function dt(V){return"Object("+V+")"}function Dt(V){return V+" { ? }"}function $t(V,ee,Re,le){var fe=le?pe(Re,le):I.call(Re,", ");return V+" ("+ee+") {"+fe+"}"}function ne(V){for(var ee=0;ee<V.length;ee++)if(Qe(V[ee],`
526
526
  `)>=0)return!1;return!0}function se(V,ee){var Re;if(V.indent===" ")Re=" ";else if(typeof V.indent=="number"&&V.indent>0)Re=I.call(Array(V.indent+1)," ");else return null;return{base:Re,prev:I.call(Array(ee+1),Re)}}function pe(V,ee){if(V.length===0)return"";var Re=`
527
527
  `+ee.prev+ee.base;return Re+I.call(V,","+Re)+`
528
528
  `+ee.prev}function Y(V,ee){var Re=K(V),le=[];if(Re){le.length=V.length;for(var fe=0;fe<V.length;fe++)le[fe]=$e(V,fe)?ee(V[fe],V):""}var ve=typeof z=="function"?z(V):[],Ae;if(j){Ae={};for(var Me=0;Me<ve.length;Me++)Ae["$"+ve[Me]]=ve[Me]}for(var ze in V)$e(V,ze)&&(Re&&String(Number(ze))===ze&&ze<V.length||j&&Ae["$"+ze]instanceof Symbol||(A.call(/[^\w$]/,ze)?le.push(ee(ze,V)+": "+ee(V[ze],V)):le.push(ze+": "+ee(V[ze],V))));if(typeof z=="function")for(var Je=0;Je<ve.length;Je++)X.call(V,ve[Je])&&le.push("["+ee(ve[Je])+"]: "+ee(V[ve[Je]],V));return le}return nm}var im,SR;function b8(){if(SR)return im;SR=1;var e=Ip(),t=Ll(),r=function(u,c,f){for(var d=u,g;(g=d.next)!=null;d=g)if(g.key===c)return d.next=g.next,f||(g.next=u.next,u.next=g),g},n=function(u,c){if(u){var f=r(u,c);return f&&f.value}},i=function(u,c,f){var d=r(u,c);d?d.value=f:u.next={key:c,next:u.next,value:f}},o=function(u,c){return u?!!r(u,c):!1},s=function(u,c){if(u)return r(u,c,!0)};return im=function(){var c,f={assert:function(d){if(!f.has(d))throw new t("Side channel does not contain "+e(d))},delete:function(d){var g=c&&c.next,h=s(c,d);return h&&g&&g===h&&(c=void 0),!!h},get:function(d){return n(c,d)},has:function(d){return o(c,d)},set:function(d,g){c||(c={next:void 0}),i(c,d,g)}};return f},im}var om,wR;function DI(){return wR||(wR=1,om=Object),om}var am,xR;function S8(){return xR||(xR=1,am=Error),am}var sm,ER;function w8(){return ER||(ER=1,sm=EvalError),sm}var lm,CR;function x8(){return CR||(CR=1,lm=RangeError),lm}var um,_R;function E8(){return _R||(_R=1,um=ReferenceError),um}var cm,RR;function C8(){return RR||(RR=1,cm=SyntaxError),cm}var fm,OR;function _8(){return OR||(OR=1,fm=URIError),fm}var dm,TR;function R8(){return TR||(TR=1,dm=Math.abs),dm}var pm,$R;function O8(){return $R||($R=1,pm=Math.floor),pm}var hm,AR;function T8(){return AR||(AR=1,hm=Math.max),hm}var gm,IR;function $8(){return IR||(IR=1,gm=Math.min),gm}var vm,PR;function A8(){return PR||(PR=1,vm=Math.pow),vm}var mm,kR;function I8(){return kR||(kR=1,mm=Math.round),mm}var ym,MR;function P8(){return MR||(MR=1,ym=Number.isNaN||function(t){return t!==t}),ym}var bm,DR;function k8(){if(DR)return bm;DR=1;var e=P8();return bm=function(r){return e(r)||r===0?r:r<0?-1:1},bm}var Sm,LR;function M8(){return LR||(LR=1,Sm=Object.getOwnPropertyDescriptor),Sm}var wm,FR;function LI(){if(FR)return wm;FR=1;var e=M8();if(e)try{e([],"length")}catch{e=null}return wm=e,wm}var xm,NR;function D8(){if(NR)return xm;NR=1;var e=Object.defineProperty||!1;if(e)try{e({},"a",{value:1})}catch{e=!1}return xm=e,xm}var Em,jR;function L8(){return jR||(jR=1,Em=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(t,r);if(u.value!==i||u.enumerable!==!0)return!1}return!0}),Em}var Cm,zR;function F8(){if(zR)return Cm;zR=1;var e=typeof Symbol<"u"&&Symbol,t=L8();return Cm=function(){return typeof e!="function"||typeof Symbol!="function"||typeof e("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Cm}var _m,BR;function FI(){return BR||(BR=1,_m=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),_m}var Rm,VR;function NI(){if(VR)return Rm;VR=1;var e=DI();return Rm=e.getPrototypeOf||null,Rm}var Om,HR;function N8(){if(HR)return Om;HR=1;var e="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,r=Math.max,n="[object Function]",i=function(c,f){for(var d=[],g=0;g<c.length;g+=1)d[g]=c[g];for(var h=0;h<f.length;h+=1)d[h+c.length]=f[h];return d},o=function(c,f){for(var d=[],g=f,h=0;g<c.length;g+=1,h+=1)d[h]=c[g];return d},s=function(u,c){for(var f="",d=0;d<u.length;d+=1)f+=u[d],d+1<u.length&&(f+=c);return f};return Om=function(c){var f=this;if(typeof f!="function"||t.apply(f)!==n)throw new TypeError(e+f);for(var d=o(arguments,1),g,h=function(){if(this instanceof g){var C=f.apply(this,i(d,arguments));return Object(C)===C?C:this}return f.apply(c,i(d,arguments))},y=r(0,f.length-d.length),m=[],S=0;S<y;S++)m[S]="$"+S;if(g=Function("binder","return function ("+s(m,",")+"){ return binder.apply(this,arguments); }")(h),f.prototype){var b=function(){};b.prototype=f.prototype,g.prototype=new b,b.prototype=null}return g},Om}var Tm,UR;function Pp(){if(UR)return Tm;UR=1;var e=N8();return Tm=Function.prototype.bind||e,Tm}var $m,WR;function vb(){return WR||(WR=1,$m=Function.prototype.call),$m}var Am,qR;function jI(){return qR||(qR=1,Am=Function.prototype.apply),Am}var Im,GR;function j8(){return GR||(GR=1,Im=typeof Reflect<"u"&&Reflect&&Reflect.apply),Im}var Pm,XR;function z8(){if(XR)return Pm;XR=1;var e=Pp(),t=jI(),r=vb(),n=j8();return Pm=n||e.call(r,t),Pm}var km,KR;function zI(){if(KR)return km;KR=1;var e=Pp(),t=Ll(),r=vb(),n=z8();return km=function(o){if(o.length<1||typeof o[0]!="function")throw new t("a function is required");return n(e,r,o)},km}var Mm,YR;function B8(){if(YR)return Mm;YR=1;var e=zI(),t=LI(),r;try{r=[].__proto__===Array.prototype}catch(s){if(!s||typeof s!="object"||!("code"in s)||s.code!=="ERR_PROTO_ACCESS")throw s}var n=!!r&&t&&t(Object.prototype,"__proto__"),i=Object,o=i.getPrototypeOf;return Mm=n&&typeof n.get=="function"?e([n.get]):typeof o=="function"?function(u){return o(u==null?u:i(u))}:!1,Mm}var Dm,QR;function V8(){if(QR)return Dm;QR=1;var e=FI(),t=NI(),r=B8();return Dm=e?function(i){return e(i)}:t?function(i){if(!i||typeof i!="object"&&typeof i!="function")throw new TypeError("getProto: not an object");return t(i)}:r?function(i){return r(i)}:null,Dm}var Lm,JR;function H8(){if(JR)return Lm;JR=1;var e=Function.prototype.call,t=Object.prototype.hasOwnProperty,r=Pp();return Lm=r.call(e,t),Lm}var Fm,ZR;function mb(){if(ZR)return Fm;ZR=1;var e,t=DI(),r=S8(),n=w8(),i=x8(),o=E8(),s=C8(),u=Ll(),c=_8(),f=R8(),d=O8(),g=T8(),h=$8(),y=A8(),m=I8(),S=k8(),b=Function,C=function(be){try{return b('"use strict"; return ('+be+").constructor;")()}catch{}},x=LI(),$=D8(),T=function(){throw new u},_=x?(function(){try{return arguments.callee,T}catch{try{return x(arguments,"callee").get}catch{return T}}})():T,A=F8()(),O=V8(),I=NI(),L=FI(),F=jI(),W=vb(),z={},B=typeof Uint8Array>"u"||!O?e:O(Uint8Array),j={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?e:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?e:ArrayBuffer,"%ArrayIteratorPrototype%":A&&O?O([][Symbol.iterator]()):e,"%AsyncFromSyncIteratorPrototype%":e,"%AsyncFunction%":z,"%AsyncGenerator%":z,"%AsyncGeneratorFunction%":z,"%AsyncIteratorPrototype%":z,"%Atomics%":typeof Atomics>"u"?e:Atomics,"%BigInt%":typeof BigInt>"u"?e:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?e:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?e:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?e:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?e:Float16Array,"%Float32Array%":typeof Float32Array>"u"?e:Float32Array,"%Float64Array%":typeof Float64Array>"u"?e:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?e:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":z,"%Int8Array%":typeof Int8Array>"u"?e:Int8Array,"%Int16Array%":typeof Int16Array>"u"?e:Int16Array,"%Int32Array%":typeof Int32Array>"u"?e:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A&&O?O(O([][Symbol.iterator]())):e,"%JSON%":typeof JSON=="object"?JSON:e,"%Map%":typeof Map>"u"?e:Map,"%MapIteratorPrototype%":typeof Map>"u"||!A||!O?e:O(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t,"%Object.getOwnPropertyDescriptor%":x,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?e:Promise,"%Proxy%":typeof Proxy>"u"?e:Proxy,"%RangeError%":i,"%ReferenceError%":o,"%Reflect%":typeof Reflect>"u"?e:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?e:Set,"%SetIteratorPrototype%":typeof Set>"u"||!A||!O?e:O(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?e:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A&&O?O(""[Symbol.iterator]()):e,"%Symbol%":A?Symbol:e,"%SyntaxError%":s,"%ThrowTypeError%":_,"%TypedArray%":B,"%TypeError%":u,"%Uint8Array%":typeof Uint8Array>"u"?e:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?e:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?e:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?e:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?e:WeakMap,"%WeakRef%":typeof WeakRef>"u"?e:WeakRef,"%WeakSet%":typeof WeakSet>"u"?e:WeakSet,"%Function.prototype.call%":W,"%Function.prototype.apply%":F,"%Object.defineProperty%":$,"%Object.getPrototypeOf%":I,"%Math.abs%":f,"%Math.floor%":d,"%Math.max%":g,"%Math.min%":h,"%Math.pow%":y,"%Math.round%":m,"%Math.sign%":S,"%Reflect.getPrototypeOf%":L};if(O)try{null.error}catch(be){var N=O(O(be));j["%Error.prototype%"]=N}var X=function be(he){var xe;if(he==="%AsyncFunction%")xe=C("async function () {}");else if(he==="%GeneratorFunction%")xe=C("function* () {}");else if(he==="%AsyncGeneratorFunction%")xe=C("async function* () {}");else if(he==="%AsyncGenerator%"){var Se=be("%AsyncGeneratorFunction%");Se&&(xe=Se.prototype)}else if(he==="%AsyncIteratorPrototype%"){var Oe=be("%AsyncGenerator%");Oe&&O&&(xe=O(Oe.prototype))}return j[he]=xe,xe},q={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},M=Pp(),J=H8(),U=M.call(W,Array.prototype.concat),D=M.call(F,Array.prototype.splice),P=M.call(W,String.prototype.replace),G=M.call(W,String.prototype.slice),Z=M.call(W,RegExp.prototype.exec),te=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,ye=function(he){var xe=G(he,0,1),Se=G(he,-1);if(xe==="%"&&Se!=="%")throw new s("invalid intrinsic syntax, expected closing `%`");if(Se==="%"&&xe!=="%")throw new s("invalid intrinsic syntax, expected opening `%`");var Oe=[];return P(he,te,function(Ee,_e,$e,Pe){Oe[Oe.length]=$e?P(Pe,K,"$1"):_e||Ee}),Oe},ae=function(he,xe){var Se=he,Oe;if(J(q,Se)&&(Oe=q[Se],Se="%"+Oe[0]+"%"),J(j,Se)){var Ee=j[Se];if(Ee===z&&(Ee=X(Se)),typeof Ee>"u"&&!xe)throw new u("intrinsic "+he+" exists, but is not available. Please file an issue!");return{alias:Oe,name:Se,value:Ee}}throw new s("intrinsic "+he+" does not exist!")};return Fm=function(he,xe){if(typeof he!="string"||he.length===0)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof xe!="boolean")throw new u('"allowMissing" argument must be a boolean');if(Z(/^%?[^%]*%?$/,he)===null)throw new s("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var Se=ye(he),Oe=Se.length>0?Se[0]:"",Ee=ae("%"+Oe+"%",xe),_e=Ee.name,$e=Ee.value,Pe=!1,qe=Ee.alias;qe&&(Oe=qe[0],D(Se,U([0,1],qe)));for(var Qe=1,Ne=!0;Qe<Se.length;Qe+=1){var je=Se[Qe],Ke=G(je,0,1),Ve=G(je,-1);if((Ke==='"'||Ke==="'"||Ke==="`"||Ve==='"'||Ve==="'"||Ve==="`")&&Ke!==Ve)throw new s("property names with quotes must have matching quotes");if((je==="constructor"||!Ne)&&(Pe=!0),Oe+="."+je,_e="%"+Oe+"%",J(j,_e))$e=j[_e];else if($e!=null){if(!(je in $e)){if(!xe)throw new u("base intrinsic for "+he+" exists, but the property is not available.");return}if(x&&Qe+1>=Se.length){var Ce=x($e,je);Ne=!!Ce,Ne&&"get"in Ce&&!("originalValue"in Ce.get)?$e=Ce.get:$e=$e[je]}else Ne=J($e,je),$e=$e[je];Ne&&!Pe&&(j[_e]=$e)}}return $e},Fm}var Nm,eO;function BI(){if(eO)return Nm;eO=1;var e=mb(),t=zI(),r=t([e("%String.prototype.indexOf%")]);return Nm=function(i,o){var s=e(i,!!o);return typeof s=="function"&&r(i,".prototype.")>-1?t([s]):s},Nm}var jm,tO;function VI(){if(tO)return jm;tO=1;var e=mb(),t=BI(),r=Ip(),n=Ll(),i=e("%Map%",!0),o=t("Map.prototype.get",!0),s=t("Map.prototype.set",!0),u=t("Map.prototype.has",!0),c=t("Map.prototype.delete",!0),f=t("Map.prototype.size",!0);return jm=!!i&&function(){var g,h={assert:function(y){if(!h.has(y))throw new n("Side channel does not contain "+r(y))},delete:function(y){if(g){var m=c(g,y);return f(g)===0&&(g=void 0),m}return!1},get:function(y){if(g)return o(g,y)},has:function(y){return g?u(g,y):!1},set:function(y,m){g||(g=new i),s(g,y,m)}};return h},jm}var zm,rO;function U8(){if(rO)return zm;rO=1;var e=mb(),t=BI(),r=Ip(),n=VI(),i=Ll(),o=e("%WeakMap%",!0),s=t("WeakMap.prototype.get",!0),u=t("WeakMap.prototype.set",!0),c=t("WeakMap.prototype.has",!0),f=t("WeakMap.prototype.delete",!0);return zm=o?(function(){var g,h,y={assert:function(m){if(!y.has(m))throw new i("Side channel does not contain "+r(m))},delete:function(m){if(o&&m&&(typeof m=="object"||typeof m=="function")){if(g)return f(g,m)}else if(n&&h)return h.delete(m);return!1},get:function(m){return o&&m&&(typeof m=="object"||typeof m=="function")&&g?s(g,m):h&&h.get(m)},has:function(m){return o&&m&&(typeof m=="object"||typeof m=="function")&&g?c(g,m):!!h&&h.has(m)},set:function(m,S){o&&m&&(typeof m=="object"||typeof m=="function")?(g||(g=new o),u(g,m,S)):n&&(h||(h=n()),h.set(m,S))}};return y}):n,zm}var Bm,nO;function HI(){if(nO)return Bm;nO=1;var e=Ll(),t=Ip(),r=b8(),n=VI(),i=U8(),o=i||n||r;return Bm=function(){var u,c={assert:function(f){if(!c.has(f))throw new e("Side channel does not contain "+t(f))},delete:function(f){return!!u&&u.delete(f)},get:function(f){return u&&u.get(f)},has:function(f){return!!u&&u.has(f)},set:function(f,d){u||(u=o()),u.set(f,d)}};return c},Bm}var Vm,iO;function yb(){if(iO)return Vm;iO=1;var e=String.prototype.replace,t=/%20/g,r={RFC1738:"RFC1738",RFC3986:"RFC3986"};return Vm={default:r.RFC3986,formatters:{RFC1738:function(n){return e.call(n,t,"+")},RFC3986:function(n){return String(n)}},RFC1738:r.RFC1738,RFC3986:r.RFC3986},Vm}var Hm,oO;function UI(){if(oO)return Hm;oO=1;var e=yb(),t=HI(),r=Object.prototype.hasOwnProperty,n=Array.isArray,i=t(),o=function(O,I){return i.set(O,I),O},s=function(O){return i.has(O)},u=function(O){return i.get(O)},c=function(O,I){i.set(O,I)},f=(function(){for(var A=[],O=0;O<256;++O)A.push("%"+((O<16?"0":"")+O.toString(16)).toUpperCase());return A})(),d=function(O){for(;O.length>1;){var I=O.pop(),L=I.obj[I.prop];if(n(L)){for(var F=[],W=0;W<L.length;++W)typeof L[W]<"u"&&F.push(L[W]);I.obj[I.prop]=F}}},g=function(O,I){for(var L=I&&I.plainObjects?{__proto__:null}:{},F=0;F<O.length;++F)typeof O[F]<"u"&&(L[F]=O[F]);return L},h=function A(O,I,L){if(!I)return O;if(typeof I!="object"&&typeof I!="function"){if(n(O))O.push(I);else if(O&&typeof O=="object")if(s(O)){var F=u(O)+1;O[F]=I,c(O,F)}else(L&&(L.plainObjects||L.allowPrototypes)||!r.call(Object.prototype,I))&&(O[I]=!0);else return[O,I];return O}if(!O||typeof O!="object"){if(s(I)){for(var W=Object.keys(I),z=L&&L.plainObjects?{__proto__:null,0:O}:{0:O},B=0;B<W.length;B++){var j=parseInt(W[B],10);z[j+1]=I[W[B]]}return o(z,u(I)+1)}return[O].concat(I)}var N=O;return n(O)&&!n(I)&&(N=g(O,L)),n(O)&&n(I)?(I.forEach(function(X,q){if(r.call(O,q)){var M=O[q];M&&typeof M=="object"&&X&&typeof X=="object"?O[q]=A(M,X,L):O.push(X)}else O[q]=X}),O):Object.keys(I).reduce(function(X,q){var M=I[q];return r.call(X,q)?X[q]=A(X[q],M,L):X[q]=M,X},N)},y=function(O,I){return Object.keys(I).reduce(function(L,F){return L[F]=I[F],L},O)},m=function(A,O,I){var L=A.replace(/\+/g," ");if(I==="iso-8859-1")return L.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(L)}catch{return L}},S=1024,b=function(O,I,L,F,W){if(O.length===0)return O;var z=O;if(typeof O=="symbol"?z=Symbol.prototype.toString.call(O):typeof O!="string"&&(z=String(O)),L==="iso-8859-1")return escape(z).replace(/%u[0-9a-f]{4}/gi,function(J){return"%26%23"+parseInt(J.slice(2),16)+"%3B"});for(var B="",j=0;j<z.length;j+=S){for(var N=z.length>=S?z.slice(j,j+S):z,X=[],q=0;q<N.length;++q){var M=N.charCodeAt(q);if(M===45||M===46||M===95||M===126||M>=48&&M<=57||M>=65&&M<=90||M>=97&&M<=122||W===e.RFC1738&&(M===40||M===41)){X[X.length]=N.charAt(q);continue}if(M<128){X[X.length]=f[M];continue}if(M<2048){X[X.length]=f[192|M>>6]+f[128|M&63];continue}if(M<55296||M>=57344){X[X.length]=f[224|M>>12]+f[128|M>>6&63]+f[128|M&63];continue}q+=1,M=65536+((M&1023)<<10|N.charCodeAt(q)&1023),X[X.length]=f[240|M>>18]+f[128|M>>12&63]+f[128|M>>6&63]+f[128|M&63]}B+=X.join("")}return B},C=function(O){for(var I=[{obj:{o:O},prop:"o"}],L=[],F=0;F<I.length;++F)for(var W=I[F],z=W.obj[W.prop],B=Object.keys(z),j=0;j<B.length;++j){var N=B[j],X=z[N];typeof X=="object"&&X!==null&&L.indexOf(X)===-1&&(I.push({obj:z,prop:N}),L.push(X))}return d(I),O},x=function(O){return Object.prototype.toString.call(O)==="[object RegExp]"},$=function(O){return!O||typeof O!="object"?!1:!!(O.constructor&&O.constructor.isBuffer&&O.constructor.isBuffer(O))},T=function(O,I,L,F){if(s(O)){var W=u(O)+1;return O[W]=I,c(O,W),O}var z=[].concat(O,I);return z.length>L?o(g(z,{plainObjects:F}),z.length-1):z},_=function(O,I){if(n(O)){for(var L=[],F=0;F<O.length;F+=1)L.push(I(O[F]));return L}return I(O)};return Hm={arrayToObject:g,assign:y,combine:T,compact:C,decode:m,encode:b,isBuffer:$,isOverflow:s,isRegExp:x,maybeMap:_,merge:h},Hm}var Um,aO;function W8(){if(aO)return Um;aO=1;var e=HI(),t=UI(),r=yb(),n=Object.prototype.hasOwnProperty,i={brackets:function(b){return b+"[]"},comma:"comma",indices:function(b,C){return b+"["+C+"]"},repeat:function(b){return b}},o=Array.isArray,s=Array.prototype.push,u=function(S,b){s.apply(S,o(b)?b:[b])},c=Date.prototype.toISOString,f=r.default,d={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:t.encode,encodeValuesOnly:!1,filter:void 0,format:f,formatter:r.formatters[f],indices:!1,serializeDate:function(b){return c.call(b)},skipNulls:!1,strictNullHandling:!1},g=function(b){return typeof b=="string"||typeof b=="number"||typeof b=="boolean"||typeof b=="symbol"||typeof b=="bigint"},h={},y=function S(b,C,x,$,T,_,A,O,I,L,F,W,z,B,j,N,X,q){for(var M=b,J=q,U=0,D=!1;(J=J.get(h))!==void 0&&!D;){var P=J.get(b);if(U+=1,typeof P<"u"){if(P===U)throw new RangeError("Cyclic object value");D=!0}typeof J.get(h)>"u"&&(U=0)}if(typeof L=="function"?M=L(C,M):M instanceof Date?M=z(M):x==="comma"&&o(M)&&(M=t.maybeMap(M,function(_e){return _e instanceof Date?z(_e):_e})),M===null){if(_)return I&&!N?I(C,d.encoder,X,"key",B):C;M=""}if(g(M)||t.isBuffer(M)){if(I){var G=N?C:I(C,d.encoder,X,"key",B);return[j(G)+"="+j(I(M,d.encoder,X,"value",B))]}return[j(C)+"="+j(String(M))]}var Z=[];if(typeof M>"u")return Z;var te;if(x==="comma"&&o(M))N&&I&&(M=t.maybeMap(M,I)),te=[{value:M.length>0?M.join(",")||null:void 0}];else if(o(L))te=L;else{var K=Object.keys(M);te=F?K.sort(F):K}var ye=O?String(C).replace(/\./g,"%2E"):String(C),ae=$&&o(M)&&M.length===1?ye+"[]":ye;if(T&&o(M)&&M.length===0)return ae+"[]";for(var be=0;be<te.length;++be){var he=te[be],xe=typeof he=="object"&&he&&typeof he.value<"u"?he.value:M[he];if(!(A&&xe===null)){var Se=W&&O?String(he).replace(/\./g,"%2E"):String(he),Oe=o(M)?typeof x=="function"?x(ae,Se):ae:ae+(W?"."+Se:"["+Se+"]");q.set(b,U);var Ee=e();Ee.set(h,q),u(Z,S(xe,Oe,x,$,T,_,A,O,x==="comma"&&N&&o(M)?null:I,L,F,W,z,B,j,N,X,Ee))}}return Z},m=function(b){if(!b)return d;if(typeof b.allowEmptyArrays<"u"&&typeof b.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof b.encodeDotInKeys<"u"&&typeof b.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(b.encoder!==null&&typeof b.encoder<"u"&&typeof b.encoder!="function")throw new TypeError("Encoder has to be a function.");var C=b.charset||d.charset;if(typeof b.charset<"u"&&b.charset!=="utf-8"&&b.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var x=r.default;if(typeof b.format<"u"){if(!n.call(r.formatters,b.format))throw new TypeError("Unknown format option provided.");x=b.format}var $=r.formatters[x],T=d.filter;(typeof b.filter=="function"||o(b.filter))&&(T=b.filter);var _;if(b.arrayFormat in i?_=b.arrayFormat:"indices"in b?_=b.indices?"indices":"repeat":_=d.arrayFormat,"commaRoundTrip"in b&&typeof b.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var A=typeof b.allowDots>"u"?b.encodeDotInKeys===!0?!0:d.allowDots:!!b.allowDots;return{addQueryPrefix:typeof b.addQueryPrefix=="boolean"?b.addQueryPrefix:d.addQueryPrefix,allowDots:A,allowEmptyArrays:typeof b.allowEmptyArrays=="boolean"?!!b.allowEmptyArrays:d.allowEmptyArrays,arrayFormat:_,charset:C,charsetSentinel:typeof b.charsetSentinel=="boolean"?b.charsetSentinel:d.charsetSentinel,commaRoundTrip:!!b.commaRoundTrip,delimiter:typeof b.delimiter>"u"?d.delimiter:b.delimiter,encode:typeof b.encode=="boolean"?b.encode:d.encode,encodeDotInKeys:typeof b.encodeDotInKeys=="boolean"?b.encodeDotInKeys:d.encodeDotInKeys,encoder:typeof b.encoder=="function"?b.encoder:d.encoder,encodeValuesOnly:typeof b.encodeValuesOnly=="boolean"?b.encodeValuesOnly:d.encodeValuesOnly,filter:T,format:x,formatter:$,serializeDate:typeof b.serializeDate=="function"?b.serializeDate:d.serializeDate,skipNulls:typeof b.skipNulls=="boolean"?b.skipNulls:d.skipNulls,sort:typeof b.sort=="function"?b.sort:null,strictNullHandling:typeof b.strictNullHandling=="boolean"?b.strictNullHandling:d.strictNullHandling}};return Um=function(S,b){var C=S,x=m(b),$,T;typeof x.filter=="function"?(T=x.filter,C=T("",C)):o(x.filter)&&(T=x.filter,$=T);var _=[];if(typeof C!="object"||C===null)return"";var A=i[x.arrayFormat],O=A==="comma"&&x.commaRoundTrip;$||($=Object.keys(C)),x.sort&&$.sort(x.sort);for(var I=e(),L=0;L<$.length;++L){var F=$[L],W=C[F];x.skipNulls&&W===null||u(_,y(W,F,A,O,x.allowEmptyArrays,x.strictNullHandling,x.skipNulls,x.encodeDotInKeys,x.encode?x.encoder:null,x.filter,x.sort,x.allowDots,x.serializeDate,x.format,x.formatter,x.encodeValuesOnly,x.charset,I))}var z=_.join(x.delimiter),B=x.addQueryPrefix===!0?"?":"";return x.charsetSentinel&&(x.charset==="iso-8859-1"?B+="utf8=%26%2310003%3B&":B+="utf8=%E2%9C%93&"),z.length>0?B+z:""},Um}var Wm,sO;function q8(){if(sO)return Wm;sO=1;var e=UI(),t=Object.prototype.hasOwnProperty,r=Array.isArray,n={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:e.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},i=function(y){return y.replace(/&#(\d+);/g,function(m,S){return String.fromCharCode(parseInt(S,10))})},o=function(y,m,S){if(y&&typeof y=="string"&&m.comma&&y.indexOf(",")>-1)return y.split(",");if(m.throwOnLimitExceeded&&S>=m.arrayLimit)throw new RangeError("Array limit exceeded. Only "+m.arrayLimit+" element"+(m.arrayLimit===1?"":"s")+" allowed in an array.");return y},s="utf8=%26%2310003%3B",u="utf8=%E2%9C%93",c=function(m,S){var b={__proto__:null},C=S.ignoreQueryPrefix?m.replace(/^\?/,""):m;C=C.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var x=S.parameterLimit===1/0?void 0:S.parameterLimit,$=C.split(S.delimiter,S.throwOnLimitExceeded?x+1:x);if(S.throwOnLimitExceeded&&$.length>x)throw new RangeError("Parameter limit exceeded. Only "+x+" parameter"+(x===1?"":"s")+" allowed.");var T=-1,_,A=S.charset;if(S.charsetSentinel)for(_=0;_<$.length;++_)$[_].indexOf("utf8=")===0&&($[_]===u?A="utf-8":$[_]===s&&(A="iso-8859-1"),T=_,_=$.length);for(_=0;_<$.length;++_)if(_!==T){var O=$[_],I=O.indexOf("]="),L=I===-1?O.indexOf("="):I+1,F,W;if(L===-1?(F=S.decoder(O,n.decoder,A,"key"),W=S.strictNullHandling?null:""):(F=S.decoder(O.slice(0,L),n.decoder,A,"key"),F!==null&&(W=e.maybeMap(o(O.slice(L+1),S,r(b[F])?b[F].length:0),function(B){return S.decoder(B,n.decoder,A,"value")}))),W&&S.interpretNumericEntities&&A==="iso-8859-1"&&(W=i(String(W))),O.indexOf("[]=")>-1&&(W=r(W)?[W]:W),F!==null){var z=t.call(b,F);z&&S.duplicates==="combine"?b[F]=e.combine(b[F],W,S.arrayLimit,S.plainObjects):(!z||S.duplicates==="last")&&(b[F]=W)}}return b},f=function(y,m,S,b){var C=0;if(y.length>0&&y[y.length-1]==="[]"){var x=y.slice(0,-1).join("");C=Array.isArray(m)&&m[x]?m[x].length:0}for(var $=b?m:o(m,S,C),T=y.length-1;T>=0;--T){var _,A=y[T];if(A==="[]"&&S.parseArrays)e.isOverflow($)?_=$:_=S.allowEmptyArrays&&($===""||S.strictNullHandling&&$===null)?[]:e.combine([],$,S.arrayLimit,S.plainObjects);else{_=S.plainObjects?{__proto__:null}:{};var O=A.charAt(0)==="["&&A.charAt(A.length-1)==="]"?A.slice(1,-1):A,I=S.decodeDotInKeys?O.replace(/%2E/g,"."):O,L=parseInt(I,10);!S.parseArrays&&I===""?_={0:$}:!isNaN(L)&&A!==I&&String(L)===I&&L>=0&&S.parseArrays&&L<=S.arrayLimit?(_=[],_[L]=$):I!=="__proto__"&&(_[I]=$)}$=_}return $},d=function(m,S){var b=S.allowDots?m.replace(/\.([^.[]+)/g,"[$1]"):m;if(S.depth<=0)return!S.plainObjects&&t.call(Object.prototype,b)&&!S.allowPrototypes?void 0:[b];var C=/(\[[^[\]]*])/,x=/(\[[^[\]]*])/g,$=C.exec(b),T=$?b.slice(0,$.index):b,_=[];if(T){if(!S.plainObjects&&t.call(Object.prototype,T)&&!S.allowPrototypes)return;_.push(T)}for(var A=0;($=x.exec(b))!==null&&A<S.depth;){A+=1;var O=$[1].slice(1,-1);if(!S.plainObjects&&t.call(Object.prototype,O)&&!S.allowPrototypes)return;_.push($[1])}if($){if(S.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+S.depth+" and strictDepth is true");_.push("["+b.slice($.index)+"]")}return _},g=function(m,S,b,C){if(m){var x=d(m,b);if(x)return f(x,S,b,C)}},h=function(m){if(!m)return n;if(typeof m.allowEmptyArrays<"u"&&typeof m.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof m.decodeDotInKeys<"u"&&typeof m.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(m.decoder!==null&&typeof m.decoder<"u"&&typeof m.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof m.charset<"u"&&m.charset!=="utf-8"&&m.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof m.throwOnLimitExceeded<"u"&&typeof m.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var S=typeof m.charset>"u"?n.charset:m.charset,b=typeof m.duplicates>"u"?n.duplicates:m.duplicates;if(b!=="combine"&&b!=="first"&&b!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var C=typeof m.allowDots>"u"?m.decodeDotInKeys===!0?!0:n.allowDots:!!m.allowDots;return{allowDots:C,allowEmptyArrays:typeof m.allowEmptyArrays=="boolean"?!!m.allowEmptyArrays:n.allowEmptyArrays,allowPrototypes:typeof m.allowPrototypes=="boolean"?m.allowPrototypes:n.allowPrototypes,allowSparse:typeof m.allowSparse=="boolean"?m.allowSparse:n.allowSparse,arrayLimit:typeof m.arrayLimit=="number"?m.arrayLimit:n.arrayLimit,charset:S,charsetSentinel:typeof m.charsetSentinel=="boolean"?m.charsetSentinel:n.charsetSentinel,comma:typeof m.comma=="boolean"?m.comma:n.comma,decodeDotInKeys:typeof m.decodeDotInKeys=="boolean"?m.decodeDotInKeys:n.decodeDotInKeys,decoder:typeof m.decoder=="function"?m.decoder:n.decoder,delimiter:typeof m.delimiter=="string"||e.isRegExp(m.delimiter)?m.delimiter:n.delimiter,depth:typeof m.depth=="number"||m.depth===!1?+m.depth:n.depth,duplicates:b,ignoreQueryPrefix:m.ignoreQueryPrefix===!0,interpretNumericEntities:typeof m.interpretNumericEntities=="boolean"?m.interpretNumericEntities:n.interpretNumericEntities,parameterLimit:typeof m.parameterLimit=="number"?m.parameterLimit:n.parameterLimit,parseArrays:m.parseArrays!==!1,plainObjects:typeof m.plainObjects=="boolean"?m.plainObjects:n.plainObjects,strictDepth:typeof m.strictDepth=="boolean"?!!m.strictDepth:n.strictDepth,strictNullHandling:typeof m.strictNullHandling=="boolean"?m.strictNullHandling:n.strictNullHandling,throwOnLimitExceeded:typeof m.throwOnLimitExceeded=="boolean"?m.throwOnLimitExceeded:!1}};return Wm=function(y,m){var S=h(m);if(y===""||y===null||typeof y>"u")return S.plainObjects?{__proto__:null}:{};for(var b=typeof y=="string"?c(y,S):y,C=S.plainObjects?{__proto__:null}:{},x=Object.keys(b),$=0;$<x.length;++$){var T=x[$],_=g(T,b[T],S,typeof y=="string");C=e.merge(C,_,S)}return S.allowSparse===!0?C:e.compact(C)},Wm}var qm,lO;function G8(){if(lO)return qm;lO=1;var e=W8(),t=q8(),r=yb();return qm={formats:r,parse:t,stringify:e},qm}var uO;function X8(){if(uO)return Ya;uO=1;var e=g8();function t(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var r=/^([a-z0-9.+-]+:)/i,n=/:[0-9]*$/,i=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=["<",">",'"',"`"," ","\r",`
@@ -1 +1 @@
1
- {"name":"@ledgerhq/device-management-kit-devtools-rozenite","version":"0.0.0-develop-20260507002614","description":"Inspect and debug your integration of the Device Management Kit","panels":[{"name":"DMK DevTools","source":"/index.html"}]}
1
+ {"name":"@ledgerhq/device-management-kit-devtools-rozenite","version":"0.0.0-develop-20260508002748","description":"Inspect and debug your integration of the Device Management Kit","panels":[{"name":"DMK DevTools","source":"/index.html"}]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "dependencies": {
3
3
  "@rozenite/plugin-bridge": "1.1.0",
4
4
  "rxjs": "7.8.2",
5
- "@ledgerhq/device-management-kit-devtools-ui": "0.0.0-develop-20260507002614"
5
+ "@ledgerhq/device-management-kit-devtools-ui": "0.0.0-develop-20260508002748"
6
6
  },
7
7
  "description": "Inspect and debug your integration of the Device Management Kit",
8
8
  "devDependencies": {
@@ -15,7 +15,7 @@
15
15
  "rozenite": "1.1.0",
16
16
  "typescript": "5.9.2",
17
17
  "vite": "7.1.6",
18
- "@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260507002614"
18
+ "@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260508002748"
19
19
  },
20
20
  "files": [
21
21
  "./dist"
@@ -27,7 +27,7 @@
27
27
  "peerDependencies": {
28
28
  "react": "*",
29
29
  "react-native": "*",
30
- "@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260507002614"
30
+ "@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260508002748"
31
31
  },
32
32
  "private": false,
33
33
  "repository": {
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "type": "module",
38
38
  "types": "./dist/react-native.d.ts",
39
- "version": "0.0.0-develop-20260507002614",
39
+ "version": "0.0.0-develop-20260508002748",
40
40
  "scripts": {
41
41
  "build": "rozenite build",
42
42
  "dev": "rozenite dev"