@ledgerhq/device-management-kit-devtools-rozenite 0.0.0-develop-20260420165047 → 0.0.0-develop-20260422001917
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 +1 -1
- package/dist/rozenite.json +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -522,7 +522,7 @@ Details
|
|
|
522
522
|
|
|
523
523
|
${(function(o){switch(o.kind){case Aa.method:return`[class: "${o.targetClass.name}", method: "${o.method.toString()}"]`;case Aa.parameter:return`[class: "${o.targetClass.name}", index: "${o.index.toString()}"]`;case Aa.property:return`[class: "${o.targetClass.name}", property: "${o.property.toString()}"]`}})(i)}`,{cause:n})}throw n}function n8(e,t){return(r,n,i)=>{try{i===void 0?(function(o,s){const u=xm(o,s);return(c,f)=>{Yu(c.constructor,Qd,Zd,r_(u(c),f))}})(e,t)(r,n):typeof i=="number"?(function(o,s){const u=xm(o,s);return(c,f,d)=>{if(!(function(g,h){return typeof g=="function"&&h===void 0})(c,f))throw new Na(Ro.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.
|
|
524
524
|
Found @inject decorator at method "${f?.toString()??""}" at class "${c.constructor.name}"`);Yu(c,Qd,Zd,(function(g,h){return b=>{const v=b.constructorArguments[h];return b.constructorArguments[h]=g(v),b}})(u(c),d))}})(e,t)(r,n,i):(function(o,s){const u=xm(o,s);return(c,f,d)=>{if(!(function(g){return g.set!==void 0})(d))throw new Na(Ro.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.
|
|
525
|
-
Found @inject decorator at method "${f.toString()}" at class "${c.constructor.name}"`);Yu(c.constructor,Qd,Zd,r_(u(c),f))}})(e,t)(r,n,i)}catch(o){r8(r,n,i,o)}}}function xm(e,t){return r=>{const n=t(r);return i=>(n(i),e(i))}}function rt(e){return n8(t8(hc.singleInjection,e),Qz)}(function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"})(Aa||(Aa={}));const n_="@inversifyjs/core/classIsInjectableFlagReflectKey",i8=[Array,BigInt,Boolean,Function,Number,Object,String];function o8(e){const t=G1(e,"design:paramtypes");t!==void 0&&Yu(e,Qd,Zd,(function(r){return n=>(r.forEach(((i,o)=>{var s;n.constructorArguments[o]!==void 0||(s=i,i8.includes(s))||(n.constructorArguments[o]=(function(u){return{isFromTypescriptParamType:!0,kind:hc.singleInjection,name:void 0,optional:!1,tags:new Map,value:u}})(i))})),n)})(t))}function Rt(e){return t=>{(function(r){if(G1(r,n_)!==void 0)throw new Na(Ro.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${r.name}"`);Kz(r,n_,!0)})(t),o8(t)}}var i_;(function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection"})(i_||(i_={}));var o_;(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"})(o_||(o_={}));let a8=class{constructor(t,r,n,i,o){this.deviceModel=t,this.serviceUuid=r,this.writeUuid=n,this.writeCmdUuid=i,this.notifyUuid=o}},tl=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 s8=Object.defineProperty,l8=(e,t,r)=>t in e?s8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,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)=>l8(e,t+"",r);let cs=class{getAllDeviceModels(){return Object.values(cs.deviceModelByIds)}getDeviceModel(t){return cs.deviceModelByIds[t.id]}filterDeviceModels(t){return this.getAllDeviceModels().filter(r=>Object.entries(t).every(([n,i])=>r[n]===i))}getBluetoothServicesInfos(){return Object.values(cs.deviceModelByIds).reduce((t,r)=>{const{bluetoothSpec:n}=r;return n?{...t,...n.reduce((i,o)=>({...i,[o.serviceUuid]:new a8(r,o.serviceUuid,o.writeUuid,o.writeCmdUuid,o.notifyUuid)}),{})}:t},{})}getBluetoothServices(){return Object.values(cs.deviceModelByIds).map(t=>(t.bluetoothSpec||[]).map(r=>r.serviceUuid)).flat().filter(t=>!!t)}};c8(cs,"deviceModelByIds",{[Zt.NANO_S]:new tl({id:Zt.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>VR.lt(VR.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[Zt.NANO_SP]:new tl({id:Zt.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[Zt.NANO_X]:new tl({id:Zt.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"}]}),[Zt.STAX]:new tl({id:Zt.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"}]}),[Zt.FLEX]:new tl({id:Zt.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"}]}),[Zt.APEX]:new tl({id:Zt.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"}]})}),cs=u8([Rt()],cs);let f8=class{statusCode;data;constructor({statusCode:t,data:r}){this.statusCode=t,this.data=r}};const d8=5,as=1,Qy=2,bl=2,Zy=2,zr=[];for(let e=0;e<256;++e)zr.push((e+256).toString(16).slice(1));function p8(e,t=0){return(zr[e[t+0]]+zr[e[t+1]]+zr[e[t+2]]+zr[e[t+3]]+"-"+zr[e[t+4]]+zr[e[t+5]]+"-"+zr[e[t+6]]+zr[e[t+7]]+"-"+zr[e[t+8]]+zr[e[t+9]]+"-"+zr[e[t+10]]+zr[e[t+11]]+zr[e[t+12]]+zr[e[t+13]]+zr[e[t+14]]+zr[e[t+15]]).toLowerCase()}let Em;const h8=new Uint8Array(16);function g8(){if(!Em){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Em=crypto.getRandomValues.bind(crypto)}return Em(h8)}const v8=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),a_={randomUUID:v8};function Jp(e,t,r){if(a_.randomUUID&&!e)return a_.randomUUID();e=e||{};const n=e.random||(e.rng||g8)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,p8(n)}const gs={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)}},s_=2,Cm=800;let l_=class{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}},m8=class{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}},u_=class{_tag="ReceiverApduError";originalError;constructor(t){this.originalError=new Error(t??"Unable to parse apdu")}},c_=class{_tag="DeviceSessionNotFound";originalError;constructor(t){this.originalError=t??new Error("Device session not found")}},P2=class{_header;_data;constructor({header:t,data:r}){this._header=t,this._data=r}toString(){return JSON.stringify({header:this._header.toString(),data:dc(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}},k2=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=>gs.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 _r={LoggerPublisherServiceFactory:Symbol.for("LoggerPublisherServiceFactory")};var y8=(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},b8=(e,t)=>(r,n)=>t(r,n,e);let f_=class{_channel;_logger;_pendingFrames;constructor({channel:t=Tn.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 Yt;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"),Yt;const n=gs.getFirstBytesFrom(this.concatFrames(this._pendingFrames),r),i=gs.getFirstBytesFrom(n,n.length-s_),o=gs.getLastBytesFrom(n,s_);return this._pendingFrames=[],dn(new f8({data:i,statusCode:o}))})}getFrameFromBytes(t){const r=this._channel.caseOf({Just:()=>Qy,Nothing:()=>0}),n=t.slice(r,r+as),i=t.slice(r+as,r+as+bl),o=i.reduce((h,b)=>h+b,0)===0;if(!o&&this._pendingFrames.length===0)return tn(new u_);const s=r+as+bl,u=o?Zy:0;if(t.length<r+as+bl+u)return tn(new u_("Unable to parse header from apdu"));const c=o?dn(t.slice(s,s+u)):Yt,f=s+u,d=t.slice(f),g=new P2({header:new k2({uuid:Jp(),channel:this._channel,dataSize:c,headTag:n,index:i,length:r+as+bl+u}),data:d});return rn(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))}};f_=y8([Rt(),b8(1,rt(_r.LoggerPublisherServiceFactory))],f_);var S8=(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},w8=(e,t)=>(r,n)=>t(r,n,e);let d_=class{_frameSize;_channel;_padding;_logger;constructor({frameSize:t,channel:r=Tn.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 l_||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 tn(new l_);if(n.getLength()>this._frameSize)return tn(new m8);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 P2({header:n,data:u});return rn(c)}getFrameHeaderFrom(t,r){const n=new k2({uuid:Jp(),channel:this._channel.map(i=>gs.getLastBytesFrom(i,Qy)),headTag:new Uint8Array([d8]),index:gs.numberToByteArray(t,bl),length:this.getFrameHeaderSizeFromIndex(t),dataSize:Tn.zero()});return t===0&&n.setDataSize(Tn.of(gs.numberToByteArray(r,Zy))),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:()=>Qy,Nothing:()=>0})+bl+as+(t===0?Zy:0)}};d_=S8([Rt(),w8(1,rt(_r.LoggerPublisherServiceFactory))],d_);const eb={LocalConfigDataSource:Symbol.for("LocalConfigDataSource"),RemoteConfigDataSource:Symbol.for("RemoteConfigDataSource"),ConfigService:Symbol.for("ConfigService")},gn={ApduSenderServiceFactory:Symbol.for("ApduSenderServiceFactory"),ApduReceiverServiceFactory:Symbol.for("ApduReceiverServiceFactory"),DeviceSessionService:Symbol.for("DeviceSessionService")},p_={ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase")},Qp={ManagerApiService:Symbol.for("ManagerApiService"),ManagerApiDataSource:Symbol.for("ManagerApiDataSource"),DmkConfig:Symbol.for("ManagerApiDmkConfig")},ja={DmkConfig:Symbol.for("TransportDmkConfig"),TransportService:Symbol.for("TransportService"),TransportsInput:Symbol.for("TransportsInput")};var x8=(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 g_=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}})}};g_=x8([Rt(),h_(0,rt(gn.DeviceSessionService)),h_(1,rt(_r.LoggerPublisherServiceFactory))],g_);var E8=(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 v_=class{execute=vi.fn(()=>"stub")};v_=E8([Rt()],v_);var C8=(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},m_=(e,t)=>(r,n)=>t(r,n,e);let y_=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}})}};y_=C8([Rt(),m_(0,rt(gn.DeviceSessionService)),m_(1,rt(_r.LoggerPublisherServiceFactory))],y_);function R8(e){return typeof e=="object"&&e!==null&&"version"in e&&"name"in e&&typeof e.version=="string"&&typeof e.name=="string"}let b_=class{constructor(t){this.err=t,this.originalError=t}_tag="ApiCallError";originalError},_8=class{constructor(t){this.err=t,this.originalError=t}_tag="ParseResponseError";originalError},M2=class{constructor(t){this.err=t,this.originalError=t}_tag="JSONParseError";originalError},O8=class{constructor(t){this.err=t,this.originalError=t}_tag="ReadFileError";originalError};const T8="@ledgerhq/device-management-kit",A8="0.0.0-develop-20260420165047",S_={name:T8,version:A8};var $8=(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 I8={name:S_.name,version:S_.version},P8=()=>JSON.stringify(I8);let w_=class{getConfig(){return Jn.encase(()=>P8()).mapLeft(t=>new O8(t)).chain(t=>Jn.encase(()=>{const r=JSON.parse(t);if(R8(r))return r;throw new Error("Invalid config file")}).mapLeft(r=>new M2(r)))}};w_=$8([Rt()],w_);var k8=(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 x_=class{getConfig(){return Jn.of({name:"DeviceSDK",version:"0.0.0-stub.1"})}};x_=k8([Rt()],x_);var M8=(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 E_=class{async getConfig(){const t=await this._callApi();if(t.isLeft())return tn(new b_(t.extract()));if(!t.extract().ok)return tn(new b_(new Error("response not ok")));const r=await t.extract().json();return r.isLeft()?tn(new M2):r.chain(n=>this._parseResponse(n)).map(n=>n)}_parseResponse(t){const{name:r,version:n}=t;return!r||!n?tn(new _8):Jn.of({name:r,version:n})}_callApi(){return new Promise(t=>{t(Jn.of({ok:!0,json:async()=>new Promise(r=>{r(Jn.of({name:"DeviceSDK",version:"0.0.0-fake.1",yolo:"yolo"}))})}))})}};E_=M8([Rt()],E_);var D8=(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 C_=class{async getConfig(){return new Promise(t=>t(Jn.of({name:"DeviceSDK",version:"0.0.0-fake.2"})))}};C_=D8([Rt()],C_);var L8=(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},Rm=(e,t)=>(r,n)=>t(r,n,e);let R_=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())}};R_=L8([Rt(),Rm(0,rt(eb.LocalConfigDataSource)),Rm(1,rt(eb.RemoteConfigDataSource)),Rm(2,rt(_r.LoggerPublisherServiceFactory))],R_);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},N8=(e,t)=>(r,n)=>t(r,n,e);let __=class{_configService;constructor(t){this._configService=t}async getDmkVersion(){return(await this._configService.getDmkConfig()).version}};__=F8([Rt(),N8(0,rt(eb.ConfigService))],__);const j8={DeviceModelDataSource:Symbol.for("DeviceModelDataSource")};var z8=(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},O_=(e,t)=>(r,n)=>t(r,n,e);let T_=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)})}};T_=z8([Rt(),O_(0,rt(gn.DeviceSessionService)),O_(1,rt(_r.LoggerPublisherServiceFactory))],T_);var B8=(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},V8=(e,t)=>(r,n)=>t(r,n,e);let A_=class{_sessions;_sessionsSubject;_logger;constructor(t){this._sessions=[],this._sessionsSubject=new d2,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 Tn.fromNullable(this._sessions.find(r=>r.id===t)).toEither(new c_)}getDeviceSessionsByDeviceId(t){return Tn.fromPredicate(({length:r})=>r>0,this._sessions.filter(r=>r.connectedDevice.id===t)).toEither(new c_)}getDeviceSessions(){return this._sessions}};A_=B8([Rt(),V8(0,rt(_r.LoggerPublisherServiceFactory))],A_);var 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},$_=(e,t)=>(r,n)=>t(r,n,e);let I_=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)}};I_=U8([Rt(),$_(0,rt(gn.DeviceSessionService)),$_(1,rt(ja.TransportService))],I_);var H8=(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},P_=(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_=H8([Rt(),P_(0,rt(gn.DeviceSessionService)),P_(1,rt(_r.LoggerPublisherServiceFactory))],k_);var W8=(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},M_=(e,t)=>(r,n)=>t(r,n,e);let D_=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)}})}};D_=W8([Rt(),M_(0,rt(gn.DeviceSessionService)),M_(1,rt(_r.LoggerPublisherServiceFactory))],D_);function q8(e){return`[will send APDU] ~...> ${dc(e,!1)}`}function G8(e){return`[exchange] <= ${dc(e.data,!1)}${dc(e.statusCode,!1)}`}const tb=1e3,_m=1e3,X8={isRefresherDisabled:!1,pollingInterval:1e3};var dr=(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))(dr||{});let K8=class{_eventEmitter=new Gl;listen(){return this._eventEmitter.asObservable()}dispatch(t){this._eventEmitter.next(t)}},Y8=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 Gl,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(Mz(()=>{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:dr.NEW_STATE});return}this.sessionEventDispatcher.dispatch({eventName:dr.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()}},J8=class{constructor(t,r){this._refresher=r,this._logger=t("refresher-service")}_refresherBlockers=new Set;_logger;disableRefresher(t){const r=`${t}-${Jp()}`;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()}},Q8=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 dr.REFRESH_NEEDED:return await this.ping();default:return null}};async mapDevicePingAction(t){switch(t){case Zt.NANO_S:{const r=async()=>{const o=await this._sendCommandFunction(new YC,Cm);return this._sendCommandFunction(new zj,Cm),o},n=new Promise(o=>{setTimeout(()=>o(null),tb*2+100)}),i=await Promise.race([r(),n]);return i?this._sessionEventDispatcher.dispatch({eventName:dr.COMMAND_SUCCEEDED,eventData:i}):this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_LOCKED}),i}default:{const r=await this._sendCommandFunction(new YC,Cm);return this._sessionEventDispatcher.dispatch({eventName:dr.COMMAND_SUCCEEDED,eventData:r}),r}}}unsubscribe(){this._subscription.unsubscribe()}},Z8=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(JR(n=>n.eventName===dr.DEVICE_STATE_UPDATE_BUSY||n.eventName===dr.NEW_STATE),Fa(n=>n.eventName===dr.DEVICE_STATE_UPDATE_BUSY),Lz(!1),Pz());this._refresherSubscription=Az(0,t).pipe(Fz(r),QR(([n,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),JR(([n,i])=>!i),QR(()=>this._sessionEventDispatcher.dispatch({eventName:dr.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 Zt.NANO_S:{const i=tb*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<_m?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${_m}`),_m):n??tb}}},eB=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=bo.BUSY;_updateDeviceState(t){const r=this._parseDeviceStatus(t);if(r){const{sessionStateType:n,deviceStatus:i,currentApp:o}=r,s=this._deviceState.getValue();s.sessionStateType===pc.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 dr.COMMAND_SUCCEEDED:return this._updateDeviceState(t.eventData);case dr.DEVICE_STATE_UPDATE_BUSY:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:bo.BUSY});case dr.DEVICE_STATE_UPDATE_LOCKED:this._pendingDeviceStatus=bo.LOCKED;return;case dr.DEVICE_STATE_UPDATE_CONNECTED:this._pendingDeviceStatus=bo.CONNECTED;return;case dr.NEW_STATE:{const n=this._pendingDeviceStatus;return this._pendingDeviceStatus=bo.BUSY,this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:n})}case dr.DEVICE_STATE_UPDATE_UNKNOWN:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:bo.BUSY});case dr.REFRESH_NEEDED:return;default:{const n=r;throw new Error(`Unhandled context type ${n}`)}}};_parseDeviceStatus(t){return sj(t)?{sessionStateType:pc.ReadyWithoutSecureChannel,deviceStatus:bo.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()}},tB=class{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new K8;_bypassIntentQueue=!1;constructor({connectedDevice:t,id:r=Jp()},n,i,o,s,u=c=>new Y8(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={...X8,...s},this._deviceState=new nz({sessionStateType:pc.Connected,deviceStatus:bo.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new Q8(n,t,this._sessionEventDispatcher,(c,f)=>this.sendCommand(c,f)),this._deviceSessionRefresher=new Z8(n,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new eB(n,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new J8(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:()=>Pl((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(KR({each:n,with:()=>{throw s(),new Nz}})):o;return XR(u)}async _unsafeInternalSendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug(q8(t)),(await this._connectedDevice.sendApdu(t,r.triggersDisconnection,r.abortTimeout)).ifRight(n=>{this._logger.debug(G8(n)),$1.isLockedDeviceResponse(n)?this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:dr.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:()=>Pl((async()=>{const u=Date.now()-n;return await this._unsafeInternalSendCommand(t,r?r-u:void 0)})())}),s=r?i.pipe(KR({each:r,with:()=>{throw o(),new jz}})):i;return XR(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(bo.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 X1={SecureChannelService:Symbol.for("SecureChannelService"),SecureChannelDataSource:Symbol.for("SecureChannelDataSource"),DmkConfig:Symbol.for("SecureChannelDmkConfig")};var rB=(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},$u=(e,t)=>(r,n)=>t(r,n,e);let L_=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 mt.liftEither(n.toEither(new q1(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 tB({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})}};L_=rB([Rt(),$u(0,rt(ja.TransportService)),$u(1,rt(gn.DeviceSessionService)),$u(2,rt(_r.LoggerPublisherServiceFactory)),$u(3,rt(Qp.ManagerApiService)),$u(4,rt(X1.SecureChannelService))],L_);var nB=(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},Om=(e,t)=>(r,n)=>t(r,n,e);let F_=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)}}),mt(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 q1(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:()=>{}})}};F_=nB([Rt(),Om(0,rt(ja.TransportService)),Om(1,rt(gn.DeviceSessionService)),Om(2,rt(_r.LoggerPublisherServiceFactory))],F_);let K1=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 iB=(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},N_=(e,t)=>(r,n)=>t(r,n,e);let j_=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 K1({sessionId:r.id,transportConnectedDevice:r.connectedDevice}),Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r}})}};j_=iB([Rt(),N_(0,rt(gn.DeviceSessionService)),N_(1,rt(_r.LoggerPublisherServiceFactory))],j_);var oB=(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},z_=(e,t)=>(r,n)=>t(r,n,e);let B_=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 K1({transportConnectedDevice:t.connectedDevice,sessionId:t.id}))}};B_=oB([Rt(),z_(0,rt(gn.DeviceSessionService)),z_(1,rt(_r.LoggerPublisherServiceFactory))],B_);var aB=(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},V_=(e,t)=>(r,n)=>t(r,n,e);let U_=class{_transports;_transportService;_logger;constructor(t,r){this._transports=t.getAllTransports(),this._transportService=t,this._logger=r("ListenToAvailableDevicesUseCase")}mapTransportDiscoveredDeviceToDiscoveredDevice(t){const r=new t2({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"),Pl([[]]);if(!t){this._logger.info("Discovering all available transports");const r=this._transports.map((n,i)=>n.listenToAvailableDevices().pipe(Fa(o=>({index:i,arr:o}))));return $z(...r).pipe(Dz((n,{index:i,arr:o})=>(n[i]=o,n),{}),Fa(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`),T2([])),Just:r=>r.listenToAvailableDevices().pipe(Fa(n=>n.map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))})}};U_=aB([Rt(),V_(0,rt(ja.TransportService)),V_(1,rt(_r.LoggerPublisherServiceFactory))],U_);var sB=(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 W_=class{constructor(t,r){this._sessionService=t,this._logger=r("ListenToConnectedDeviceUseCase")}_logger;execute(){return this._logger.info("Observe connected devices"),this._sessionService.sessionsObs.pipe(Fa(t=>new K1({transportConnectedDevice:t.connectedDevice,sessionId:t.id})))}};W_=sB([Rt(),H_(0,rt(gn.DeviceSessionService)),H_(1,rt(_r.LoggerPublisherServiceFactory))],W_);var lB=(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 q_=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})}};q_=lB([Rt(),Tm(0,rt(p_.ConnectUseCase)),Tm(1,rt(p_.DisconnectUseCase)),Tm(2,rt(_r.LoggerPublisherServiceFactory))],q_);var uB=(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},cB=(e,t)=>(r,n)=>t(r,n,e);let G_=class{constructor(t){this._transportService=t}mapDiscoveredDevice(t){const r=new t2({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 T2(...r).pipe(W1(n=>n.startDiscovering().pipe(Fa(i=>this.mapDiscoveredDevice(i)))))}return this._transportService.getTransport(t).caseOf({Just:r=>r.startDiscovering().pipe(Fa(n=>this.mapDiscoveredDevice(n))),Nothing:()=>{throw new q1(new Error("Unknown transport"))}})}};G_=uB([Rt(),cB(0,rt(ja.TransportService))],G_);var fB=(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{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()}};K_=fB([Rt(),X_(0,rt(ja.TransportService)),X_(1,rt(_r.LoggerPublisherServiceFactory))],K_);var zu=(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))(zu||{});let dB=class{format(t){return Array.isArray(t)?t.map(r=>`[${r}]`).join(" "):`[${t}]`}};function rb(e,t){if(typeof e=="bigint")return e.toString();if(Array.isArray(e))return t.has(e)?"[Circular]":(t.add(e),e.map(r=>rb(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]=rb(i,t);return r}return e}function pB(e){const t=new WeakSet;t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=rb(i,t);return r}var hB=(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 Y_=class{subscribers;tag;tagFormatter;constructor(t,r,n=new dB){this.subscribers=t,this.tag=r,this.tagFormatter=n}_log(t,r,n){const i=n?.data?pB(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(zu.Info,t,r)}warn(t,r){this._log(zu.Warning,t,r)}debug(t,r){this._log(zu.Debug,t,r)}error(t,r){this._log(zu.Error,t,r)}};Y_=hB([Rt()],Y_);function D2(e,t){return function(){return e.apply(t,arguments)}}const{toString:gB}=Object.prototype,{getPrototypeOf:Y1}=Object,{iterator:Zp,toStringTag:L2}=Symbol,eh=(e=>t=>{const r=gB.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),so=e=>(e=e.toLowerCase(),t=>eh(t)===e),th=e=>t=>typeof t===e,{isArray:Xl}=Array,kl=th("undefined");function Fc(e){return e!==null&&!kl(e)&&e.constructor!==null&&!kl(e.constructor)&&An(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const F2=so("ArrayBuffer");function vB(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&F2(e.buffer),t}const mB=th("string"),An=th("function"),N2=th("number"),Nc=e=>e!==null&&typeof e=="object",yB=e=>e===!0||e===!1,ep=e=>{if(eh(e)!=="object")return!1;const t=Y1(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(L2 in e)&&!(Zp in e)},bB=e=>{if(!Nc(e)||Fc(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},SB=so("Date"),wB=so("File"),xB=so("Blob"),EB=so("FileList"),CB=e=>Nc(e)&&An(e.pipe),RB=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||An(e.append)&&((t=eh(e))==="formdata"||t==="object"&&An(e.toString)&&e.toString()==="[object FormData]"))},_B=so("URLSearchParams"),[OB,TB,AB,$B]=["ReadableStream","Request","Response","Headers"].map(so),IB=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function jc(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Xl(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(Fc(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let u;for(n=0;n<s;n++)u=o[n],t.call(null,e[u],u,e)}}function j2(e,t){if(Fc(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const fs=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:self,z2=e=>!kl(e)&&e!==fs;function nb(){const{caseless:e,skipUndefined:t}=z2(this)&&this||{},r={},n=(i,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const s=e&&j2(r,o)||o;ep(r[s])&&ep(i)?r[s]=nb(r[s],i):ep(i)?r[s]=nb({},i):Xl(i)?r[s]=i.slice():(!t||!kl(i))&&(r[s]=i)};for(let i=0,o=arguments.length;i<o;i++)arguments[i]&&jc(arguments[i],n);return r}const PB=(e,t,r,{allOwnKeys:n}={})=>(jc(t,(i,o)=>{r&&An(i)?Object.defineProperty(e,o,{value:D2(i,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),kB=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),MB=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},DB=(e,t,r,n)=>{let i,o,s;const u={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=r!==!1&&Y1(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},LB=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},FB=e=>{if(!e)return null;if(Xl(e))return e;let t=e.length;if(!N2(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},NB=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Y1(Uint8Array)),jB=(e,t)=>{const n=(e&&e[Zp]).call(e);let i;for(;(i=n.next())&&!i.done;){const o=i.value;t.call(e,o[0],o[1])}},zB=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},BB=so("HTMLFormElement"),VB=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),J_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),UB=so("RegExp"),B2=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};jc(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},HB=e=>{B2(e,(t,r)=>{if(An(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(An(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},WB=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Xl(e)?n(e):n(String(e).split(t)),r},qB=()=>{},GB=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function XB(e){return!!(e&&An(e.append)&&e[L2]==="FormData"&&e[Zp])}const KB=e=>{const t=new Array(10),r=(n,i)=>{if(Nc(n)){if(t.indexOf(n)>=0)return;if(Fc(n))return n;if(!("toJSON"in n)){t[i]=n;const o=Xl(n)?[]:{};return jc(n,(s,u)=>{const c=r(s,i+1);!kl(c)&&(o[u]=c)}),t[i]=void 0,o}}return n};return r(e,0)},YB=so("AsyncFunction"),JB=e=>e&&(Nc(e)||An(e))&&An(e.then)&&An(e.catch),V2=((e,t)=>e?setImmediate:t?((r,n)=>(fs.addEventListener("message",({source:i,data:o})=>{i===fs&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),fs.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",An(fs.postMessage)),QB=typeof queueMicrotask<"u"?queueMicrotask.bind(fs):typeof process<"u"&&process.nextTick||V2,ZB=e=>e!=null&&An(e[Zp]),ye={isArray:Xl,isArrayBuffer:F2,isBuffer:Fc,isFormData:RB,isArrayBufferView:vB,isString:mB,isNumber:N2,isBoolean:yB,isObject:Nc,isPlainObject:ep,isEmptyObject:bB,isReadableStream:OB,isRequest:TB,isResponse:AB,isHeaders:$B,isUndefined:kl,isDate:SB,isFile:wB,isBlob:xB,isRegExp:UB,isFunction:An,isStream:CB,isURLSearchParams:_B,isTypedArray:NB,isFileList:EB,forEach:jc,merge:nb,extend:PB,trim:IB,stripBOM:kB,inherits:MB,toFlatObject:DB,kindOf:eh,kindOfTest:so,endsWith:LB,toArray:FB,forEachEntry:jB,matchAll:zB,isHTMLForm:BB,hasOwnProperty:J_,hasOwnProp:J_,reduceDescriptors:B2,freezeMethods:HB,toObjectSet:WB,toCamelCase:VB,noop:qB,toFiniteNumber:GB,findKey:j2,global:fs,isContextDefined:z2,isSpecCompliantForm:XB,toJSONObject:KB,isAsyncFn:YB,isThenable:JB,setImmediate:V2,asap:QB,isIterable:ZB};let ut=class U2 extends Error{static from(t,r,n,i,o,s){const u=new U2(t.message,r||t.code,n,i,o);return u.cause=t,u.name=t.name,s&&Object.assign(u,s),u}constructor(t,r,n,i,o){super(t),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),i&&(this.request=i),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ye.toJSONObject(this.config),code:this.code,status:this.status}}};ut.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ut.ERR_BAD_OPTION="ERR_BAD_OPTION";ut.ECONNABORTED="ECONNABORTED";ut.ETIMEDOUT="ETIMEDOUT";ut.ERR_NETWORK="ERR_NETWORK";ut.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ut.ERR_DEPRECATED="ERR_DEPRECATED";ut.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ut.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ut.ERR_CANCELED="ERR_CANCELED";ut.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ut.ERR_INVALID_URL="ERR_INVALID_URL";const eV=null;function ib(e){return ye.isPlainObject(e)||ye.isArray(e)}function H2(e){return ye.endsWith(e,"[]")?e.slice(0,-2):e}function Q_(e,t,r){return e?e.concat(t).map(function(i,o){return i=H2(i),!r&&o?"["+i+"]":i}).join(r?".":""):t}function tV(e){return ye.isArray(e)&&!e.some(ib)}const rV=ye.toFlatObject(ye,{},null,function(t){return/^is[A-Z]/.test(t)});function rh(e,t,r){if(!ye.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=ye.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,y){return!ye.isUndefined(y[S])});const n=r.metaTokens,i=r.visitor||d,o=r.dots,s=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&ye.isSpecCompliantForm(t);if(!ye.isFunction(i))throw new TypeError("visitor must be a function");function f(v){if(v===null)return"";if(ye.isDate(v))return v.toISOString();if(ye.isBoolean(v))return v.toString();if(!c&&ye.isBlob(v))throw new ut("Blob is not supported. Use a Buffer instead.");return ye.isArrayBuffer(v)||ye.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,S,y){let E=v;if(v&&!y&&typeof v=="object"){if(ye.endsWith(S,"{}"))S=n?S:S.slice(0,-2),v=JSON.stringify(v);else if(ye.isArray(v)&&tV(v)||(ye.isFileList(v)||ye.endsWith(S,"[]"))&&(E=ye.toArray(v)))return S=H2(S),E.forEach(function(T,A){!(ye.isUndefined(T)||T===null)&&t.append(s===!0?Q_([S],A,o):s===null?S:S+"[]",f(T))}),!1}return ib(v)?!0:(t.append(Q_(y,S,o),f(v)),!1)}const g=[],h=Object.assign(rV,{defaultVisitor:d,convertValue:f,isVisitable:ib});function b(v,S){if(!ye.isUndefined(v)){if(g.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));g.push(v),ye.forEach(v,function(E,x){(!(ye.isUndefined(E)||E===null)&&i.call(t,E,ye.isString(x)?x.trim():x,S,h))===!0&&b(E,S?S.concat(x):[x])}),g.pop()}}if(!ye.isObject(e))throw new TypeError("data must be an object");return b(e),t}function Z_(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function J1(e,t){this._pairs=[],e&&rh(e,this,t)}const W2=J1.prototype;W2.append=function(t,r){this._pairs.push([t,r])};W2.toString=function(t){const r=t?function(n){return t.call(this,n,Z_)}:Z_;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function nV(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function q2(e,t,r){if(!t)return e;const n=r&&r.encode||nV,i=ye.isFunction(r)?{serialize:r}:r,o=i&&i.serialize;let s;if(o?s=o(t,i):s=ye.isURLSearchParams(t)?t.toString():new J1(t,i).toString(n),s){const u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class eO{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ye.forEach(this.handlers,function(n){n!==null&&t(n)})}}const Q1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},iV=typeof URLSearchParams<"u"?URLSearchParams:J1,oV=typeof FormData<"u"?FormData:null,aV=typeof Blob<"u"?Blob:null,sV={isBrowser:!0,classes:{URLSearchParams:iV,FormData:oV,Blob:aV},protocols:["http","https","file","blob","url","data"]},Z1=typeof window<"u"&&typeof document<"u",ob=typeof navigator=="object"&&navigator||void 0,lV=Z1&&(!ob||["ReactNative","NativeScript","NS"].indexOf(ob.product)<0),uV=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",cV=Z1&&window.location.href||"http://localhost",fV=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Z1,hasStandardBrowserEnv:lV,hasStandardBrowserWebWorkerEnv:uV,navigator:ob,origin:cV},Symbol.toStringTag,{value:"Module"})),en={...fV,...sV};function dV(e,t){return rh(e,new en.classes.URLSearchParams,{visitor:function(r,n,i,o){return en.isNode&&ye.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function pV(e){return ye.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hV(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function G2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const u=Number.isFinite(+s),c=o>=r.length;return s=!s&&ye.isArray(i)?i.length:s,c?(ye.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!u):((!i[s]||!ye.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&ye.isArray(i[s])&&(i[s]=hV(i[s])),!u)}if(ye.isFormData(e)&&ye.isFunction(e.entries)){const r={};return ye.forEachEntry(e,(n,i)=>{t(pV(n),i,r,0)}),r}return null}function gV(e,t,r){if(ye.isString(e))try{return(t||JSON.parse)(e),ye.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const zc={transitional:Q1,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,o=ye.isObject(t);if(o&&ye.isHTMLForm(t)&&(t=new FormData(t)),ye.isFormData(t))return i?JSON.stringify(G2(t)):t;if(ye.isArrayBuffer(t)||ye.isBuffer(t)||ye.isStream(t)||ye.isFile(t)||ye.isBlob(t)||ye.isReadableStream(t))return t;if(ye.isArrayBufferView(t))return t.buffer;if(ye.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return dV(t,this.formSerializer).toString();if((u=ye.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return rh(u?{"files[]":t}:t,c&&new c,this.formSerializer)}}return o||i?(r.setContentType("application/json",!1),gV(t)):t}],transformResponse:[function(t){const r=this.transitional||zc.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(ye.isResponse(t)||ye.isReadableStream(t))return t;if(t&&ye.isString(t)&&(n&&!this.responseType||i)){const s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(u){if(s)throw u.name==="SyntaxError"?ut.from(u,ut.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:en.classes.FormData,Blob:en.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ye.forEach(["delete","get","head","post","put","patch"],e=>{zc.headers[e]={}});const vV=ye.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),mV=e=>{const t={};let r,n,i;return e&&e.split(`
|
|
525
|
+
Found @inject decorator at method "${f.toString()}" at class "${c.constructor.name}"`);Yu(c.constructor,Qd,Zd,r_(u(c),f))}})(e,t)(r,n,i)}catch(o){r8(r,n,i,o)}}}function xm(e,t){return r=>{const n=t(r);return i=>(n(i),e(i))}}function rt(e){return n8(t8(hc.singleInjection,e),Qz)}(function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"})(Aa||(Aa={}));const n_="@inversifyjs/core/classIsInjectableFlagReflectKey",i8=[Array,BigInt,Boolean,Function,Number,Object,String];function o8(e){const t=G1(e,"design:paramtypes");t!==void 0&&Yu(e,Qd,Zd,(function(r){return n=>(r.forEach(((i,o)=>{var s;n.constructorArguments[o]!==void 0||(s=i,i8.includes(s))||(n.constructorArguments[o]=(function(u){return{isFromTypescriptParamType:!0,kind:hc.singleInjection,name:void 0,optional:!1,tags:new Map,value:u}})(i))})),n)})(t))}function Rt(e){return t=>{(function(r){if(G1(r,n_)!==void 0)throw new Na(Ro.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${r.name}"`);Kz(r,n_,!0)})(t),o8(t)}}var i_;(function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection"})(i_||(i_={}));var o_;(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"})(o_||(o_={}));let a8=class{constructor(t,r,n,i,o){this.deviceModel=t,this.serviceUuid=r,this.writeUuid=n,this.writeCmdUuid=i,this.notifyUuid=o}},tl=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 s8=Object.defineProperty,l8=(e,t,r)=>t in e?s8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,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)=>l8(e,t+"",r);let cs=class{getAllDeviceModels(){return Object.values(cs.deviceModelByIds)}getDeviceModel(t){return cs.deviceModelByIds[t.id]}filterDeviceModels(t){return this.getAllDeviceModels().filter(r=>Object.entries(t).every(([n,i])=>r[n]===i))}getBluetoothServicesInfos(){return Object.values(cs.deviceModelByIds).reduce((t,r)=>{const{bluetoothSpec:n}=r;return n?{...t,...n.reduce((i,o)=>({...i,[o.serviceUuid]:new a8(r,o.serviceUuid,o.writeUuid,o.writeCmdUuid,o.notifyUuid)}),{})}:t},{})}getBluetoothServices(){return Object.values(cs.deviceModelByIds).map(t=>(t.bluetoothSpec||[]).map(r=>r.serviceUuid)).flat().filter(t=>!!t)}};c8(cs,"deviceModelByIds",{[Zt.NANO_S]:new tl({id:Zt.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:e=>VR.lt(VR.coerce(e.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[Zt.NANO_SP]:new tl({id:Zt.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[Zt.NANO_X]:new tl({id:Zt.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"}]}),[Zt.STAX]:new tl({id:Zt.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"}]}),[Zt.FLEX]:new tl({id:Zt.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"}]}),[Zt.APEX]:new tl({id:Zt.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"}]})}),cs=u8([Rt()],cs);let f8=class{statusCode;data;constructor({statusCode:t,data:r}){this.statusCode=t,this.data=r}};const d8=5,as=1,Qy=2,bl=2,Zy=2,zr=[];for(let e=0;e<256;++e)zr.push((e+256).toString(16).slice(1));function p8(e,t=0){return(zr[e[t+0]]+zr[e[t+1]]+zr[e[t+2]]+zr[e[t+3]]+"-"+zr[e[t+4]]+zr[e[t+5]]+"-"+zr[e[t+6]]+zr[e[t+7]]+"-"+zr[e[t+8]]+zr[e[t+9]]+"-"+zr[e[t+10]]+zr[e[t+11]]+zr[e[t+12]]+zr[e[t+13]]+zr[e[t+14]]+zr[e[t+15]]).toLowerCase()}let Em;const h8=new Uint8Array(16);function g8(){if(!Em){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Em=crypto.getRandomValues.bind(crypto)}return Em(h8)}const v8=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),a_={randomUUID:v8};function Jp(e,t,r){if(a_.randomUUID&&!e)return a_.randomUUID();e=e||{};const n=e.random||(e.rng||g8)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,p8(n)}const gs={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)}},s_=2,Cm=800;let l_=class{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}},m8=class{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}},u_=class{_tag="ReceiverApduError";originalError;constructor(t){this.originalError=new Error(t??"Unable to parse apdu")}},c_=class{_tag="DeviceSessionNotFound";originalError;constructor(t){this.originalError=t??new Error("Device session not found")}},P2=class{_header;_data;constructor({header:t,data:r}){this._header=t,this._data=r}toString(){return JSON.stringify({header:this._header.toString(),data:dc(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}},k2=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=>gs.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 _r={LoggerPublisherServiceFactory:Symbol.for("LoggerPublisherServiceFactory")};var y8=(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},b8=(e,t)=>(r,n)=>t(r,n,e);let f_=class{_channel;_logger;_pendingFrames;constructor({channel:t=Tn.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 Yt;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"),Yt;const n=gs.getFirstBytesFrom(this.concatFrames(this._pendingFrames),r),i=gs.getFirstBytesFrom(n,n.length-s_),o=gs.getLastBytesFrom(n,s_);return this._pendingFrames=[],dn(new f8({data:i,statusCode:o}))})}getFrameFromBytes(t){const r=this._channel.caseOf({Just:()=>Qy,Nothing:()=>0}),n=t.slice(r,r+as),i=t.slice(r+as,r+as+bl),o=i.reduce((h,b)=>h+b,0)===0;if(!o&&this._pendingFrames.length===0)return tn(new u_);const s=r+as+bl,u=o?Zy:0;if(t.length<r+as+bl+u)return tn(new u_("Unable to parse header from apdu"));const c=o?dn(t.slice(s,s+u)):Yt,f=s+u,d=t.slice(f),g=new P2({header:new k2({uuid:Jp(),channel:this._channel,dataSize:c,headTag:n,index:i,length:r+as+bl+u}),data:d});return rn(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))}};f_=y8([Rt(),b8(1,rt(_r.LoggerPublisherServiceFactory))],f_);var S8=(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},w8=(e,t)=>(r,n)=>t(r,n,e);let d_=class{_frameSize;_channel;_padding;_logger;constructor({frameSize:t,channel:r=Tn.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 l_||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 tn(new l_);if(n.getLength()>this._frameSize)return tn(new m8);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 P2({header:n,data:u});return rn(c)}getFrameHeaderFrom(t,r){const n=new k2({uuid:Jp(),channel:this._channel.map(i=>gs.getLastBytesFrom(i,Qy)),headTag:new Uint8Array([d8]),index:gs.numberToByteArray(t,bl),length:this.getFrameHeaderSizeFromIndex(t),dataSize:Tn.zero()});return t===0&&n.setDataSize(Tn.of(gs.numberToByteArray(r,Zy))),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:()=>Qy,Nothing:()=>0})+bl+as+(t===0?Zy:0)}};d_=S8([Rt(),w8(1,rt(_r.LoggerPublisherServiceFactory))],d_);const eb={LocalConfigDataSource:Symbol.for("LocalConfigDataSource"),RemoteConfigDataSource:Symbol.for("RemoteConfigDataSource"),ConfigService:Symbol.for("ConfigService")},gn={ApduSenderServiceFactory:Symbol.for("ApduSenderServiceFactory"),ApduReceiverServiceFactory:Symbol.for("ApduReceiverServiceFactory"),DeviceSessionService:Symbol.for("DeviceSessionService")},p_={ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase")},Qp={ManagerApiService:Symbol.for("ManagerApiService"),ManagerApiDataSource:Symbol.for("ManagerApiDataSource"),DmkConfig:Symbol.for("ManagerApiDmkConfig")},ja={DmkConfig:Symbol.for("TransportDmkConfig"),TransportService:Symbol.for("TransportService"),TransportsInput:Symbol.for("TransportsInput")};var x8=(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 g_=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}})}};g_=x8([Rt(),h_(0,rt(gn.DeviceSessionService)),h_(1,rt(_r.LoggerPublisherServiceFactory))],g_);var E8=(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 v_=class{execute=vi.fn(()=>"stub")};v_=E8([Rt()],v_);var C8=(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},m_=(e,t)=>(r,n)=>t(r,n,e);let y_=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}})}};y_=C8([Rt(),m_(0,rt(gn.DeviceSessionService)),m_(1,rt(_r.LoggerPublisherServiceFactory))],y_);function R8(e){return typeof e=="object"&&e!==null&&"version"in e&&"name"in e&&typeof e.version=="string"&&typeof e.name=="string"}let b_=class{constructor(t){this.err=t,this.originalError=t}_tag="ApiCallError";originalError},_8=class{constructor(t){this.err=t,this.originalError=t}_tag="ParseResponseError";originalError},M2=class{constructor(t){this.err=t,this.originalError=t}_tag="JSONParseError";originalError},O8=class{constructor(t){this.err=t,this.originalError=t}_tag="ReadFileError";originalError};const T8="@ledgerhq/device-management-kit",A8="0.0.0-develop-20260422001917",S_={name:T8,version:A8};var $8=(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 I8={name:S_.name,version:S_.version},P8=()=>JSON.stringify(I8);let w_=class{getConfig(){return Jn.encase(()=>P8()).mapLeft(t=>new O8(t)).chain(t=>Jn.encase(()=>{const r=JSON.parse(t);if(R8(r))return r;throw new Error("Invalid config file")}).mapLeft(r=>new M2(r)))}};w_=$8([Rt()],w_);var k8=(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 x_=class{getConfig(){return Jn.of({name:"DeviceSDK",version:"0.0.0-stub.1"})}};x_=k8([Rt()],x_);var M8=(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 E_=class{async getConfig(){const t=await this._callApi();if(t.isLeft())return tn(new b_(t.extract()));if(!t.extract().ok)return tn(new b_(new Error("response not ok")));const r=await t.extract().json();return r.isLeft()?tn(new M2):r.chain(n=>this._parseResponse(n)).map(n=>n)}_parseResponse(t){const{name:r,version:n}=t;return!r||!n?tn(new _8):Jn.of({name:r,version:n})}_callApi(){return new Promise(t=>{t(Jn.of({ok:!0,json:async()=>new Promise(r=>{r(Jn.of({name:"DeviceSDK",version:"0.0.0-fake.1",yolo:"yolo"}))})}))})}};E_=M8([Rt()],E_);var D8=(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 C_=class{async getConfig(){return new Promise(t=>t(Jn.of({name:"DeviceSDK",version:"0.0.0-fake.2"})))}};C_=D8([Rt()],C_);var L8=(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},Rm=(e,t)=>(r,n)=>t(r,n,e);let R_=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())}};R_=L8([Rt(),Rm(0,rt(eb.LocalConfigDataSource)),Rm(1,rt(eb.RemoteConfigDataSource)),Rm(2,rt(_r.LoggerPublisherServiceFactory))],R_);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},N8=(e,t)=>(r,n)=>t(r,n,e);let __=class{_configService;constructor(t){this._configService=t}async getDmkVersion(){return(await this._configService.getDmkConfig()).version}};__=F8([Rt(),N8(0,rt(eb.ConfigService))],__);const j8={DeviceModelDataSource:Symbol.for("DeviceModelDataSource")};var z8=(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},O_=(e,t)=>(r,n)=>t(r,n,e);let T_=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)})}};T_=z8([Rt(),O_(0,rt(gn.DeviceSessionService)),O_(1,rt(_r.LoggerPublisherServiceFactory))],T_);var B8=(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},V8=(e,t)=>(r,n)=>t(r,n,e);let A_=class{_sessions;_sessionsSubject;_logger;constructor(t){this._sessions=[],this._sessionsSubject=new d2,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 Tn.fromNullable(this._sessions.find(r=>r.id===t)).toEither(new c_)}getDeviceSessionsByDeviceId(t){return Tn.fromPredicate(({length:r})=>r>0,this._sessions.filter(r=>r.connectedDevice.id===t)).toEither(new c_)}getDeviceSessions(){return this._sessions}};A_=B8([Rt(),V8(0,rt(_r.LoggerPublisherServiceFactory))],A_);var 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},$_=(e,t)=>(r,n)=>t(r,n,e);let I_=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)}};I_=U8([Rt(),$_(0,rt(gn.DeviceSessionService)),$_(1,rt(ja.TransportService))],I_);var H8=(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},P_=(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_=H8([Rt(),P_(0,rt(gn.DeviceSessionService)),P_(1,rt(_r.LoggerPublisherServiceFactory))],k_);var W8=(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},M_=(e,t)=>(r,n)=>t(r,n,e);let D_=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)}})}};D_=W8([Rt(),M_(0,rt(gn.DeviceSessionService)),M_(1,rt(_r.LoggerPublisherServiceFactory))],D_);function q8(e){return`[will send APDU] ~...> ${dc(e,!1)}`}function G8(e){return`[exchange] <= ${dc(e.data,!1)}${dc(e.statusCode,!1)}`}const tb=1e3,_m=1e3,X8={isRefresherDisabled:!1,pollingInterval:1e3};var dr=(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))(dr||{});let K8=class{_eventEmitter=new Gl;listen(){return this._eventEmitter.asObservable()}dispatch(t){this._eventEmitter.next(t)}},Y8=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 Gl,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(Mz(()=>{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:dr.NEW_STATE});return}this.sessionEventDispatcher.dispatch({eventName:dr.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()}},J8=class{constructor(t,r){this._refresher=r,this._logger=t("refresher-service")}_refresherBlockers=new Set;_logger;disableRefresher(t){const r=`${t}-${Jp()}`;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()}},Q8=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 dr.REFRESH_NEEDED:return await this.ping();default:return null}};async mapDevicePingAction(t){switch(t){case Zt.NANO_S:{const r=async()=>{const o=await this._sendCommandFunction(new YC,Cm);return this._sendCommandFunction(new zj,Cm),o},n=new Promise(o=>{setTimeout(()=>o(null),tb*2+100)}),i=await Promise.race([r(),n]);return i?this._sessionEventDispatcher.dispatch({eventName:dr.COMMAND_SUCCEEDED,eventData:i}):this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_LOCKED}),i}default:{const r=await this._sendCommandFunction(new YC,Cm);return this._sessionEventDispatcher.dispatch({eventName:dr.COMMAND_SUCCEEDED,eventData:r}),r}}}unsubscribe(){this._subscription.unsubscribe()}},Z8=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(JR(n=>n.eventName===dr.DEVICE_STATE_UPDATE_BUSY||n.eventName===dr.NEW_STATE),Fa(n=>n.eventName===dr.DEVICE_STATE_UPDATE_BUSY),Lz(!1),Pz());this._refresherSubscription=Az(0,t).pipe(Fz(r),QR(([n,i])=>{i&&this._logger.debug("Refresh skipped: device is busy")}),JR(([n,i])=>!i),QR(()=>this._sessionEventDispatcher.dispatch({eventName:dr.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 Zt.NANO_S:{const i=tb*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<_m?(r.warn(`Polling interval of ${n} is too low, setting to minimum as ${_m}`),_m):n??tb}}},eB=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=bo.BUSY;_updateDeviceState(t){const r=this._parseDeviceStatus(t);if(r){const{sessionStateType:n,deviceStatus:i,currentApp:o}=r,s=this._deviceState.getValue();s.sessionStateType===pc.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 dr.COMMAND_SUCCEEDED:return this._updateDeviceState(t.eventData);case dr.DEVICE_STATE_UPDATE_BUSY:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:bo.BUSY});case dr.DEVICE_STATE_UPDATE_LOCKED:this._pendingDeviceStatus=bo.LOCKED;return;case dr.DEVICE_STATE_UPDATE_CONNECTED:this._pendingDeviceStatus=bo.CONNECTED;return;case dr.NEW_STATE:{const n=this._pendingDeviceStatus;return this._pendingDeviceStatus=bo.BUSY,this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:n})}case dr.DEVICE_STATE_UPDATE_UNKNOWN:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:bo.BUSY});case dr.REFRESH_NEEDED:return;default:{const n=r;throw new Error(`Unhandled context type ${n}`)}}};_parseDeviceStatus(t){return sj(t)?{sessionStateType:pc.ReadyWithoutSecureChannel,deviceStatus:bo.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()}},tB=class{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new K8;_bypassIntentQueue=!1;constructor({connectedDevice:t,id:r=Jp()},n,i,o,s,u=c=>new Y8(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={...X8,...s},this._deviceState=new nz({sessionStateType:pc.Connected,deviceStatus:bo.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new Q8(n,t,this._sessionEventDispatcher,(c,f)=>this.sendCommand(c,f)),this._deviceSessionRefresher=new Z8(n,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new eB(n,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,c=>this.setDeviceSessionState(c)),this._refresherService=new J8(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:()=>Pl((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(KR({each:n,with:()=>{throw s(),new Nz}})):o;return XR(u)}async _unsafeInternalSendApdu(t,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug(q8(t)),(await this._connectedDevice.sendApdu(t,r.triggersDisconnection,r.abortTimeout)).ifRight(n=>{this._logger.debug(G8(n)),$1.isLockedDeviceResponse(n)?this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:dr.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:dr.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:()=>Pl((async()=>{const u=Date.now()-n;return await this._unsafeInternalSendCommand(t,r?r-u:void 0)})())}),s=r?i.pipe(KR({each:r,with:()=>{throw o(),new jz}})):i;return XR(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(bo.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 X1={SecureChannelService:Symbol.for("SecureChannelService"),SecureChannelDataSource:Symbol.for("SecureChannelDataSource"),DmkConfig:Symbol.for("SecureChannelDmkConfig")};var rB=(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},$u=(e,t)=>(r,n)=>t(r,n,e);let L_=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 mt.liftEither(n.toEither(new q1(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 tB({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})}};L_=rB([Rt(),$u(0,rt(ja.TransportService)),$u(1,rt(gn.DeviceSessionService)),$u(2,rt(_r.LoggerPublisherServiceFactory)),$u(3,rt(Qp.ManagerApiService)),$u(4,rt(X1.SecureChannelService))],L_);var nB=(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},Om=(e,t)=>(r,n)=>t(r,n,e);let F_=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)}}),mt(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 q1(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:()=>{}})}};F_=nB([Rt(),Om(0,rt(ja.TransportService)),Om(1,rt(gn.DeviceSessionService)),Om(2,rt(_r.LoggerPublisherServiceFactory))],F_);let K1=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 iB=(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},N_=(e,t)=>(r,n)=>t(r,n,e);let j_=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 K1({sessionId:r.id,transportConnectedDevice:r.connectedDevice}),Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r}})}};j_=iB([Rt(),N_(0,rt(gn.DeviceSessionService)),N_(1,rt(_r.LoggerPublisherServiceFactory))],j_);var oB=(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},z_=(e,t)=>(r,n)=>t(r,n,e);let B_=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 K1({transportConnectedDevice:t.connectedDevice,sessionId:t.id}))}};B_=oB([Rt(),z_(0,rt(gn.DeviceSessionService)),z_(1,rt(_r.LoggerPublisherServiceFactory))],B_);var aB=(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},V_=(e,t)=>(r,n)=>t(r,n,e);let U_=class{_transports;_transportService;_logger;constructor(t,r){this._transports=t.getAllTransports(),this._transportService=t,this._logger=r("ListenToAvailableDevicesUseCase")}mapTransportDiscoveredDeviceToDiscoveredDevice(t){const r=new t2({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"),Pl([[]]);if(!t){this._logger.info("Discovering all available transports");const r=this._transports.map((n,i)=>n.listenToAvailableDevices().pipe(Fa(o=>({index:i,arr:o}))));return $z(...r).pipe(Dz((n,{index:i,arr:o})=>(n[i]=o,n),{}),Fa(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`),T2([])),Just:r=>r.listenToAvailableDevices().pipe(Fa(n=>n.map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))})}};U_=aB([Rt(),V_(0,rt(ja.TransportService)),V_(1,rt(_r.LoggerPublisherServiceFactory))],U_);var sB=(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 W_=class{constructor(t,r){this._sessionService=t,this._logger=r("ListenToConnectedDeviceUseCase")}_logger;execute(){return this._logger.info("Observe connected devices"),this._sessionService.sessionsObs.pipe(Fa(t=>new K1({transportConnectedDevice:t.connectedDevice,sessionId:t.id})))}};W_=sB([Rt(),H_(0,rt(gn.DeviceSessionService)),H_(1,rt(_r.LoggerPublisherServiceFactory))],W_);var lB=(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 q_=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})}};q_=lB([Rt(),Tm(0,rt(p_.ConnectUseCase)),Tm(1,rt(p_.DisconnectUseCase)),Tm(2,rt(_r.LoggerPublisherServiceFactory))],q_);var uB=(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},cB=(e,t)=>(r,n)=>t(r,n,e);let G_=class{constructor(t){this._transportService=t}mapDiscoveredDevice(t){const r=new t2({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 T2(...r).pipe(W1(n=>n.startDiscovering().pipe(Fa(i=>this.mapDiscoveredDevice(i)))))}return this._transportService.getTransport(t).caseOf({Just:r=>r.startDiscovering().pipe(Fa(n=>this.mapDiscoveredDevice(n))),Nothing:()=>{throw new q1(new Error("Unknown transport"))}})}};G_=uB([Rt(),cB(0,rt(ja.TransportService))],G_);var fB=(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{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()}};K_=fB([Rt(),X_(0,rt(ja.TransportService)),X_(1,rt(_r.LoggerPublisherServiceFactory))],K_);var zu=(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))(zu||{});let dB=class{format(t){return Array.isArray(t)?t.map(r=>`[${r}]`).join(" "):`[${t}]`}};function rb(e,t){if(typeof e=="bigint")return e.toString();if(Array.isArray(e))return t.has(e)?"[Circular]":(t.add(e),e.map(r=>rb(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]=rb(i,t);return r}return e}function pB(e){const t=new WeakSet;t.add(e);const r={};for(const[n,i]of Object.entries(e))r[n]=rb(i,t);return r}var hB=(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 Y_=class{subscribers;tag;tagFormatter;constructor(t,r,n=new dB){this.subscribers=t,this.tag=r,this.tagFormatter=n}_log(t,r,n){const i=n?.data?pB(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(zu.Info,t,r)}warn(t,r){this._log(zu.Warning,t,r)}debug(t,r){this._log(zu.Debug,t,r)}error(t,r){this._log(zu.Error,t,r)}};Y_=hB([Rt()],Y_);function D2(e,t){return function(){return e.apply(t,arguments)}}const{toString:gB}=Object.prototype,{getPrototypeOf:Y1}=Object,{iterator:Zp,toStringTag:L2}=Symbol,eh=(e=>t=>{const r=gB.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),so=e=>(e=e.toLowerCase(),t=>eh(t)===e),th=e=>t=>typeof t===e,{isArray:Xl}=Array,kl=th("undefined");function Fc(e){return e!==null&&!kl(e)&&e.constructor!==null&&!kl(e.constructor)&&An(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const F2=so("ArrayBuffer");function vB(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&F2(e.buffer),t}const mB=th("string"),An=th("function"),N2=th("number"),Nc=e=>e!==null&&typeof e=="object",yB=e=>e===!0||e===!1,ep=e=>{if(eh(e)!=="object")return!1;const t=Y1(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(L2 in e)&&!(Zp in e)},bB=e=>{if(!Nc(e)||Fc(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},SB=so("Date"),wB=so("File"),xB=so("Blob"),EB=so("FileList"),CB=e=>Nc(e)&&An(e.pipe),RB=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||An(e.append)&&((t=eh(e))==="formdata"||t==="object"&&An(e.toString)&&e.toString()==="[object FormData]"))},_B=so("URLSearchParams"),[OB,TB,AB,$B]=["ReadableStream","Request","Response","Headers"].map(so),IB=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function jc(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),Xl(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(Fc(e))return;const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let u;for(n=0;n<s;n++)u=o[n],t.call(null,e[u],u,e)}}function j2(e,t){if(Fc(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}const fs=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:self,z2=e=>!kl(e)&&e!==fs;function nb(){const{caseless:e,skipUndefined:t}=z2(this)&&this||{},r={},n=(i,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const s=e&&j2(r,o)||o;ep(r[s])&&ep(i)?r[s]=nb(r[s],i):ep(i)?r[s]=nb({},i):Xl(i)?r[s]=i.slice():(!t||!kl(i))&&(r[s]=i)};for(let i=0,o=arguments.length;i<o;i++)arguments[i]&&jc(arguments[i],n);return r}const PB=(e,t,r,{allOwnKeys:n}={})=>(jc(t,(i,o)=>{r&&An(i)?Object.defineProperty(e,o,{value:D2(i,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),kB=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),MB=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},DB=(e,t,r,n)=>{let i,o,s;const u={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],(!n||n(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=r!==!1&&Y1(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},LB=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},FB=e=>{if(!e)return null;if(Xl(e))return e;let t=e.length;if(!N2(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},NB=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Y1(Uint8Array)),jB=(e,t)=>{const n=(e&&e[Zp]).call(e);let i;for(;(i=n.next())&&!i.done;){const o=i.value;t.call(e,o[0],o[1])}},zB=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},BB=so("HTMLFormElement"),VB=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),J_=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),UB=so("RegExp"),B2=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};jc(r,(i,o)=>{let s;(s=t(i,o,e))!==!1&&(n[o]=s||i)}),Object.defineProperties(e,n)},HB=e=>{B2(e,(t,r)=>{if(An(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(An(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},WB=(e,t)=>{const r={},n=i=>{i.forEach(o=>{r[o]=!0})};return Xl(e)?n(e):n(String(e).split(t)),r},qB=()=>{},GB=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function XB(e){return!!(e&&An(e.append)&&e[L2]==="FormData"&&e[Zp])}const KB=e=>{const t=new Array(10),r=(n,i)=>{if(Nc(n)){if(t.indexOf(n)>=0)return;if(Fc(n))return n;if(!("toJSON"in n)){t[i]=n;const o=Xl(n)?[]:{};return jc(n,(s,u)=>{const c=r(s,i+1);!kl(c)&&(o[u]=c)}),t[i]=void 0,o}}return n};return r(e,0)},YB=so("AsyncFunction"),JB=e=>e&&(Nc(e)||An(e))&&An(e.then)&&An(e.catch),V2=((e,t)=>e?setImmediate:t?((r,n)=>(fs.addEventListener("message",({source:i,data:o})=>{i===fs&&o===r&&n.length&&n.shift()()},!1),i=>{n.push(i),fs.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",An(fs.postMessage)),QB=typeof queueMicrotask<"u"?queueMicrotask.bind(fs):typeof process<"u"&&process.nextTick||V2,ZB=e=>e!=null&&An(e[Zp]),ye={isArray:Xl,isArrayBuffer:F2,isBuffer:Fc,isFormData:RB,isArrayBufferView:vB,isString:mB,isNumber:N2,isBoolean:yB,isObject:Nc,isPlainObject:ep,isEmptyObject:bB,isReadableStream:OB,isRequest:TB,isResponse:AB,isHeaders:$B,isUndefined:kl,isDate:SB,isFile:wB,isBlob:xB,isRegExp:UB,isFunction:An,isStream:CB,isURLSearchParams:_B,isTypedArray:NB,isFileList:EB,forEach:jc,merge:nb,extend:PB,trim:IB,stripBOM:kB,inherits:MB,toFlatObject:DB,kindOf:eh,kindOfTest:so,endsWith:LB,toArray:FB,forEachEntry:jB,matchAll:zB,isHTMLForm:BB,hasOwnProperty:J_,hasOwnProp:J_,reduceDescriptors:B2,freezeMethods:HB,toObjectSet:WB,toCamelCase:VB,noop:qB,toFiniteNumber:GB,findKey:j2,global:fs,isContextDefined:z2,isSpecCompliantForm:XB,toJSONObject:KB,isAsyncFn:YB,isThenable:JB,setImmediate:V2,asap:QB,isIterable:ZB};let ut=class U2 extends Error{static from(t,r,n,i,o,s){const u=new U2(t.message,r||t.code,n,i,o);return u.cause=t,u.name=t.name,s&&Object.assign(u,s),u}constructor(t,r,n,i,o){super(t),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),i&&(this.request=i),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ye.toJSONObject(this.config),code:this.code,status:this.status}}};ut.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ut.ERR_BAD_OPTION="ERR_BAD_OPTION";ut.ECONNABORTED="ECONNABORTED";ut.ETIMEDOUT="ETIMEDOUT";ut.ERR_NETWORK="ERR_NETWORK";ut.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ut.ERR_DEPRECATED="ERR_DEPRECATED";ut.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ut.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ut.ERR_CANCELED="ERR_CANCELED";ut.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ut.ERR_INVALID_URL="ERR_INVALID_URL";const eV=null;function ib(e){return ye.isPlainObject(e)||ye.isArray(e)}function H2(e){return ye.endsWith(e,"[]")?e.slice(0,-2):e}function Q_(e,t,r){return e?e.concat(t).map(function(i,o){return i=H2(i),!r&&o?"["+i+"]":i}).join(r?".":""):t}function tV(e){return ye.isArray(e)&&!e.some(ib)}const rV=ye.toFlatObject(ye,{},null,function(t){return/^is[A-Z]/.test(t)});function rh(e,t,r){if(!ye.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=ye.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,y){return!ye.isUndefined(y[S])});const n=r.metaTokens,i=r.visitor||d,o=r.dots,s=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&ye.isSpecCompliantForm(t);if(!ye.isFunction(i))throw new TypeError("visitor must be a function");function f(v){if(v===null)return"";if(ye.isDate(v))return v.toISOString();if(ye.isBoolean(v))return v.toString();if(!c&&ye.isBlob(v))throw new ut("Blob is not supported. Use a Buffer instead.");return ye.isArrayBuffer(v)||ye.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,S,y){let E=v;if(v&&!y&&typeof v=="object"){if(ye.endsWith(S,"{}"))S=n?S:S.slice(0,-2),v=JSON.stringify(v);else if(ye.isArray(v)&&tV(v)||(ye.isFileList(v)||ye.endsWith(S,"[]"))&&(E=ye.toArray(v)))return S=H2(S),E.forEach(function(T,A){!(ye.isUndefined(T)||T===null)&&t.append(s===!0?Q_([S],A,o):s===null?S:S+"[]",f(T))}),!1}return ib(v)?!0:(t.append(Q_(y,S,o),f(v)),!1)}const g=[],h=Object.assign(rV,{defaultVisitor:d,convertValue:f,isVisitable:ib});function b(v,S){if(!ye.isUndefined(v)){if(g.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));g.push(v),ye.forEach(v,function(E,x){(!(ye.isUndefined(E)||E===null)&&i.call(t,E,ye.isString(x)?x.trim():x,S,h))===!0&&b(E,S?S.concat(x):[x])}),g.pop()}}if(!ye.isObject(e))throw new TypeError("data must be an object");return b(e),t}function Z_(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function J1(e,t){this._pairs=[],e&&rh(e,this,t)}const W2=J1.prototype;W2.append=function(t,r){this._pairs.push([t,r])};W2.toString=function(t){const r=t?function(n){return t.call(this,n,Z_)}:Z_;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function nV(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function q2(e,t,r){if(!t)return e;const n=r&&r.encode||nV,i=ye.isFunction(r)?{serialize:r}:r,o=i&&i.serialize;let s;if(o?s=o(t,i):s=ye.isURLSearchParams(t)?t.toString():new J1(t,i).toString(n),s){const u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class eO{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ye.forEach(this.handlers,function(n){n!==null&&t(n)})}}const Q1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},iV=typeof URLSearchParams<"u"?URLSearchParams:J1,oV=typeof FormData<"u"?FormData:null,aV=typeof Blob<"u"?Blob:null,sV={isBrowser:!0,classes:{URLSearchParams:iV,FormData:oV,Blob:aV},protocols:["http","https","file","blob","url","data"]},Z1=typeof window<"u"&&typeof document<"u",ob=typeof navigator=="object"&&navigator||void 0,lV=Z1&&(!ob||["ReactNative","NativeScript","NS"].indexOf(ob.product)<0),uV=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",cV=Z1&&window.location.href||"http://localhost",fV=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Z1,hasStandardBrowserEnv:lV,hasStandardBrowserWebWorkerEnv:uV,navigator:ob,origin:cV},Symbol.toStringTag,{value:"Module"})),en={...fV,...sV};function dV(e,t){return rh(e,new en.classes.URLSearchParams,{visitor:function(r,n,i,o){return en.isNode&&ye.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...t})}function pV(e){return ye.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hV(e){const t={},r=Object.keys(e);let n;const i=r.length;let o;for(n=0;n<i;n++)o=r[n],t[o]=e[o];return t}function G2(e){function t(r,n,i,o){let s=r[o++];if(s==="__proto__")return!0;const u=Number.isFinite(+s),c=o>=r.length;return s=!s&&ye.isArray(i)?i.length:s,c?(ye.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!u):((!i[s]||!ye.isObject(i[s]))&&(i[s]=[]),t(r,n,i[s],o)&&ye.isArray(i[s])&&(i[s]=hV(i[s])),!u)}if(ye.isFormData(e)&&ye.isFunction(e.entries)){const r={};return ye.forEachEntry(e,(n,i)=>{t(pV(n),i,r,0)}),r}return null}function gV(e,t,r){if(ye.isString(e))try{return(t||JSON.parse)(e),ye.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const zc={transitional:Q1,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,o=ye.isObject(t);if(o&&ye.isHTMLForm(t)&&(t=new FormData(t)),ye.isFormData(t))return i?JSON.stringify(G2(t)):t;if(ye.isArrayBuffer(t)||ye.isBuffer(t)||ye.isStream(t)||ye.isFile(t)||ye.isBlob(t)||ye.isReadableStream(t))return t;if(ye.isArrayBufferView(t))return t.buffer;if(ye.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return dV(t,this.formSerializer).toString();if((u=ye.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return rh(u?{"files[]":t}:t,c&&new c,this.formSerializer)}}return o||i?(r.setContentType("application/json",!1),gV(t)):t}],transformResponse:[function(t){const r=this.transitional||zc.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(ye.isResponse(t)||ye.isReadableStream(t))return t;if(t&&ye.isString(t)&&(n&&!this.responseType||i)){const s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(u){if(s)throw u.name==="SyntaxError"?ut.from(u,ut.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:en.classes.FormData,Blob:en.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ye.forEach(["delete","get","head","post","put","patch"],e=>{zc.headers[e]={}});const vV=ye.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),mV=e=>{const t={};let r,n,i;return e&&e.split(`
|
|
526
526
|
`).forEach(function(s){i=s.indexOf(":"),r=s.substring(0,i).trim().toLowerCase(),n=s.substring(i+1).trim(),!(!r||t[r]&&vV[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},tO=Symbol("internals");function Iu(e){return e&&String(e).trim().toLowerCase()}function tp(e){return e===!1||e==null?e:ye.isArray(e)?e.map(tp):String(e)}function yV(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const bV=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Am(e,t,r,n,i){if(ye.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!ye.isString(t)){if(ye.isString(n))return t.indexOf(n)!==-1;if(ye.isRegExp(n))return n.test(t)}}function SV(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function wV(e,t){const r=ye.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,o,s){return this[n].call(this,t,i,o,s)},configurable:!0})})}let $n=class{constructor(t){t&&this.set(t)}set(t,r,n){const i=this;function o(u,c,f){const d=Iu(c);if(!d)throw new Error("header name must be a non-empty string");const g=ye.findKey(i,d);(!g||i[g]===void 0||f===!0||f===void 0&&i[g]!==!1)&&(i[g||c]=tp(u))}const s=(u,c)=>ye.forEach(u,(f,d)=>o(f,d,c));if(ye.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(ye.isString(t)&&(t=t.trim())&&!bV(t))s(mV(t),r);else if(ye.isObject(t)&&ye.isIterable(t)){let u={},c,f;for(const d of t){if(!ye.isArray(d))throw TypeError("Object iterator must return a key-value pair");u[f=d[0]]=(c=u[f])?ye.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}s(u,r)}else t!=null&&o(r,t,n);return this}get(t,r){if(t=Iu(t),t){const n=ye.findKey(this,t);if(n){const i=this[n];if(!r)return i;if(r===!0)return yV(i);if(ye.isFunction(r))return r.call(this,i,n);if(ye.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Iu(t),t){const n=ye.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Am(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let i=!1;function o(s){if(s=Iu(s),s){const u=ye.findKey(n,s);u&&(!r||Am(n,n[u],u,r))&&(delete n[u],i=!0)}}return ye.isArray(t)?t.forEach(o):o(t),i}clear(t){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const o=r[n];(!t||Am(this,this[o],o,t,!0))&&(delete this[o],i=!0)}return i}normalize(t){const r=this,n={};return ye.forEach(this,(i,o)=>{const s=ye.findKey(n,o);if(s){r[s]=tp(i),delete r[o];return}const u=t?SV(o):String(o).trim();u!==o&&delete r[o],r[u]=tp(i),n[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return ye.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&ye.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
527
527
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const n=(this[tO]=this[tO]={accessors:{}}).accessors,i=this.prototype;function o(s){const u=Iu(s);n[u]||(wV(i,s),n[u]=!0)}return ye.isArray(t)?t.forEach(o):o(t),this}};$n.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ye.reduceDescriptors($n.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});ye.freezeMethods($n);function $m(e,t){const r=this||zc,n=t||r,i=$n.from(n.headers);let o=n.data;return ye.forEach(e,function(u){o=u.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function X2(e){return!!(e&&e.__CANCEL__)}let Bc=class extends ut{constructor(t,r,n){super(t??"canceled",ut.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function K2(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new ut("Request failed with status code "+r.status,[ut.ERR_BAD_REQUEST,ut.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function xV(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function EV(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,o=0,s;return t=t!==void 0?t:1e3,function(c){const f=Date.now(),d=n[o];s||(s=f),r[i]=c,n[i]=f;let g=o,h=0;for(;g!==i;)h+=r[g++],g=g%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),f-s<t)return;const b=d&&f-d;return b?Math.round(h*1e3/b):void 0}}function CV(e,t){let r=0,n=1e3/t,i,o;const s=(f,d=Date.now())=>{r=d,i=null,o&&(clearTimeout(o),o=null),e(...f)};return[(...f)=>{const d=Date.now(),g=d-r;g>=n?s(f,d):(i=f,o||(o=setTimeout(()=>{o=null,s(i)},n-g)))},()=>i&&s(i)]}const xp=(e,t,r=3)=>{let n=0;const i=EV(50,250);return CV(o=>{const s=o.loaded,u=o.lengthComputable?o.total:void 0,c=s-n,f=i(c),d=s<=u;n=s;const g={loaded:s,total:u,progress:u?s/u:void 0,bytes:c,rate:f||void 0,estimated:f&&u&&d?(u-s)/f:void 0,event:o,lengthComputable:u!=null,[t?"download":"upload"]:!0};e(g)},r)},rO=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},nO=e=>(...t)=>ye.asap(()=>e(...t)),RV=en.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,en.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(en.origin),en.navigator&&/(msie|trident)/i.test(en.navigator.userAgent)):()=>!0,_V=en.hasStandardBrowserEnv?{write(e,t,r,n,i,o,s){if(typeof document>"u")return;const u=[`${e}=${encodeURIComponent(t)}`];ye.isNumber(r)&&u.push(`expires=${new Date(r).toUTCString()}`),ye.isString(n)&&u.push(`path=${n}`),ye.isString(i)&&u.push(`domain=${i}`),o===!0&&u.push("secure"),ye.isString(s)&&u.push(`SameSite=${s}`),document.cookie=u.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function OV(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function TV(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Y2(e,t,r){let n=!OV(t);return e&&(n||r==!1)?TV(e,t):t}const iO=e=>e instanceof $n?{...e}:e;function Es(e,t){t=t||{};const r={};function n(f,d,g,h){return ye.isPlainObject(f)&&ye.isPlainObject(d)?ye.merge.call({caseless:h},f,d):ye.isPlainObject(d)?ye.merge({},d):ye.isArray(d)?d.slice():d}function i(f,d,g,h){if(ye.isUndefined(d)){if(!ye.isUndefined(f))return n(void 0,f,g,h)}else return n(f,d,g,h)}function o(f,d){if(!ye.isUndefined(d))return n(void 0,d)}function s(f,d){if(ye.isUndefined(d)){if(!ye.isUndefined(f))return n(void 0,f)}else return n(void 0,d)}function u(f,d,g){if(g in t)return n(f,d);if(g in e)return n(void 0,f)}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u,headers:(f,d,g)=>i(iO(f),iO(d),g,!0)};return ye.forEach(Object.keys({...e,...t}),function(d){if(d==="__proto__"||d==="constructor"||d==="prototype")return;const g=ye.hasOwnProp(c,d)?c[d]:i,h=g(e[d],t[d],d);ye.isUndefined(h)&&g!==u||(r[d]=h)}),r}const J2=e=>{const t=Es({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:u}=t;if(t.headers=s=$n.from(s),t.url=q2(Y2(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),u&&s.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):""))),ye.isFormData(r)){if(en.hasStandardBrowserEnv||en.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(ye.isFunction(r.getHeaders)){const c=r.getHeaders(),f=["content-type","content-length"];Object.entries(c).forEach(([d,g])=>{f.includes(d.toLowerCase())&&s.set(d,g)})}}if(en.hasStandardBrowserEnv&&(n&&ye.isFunction(n)&&(n=n(t)),n||n!==!1&&RV(t.url))){const c=i&&o&&_V.read(o);c&&s.set(i,c)}return t},AV=typeof XMLHttpRequest<"u",$V=AV&&function(e){return new Promise(function(r,n){const i=J2(e);let o=i.data;const s=$n.from(i.headers).normalize();let{responseType:u,onUploadProgress:c,onDownloadProgress:f}=i,d,g,h,b,v;function S(){b&&b(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(d),i.signal&&i.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(i.method.toUpperCase(),i.url,!0),y.timeout=i.timeout;function E(){if(!y)return;const T=$n.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),R={data:!u||u==="text"||u==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:T,config:e,request:y};K2(function(O){r(O),S()},function(O){n(O),S()},R),y=null}"onloadend"in y?y.onloadend=E:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(E)},y.onabort=function(){y&&(n(new ut("Request aborted",ut.ECONNABORTED,e,y)),y=null)},y.onerror=function(A){const R=A&&A.message?A.message:"Network Error",$=new ut(R,ut.ERR_NETWORK,e,y);$.event=A||null,n($),y=null},y.ontimeout=function(){let A=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const R=i.transitional||Q1;i.timeoutErrorMessage&&(A=i.timeoutErrorMessage),n(new ut(A,R.clarifyTimeoutError?ut.ETIMEDOUT:ut.ECONNABORTED,e,y)),y=null},o===void 0&&s.setContentType(null),"setRequestHeader"in y&&ye.forEach(s.toJSON(),function(A,R){y.setRequestHeader(R,A)}),ye.isUndefined(i.withCredentials)||(y.withCredentials=!!i.withCredentials),u&&u!=="json"&&(y.responseType=i.responseType),f&&([h,v]=xp(f,!0),y.addEventListener("progress",h)),c&&y.upload&&([g,b]=xp(c),y.upload.addEventListener("progress",g),y.upload.addEventListener("loadend",b)),(i.cancelToken||i.signal)&&(d=T=>{y&&(n(!T||T.type?new Bc(null,e,y):T),y.abort(),y=null)},i.cancelToken&&i.cancelToken.subscribe(d),i.signal&&(i.signal.aborted?d():i.signal.addEventListener("abort",d)));const x=xV(i.url);if(x&&en.protocols.indexOf(x)===-1){n(new ut("Unsupported protocol "+x+":",ut.ERR_BAD_REQUEST,e));return}y.send(o||null)})},IV=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const o=function(f){if(!i){i=!0,u();const d=f instanceof Error?f:this.reason;n.abort(d instanceof ut?d:new Bc(d instanceof Error?d.message:d))}};let s=t&&setTimeout(()=>{s=null,o(new ut(`timeout of ${t}ms exceeded`,ut.ETIMEDOUT))},t);const u=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),e=null)};e.forEach(f=>f.addEventListener("abort",o));const{signal:c}=n;return c.unsubscribe=()=>ye.asap(u),c}},PV=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},kV=async function*(e,t){for await(const r of MV(e))yield*PV(r,t)},MV=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},oO=(e,t,r,n)=>{const i=kV(e,t);let o=0,s,u=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:f,value:d}=await i.next();if(f){u(),c.close();return}let g=d.byteLength;if(r){let h=o+=g;r(h)}c.enqueue(new Uint8Array(d))}catch(f){throw u(f),f}},cancel(c){return u(c),i.return()}},{highWaterMark:2})},aO=64*1024,{isFunction:yd}=ye,DV=(({Request:e,Response:t})=>({Request:e,Response:t}))(ye.global),{ReadableStream:sO,TextEncoder:lO}=ye.global,uO=(e,...t)=>{try{return!!e(...t)}catch{return!1}},LV=e=>{e=ye.merge.call({skipUndefined:!0},DV,e);const{fetch:t,Request:r,Response:n}=e,i=t?yd(t):typeof fetch=="function",o=yd(r),s=yd(n);if(!i)return!1;const u=i&&yd(sO),c=i&&(typeof lO=="function"?(v=>S=>v.encode(S))(new lO):async v=>new Uint8Array(await new r(v).arrayBuffer())),f=o&&u&&uO(()=>{let v=!1;const S=new r(en.origin,{body:new sO,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!S}),d=s&&u&&uO(()=>ye.isReadableStream(new n("").body)),g={stream:d&&(v=>v.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!g[v]&&(g[v]=(S,y)=>{let E=S&&S[v];if(E)return E.call(S);throw new ut(`Response type '${v}' is not supported`,ut.ERR_NOT_SUPPORT,y)})});const h=async v=>{if(v==null)return 0;if(ye.isBlob(v))return v.size;if(ye.isSpecCompliantForm(v))return(await new r(en.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(ye.isArrayBufferView(v)||ye.isArrayBuffer(v))return v.byteLength;if(ye.isURLSearchParams(v)&&(v=v+""),ye.isString(v))return(await c(v)).byteLength},b=async(v,S)=>{const y=ye.toFiniteNumber(v.getContentLength());return y??h(S)};return async v=>{let{url:S,method:y,data:E,signal:x,cancelToken:T,timeout:A,onDownloadProgress:R,onUploadProgress:$,responseType:O,headers:I,withCredentials:L="same-origin",fetchOptions:F}=J2(v),q=t||fetch;O=O?(O+"").toLowerCase():"text";let z=IV([x,T&&T.toAbortSignal()],A),B=null;const N=z&&z.unsubscribe&&(()=>{z.unsubscribe()});let j;try{if($&&f&&y!=="get"&&y!=="head"&&(j=await b(I,E))!==0){let D=new r(S,{method:"POST",body:E,duplex:"half"}),P;if(ye.isFormData(E)&&(P=D.headers.get("content-type"))&&I.setContentType(P),D.body){const[G,Z]=rO(j,xp(nO($)));E=oO(D.body,aO,G,Z)}}ye.isString(L)||(L=L?"include":"omit");const H=o&&"credentials"in r.prototype,X={...F,signal:z,method:y.toUpperCase(),headers:I.normalize().toJSON(),body:E,duplex:"half",credentials:H?L:void 0};B=o&&new r(S,X);let M=await(o?q(B,F):q(S,X));const Q=d&&(O==="stream"||O==="response");if(d&&(R||Q&&N)){const D={};["status","statusText","headers"].forEach(te=>{D[te]=M[te]});const P=ye.toFiniteNumber(M.headers.get("content-length")),[G,Z]=R&&rO(P,xp(nO(R),!0))||[];M=new n(oO(M.body,aO,G,()=>{Z&&Z(),N&&N()}),D)}O=O||"text";let W=await g[ye.findKey(g,O)||"text"](M,v);return!Q&&N&&N(),await new Promise((D,P)=>{K2(D,P,{data:W,headers:$n.from(M.headers),status:M.status,statusText:M.statusText,config:v,request:B})})}catch(H){throw N&&N(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new ut("Network Error",ut.ERR_NETWORK,v,B,H&&H.response),{cause:H.cause||H}):ut.from(H,H&&H.code,v,B,H&&H.response)}}},FV=new Map,Q2=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:i}=t,o=[n,i,r];let s=o.length,u=s,c,f,d=FV;for(;u--;)c=o[u],f=d.get(c),f===void 0&&d.set(c,f=u?new Map:LV(t)),d=f;return f};Q2();const eS={http:eV,xhr:$V,fetch:{get:Q2}};ye.forEach(eS,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const cO=e=>`- ${e}`,NV=e=>ye.isFunction(e)||e===null||e===!1;function jV(e,t){e=ye.isArray(e)?e:[e];const{length:r}=e;let n,i;const o={};for(let s=0;s<r;s++){n=e[s];let u;if(i=n,!NV(n)&&(i=eS[(u=String(n)).toLowerCase()],i===void 0))throw new ut(`Unknown adapter '${u}'`);if(i&&(ye.isFunction(i)||(i=i.get(t))))break;o[u||"#"+s]=i}if(!i){const s=Object.entries(o).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let u=r?s.length>1?`since :
|
|
528
528
|
`+s.map(cO).join(`
|
package/dist/rozenite.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@ledgerhq/device-management-kit-devtools-rozenite","version":"0.0.0-develop-
|
|
1
|
+
{"name":"@ledgerhq/device-management-kit-devtools-rozenite","version":"0.0.0-develop-20260422001917","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-
|
|
5
|
+
"@ledgerhq/device-management-kit-devtools-ui": "0.0.0-develop-20260422001917"
|
|
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-
|
|
18
|
+
"@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260422001917"
|
|
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-
|
|
30
|
+
"@ledgerhq/device-management-kit-devtools-core": "0.0.0-develop-20260422001917"
|
|
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-
|
|
39
|
+
"version": "0.0.0-develop-20260422001917",
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "rozenite build",
|
|
42
42
|
"dev": "rozenite dev"
|