@danidoble/webserial 4.4.6 → 4.4.7

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/pinpax.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-CR94n4kR.cjs"),s=require("./relay-E3NCcSjS.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:i=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:t=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:i,config_port:e,no_device:t,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
- `,this.#t(),c.Devices.add(this),this.getResponseAsString()}#t(){const i=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of i)this.serialRegisterAvailableListener(e)}set businessId(i){this.__pinpax__.businessId=i}get businessId(){return this.__pinpax__.businessId}set encryptionKey(i){this.__pinpax__.encryptionKey=i}get encryptionKey(){return this.__pinpax__.encryptionKey}set apiKey(i){this.__pinpax__.apiKey=i}get apiKey(){return this.__pinpax__.apiKey}set server(i){this.__pinpax__.server=i}get server(){return this.__pinpax__.server}serialMessage(i){let e=null;try{e=JSON.parse(i),e.request||(e.request=this.lastAction),e.name||(e.name=this.lastAction)}catch(t){console.error("Error parsing response",t,i),this.dispatch("serial:message",i);return}switch(e.response){case"INIT":this.dispatch("init",{name:"INIT",request:this.lastAction,status:"ok"}),this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="received");break;case"INITAPP":this.dispatch("init-app",{name:"INITAPP",request:this.lastAction,status:"started"}),this.__pinpax__.waiting.sale_init==="waiting"?this.__pinpax__.waiting.sale_init="received":this.#n().then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{name:"CONNECT",request:this.lastAction,status:"connected"}),this.#r().then(()=>{});break;case"LOGIN":e.name||(e.name="LOGIN"),this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="received"),this.dispatch("login",e);break;case"LASTVOUCHER":e.name||(e.name="LASTVOUCHER"),this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":e.name||(e.name="DEVICEINFO"),this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{name:"KEEPALIVE",request:this.lastAction,status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{name:"RESETAPP",request:this.lastAction,status:"accepted"});break;case"GETCONFIG":e.name||(e.name="GETCONFIG"),this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{name:"HIDEBUTTONS",request:this.lastAction,hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{name:"SHOWBUTTONS",request:this.lastAction,hidden:!1});break;case"PAYMENT_PROCESS":e.name||(e.name="PAYMENT_PROCESS"),this.dispatch("payment",{name:"PAYMENT_PROCESS",request:this.lastAction,status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{name:"INSERT_CARD",request:this.lastAction,status:"insert card"});break;case"CARD_DATA":e.name||(e.name="CARD_DATA"),this.dispatch("payment",{name:"CARD_DATA",request:this.lastAction,status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":e.name||(e.name="MERCHANT"),this.dispatch("payment",{request:this.lastAction,status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":e.name||(e.name="TRANSACTION_RESULT"),this.#o({status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":e.name||(e.name="ERROR"),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:e}),this.dispatch("payment",{name:"ERROR",request:this.lastAction,status:"error",response:e});break;case"REFUND":this.dispatch("refund",{name:"ERROR",request:this.lastAction,status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){return s.s.connection()}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(i={}){if(typeof i!="object")throw new Error("Invalid object");if(i.constructor!==Object)throw new Error("Invalid object");if(Object.keys(i).length===0)throw new Error("Empty object");if(i.action===void 0||i.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(i),t=this.parseStringToBytes(e,`\r
3
- `);await this.appendToQueue(this.stringArrayToUint8Array(t),"custom")}async connectMessage(){await this.appendToQueue(s.s.connect(),"connect:message")}async#e(){if(this.isDisconnected)throw new Error("Device is disconnected");return this.queue.length===0?!0:new Promise(i=>{const e=setInterval(()=>{this.queue.length===0&&(clearInterval(e),i(!0))},500)})}async#i({type:i="production"}={}){const e=s.s.readQR({type:i});return await this.appendToQueue(e,"read-qr")}async#s(){await this.appendToQueue(s.s.forceHide(),"force-hide")}async#a(){await this.appendToQueue(s.s.forceShow(),"force-show")}async#n(){await this.connectMessage()}async#r(){await this.hideButtons()}#o(i){this.dispatch("payment",i),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=i)}cancelSaleRequestInProcess(){this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:{}})}async#c(){return new Promise((i,e)=>{const t=setTimeout(()=>{this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="timeout",e(new Error("Login timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_login==="received"&&(clearTimeout(t),clearInterval(a),i(!0))},100)})}async#p(){return new Promise((i,e)=>{const t=setTimeout(()=>{this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="timeout",e(new Error("Init timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_init==="received"&&(clearTimeout(t),clearInterval(a),i(!0))},100)})}async makeSale({amount:i=0,reference:e=null}={amount:0,reference:null}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const t=s.s.makeSale({amount:i,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await this.#e();let a=!1;try{this.__pinpax__.waiting.sale_login="waiting",await this.login(),await this.#c(),this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="waiting",await this.init(),await this.#p(),this.__pinpax__.waiting.sale_init="idle"}catch(n){a=!0,this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="idle",this.__pinpax__.waiting.sale=!1,this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:"Error during login/init before sale",error:n})}return a?!1:(await this.appendToQueue(t,"make-sale"),new Promise(n=>{const r=setInterval(()=>{if(this.__pinpax__.asyncResponses.sale){const o=this.__pinpax__.asyncResponses.sale;this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.waiting.sale=!1,clearInterval(r),n(o.approved)}},100)}))}async getVoucher({folio:i=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!i)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=s.s.getVoucher({folio:i});return this.queue.length>0&&await this.#e(),await this.appendToQueue(e,"get-voucher"),new Promise((t,a)=>{const n=setTimeout(()=>{this.__pinpax__.waiting.voucher=!1,a("Timeout")},1e4),r=setInterval(()=>{if(this.__pinpax__.asyncResponses.voucher){const o=this.__pinpax__.asyncResponses.voucher;this.__pinpax__.asyncResponses.voucher=null,this.__pinpax__.waiting.voucher=!1,clearInterval(r),clearTimeout(n),t(o.voucher)}},100)})}async info(){await this.appendToQueue(s.s.info(),"info")}async keepAlive(){await this.appendToQueue(s.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(s.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(s.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(s.s.hideButtons(),"hide-buttons"),await this.#s()}async showButtons(){return await this.appendToQueue(s.s.showButtons(),"show-buttons"),await this.#a()}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(s.s.demo(),"demo")}async refund({amount:i=0,folio:e=null,auth:t=null}={}){return await this.appendToQueue(s.s.refund({amount:i,folio:e,auth:t}),"refund")}async readProductionQR(){return await this.#i({type:"production"})}async readQualityAssuranceQR(){return this.#i({type:"QA"})}async exit(){return await this.appendToQueue(s.s.exit(),"exit-app")}async init(){await this.appendToQueue(s.s.init(),"init-app")}async login(){if(!this.apiKey||!this.businessId||!this.encryptionKey||!this.server)throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");const i=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,business_id:this.__pinpax__.businessId,encryption_key:this.__pinpax__.encryptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(i,`\r
4
- `);await this.appendToQueue(e,"login")}}exports.PinPax=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-Di_61btz.cjs"),i=require("./relay-BG7CetDU.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:t=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:s=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:t,config_port:e,no_device:s,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
+ `,this.#i(),c.Devices.add(this),this.getResponseAsString()}#i(){const t=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of t)this.serialRegisterAvailableListener(e)}set businessId(t){this.__pinpax__.businessId=t}get businessId(){return this.__pinpax__.businessId}set encryptionKey(t){this.__pinpax__.encryptionKey=t}get encryptionKey(){return this.__pinpax__.encryptionKey}set apiKey(t){this.__pinpax__.apiKey=t}get apiKey(){return this.__pinpax__.apiKey}set server(t){this.__pinpax__.server=t}get server(){return this.__pinpax__.server}serialMessage(t){let e=null;try{e=JSON.parse(t),e.request||(e.request=this.lastAction),e.name||(e.name=this.lastAction)}catch(s){console.error("Error parsing response",s,t),this.dispatch("serial:message",t);return}switch(e.response){case"INIT":this.dispatch("init",{name:"INIT",request:this.lastAction,status:"ok"}),this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="received");break;case"INITAPP":this.dispatch("init-app",{name:"INITAPP",request:this.lastAction,status:"started"}),this.__pinpax__.waiting.sale_init==="waiting"?this.__pinpax__.waiting.sale_init="received":this.#n().then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{name:"CONNECT",request:this.lastAction,status:"connected"}),this.#r().then(()=>{});break;case"LOGIN":e.name||(e.name="LOGIN"),this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="received"),this.dispatch("login",e);break;case"LASTVOUCHER":e.name||(e.name="LASTVOUCHER"),this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":e.name||(e.name="DEVICEINFO"),this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{name:"KEEPALIVE",request:this.lastAction,status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{name:"RESETAPP",request:this.lastAction,status:"accepted"});break;case"GETCONFIG":e.name||(e.name="GETCONFIG"),this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{name:"HIDEBUTTONS",request:this.lastAction,hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{name:"SHOWBUTTONS",request:this.lastAction,hidden:!1});break;case"PAYMENT_PROCESS":e.name||(e.name="PAYMENT_PROCESS"),this.dispatch("payment",{name:"PAYMENT_PROCESS",request:this.lastAction,status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{name:"INSERT_CARD",request:this.lastAction,status:"insert card"});break;case"CARD_DATA":e.name||(e.name="CARD_DATA"),this.dispatch("payment",{name:"CARD_DATA",request:this.lastAction,status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":e.name||(e.name="MERCHANT"),this.dispatch("payment",{request:this.lastAction,status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":e.name||(e.name="TRANSACTION_RESULT"),this.#o({status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":e.name||(e.name="ERROR"),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:e}),this.dispatch("payment",{name:"ERROR",request:this.lastAction,status:"error",response:e});break;case"CHECKINTERNET":this.dispatch("network",{name:"CHECKINTERNET",request:this.lastAction,hasInternet:e.internet,quality:e.quality});break;case"REFUND":this.dispatch("refund",{name:"ERROR",request:this.lastAction,status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){return i.s.connection()}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(t={}){if(typeof t!="object")throw new Error("Invalid object");if(t.constructor!==Object)throw new Error("Invalid object");if(Object.keys(t).length===0)throw new Error("Empty object");if(t.action===void 0||t.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(t),s=this.parseStringToBytes(e,`\r
3
+ `);await this.appendToQueue(this.stringArrayToUint8Array(s),"custom")}async connectMessage(){await this.appendToQueue(i.s.connect(),"connect:message")}async#e(){if(this.isDisconnected)throw new Error("Device is disconnected");return this.queue.length===0?!0:new Promise(t=>{const e=setInterval(()=>{this.queue.length===0&&(clearInterval(e),t(!0))},500)})}async#t({type:t="production"}={}){const e=i.s.readQR({type:t});return await this.appendToQueue(e,"read-qr")}async#s(){await this.appendToQueue(i.s.forceHide(),"force-hide")}async#a(){await this.appendToQueue(i.s.forceShow(),"force-show")}async#n(){await this.connectMessage()}async#r(){await this.hideButtons()}#o(t){this.dispatch("payment",t),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=t)}cancelSaleRequestInProcess(){this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:{}})}async#c(){return new Promise((t,e)=>{const s=setTimeout(()=>{this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="timeout",e(new Error("Login timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_login==="received"&&(clearTimeout(s),clearInterval(a),t(!0))},100)})}async#p(){return new Promise((t,e)=>{const s=setTimeout(()=>{this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="timeout",e(new Error("Init timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_init==="received"&&(clearTimeout(s),clearInterval(a),t(!0))},100)})}async makeSale({amount:t=0,reference:e=null}={amount:0,reference:null}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const s=i.s.makeSale({amount:t,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await this.#e();let a=!1;try{this.__pinpax__.waiting.sale_login="waiting",await this.login(),await this.#c(),this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="waiting",await this.init(),await this.#p(),this.__pinpax__.waiting.sale_init="idle"}catch(n){a=!0,this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="idle",this.__pinpax__.waiting.sale=!1,this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:"Error during login/init before sale",error:n})}return a?!1:(await this.appendToQueue(s,"make-sale"),new Promise(n=>{const r=setInterval(()=>{if(this.__pinpax__.asyncResponses.sale){const o=this.__pinpax__.asyncResponses.sale;this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.waiting.sale=!1,clearInterval(r),n(o.approved)}},100)}))}async getVoucher({folio:t=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!t)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=i.s.getVoucher({folio:t});return this.queue.length>0&&await this.#e(),await this.appendToQueue(e,"get-voucher"),new Promise((s,a)=>{const n=setTimeout(()=>{this.__pinpax__.waiting.voucher=!1,a("Timeout")},1e4),r=setInterval(()=>{if(this.__pinpax__.asyncResponses.voucher){const o=this.__pinpax__.asyncResponses.voucher;this.__pinpax__.asyncResponses.voucher=null,this.__pinpax__.waiting.voucher=!1,clearInterval(r),clearTimeout(n),s(o.voucher)}},100)})}async info(){await this.appendToQueue(i.s.info(),"info")}async keepAlive(){await this.appendToQueue(i.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(i.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(i.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(i.s.hideButtons(),"hide-buttons"),await this.#s()}async showButtons(){return await this.appendToQueue(i.s.showButtons(),"show-buttons"),await this.#a()}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(i.s.demo(),"demo")}async refund({amount:t=0,folio:e=null,auth:s=null}={}){return await this.appendToQueue(i.s.refund({amount:t,folio:e,auth:s}),"refund")}async readProductionQR(){return await this.#t({type:"production"})}async readQualityAssuranceQR(){return this.#t({type:"QA"})}async exit(){return await this.appendToQueue(i.s.exit(),"exit-app")}async init(){await this.appendToQueue(i.s.init(),"init-app")}async login(){if(!this.apiKey||!this.businessId||!this.encryptionKey||!this.server)throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");const t=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,business_id:this.__pinpax__.businessId,encryption_key:this.__pinpax__.encryptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(t,`\r
4
+ `);await this.appendToQueue(e,"login")}async stop(){await this.appendToQueue(i.s.stop(),"stop")}async verifyNetwork(){await this.appendToQueue(i.s.verifyNetwork(),"verify-network")}}exports.PinPax=p;
package/dist/pinpax.js CHANGED
@@ -1,5 +1,5 @@
1
- import { K as p, D as c } from "./kernel-BfYgLcpB.js";
2
- import { s } from "./relay-DP8PLsDP.js";
1
+ import { K as p, D as c } from "./kernel-Cm9N-fc9.js";
2
+ import { s as i } from "./relay-C71zVBZv.js";
3
3
  class l extends p {
4
4
  __pinpax__ = {
5
5
  server: "DEV",
@@ -18,7 +18,7 @@ class l extends p {
18
18
  }
19
19
  };
20
20
  constructor({
21
- filters: i = null,
21
+ filters: t = null,
22
22
  config_port: e = {
23
23
  baudRate: 115200,
24
24
  dataBits: 8,
@@ -27,7 +27,7 @@ class l extends p {
27
27
  bufferSize: 32768,
28
28
  flowControl: "none"
29
29
  },
30
- no_device: t = 1,
30
+ no_device: s = 1,
31
31
  device_listen_on_channel: a = 1,
32
32
  socket: n = !1
33
33
  } = {
@@ -44,13 +44,13 @@ class l extends p {
44
44
  device_listen_on_channel: 1,
45
45
  socket: !1
46
46
  }) {
47
- if (super({ filters: i, config_port: e, no_device: t, device_listen_on_channel: a, socket: n }), this.__internal__.device.type = "pinpax", c.getCustom(this.typeDevice, t))
48
- throw new Error(`Device ${this.typeDevice} ${t} already exists`);
47
+ if (super({ filters: t, config_port: e, no_device: s, device_listen_on_channel: a, socket: n }), this.__internal__.device.type = "pinpax", c.getCustom(this.typeDevice, s))
48
+ throw new Error(`Device ${this.typeDevice} ${s} already exists`);
49
49
  this.__internal__.time.response_connection = 4e3, this.__internal__.time.response_general = 3e3, this.__internal__.serial.delay_first_connection = 1e3, this.__internal__.serial.response.replacer = "", this.__internal__.serial.response.limiter = `\r
50
- `, this.#t(), c.add(this), this.getResponseAsString();
50
+ `, this.#i(), c.add(this), this.getResponseAsString();
51
51
  }
52
- #t() {
53
- const i = [
52
+ #i() {
53
+ const t = [
54
54
  "buttons-status",
55
55
  "init-app",
56
56
  "connectMessage",
@@ -64,39 +64,39 @@ class l extends p {
64
64
  "refund",
65
65
  "login"
66
66
  ];
67
- for (const e of i)
67
+ for (const e of t)
68
68
  this.serialRegisterAvailableListener(e);
69
69
  }
70
- set businessId(i) {
71
- this.__pinpax__.businessId = i;
70
+ set businessId(t) {
71
+ this.__pinpax__.businessId = t;
72
72
  }
73
73
  get businessId() {
74
74
  return this.__pinpax__.businessId;
75
75
  }
76
- set encryptionKey(i) {
77
- this.__pinpax__.encryptionKey = i;
76
+ set encryptionKey(t) {
77
+ this.__pinpax__.encryptionKey = t;
78
78
  }
79
79
  get encryptionKey() {
80
80
  return this.__pinpax__.encryptionKey;
81
81
  }
82
- set apiKey(i) {
83
- this.__pinpax__.apiKey = i;
82
+ set apiKey(t) {
83
+ this.__pinpax__.apiKey = t;
84
84
  }
85
85
  get apiKey() {
86
86
  return this.__pinpax__.apiKey;
87
87
  }
88
- set server(i) {
89
- this.__pinpax__.server = i;
88
+ set server(t) {
89
+ this.__pinpax__.server = t;
90
90
  }
91
91
  get server() {
92
92
  return this.__pinpax__.server;
93
93
  }
94
- serialMessage(i) {
94
+ serialMessage(t) {
95
95
  let e = null;
96
96
  try {
97
- e = JSON.parse(i), e.request || (e.request = this.lastAction), e.name || (e.name = this.lastAction);
98
- } catch (t) {
99
- console.error("Error parsing response", t, i), this.dispatch("serial:message", i);
97
+ e = JSON.parse(t), e.request || (e.request = this.lastAction), e.name || (e.name = this.lastAction);
98
+ } catch (s) {
99
+ console.error("Error parsing response", s, t), this.dispatch("serial:message", t);
100
100
  return;
101
101
  }
102
102
  switch (e.response) {
@@ -220,6 +220,14 @@ class l extends p {
220
220
  response: e
221
221
  }), this.dispatch("error", { name: "ERROR", request: this.lastAction, status: "error", response: e }), this.dispatch("payment", { name: "ERROR", request: this.lastAction, status: "error", response: e });
222
222
  break;
223
+ case "CHECKINTERNET":
224
+ this.dispatch("network", {
225
+ name: "CHECKINTERNET",
226
+ request: this.lastAction,
227
+ hasInternet: e.internet,
228
+ quality: e.quality
229
+ });
230
+ break;
223
231
  case "REFUND":
224
232
  this.dispatch("refund", { name: "ERROR", request: this.lastAction, status: "refund", response: e });
225
233
  break;
@@ -227,40 +235,40 @@ class l extends p {
227
235
  this.dispatch("serial:message", e);
228
236
  }
229
237
  serialSetConnectionConstant() {
230
- return s.connection();
238
+ return i.connection();
231
239
  }
232
240
  softReload() {
233
241
  super.softReload(), this.__pinpax__.waiting.sale = !1, this.__pinpax__.waiting.voucher = !1, this.__pinpax__.asyncResponses.sale = null, this.__pinpax__.asyncResponses.voucher = null;
234
242
  }
235
- async sendCustomCode(i = {}) {
236
- if (typeof i != "object") throw new Error("Invalid object");
237
- if (i.constructor !== Object) throw new Error("Invalid object");
238
- if (Object.keys(i).length === 0) throw new Error("Empty object");
239
- if (i.action === void 0 || i.action === null) throw new Error("Invalid object add action");
240
- const e = JSON.stringify(i), t = this.parseStringToBytes(e, `\r
243
+ async sendCustomCode(t = {}) {
244
+ if (typeof t != "object") throw new Error("Invalid object");
245
+ if (t.constructor !== Object) throw new Error("Invalid object");
246
+ if (Object.keys(t).length === 0) throw new Error("Empty object");
247
+ if (t.action === void 0 || t.action === null) throw new Error("Invalid object add action");
248
+ const e = JSON.stringify(t), s = this.parseStringToBytes(e, `\r
241
249
  `);
242
- await this.appendToQueue(this.stringArrayToUint8Array(t), "custom");
250
+ await this.appendToQueue(this.stringArrayToUint8Array(s), "custom");
243
251
  }
244
252
  async connectMessage() {
245
- await this.appendToQueue(s.connect(), "connect:message");
253
+ await this.appendToQueue(i.connect(), "connect:message");
246
254
  }
247
255
  async #e() {
248
256
  if (this.isDisconnected) throw new Error("Device is disconnected");
249
- return this.queue.length === 0 ? !0 : new Promise((i) => {
257
+ return this.queue.length === 0 ? !0 : new Promise((t) => {
250
258
  const e = setInterval(() => {
251
- this.queue.length === 0 && (clearInterval(e), i(!0));
259
+ this.queue.length === 0 && (clearInterval(e), t(!0));
252
260
  }, 500);
253
261
  });
254
262
  }
255
- async #i({ type: i = "production" } = {}) {
256
- const e = s.readQR({ type: i });
263
+ async #t({ type: t = "production" } = {}) {
264
+ const e = i.readQR({ type: t });
257
265
  return await this.appendToQueue(e, "read-qr");
258
266
  }
259
267
  async #s() {
260
- await this.appendToQueue(s.forceHide(), "force-hide");
268
+ await this.appendToQueue(i.forceHide(), "force-hide");
261
269
  }
262
270
  async #a() {
263
- await this.appendToQueue(s.forceShow(), "force-show");
271
+ await this.appendToQueue(i.forceShow(), "force-show");
264
272
  }
265
273
  async #n() {
266
274
  await this.connectMessage();
@@ -268,8 +276,8 @@ class l extends p {
268
276
  async #r() {
269
277
  await this.hideButtons();
270
278
  }
271
- #o(i) {
272
- this.dispatch("payment", i), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = i);
279
+ #o(t) {
280
+ this.dispatch("payment", t), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = t);
273
281
  }
274
282
  cancelSaleRequestInProcess() {
275
283
  this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = {
@@ -279,25 +287,25 @@ class l extends p {
279
287
  });
280
288
  }
281
289
  async #c() {
282
- return new Promise((i, e) => {
283
- const t = setTimeout(() => {
290
+ return new Promise((t, e) => {
291
+ const s = setTimeout(() => {
284
292
  this.__pinpax__.waiting.sale_login === "waiting" && (this.__pinpax__.waiting.sale_login = "timeout", e(new Error("Login timeout")));
285
293
  }, 1e4), a = setInterval(() => {
286
- this.__pinpax__.waiting.sale_login === "received" && (clearTimeout(t), clearInterval(a), i(!0));
294
+ this.__pinpax__.waiting.sale_login === "received" && (clearTimeout(s), clearInterval(a), t(!0));
287
295
  }, 100);
288
296
  });
289
297
  }
290
298
  async #p() {
291
- return new Promise((i, e) => {
292
- const t = setTimeout(() => {
299
+ return new Promise((t, e) => {
300
+ const s = setTimeout(() => {
293
301
  this.__pinpax__.waiting.sale_init === "waiting" && (this.__pinpax__.waiting.sale_init = "timeout", e(new Error("Init timeout")));
294
302
  }, 1e4), a = setInterval(() => {
295
- this.__pinpax__.waiting.sale_init === "received" && (clearTimeout(t), clearInterval(a), i(!0));
303
+ this.__pinpax__.waiting.sale_init === "received" && (clearTimeout(s), clearInterval(a), t(!0));
296
304
  }, 100);
297
305
  });
298
306
  }
299
307
  async makeSale({
300
- amount: i = 0,
308
+ amount: t = 0,
301
309
  reference: e = null
302
310
  } = {
303
311
  amount: 0,
@@ -305,7 +313,7 @@ class l extends p {
305
313
  }) {
306
314
  if (this.isDisconnected) throw new Error("Device is disconnected");
307
315
  if (this.__pinpax__.waiting.sale) throw new Error("Already waiting for sale response");
308
- const t = s.makeSale({ amount: i, reference: e });
316
+ const s = i.makeSale({ amount: t, reference: e });
309
317
  this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await this.#e();
310
318
  let a = !1;
311
319
  try {
@@ -319,7 +327,7 @@ class l extends p {
319
327
  error: n
320
328
  });
321
329
  }
322
- return a ? !1 : (await this.appendToQueue(t, "make-sale"), new Promise((n) => {
330
+ return a ? !1 : (await this.appendToQueue(s, "make-sale"), new Promise((n) => {
323
331
  const r = setInterval(() => {
324
332
  if (this.__pinpax__.asyncResponses.sale) {
325
333
  const o = this.__pinpax__.asyncResponses.sale;
@@ -328,79 +336,85 @@ class l extends p {
328
336
  }, 100);
329
337
  }));
330
338
  }
331
- async getVoucher({ folio: i = null } = {}) {
339
+ async getVoucher({ folio: t = null } = {}) {
332
340
  if (this.isDisconnected) throw new Error("Device is disconnected");
333
341
  if (this.__pinpax__.waiting.voucher) throw new Error("Already waiting for voucher");
334
- if (!i) throw new Error("Folio is required");
342
+ if (!t) throw new Error("Folio is required");
335
343
  this.__pinpax__.waiting.voucher = !0, this.__pinpax__.asyncResponses.voucher = null;
336
- const e = s.getVoucher({ folio: i });
337
- return this.queue.length > 0 && await this.#e(), await this.appendToQueue(e, "get-voucher"), new Promise((t, a) => {
344
+ const e = i.getVoucher({ folio: t });
345
+ return this.queue.length > 0 && await this.#e(), await this.appendToQueue(e, "get-voucher"), new Promise((s, a) => {
338
346
  const n = setTimeout(() => {
339
347
  this.__pinpax__.waiting.voucher = !1, a("Timeout");
340
348
  }, 1e4), r = setInterval(() => {
341
349
  if (this.__pinpax__.asyncResponses.voucher) {
342
350
  const o = this.__pinpax__.asyncResponses.voucher;
343
- this.__pinpax__.asyncResponses.voucher = null, this.__pinpax__.waiting.voucher = !1, clearInterval(r), clearTimeout(n), t(o.voucher);
351
+ this.__pinpax__.asyncResponses.voucher = null, this.__pinpax__.waiting.voucher = !1, clearInterval(r), clearTimeout(n), s(o.voucher);
344
352
  }
345
353
  }, 100);
346
354
  });
347
355
  }
348
356
  async info() {
349
- await this.appendToQueue(s.info(), "info");
357
+ await this.appendToQueue(i.info(), "info");
350
358
  }
351
359
  async keepAlive() {
352
- await this.appendToQueue(s.keepAlive(), "keep-alive");
360
+ await this.appendToQueue(i.keepAlive(), "keep-alive");
353
361
  }
354
362
  async restartApp() {
355
- await this.appendToQueue(s.restartApp(), "reset-app");
363
+ await this.appendToQueue(i.restartApp(), "reset-app");
356
364
  }
357
365
  async getConfig() {
358
- return await this.appendToQueue(s.getConfig(), "get-config");
366
+ return await this.appendToQueue(i.getConfig(), "get-config");
359
367
  }
360
368
  async hideButtons() {
361
- return await this.appendToQueue(s.hideButtons(), "hide-buttons"), await this.#s();
369
+ return await this.appendToQueue(i.hideButtons(), "hide-buttons"), await this.#s();
362
370
  }
363
371
  async showButtons() {
364
- return await this.appendToQueue(s.showButtons(), "show-buttons"), await this.#a();
372
+ return await this.appendToQueue(i.showButtons(), "show-buttons"), await this.#a();
365
373
  }
366
374
  async demo() {
367
- return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(s.demo(), "demo");
375
+ return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(i.demo(), "demo");
368
376
  }
369
- async refund({ amount: i = 0, folio: e = null, auth: t = null } = {}) {
377
+ async refund({ amount: t = 0, folio: e = null, auth: s = null } = {}) {
370
378
  return await this.appendToQueue(
371
- s.refund({
372
- amount: i,
379
+ i.refund({
380
+ amount: t,
373
381
  folio: e,
374
- auth: t
382
+ auth: s
375
383
  }),
376
384
  "refund"
377
385
  );
378
386
  }
379
387
  async readProductionQR() {
380
- return await this.#i({ type: "production" });
388
+ return await this.#t({ type: "production" });
381
389
  }
382
390
  async readQualityAssuranceQR() {
383
- return this.#i({ type: "QA" });
391
+ return this.#t({ type: "QA" });
384
392
  }
385
393
  async exit() {
386
- return await this.appendToQueue(s.exit(), "exit-app");
394
+ return await this.appendToQueue(i.exit(), "exit-app");
387
395
  }
388
396
  async init() {
389
- await this.appendToQueue(s.init(), "init-app");
397
+ await this.appendToQueue(i.init(), "init-app");
390
398
  }
391
399
  async login() {
392
400
  if (!this.apiKey || !this.businessId || !this.encryptionKey || !this.server)
393
401
  throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");
394
- const i = JSON.stringify({
402
+ const t = JSON.stringify({
395
403
  action: "LOGIN_MIT",
396
404
  server: this.__pinpax__.server,
397
405
  business_id: this.__pinpax__.businessId,
398
406
  encryption_key: this.__pinpax__.encryptionKey,
399
407
  api_key: this.__pinpax__.apiKey
400
- }), e = this.parseStringToBytes(i, `\r
408
+ }), e = this.parseStringToBytes(t, `\r
401
409
  `);
402
410
  await this.appendToQueue(e, "login");
403
411
  }
412
+ async stop() {
413
+ await this.appendToQueue(i.stop(), "stop");
414
+ }
415
+ async verifyNetwork() {
416
+ await this.appendToQueue(i.verifyNetwork(), "verify-network");
417
+ }
404
418
  }
405
419
  export {
406
420
  l as PinPax
@@ -1,3 +1,3 @@
1
- "use strict";const g=i=>{if(i instanceof Uint8Array)return i;if(Array.isArray(i))return new Uint8Array(i);if(typeof i=="string")return new TextEncoder().encode(i);if(i instanceof ArrayBuffer)return new Uint8Array(i);throw new Error("Unsupported data type")},P=({data:i,asString:e=!0})=>e?Array.from(i).map(n=>n.toString(16).padStart(2,"0")).join(" "):Array.from(i).map(n=>n.toString(16).padStart(2,"0"));var F=Object.defineProperty,L=(i,e,n)=>e in i?F(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,D=(i,e,n)=>L(i,typeof e!="symbol"?e+"":e,n);const f=class d{build(e){return g(e+d.append)}static connection(){return d.instance.build("CONNECT")}static connect(){return d.connection()}static credits(){return d.instance.build("CREDITS")}static hi(){return d.instance.build("HI")}static ara(){return d.instance.build("ARA")}static custom(e){return d.instance.build(e)}};D(f,"append",`
2
- `),D(f,"instance");let T=f;T.instance=new T;var H=Object.defineProperty,B=(i,e,n)=>e in i?H(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,$=(i,e,n)=>B(i,typeof e!="symbol"?e+"":e,n);const b=class c{build(e){return c.asHex?P({data:e,asString:!1}):g(e)}serialBoardroidSumHex(e){let n=0;for(let a=0;a<e.length;a++)a===0||a===11||(n+=e[a]);return n}boardroidCheckSum(e){return e[11]=this.serialBoardroidSumHex(e),e}static connection({channel:e=1}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,5+e,0,0,0,0,0,0,0,0,242,248]));return c.instance.build(n)}static coinPurseConfiguration({enable:e=!1,high:n=255,low:a=255}={}){const t=c.instance.boardroidCheckSum(new Uint8Array([241,193,e?1:0,n,a,0,0,0,0,0,242,0]));return c.instance.build(t)}static coinPurseDispense({$50c:e=0,$1:n=0,$2:a=0,$5:t=0,$10:s=0}={}){if([e,n,a,t,s].some(u=>isNaN(u)||typeof u=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&a<1&&t<1&&s<1)throw new Error("No coins to dispense");const o=c.instance.boardroidCheckSum(new Uint8Array([241,198,e,n,a,t,s,0,0,0,242,0]));return c.instance.build(o)}static coinPurseReadTubes(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,194,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseICTConfigure({enable:e=!1,scrow:n=!1}={}){const a=e?255:0,t=n?255:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,a,a,t,t,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseOtherConfigure({enable:e=!1,scrow:n=!1}={}){const a=e?1:0,t=n?1:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,a,t,0,0,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseICTDispense({quantity:e=1,denomination:n=20}){if(e<1)throw new Error("No banknotes to dispense");if([20,50,100,200,500].indexOf(n)===-1)throw new Error("Invalid denomination");const a=[20,50,100,200,500].indexOf(n),t=c.instance.boardroidCheckSum(new Uint8Array([241,197,a,e,0,0,0,0,0,0,242,0]));return c.instance.build(t)}static banknotePurseOtherDispense({$20:e=0,$50:n=0,$100:a=0,$200:t=0,$500:s=0,$1000:o=0}={}){if([e,n,a,t,s,o].some(m=>isNaN(m)||typeof m=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&a<1&&t<1&&s<1&&o<1)throw new Error("No banknotes to dispense");const u=c.instance.boardroidCheckSum(new Uint8Array([241,197,e,n,a,t,s,o,0,0,242,0]));return c.instance.build(u)}static banknotePurseAcceptInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,1,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseRejectInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseSaveMemory({channel:e=null,$20:n=null,$50:a=null,$100:t=null,$200:s=null,$500:o=null,$1000:u=null}={channel:null,$20:null,$50:null,$100:null,$200:null,$500:null,$1000:null}){if(e===null||n===null||a===null||t===null||s===null||o===null||u===null)throw new Error("One of the values is not defined: "+JSON.stringify({channel:e,$20:n,$50:a,$100:t,$200:s,$500:o,$1000:u}));const m=c.instance.boardroidCheckSum(new Uint8Array([241,200,e,0,n,a,t,s,o,u,242,0]));return c.instance.build(m)}static banknotePurseReadRecycler(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,195,0,0,0,0,0,0,0,0,242,181]));return c.instance.build(e)}static cardReaderDisable(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,205,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static cardReaderDispense({selection:e=1,second_selection:n=null,sensor:a=!0,seconds:t=null,price:s=0}={selection:1,second_selection:null,sensor:!0,seconds:null,price:0}){const o=s/256,u=s%256,m=e+9;let p=0;n&&(p=n+9);let A=0;a||(t||(t=1.5),A=Math.round(t*6.2));const M=c.instance.boardroidCheckSum(new Uint8Array([241,205,1,m,p,A,o,u,0,0,242,0]));return c.instance.build(M)}static coolingRelayConfigure({enable:e=!0}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,204,e?1:0,0,0,0,0,0,0,0,242,0]));return c.instance.build(n)}static readTemperature(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,203,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static dispense({selection:e=1,second_selection:n=null,sensor:a=!0,seconds:t=null}={selection:1,second_selection:null,sensor:!0,seconds:null}){e+=9;const s=e;let o=0;n&&(n+=9,o=n);let u=0;a||(t||(t=1.5),u=Math.round(t*6.2));const m=c.instance.boardroidCheckSum(new Uint8Array([241,199,s,o,u,0,0,0,0,0,242,0]));return c.instance.build(m)}static customCode(e){typeof e[0]=="string"&&(e=e.map(a=>parseInt(a,16)));const n=c.instance.boardroidCheckSum(new Uint8Array(e));return c.instance.build(n)}};$(b,"asHex",!1),$(b,"instance");let w=b;w.instance=new w;var J=Object.defineProperty,G=(i,e,n)=>e in i?J(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,O=(i,e,n)=>G(i,typeof e!="symbol"?e+"":e,n);const y=class r{build(e){const n=this.jofemarCheckSum(e);return r.asHex?P({data:new Uint8Array(n),asString:!1}):g(n)}calcCheckSums(e){const n=[];return n.push(e&255|240),n.push(e&255|15),n}jofemarCheckSum(e){let n=0;for(let t=0;t<e.length;t++)n+=e[t];const a=this.calcCheckSums(n);return e.push(a[0]),e.push(a[1]),e.push(3),new Uint8Array(e)}getTrayAndChannelBySelection(e){if(e=parseInt(e)+109,e=e.toString(),e.length!==3)throw new Error("Invalid selection");const n=(parseInt(e.substring(0,2))+128).toString(16).padStart(2,"0"),a=(parseInt(e.substring(2,3))+128).toString(16).padStart(2,"0");return{channel:parseInt(a,16),tray:parseInt(n,16)}}makeDisplayMessage(e=""){e=e.padEnd(32," ");const n=[];for(let a=0;a<32;a++)n.push(e.charCodeAt(a));return n}makeTimeFormat(e){if(!(e instanceof Date))throw new Error("Invalid date, must be an instance of Date");const n=e.getHours().toString().padStart(2,"0"),a=e.getMinutes().toString().padStart(2,"0"),t=e.getDate().toString().padStart(2,"0"),s=(e.getMonth()+1).toString().padStart(2,"0"),o=e.getFullYear().toString().substring(2,4),u=`${n}:${a} ${t}-${s}-${o}`,m=[];for(let p=0;p<14;p++)m.push(u.charCodeAt(p));return m}static connection({channel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static dispense({machineChannel:e=1,selection:n=1,cart:a=!1}={machineChannel:1,selection:1,cart:!1}){if(n=parseInt(n),isNaN(n)||n<1||n>130)throw new Error("Invalid selection");const{channel:t,tray:s}=r.instance.getTrayAndChannelBySelection(n);return r.instance.build([2,48,48,128+e,a?77:86,s,t])}static endCartDispense({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,77,128,128])}static collect({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,78,255,255])}static reset({machineChannel:e=1,type:n="soldOut"}={}){let a=128;return n==="waiting"?a=129:n==="machine"&&(a=255),r.instance.build([2,48,48,128+e,82,a,255])}static status({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static lights({machineChannel:e=1,type:n="on"}={}){const a=n==="on"?129:128;return r.instance.build([2,48,48,128+e,76,a,255])}static program({machineChannel:e=1,param1:n=255,param2:a=255}={}){return r.instance.build([2,48,48,128+e,80,n,a])}static programDisplayLanguage({machineChannel:e=1,language:n="spanish"}={}){const a={spanish:48,english:49,french:50};if(!a[n])throw new Error("Invalid language");return r.program({machineChannel:e,param1:73,param2:a[n]})}static programBeeper({machineChannel:e=1,enable:n=!0}){return r.program({machineChannel:e,param1:90,param2:n?49:48})}static programDisableWorkingTemperature({machineChannel:e=1}){return r.program({machineChannel:e,param1:84,param2:128})}static programDisableThermometer({machineChannel:e=1}){return r.programDisableWorkingTemperature({machineChannel:e})}static programWorkingTemperature({machineChannel:e=1,degrees:n=.5,machineType:a="esplus"}={}){typeof n=="string"&&(n=parseFloat(n));const t=a==="iceplus"?6.5:32,s=a==="iceplus"?-25:.5;if(isNaN(n)||n<s||n>t||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let o=n*2+128;return a==="iceplus"&&(o+=51),o=Math.ceil(o),r.program({param1:84,param2:o,machineChannel:e})}static programIsolationTray({machineChannel:e=1,tray:n=0}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<0||n>12)throw new Error("Invalid tray, valid range is 0 to 12");const a=n===0?128:n+139;return r.program({param1:66,param2:a,machineChannel:e})}static programTimeToStandbyAfterCollect({machineChannel:e=1,seconds:n=15}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<15||n>120)throw new Error("Invalid seconds, valid range is 15 to 120");const a=128+n;return r.program({param1:70,param2:a,machineChannel:e})}static programTimeToStandbyWithoutCollect({machineChannel:e=1,minutes:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>10)throw new Error("Invalid minutes, valid range is 1 to 10");const a=128+n;return r.program({param1:72,param2:a,machineChannel:e})}static programElevatorSpeed({machineChannel:e=1,speed:n="high"}={}){const a={high:49,low:48};if(!a[n])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return r.program({param1:118,param2:a[n],machineChannel:e})}static programTemperatureExpiration({machineChannel:e=1,enable:n=!1}){return r.program({machineChannel:e,param1:99,param2:n?49:48})}static programMachineAddress({machineChannel:e=1,address:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>31)throw new Error("Invalid address, valid range is 1 to 31");return r.program({param1:100,param2:128+n,machineChannel:e})}static programTemperatureBeforeExpiration({machineChannel:e=1,degrees:n=.5}){if(typeof n=="string"&&(n=parseFloat(n)),isNaN(n)||n<.5||n>30||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const a=128+n*2;return r.program({param1:101,param2:a,machineChannel:e})}static programTimeBeforeExpirationByTemperature({machineChannel:e=1,minutes:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>120)throw new Error("Invalid minutes, valid range is 1 to 120");const a=128+n;return r.program({param1:102,param2:a,machineChannel:e})}static programTemperatureScale({machineChannel:e=1,scale:n="celsius"}={}){const a={celsius:67,fahrenheit:70};if(!a[n])throw new Error("Invalid scale, valid scales are 'celsius' and 'fahrenheit'");return r.program({param1:103,param2:a[n],machineChannel:e})}static programVoltageEngine({machineChannel:e=1,selection:n=1,voltage:a=5}={}){if(typeof a=="string"&&(a=parseFloat(a)),typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(a)||a<5||a>9.5||a%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const t=109+n,s=128+(a-5)*2;return r.instance.build([2,48,48,128+e,71,t,s])}static programPushOverProducts({machineChannel:e=1,selection:n=1,enable:a=!0}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");const t=109+n,s=a?49:48;return r.instance.build([2,48,48,128+e,79,t,s])}static programChannelRunningAfterDispense({machineChannel:e=1,selection:n=1,seconds:a=0}={}){if(typeof n=="string"&&(n=parseInt(n)),typeof a=="string"&&(a=parseFloat(a)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(a)||a<0||a>10||a%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const t=109+n;a=10*parseFloat(a.toFixed(1));const s=128+a;return r.instance.build([2,48,48,128+e,69,t,s])}static checkData({machineChannel:e=1,type:n=255,aux:a=255}){return r.instance.build([2,48,48,128+e,67,n,a])}static getDisplayLanguage({machineChannel:e=1}){return r.checkData({machineChannel:e,type:73})}static getBeeper({machineChannel:e=1}){return r.checkData({machineChannel:e,type:90})}static getWorkingTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:84})}static getIsolationTray({machineChannel:e=1}){return r.checkData({machineChannel:e,type:66})}static getProgramVersion({machineChannel:e=1}){return r.checkData({machineChannel:e,type:80})}static getFaults({machineChannel:e=1}){return r.checkData({machineChannel:e,type:83})}static getMachineId({machineChannel:e=1}){return r.checkData({machineChannel:e,type:78})}static getCurrentTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:116})}static getTimeToStandbyAfterCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:70})}static getTimeToStandbyWithoutCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:72})}static getElevatorSpeed({machineChannel:e=1}){return r.checkData({machineChannel:e,type:118})}static getTemperatureExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:99})}static getTemperatureBeforeExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:101})}static getTimeBeforeExpirationByTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:102})}static getTemperatureScale({machineChannel:e=1}){return r.checkData({machineChannel:e,type:103})}static getClockRegisters({machineChannel:e=1}){return r.checkData({machineChannel:e,type:114})}static getMachineActivity({machineChannel:e=1}){return r.checkData({machineChannel:e,type:65})}static getVoltageEngine({machineChannel:e=1,selection:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:71,aux:109+n})}static getChannelPresence({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:67,aux:109+n})}static getPushOverProducts({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:79,aux:109+n})}static getChannelRunningAfterDispense({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:69,aux:109+n})}static displayConfig({machineChannel:e=1,type:n=128,param2:a=[]}={}){return r.instance.build([2,48,48,128+e,68,n,...a])}static setDisplayStandbyMessage({machineChannel:e=1,message:n=""}={}){n=n.substring(0,32);const a=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:128,param2:a})}static setDisplayMessageTemporarily({machineChannel:e=1,message:n="",seconds:a=1}){if(n=n.substring(0,32),typeof a=="string"&&(a=parseInt(a)),isNaN(a)||a<1||a>125)throw new Error("Invalid seconds, valid range is 1 to 125");const t=r.instance.makeDisplayMessage(n),s=128+a;return r.displayConfig({machineChannel:e,type:s,param2:t})}static setDisplayMessageUnlimited({machineChannel:e=1,message:n=""}){n=n.substring(0,32);const a=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:255,param2:a})}static programClock({machineChannel:e=1,date:n=new Date}={}){if(!(n instanceof Date))throw new Error("Invalid date, must be an instance of Date");return r.instance.build([2,48,48,128+e,114,...r.instance.makeTimeFormat(n)])}static eventsConfig({machineChannel:e=1,event:n=null,enable:a=!0}={}){if(n===null)throw new Error("Invalid event");const t=a?49:48;return r.instance.build([2,48,48,128+e,65,n,t])}static eventEnable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const a=parseInt(n,16);if(isNaN(a)||a<38||a>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!0})}static eventDisable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const a=parseInt(n,16);if(isNaN(a)||a<38||a>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!1})}static sendCustomCode({code:e=[]}={}){if(e.length<5)throw new Error("Invalid code, minimum length is 5");return r.instance.build(e)}};O(y,"asHex",!1),O(y,"instance");let v=y;v.instance=new v;var j=Object.defineProperty,W=(i,e,n)=>e in i?j(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,U=(i,e,n)=>W(i,typeof e!="symbol"?e+"":e,n);const E=class h{serialLockerCmdMaker(e){let n;try{n=new Uint8Array(e.length+8),n.set(e,2),n[0]=2,n[1]=e.length+4,n[n.length-2]=3;let a=0;for(let o=1;o<e.length;o++)a+=e[o],a*=parseInt(Math.pow(2,o-1).toString());n[e.length+2]=a%256,n[e.length+3]=666*3%256,n[e.length+4]=666*8%256;let t=0;for(let o=3;o<e.length+5;o++)t+=n[o];n[e.length+5]=t%256;let s=0;for(let o=0;o<n.length-1;o++)s^=n[o];n[n.length-1]=s}catch(a){throw n=new Uint8Array(0),a instanceof Error?new Error(`Error generating command: ${a.message}`):new Error("Error generating command: Unknown error")}return n}serialLockerHexCmd(e){const n=this.serialLockerCmdMaker(e),a=[];for(let t=0;t<n.length;t++){const s=n[t].toString(16).padStart(2,"0");a.push(s)}return a}validateCell(e=1){let n;if(typeof e=="string"?n=parseInt(e):n=e,isNaN(n)||n<1||n>90)throw new Error("Invalid cell number");return n}serialLockerGetStatusCellCmd({cell:e=1,channel:n=1}={}){return e=this.validateCell(e),this.build(new Uint8Array([16,n,e]))}serialLockerGetLightScanCmd({since:e=0,until:n=10,channel:a=1}={}){return this.build(new Uint8Array([32,a,e,n]))}parseCellToColumnRow(e){const n=Math.floor((e-1)/10)+1;let a=e%8;return a===0&&(a=8),[n,a]}serialLockerGetConfigureCellCmd({enable:e=!0,column:n=0,row:a=10,channel:t=1}={}){if(n<0||n>8)throw new Error("Invalid column number");if(a<0||a>10)throw new Error("Invalid row number");let s=1;return e||(s=0),this.build(new Uint8Array([48,t,n,a,s]))}serialLockerGetOpenCmd({cell:e=1,channel:n=1}={}){e=this.validateCell(e);const a=666,t=a%256,s=Math.floor(a/3)%256;return this.build(new Uint8Array([64,n,e,t,s]))}build(e){return h.asHex?this.serialLockerHexCmd(e):g(this.serialLockerCmdMaker(e))}static connection({channel:e=1}={}){return h.instance.build(new Uint8Array([0,e]))}static openCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetOpenCmd({cell:e,channel:n})}static statusCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetStatusCellCmd({cell:e,channel:n})}static lightScan({since:e=0,until:n=10,channel:a=1}={}){if(e<0||e>10)throw new Error("Invalid since number");if(n<0||n>10)throw new Error("Invalid until number");return h.instance.serialLockerGetLightScanCmd({since:e,until:n,channel:a})}static enableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[a,t]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!0,column:a,row:t,channel:n})}static disableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[a,t]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!1,column:a,row:t,channel:n})}};U(E,"asHex",!1),U(E,"instance");let S=E;S.instance=new S;var V=Object.defineProperty,Q=(i,e,n)=>e in i?V(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,x=(i,e,n)=>Q(i,typeof e!="symbol"?e+"":e,n);const k=class l{build(e){return g(e+l.append)}static connection(){const e=JSON.stringify({action:"CONNECT"});return l.instance.build(e)}static connect(){return l.connection()}static custom(e){if(typeof e!="string")throw new Error("Invalid string");return l.instance.build(e)}static readQR({type:e="production"}={type:"production"}){const n=JSON.stringify({action:"READQR",server:e==="production"?"PROD":"QA"});return l.instance.build(n)}static forceHide(){const e=JSON.stringify({action:"FORCEHIDE"});return l.instance.build(e)}static forceShow(){const e=JSON.stringify({action:"FORCESHOW"});return l.instance.build(e)}static makeSale({amount:e=0,reference:n=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(n&&!/^[A-Z-a-z0-9_\s]+$/g.test(n))throw new Error("Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null");const a=e.toFixed(2),t=JSON.stringify({action:"PAYMENT",amount:a,reference:n});return l.instance.build(t)}static getVoucher({folio:e=null}={}){if(!e)throw new Error("Folio must be a number");const n=JSON.stringify({action:"GETVOUCHER",folio:e});return l.instance.build(n)}static info(){const e=JSON.stringify({action:"DEVICEINFO"});return l.instance.build(e)}static keepAlive(){const e=JSON.stringify({action:"KEEPALIVE"});return l.instance.build(e)}static restartApp(){const e=JSON.stringify({action:"RESETAPP"});return l.instance.build(e)}static getConfig(){const e=JSON.stringify({action:"GETCONFIG"});return l.instance.build(e)}static hideButtons(){const e=JSON.stringify({action:"HIDEBUTTONS"});return l.instance.build(e)}static showButtons(){const e=JSON.stringify({action:"SHOWBUTTONS"});return l.instance.build(e)}static demo(){const e=JSON.stringify({action:"DEMO"});return l.instance.build(e)}static refund({amount:e=0,folio:n=null,auth:a=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(!n)throw new Error("Folio must be a number");if(!a)throw new Error("Auth must be a number");const t=e.toFixed(2),s=JSON.stringify({action:"REFUND",amount:t,folio:n,auth:a});return l.instance.build(s)}static exit(){const e=JSON.stringify({action:"EXIT"});return l.instance.build(e)}static init(){const e=JSON.stringify({action:"INIT"});return l.instance.build(e)}};x(k,"append",`\r
3
- `),x(k,"instance");let I=k;I.instance=new I;var Y=Object.defineProperty,q=(i,e,n)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,z=(i,e,n)=>q(i,e+"",n);const R=class C{build(e){return e[3]=this.withChecksum(e),g(e)}withChecksum(e){let n=0;return e.forEach((a,t)=>{t!==3&&(n+=a)}),n}static connection(e=1){return C.instance.build([160,e,0,161])}static deactivate(e=1){return C.connection(e)}static activate(e=1){return C.instance.build([160,e,1,162])}static custom(e){return C.instance.build(e)}};z(R,"instance");let N=R;N.instance=new N;exports.e=N;exports.l=w;exports.o=v;exports.s=I;exports.u=S;
1
+ "use strict";const g=i=>{if(i instanceof Uint8Array)return i;if(Array.isArray(i))return new Uint8Array(i);if(typeof i=="string")return new TextEncoder().encode(i);if(i instanceof ArrayBuffer)return new Uint8Array(i);throw new Error("Unsupported data type")},x=({data:i,asString:e=!0})=>e?Array.from(i).map(n=>n.toString(16).padStart(2,"0")).join(" "):Array.from(i).map(n=>n.toString(16).padStart(2,"0"));var F=Object.defineProperty,H=(i,e,n)=>e in i?F(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,D=(i,e,n)=>H(i,typeof e!="symbol"?e+"":e,n);const C=class m{build(e){return g(e+m.append)}static connection(){return m.instance.build("CONNECT")}static connect(){return m.connection()}static credits(){return m.instance.build("CREDITS")}static hi(){return m.instance.build("HI")}static ara(){return m.instance.build("ARA")}static custom(e){return m.instance.build(e)}};D(C,"append",`
2
+ `),D(C,"instance");let T=C;T.instance=new T;var J=Object.defineProperty,L=(i,e,n)=>e in i?J(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,$=(i,e,n)=>L(i,typeof e!="symbol"?e+"":e,n);const b=class c{build(e){return c.asHex?x({data:e,asString:!1}):g(e)}serialBoardroidSumHex(e){let n=0;for(let t=0;t<e.length;t++)t===0||t===11||(n+=e[t]);return n}boardroidCheckSum(e){return e[11]=this.serialBoardroidSumHex(e),e}static connection({channel:e=1}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,5+e,0,0,0,0,0,0,0,0,242,248]));return c.instance.build(n)}static coinPurseConfiguration({enable:e=!1,high:n=255,low:t=255}={}){const a=c.instance.boardroidCheckSum(new Uint8Array([241,193,e?1:0,n,t,0,0,0,0,0,242,0]));return c.instance.build(a)}static coinPurseDispense({$50c:e=0,$1:n=0,$2:t=0,$5:a=0,$10:s=0}={}){if([e,n,t,a,s].some(u=>isNaN(u)||typeof u=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&t<1&&a<1&&s<1)throw new Error("No coins to dispense");const o=c.instance.boardroidCheckSum(new Uint8Array([241,198,e,n,t,a,s,0,0,0,242,0]));return c.instance.build(o)}static coinPurseReadTubes(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,194,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseICTConfigure({enable:e=!1,scrow:n=!1}={}){const t=e?255:0,a=n?255:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,t,t,a,a,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseOtherConfigure({enable:e=!1,scrow:n=!1}={}){const t=e?1:0,a=n?1:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,t,a,0,0,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseICTDispense({quantity:e=1,denomination:n=20}){if(e<1)throw new Error("No banknotes to dispense");if([20,50,100,200,500].indexOf(n)===-1)throw new Error("Invalid denomination");const t=[20,50,100,200,500].indexOf(n),a=c.instance.boardroidCheckSum(new Uint8Array([241,197,t,e,0,0,0,0,0,0,242,0]));return c.instance.build(a)}static banknotePurseOtherDispense({$20:e=0,$50:n=0,$100:t=0,$200:a=0,$500:s=0,$1000:o=0}={}){if([e,n,t,a,s,o].some(d=>isNaN(d)||typeof d=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&t<1&&a<1&&s<1&&o<1)throw new Error("No banknotes to dispense");const u=c.instance.boardroidCheckSum(new Uint8Array([241,197,e,n,t,a,s,o,0,0,242,0]));return c.instance.build(u)}static banknotePurseAcceptInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,1,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseRejectInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseSaveMemory({channel:e=null,$20:n=null,$50:t=null,$100:a=null,$200:s=null,$500:o=null,$1000:u=null}={channel:null,$20:null,$50:null,$100:null,$200:null,$500:null,$1000:null}){if(e===null||n===null||t===null||a===null||s===null||o===null||u===null)throw new Error("One of the values is not defined: "+JSON.stringify({channel:e,$20:n,$50:t,$100:a,$200:s,$500:o,$1000:u}));const d=c.instance.boardroidCheckSum(new Uint8Array([241,200,e,0,n,t,a,s,o,u,242,0]));return c.instance.build(d)}static banknotePurseReadRecycler(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,195,0,0,0,0,0,0,0,0,242,181]));return c.instance.build(e)}static cardReaderDisable(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,205,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static cardReaderDispense({selection:e=1,second_selection:n=null,sensor:t=!0,seconds:a=null,price:s=0}={selection:1,second_selection:null,sensor:!0,seconds:null,price:0}){const o=s/256,u=s%256,d=e+9;let p=0;n&&(p=n+9);let A=0;t||(a||(a=1.5),A=Math.round(a*6.2));const M=c.instance.boardroidCheckSum(new Uint8Array([241,205,1,d,p,A,o,u,0,0,242,0]));return c.instance.build(M)}static coolingRelayConfigure({enable:e=!0}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,204,e?1:0,0,0,0,0,0,0,0,242,0]));return c.instance.build(n)}static readTemperature(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,203,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static dispense({selection:e=1,second_selection:n=null,sensor:t=!0,seconds:a=null}={selection:1,second_selection:null,sensor:!0,seconds:null}){e+=9;const s=e;let o=0;n&&(n+=9,o=n);let u=0;t||(a||(a=1.5),u=Math.round(a*6.2));const d=c.instance.boardroidCheckSum(new Uint8Array([241,199,s,o,u,0,0,0,0,0,242,0]));return c.instance.build(d)}static customCode(e){typeof e[0]=="string"&&(e=e.map(t=>parseInt(t,16)));const n=c.instance.boardroidCheckSum(new Uint8Array(e));return c.instance.build(n)}};$(b,"asHex",!1),$(b,"instance");let w=b;w.instance=new w;var B=Object.defineProperty,G=(i,e,n)=>e in i?B(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,O=(i,e,n)=>G(i,typeof e!="symbol"?e+"":e,n);const y=class r{build(e){const n=this.jofemarCheckSum(e);return r.asHex?x({data:new Uint8Array(n),asString:!1}):g(n)}calcCheckSums(e){const n=[];return n.push(e&255|240),n.push(e&255|15),n}jofemarCheckSum(e){let n=0;for(let a=0;a<e.length;a++)n+=e[a];const t=this.calcCheckSums(n);return e.push(t[0]),e.push(t[1]),e.push(3),new Uint8Array(e)}getTrayAndChannelBySelection(e){if(e=parseInt(e)+109,e=e.toString(),e.length!==3)throw new Error("Invalid selection");const n=(parseInt(e.substring(0,2))+128).toString(16).padStart(2,"0"),t=(parseInt(e.substring(2,3))+128).toString(16).padStart(2,"0");return{channel:parseInt(t,16),tray:parseInt(n,16)}}makeDisplayMessage(e=""){e=e.padEnd(32," ");const n=[];for(let t=0;t<32;t++)n.push(e.charCodeAt(t));return n}makeTimeFormat(e){if(!(e instanceof Date))throw new Error("Invalid date, must be an instance of Date");const n=e.getHours().toString().padStart(2,"0"),t=e.getMinutes().toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0"),s=(e.getMonth()+1).toString().padStart(2,"0"),o=e.getFullYear().toString().substring(2,4),u=`${n}:${t} ${a}-${s}-${o}`,d=[];for(let p=0;p<14;p++)d.push(u.charCodeAt(p));return d}static connection({channel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static dispense({machineChannel:e=1,selection:n=1,cart:t=!1}={machineChannel:1,selection:1,cart:!1}){if(n=parseInt(n),isNaN(n)||n<1||n>130)throw new Error("Invalid selection");const{channel:a,tray:s}=r.instance.getTrayAndChannelBySelection(n);return r.instance.build([2,48,48,128+e,t?77:86,s,a])}static endCartDispense({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,77,128,128])}static collect({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,78,255,255])}static reset({machineChannel:e=1,type:n="soldOut"}={}){let t=128;return n==="waiting"?t=129:n==="machine"&&(t=255),r.instance.build([2,48,48,128+e,82,t,255])}static status({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static lights({machineChannel:e=1,type:n="on"}={}){const t=n==="on"?129:128;return r.instance.build([2,48,48,128+e,76,t,255])}static program({machineChannel:e=1,param1:n=255,param2:t=255}={}){return r.instance.build([2,48,48,128+e,80,n,t])}static programDisplayLanguage({machineChannel:e=1,language:n="spanish"}={}){const t={spanish:48,english:49,french:50};if(!t[n])throw new Error("Invalid language");return r.program({machineChannel:e,param1:73,param2:t[n]})}static programBeeper({machineChannel:e=1,enable:n=!0}){return r.program({machineChannel:e,param1:90,param2:n?49:48})}static programDisableWorkingTemperature({machineChannel:e=1}){return r.program({machineChannel:e,param1:84,param2:128})}static programDisableThermometer({machineChannel:e=1}){return r.programDisableWorkingTemperature({machineChannel:e})}static programWorkingTemperature({machineChannel:e=1,degrees:n=.5,machineType:t="esplus"}={}){typeof n=="string"&&(n=parseFloat(n));const a=t==="iceplus"?6.5:32,s=t==="iceplus"?-25:.5;if(isNaN(n)||n<s||n>a||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let o=n*2+128;return t==="iceplus"&&(o+=51),o=Math.ceil(o),r.program({param1:84,param2:o,machineChannel:e})}static programIsolationTray({machineChannel:e=1,tray:n=0}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<0||n>12)throw new Error("Invalid tray, valid range is 0 to 12");const t=n===0?128:n+139;return r.program({param1:66,param2:t,machineChannel:e})}static programTimeToStandbyAfterCollect({machineChannel:e=1,seconds:n=15}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<15||n>120)throw new Error("Invalid seconds, valid range is 15 to 120");const t=128+n;return r.program({param1:70,param2:t,machineChannel:e})}static programTimeToStandbyWithoutCollect({machineChannel:e=1,minutes:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>10)throw new Error("Invalid minutes, valid range is 1 to 10");const t=128+n;return r.program({param1:72,param2:t,machineChannel:e})}static programElevatorSpeed({machineChannel:e=1,speed:n="high"}={}){const t={high:49,low:48};if(!t[n])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return r.program({param1:118,param2:t[n],machineChannel:e})}static programTemperatureExpiration({machineChannel:e=1,enable:n=!1}){return r.program({machineChannel:e,param1:99,param2:n?49:48})}static programMachineAddress({machineChannel:e=1,address:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>31)throw new Error("Invalid address, valid range is 1 to 31");return r.program({param1:100,param2:128+n,machineChannel:e})}static programTemperatureBeforeExpiration({machineChannel:e=1,degrees:n=.5}){if(typeof n=="string"&&(n=parseFloat(n)),isNaN(n)||n<.5||n>30||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const t=128+n*2;return r.program({param1:101,param2:t,machineChannel:e})}static programTimeBeforeExpirationByTemperature({machineChannel:e=1,minutes:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>120)throw new Error("Invalid minutes, valid range is 1 to 120");const t=128+n;return r.program({param1:102,param2:t,machineChannel:e})}static programTemperatureScale({machineChannel:e=1,scale:n="celsius"}={}){const t={celsius:67,fahrenheit:70};if(!t[n])throw new Error("Invalid scale, valid scales are 'celsius' and 'fahrenheit'");return r.program({param1:103,param2:t[n],machineChannel:e})}static programVoltageEngine({machineChannel:e=1,selection:n=1,voltage:t=5}={}){if(typeof t=="string"&&(t=parseFloat(t)),typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(t)||t<5||t>9.5||t%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const a=109+n,s=128+(t-5)*2;return r.instance.build([2,48,48,128+e,71,a,s])}static programPushOverProducts({machineChannel:e=1,selection:n=1,enable:t=!0}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");const a=109+n,s=t?49:48;return r.instance.build([2,48,48,128+e,79,a,s])}static programChannelRunningAfterDispense({machineChannel:e=1,selection:n=1,seconds:t=0}={}){if(typeof n=="string"&&(n=parseInt(n)),typeof t=="string"&&(t=parseFloat(t)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(t)||t<0||t>10||t%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const a=109+n;t=10*parseFloat(t.toFixed(1));const s=128+t;return r.instance.build([2,48,48,128+e,69,a,s])}static checkData({machineChannel:e=1,type:n=255,aux:t=255}){return r.instance.build([2,48,48,128+e,67,n,t])}static getDisplayLanguage({machineChannel:e=1}){return r.checkData({machineChannel:e,type:73})}static getBeeper({machineChannel:e=1}){return r.checkData({machineChannel:e,type:90})}static getWorkingTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:84})}static getIsolationTray({machineChannel:e=1}){return r.checkData({machineChannel:e,type:66})}static getProgramVersion({machineChannel:e=1}){return r.checkData({machineChannel:e,type:80})}static getFaults({machineChannel:e=1}){return r.checkData({machineChannel:e,type:83})}static getMachineId({machineChannel:e=1}){return r.checkData({machineChannel:e,type:78})}static getCurrentTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:116})}static getTimeToStandbyAfterCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:70})}static getTimeToStandbyWithoutCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:72})}static getElevatorSpeed({machineChannel:e=1}){return r.checkData({machineChannel:e,type:118})}static getTemperatureExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:99})}static getTemperatureBeforeExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:101})}static getTimeBeforeExpirationByTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:102})}static getTemperatureScale({machineChannel:e=1}){return r.checkData({machineChannel:e,type:103})}static getClockRegisters({machineChannel:e=1}){return r.checkData({machineChannel:e,type:114})}static getMachineActivity({machineChannel:e=1}){return r.checkData({machineChannel:e,type:65})}static getVoltageEngine({machineChannel:e=1,selection:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:71,aux:109+n})}static getChannelPresence({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:67,aux:109+n})}static getPushOverProducts({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:79,aux:109+n})}static getChannelRunningAfterDispense({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:69,aux:109+n})}static displayConfig({machineChannel:e=1,type:n=128,param2:t=[]}={}){return r.instance.build([2,48,48,128+e,68,n,...t])}static setDisplayStandbyMessage({machineChannel:e=1,message:n=""}={}){n=n.substring(0,32);const t=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:128,param2:t})}static setDisplayMessageTemporarily({machineChannel:e=1,message:n="",seconds:t=1}){if(n=n.substring(0,32),typeof t=="string"&&(t=parseInt(t)),isNaN(t)||t<1||t>125)throw new Error("Invalid seconds, valid range is 1 to 125");const a=r.instance.makeDisplayMessage(n),s=128+t;return r.displayConfig({machineChannel:e,type:s,param2:a})}static setDisplayMessageUnlimited({machineChannel:e=1,message:n=""}){n=n.substring(0,32);const t=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:255,param2:t})}static programClock({machineChannel:e=1,date:n=new Date}={}){if(!(n instanceof Date))throw new Error("Invalid date, must be an instance of Date");return r.instance.build([2,48,48,128+e,114,...r.instance.makeTimeFormat(n)])}static eventsConfig({machineChannel:e=1,event:n=null,enable:t=!0}={}){if(n===null)throw new Error("Invalid event");const a=t?49:48;return r.instance.build([2,48,48,128+e,65,n,a])}static eventEnable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const t=parseInt(n,16);if(isNaN(t)||t<38||t>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!0})}static eventDisable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const t=parseInt(n,16);if(isNaN(t)||t<38||t>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!1})}static sendCustomCode({code:e=[]}={}){if(e.length<5)throw new Error("Invalid code, minimum length is 5");return r.instance.build(e)}};O(y,"asHex",!1),O(y,"instance");let v=y;v.instance=new v;var j=Object.defineProperty,W=(i,e,n)=>e in i?j(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,U=(i,e,n)=>W(i,typeof e!="symbol"?e+"":e,n);const E=class h{serialLockerCmdMaker(e){let n;try{n=new Uint8Array(e.length+8),n.set(e,2),n[0]=2,n[1]=e.length+4,n[n.length-2]=3;let t=0;for(let o=1;o<e.length;o++)t+=e[o],t*=parseInt(Math.pow(2,o-1).toString());n[e.length+2]=t%256,n[e.length+3]=666*3%256,n[e.length+4]=666*8%256;let a=0;for(let o=3;o<e.length+5;o++)a+=n[o];n[e.length+5]=a%256;let s=0;for(let o=0;o<n.length-1;o++)s^=n[o];n[n.length-1]=s}catch(t){throw n=new Uint8Array(0),t instanceof Error?new Error(`Error generating command: ${t.message}`):new Error("Error generating command: Unknown error")}return n}serialLockerHexCmd(e){const n=this.serialLockerCmdMaker(e),t=[];for(let a=0;a<n.length;a++){const s=n[a].toString(16).padStart(2,"0");t.push(s)}return t}validateCell(e=1){let n;if(typeof e=="string"?n=parseInt(e):n=e,isNaN(n)||n<1||n>90)throw new Error("Invalid cell number");return n}serialLockerGetStatusCellCmd({cell:e=1,channel:n=1}={}){return e=this.validateCell(e),this.build(new Uint8Array([16,n,e]))}serialLockerGetLightScanCmd({since:e=0,until:n=10,channel:t=1}={}){return this.build(new Uint8Array([32,t,e,n]))}parseCellToColumnRow(e){const n=Math.floor((e-1)/10)+1;let t=e%8;return t===0&&(t=8),[n,t]}serialLockerGetConfigureCellCmd({enable:e=!0,column:n=0,row:t=10,channel:a=1}={}){if(n<0||n>8)throw new Error("Invalid column number");if(t<0||t>10)throw new Error("Invalid row number");let s=1;return e||(s=0),this.build(new Uint8Array([48,a,n,t,s]))}serialLockerGetOpenCmd({cell:e=1,channel:n=1}={}){e=this.validateCell(e);const t=666,a=t%256,s=Math.floor(t/3)%256;return this.build(new Uint8Array([64,n,e,a,s]))}build(e){return h.asHex?this.serialLockerHexCmd(e):g(this.serialLockerCmdMaker(e))}static connection({channel:e=1}={}){return h.instance.build(new Uint8Array([0,e]))}static openCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetOpenCmd({cell:e,channel:n})}static statusCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetStatusCellCmd({cell:e,channel:n})}static lightScan({since:e=0,until:n=10,channel:t=1}={}){if(e<0||e>10)throw new Error("Invalid since number");if(n<0||n>10)throw new Error("Invalid until number");return h.instance.serialLockerGetLightScanCmd({since:e,until:n,channel:t})}static enableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[t,a]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!0,column:t,row:a,channel:n})}static disableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[t,a]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!1,column:t,row:a,channel:n})}};U(E,"asHex",!1),U(E,"instance");let S=E;S.instance=new S;var V=Object.defineProperty,Q=(i,e,n)=>e in i?V(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,P=(i,e,n)=>Q(i,typeof e!="symbol"?e+"":e,n);const k=class l{build(e){return g(e+l.append)}static connection(){const e=JSON.stringify({action:"CONNECT"});return l.instance.build(e)}static connect(){return l.connection()}static custom(e){if(typeof e!="string")throw new Error("Invalid string");return l.instance.build(e)}static readQR({type:e="production"}={type:"production"}){const n=JSON.stringify({action:"READQR",server:e==="production"?"PROD":"QA"});return l.instance.build(n)}static forceHide(){const e=JSON.stringify({action:"FORCEHIDE"});return l.instance.build(e)}static forceShow(){const e=JSON.stringify({action:"FORCESHOW"});return l.instance.build(e)}static makeSale({amount:e=0,reference:n=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(n&&!/^[A-Z-a-z0-9_\s]+$/g.test(n))throw new Error("Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null");const t=e.toFixed(2),a=JSON.stringify({action:"PAYMENT",amount:t,reference:n});return l.instance.build(a)}static getVoucher({folio:e=null}={}){if(!e)throw new Error("Folio must be a number");const n=JSON.stringify({action:"GETVOUCHER",folio:e});return l.instance.build(n)}static info(){const e=JSON.stringify({action:"DEVICEINFO"});return l.instance.build(e)}static keepAlive(){const e=JSON.stringify({action:"KEEPALIVE"});return l.instance.build(e)}static restartApp(){const e=JSON.stringify({action:"RESETAPP"});return l.instance.build(e)}static getConfig(){const e=JSON.stringify({action:"GETCONFIG"});return l.instance.build(e)}static hideButtons(){const e=JSON.stringify({action:"HIDEBUTTONS"});return l.instance.build(e)}static showButtons(){const e=JSON.stringify({action:"SHOWBUTTONS"});return l.instance.build(e)}static demo(){const e=JSON.stringify({action:"DEMO"});return l.instance.build(e)}static refund({amount:e=0,folio:n=null,auth:t=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(!n)throw new Error("Folio must be a number");if(!t)throw new Error("Auth must be a number");const a=e.toFixed(2),s=JSON.stringify({action:"REFUND",amount:a,folio:n,auth:t});return l.instance.build(s)}static exit(){const e=JSON.stringify({action:"EXIT"});return l.instance.build(e)}static init(){const e=JSON.stringify({action:"INIT"});return l.instance.build(e)}static stop(){const e=JSON.stringify({action:"STOP"});return l.instance.build(e)}static verifyNetwork(){const e=JSON.stringify({action:"CHECKINTERNET"});return l.instance.build(e)}};P(k,"append",`\r
3
+ `),P(k,"instance");let N=k;N.instance=new N;var K=Object.defineProperty,Y=(i,e,n)=>e in i?K(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,q=(i,e,n)=>Y(i,e+"",n);const R=class f{build(e){return e[3]=this.withChecksum(e),g(e)}withChecksum(e){let n=0;return e.forEach((t,a)=>{a!==3&&(n+=t)}),n}static connection(e=1){return f.instance.build([160,e,0,161])}static deactivate(e=1){return f.connection(e)}static activate(e=1){return f.instance.build([160,e,1,162])}static custom(e){return f.instance.build(e)}};q(R,"instance");let I=R;I.instance=new I;exports.e=I;exports.l=w;exports.o=v;exports.s=N;exports.u=S;