@danidoble/webserial 4.5.0-beta.3 → 4.5.0-beta.5

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 p=require("./kernel-c6KuKgQ5.cjs"),c=require("./devices-CcYKrJpP.cjs"),s=require("./relay-E3NCcSjS.cjs");class _ extends p.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"}={type:"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}={folio: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}={amount:0,folio:null,auth: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=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./kernel-c6KuKgQ5.cjs"),c=require("./devices-CcYKrJpP.cjs"),i=require("./relay-BG7CetDU.cjs");class _ extends p.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"}={type:"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}={folio: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}={amount:0,folio:null,auth: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=_;
package/dist/pinpax.js CHANGED
@@ -1,7 +1,7 @@
1
- import { K as p } from "./kernel-BhNOFt2M.js";
2
- import { D as c } from "./devices-2YN3FSHn.js";
3
- import { s } from "./relay-DP8PLsDP.js";
4
- class d extends p {
1
+ import { K as c } from "./kernel-BhNOFt2M.js";
2
+ import { D as p } from "./devices-2YN3FSHn.js";
3
+ import { s as i } from "./relay-C71zVBZv.js";
4
+ class d extends c {
5
5
  __pinpax__ = {
6
6
  server: "DEV",
7
7
  businessId: null,
@@ -19,7 +19,7 @@ class d extends p {
19
19
  }
20
20
  };
21
21
  constructor({
22
- filters: i = null,
22
+ filters: t = null,
23
23
  config_port: e = {
24
24
  baudRate: 115200,
25
25
  dataBits: 8,
@@ -28,7 +28,7 @@ class d extends p {
28
28
  bufferSize: 32768,
29
29
  flowControl: "none"
30
30
  },
31
- no_device: t = 1,
31
+ no_device: s = 1,
32
32
  device_listen_on_channel: a = 1,
33
33
  socket: n = !1
34
34
  } = {
@@ -45,13 +45,13 @@ class d extends p {
45
45
  device_listen_on_channel: 1,
46
46
  socket: !1
47
47
  }) {
48
- 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))
49
- throw new Error(`Device ${this.typeDevice} ${t} already exists`);
48
+ if (super({ filters: t, config_port: e, no_device: s, device_listen_on_channel: a, socket: n }), this.__internal__.device.type = "pinpax", p.getCustom(this.typeDevice, s))
49
+ throw new Error(`Device ${this.typeDevice} ${s} already exists`);
50
50
  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
51
- `, this.#t(), c.add(this), this.getResponseAsString();
51
+ `, this.#i(), p.add(this), this.getResponseAsString();
52
52
  }
53
- #t() {
54
- const i = [
53
+ #i() {
54
+ const t = [
55
55
  "buttons-status",
56
56
  "init-app",
57
57
  "connectMessage",
@@ -65,39 +65,39 @@ class d extends p {
65
65
  "refund",
66
66
  "login"
67
67
  ];
68
- for (const e of i)
68
+ for (const e of t)
69
69
  this.serialRegisterAvailableListener(e);
70
70
  }
71
- set businessId(i) {
72
- this.__pinpax__.businessId = i;
71
+ set businessId(t) {
72
+ this.__pinpax__.businessId = t;
73
73
  }
74
74
  get businessId() {
75
75
  return this.__pinpax__.businessId;
76
76
  }
77
- set encryptionKey(i) {
78
- this.__pinpax__.encryptionKey = i;
77
+ set encryptionKey(t) {
78
+ this.__pinpax__.encryptionKey = t;
79
79
  }
80
80
  get encryptionKey() {
81
81
  return this.__pinpax__.encryptionKey;
82
82
  }
83
- set apiKey(i) {
84
- this.__pinpax__.apiKey = i;
83
+ set apiKey(t) {
84
+ this.__pinpax__.apiKey = t;
85
85
  }
86
86
  get apiKey() {
87
87
  return this.__pinpax__.apiKey;
88
88
  }
89
- set server(i) {
90
- this.__pinpax__.server = i;
89
+ set server(t) {
90
+ this.__pinpax__.server = t;
91
91
  }
92
92
  get server() {
93
93
  return this.__pinpax__.server;
94
94
  }
95
- serialMessage(i) {
95
+ serialMessage(t) {
96
96
  let e = null;
97
97
  try {
98
- e = JSON.parse(i), e.request || (e.request = this.lastAction), e.name || (e.name = this.lastAction);
99
- } catch (t) {
100
- console.error("Error parsing response", t, i), this.dispatch("serial:message", i);
98
+ e = JSON.parse(t), e.request || (e.request = this.lastAction), e.name || (e.name = this.lastAction);
99
+ } catch (s) {
100
+ console.error("Error parsing response", s, t), this.dispatch("serial:message", t);
101
101
  return;
102
102
  }
103
103
  switch (e.response) {
@@ -221,6 +221,14 @@ class d extends p {
221
221
  response: e
222
222
  }), this.dispatch("error", { name: "ERROR", request: this.lastAction, status: "error", response: e }), this.dispatch("payment", { name: "ERROR", request: this.lastAction, status: "error", response: e });
223
223
  break;
224
+ case "CHECKINTERNET":
225
+ this.dispatch("network", {
226
+ name: "CHECKINTERNET",
227
+ request: this.lastAction,
228
+ hasInternet: e.internet,
229
+ quality: e.quality
230
+ });
231
+ break;
224
232
  case "REFUND":
225
233
  this.dispatch("refund", { name: "ERROR", request: this.lastAction, status: "refund", response: e });
226
234
  break;
@@ -228,44 +236,44 @@ class d extends p {
228
236
  this.dispatch("serial:message", e);
229
237
  }
230
238
  serialSetConnectionConstant() {
231
- return s.connection();
239
+ return i.connection();
232
240
  }
233
241
  softReload() {
234
242
  super.softReload(), this.__pinpax__.waiting.sale = !1, this.__pinpax__.waiting.voucher = !1, this.__pinpax__.asyncResponses.sale = null, this.__pinpax__.asyncResponses.voucher = null;
235
243
  }
236
- async sendCustomCode(i = {}) {
237
- if (typeof i != "object") throw new Error("Invalid object");
238
- if (i.constructor !== Object) throw new Error("Invalid object");
239
- if (Object.keys(i).length === 0) throw new Error("Empty object");
240
- if (i.action === void 0 || i.action === null) throw new Error("Invalid object add action");
241
- const e = JSON.stringify(i), t = this.parseStringToBytes(e, `\r
244
+ async sendCustomCode(t = {}) {
245
+ if (typeof t != "object") throw new Error("Invalid object");
246
+ if (t.constructor !== Object) throw new Error("Invalid object");
247
+ if (Object.keys(t).length === 0) throw new Error("Empty object");
248
+ if (t.action === void 0 || t.action === null) throw new Error("Invalid object add action");
249
+ const e = JSON.stringify(t), s = this.parseStringToBytes(e, `\r
242
250
  `);
243
- await this.appendToQueue(this.stringArrayToUint8Array(t), "custom");
251
+ await this.appendToQueue(this.stringArrayToUint8Array(s), "custom");
244
252
  }
245
253
  async connectMessage() {
246
- await this.appendToQueue(s.connect(), "connect:message");
254
+ await this.appendToQueue(i.connect(), "connect:message");
247
255
  }
248
256
  async #e() {
249
257
  if (this.isDisconnected) throw new Error("Device is disconnected");
250
- return this.queue.length === 0 ? !0 : new Promise((i) => {
258
+ return this.queue.length === 0 ? !0 : new Promise((t) => {
251
259
  const e = setInterval(() => {
252
- this.queue.length === 0 && (clearInterval(e), i(!0));
260
+ this.queue.length === 0 && (clearInterval(e), t(!0));
253
261
  }, 500);
254
262
  });
255
263
  }
256
- async #i({
257
- type: i = "production"
264
+ async #t({
265
+ type: t = "production"
258
266
  } = {
259
267
  type: "production"
260
268
  }) {
261
- const e = s.readQR({ type: i });
269
+ const e = i.readQR({ type: t });
262
270
  return await this.appendToQueue(e, "read-qr");
263
271
  }
264
272
  async #s() {
265
- await this.appendToQueue(s.forceHide(), "force-hide");
273
+ await this.appendToQueue(i.forceHide(), "force-hide");
266
274
  }
267
275
  async #a() {
268
- await this.appendToQueue(s.forceShow(), "force-show");
276
+ await this.appendToQueue(i.forceShow(), "force-show");
269
277
  }
270
278
  async #n() {
271
279
  await this.connectMessage();
@@ -273,8 +281,8 @@ class d extends p {
273
281
  async #r() {
274
282
  await this.hideButtons();
275
283
  }
276
- #o(i) {
277
- this.dispatch("payment", i), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = i);
284
+ #o(t) {
285
+ this.dispatch("payment", t), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = t);
278
286
  }
279
287
  cancelSaleRequestInProcess() {
280
288
  this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = {
@@ -283,26 +291,26 @@ class d extends p {
283
291
  response: {}
284
292
  });
285
293
  }
286
- async #c() {
287
- return new Promise((i, e) => {
288
- const t = setTimeout(() => {
294
+ async #p() {
295
+ return new Promise((t, e) => {
296
+ const s = setTimeout(() => {
289
297
  this.__pinpax__.waiting.sale_login === "waiting" && (this.__pinpax__.waiting.sale_login = "timeout", e(new Error("Login timeout")));
290
298
  }, 1e4), a = setInterval(() => {
291
- this.__pinpax__.waiting.sale_login === "received" && (clearTimeout(t), clearInterval(a), i(!0));
299
+ this.__pinpax__.waiting.sale_login === "received" && (clearTimeout(s), clearInterval(a), t(!0));
292
300
  }, 100);
293
301
  });
294
302
  }
295
- async #p() {
296
- return new Promise((i, e) => {
297
- const t = setTimeout(() => {
303
+ async #c() {
304
+ return new Promise((t, e) => {
305
+ const s = setTimeout(() => {
298
306
  this.__pinpax__.waiting.sale_init === "waiting" && (this.__pinpax__.waiting.sale_init = "timeout", e(new Error("Init timeout")));
299
307
  }, 1e4), a = setInterval(() => {
300
- this.__pinpax__.waiting.sale_init === "received" && (clearTimeout(t), clearInterval(a), i(!0));
308
+ this.__pinpax__.waiting.sale_init === "received" && (clearTimeout(s), clearInterval(a), t(!0));
301
309
  }, 100);
302
310
  });
303
311
  }
304
312
  async makeSale({
305
- amount: i = 0,
313
+ amount: t = 0,
306
314
  reference: e = null
307
315
  } = {
308
316
  amount: 0,
@@ -310,11 +318,11 @@ class d extends p {
310
318
  }) {
311
319
  if (this.isDisconnected) throw new Error("Device is disconnected");
312
320
  if (this.__pinpax__.waiting.sale) throw new Error("Already waiting for sale response");
313
- const t = s.makeSale({ amount: i, reference: e });
321
+ const s = i.makeSale({ amount: t, reference: e });
314
322
  this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await this.#e();
315
323
  let a = !1;
316
324
  try {
317
- 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";
325
+ this.__pinpax__.waiting.sale_login = "waiting", await this.login(), await this.#p(), this.__pinpax__.waiting.sale_login = "idle", this.__pinpax__.waiting.sale_init = "waiting", await this.init(), await this.#c(), this.__pinpax__.waiting.sale_init = "idle";
318
326
  } catch (n) {
319
327
  a = !0, this.__pinpax__.waiting.sale_login = "idle", this.__pinpax__.waiting.sale_init = "idle", this.__pinpax__.waiting.sale = !1, this.dispatch("error", {
320
328
  name: "ERROR",
@@ -324,7 +332,7 @@ class d extends p {
324
332
  error: n
325
333
  });
326
334
  }
327
- return a ? !1 : (await this.appendToQueue(t, "make-sale"), new Promise((n) => {
335
+ return a ? !1 : (await this.appendToQueue(s, "make-sale"), new Promise((n) => {
328
336
  const r = setInterval(() => {
329
337
  if (this.__pinpax__.asyncResponses.sale) {
330
338
  const o = this.__pinpax__.asyncResponses.sale;
@@ -334,90 +342,96 @@ class d extends p {
334
342
  }));
335
343
  }
336
344
  async getVoucher({
337
- folio: i = null
345
+ folio: t = null
338
346
  } = {
339
347
  folio: null
340
348
  }) {
341
349
  if (this.isDisconnected) throw new Error("Device is disconnected");
342
350
  if (this.__pinpax__.waiting.voucher) throw new Error("Already waiting for voucher");
343
- if (!i) throw new Error("Folio is required");
351
+ if (!t) throw new Error("Folio is required");
344
352
  this.__pinpax__.waiting.voucher = !0, this.__pinpax__.asyncResponses.voucher = null;
345
- const e = s.getVoucher({ folio: i });
346
- return this.queue.length > 0 && await this.#e(), await this.appendToQueue(e, "get-voucher"), new Promise((t, a) => {
353
+ const e = i.getVoucher({ folio: t });
354
+ return this.queue.length > 0 && await this.#e(), await this.appendToQueue(e, "get-voucher"), new Promise((s, a) => {
347
355
  const n = setTimeout(() => {
348
356
  this.__pinpax__.waiting.voucher = !1, a("Timeout");
349
357
  }, 1e4), r = setInterval(() => {
350
358
  if (this.__pinpax__.asyncResponses.voucher) {
351
359
  const o = this.__pinpax__.asyncResponses.voucher;
352
- this.__pinpax__.asyncResponses.voucher = null, this.__pinpax__.waiting.voucher = !1, clearInterval(r), clearTimeout(n), t(o.voucher);
360
+ this.__pinpax__.asyncResponses.voucher = null, this.__pinpax__.waiting.voucher = !1, clearInterval(r), clearTimeout(n), s(o.voucher);
353
361
  }
354
362
  }, 100);
355
363
  });
356
364
  }
357
365
  async info() {
358
- await this.appendToQueue(s.info(), "info");
366
+ await this.appendToQueue(i.info(), "info");
359
367
  }
360
368
  async keepAlive() {
361
- await this.appendToQueue(s.keepAlive(), "keep-alive");
369
+ await this.appendToQueue(i.keepAlive(), "keep-alive");
362
370
  }
363
371
  async restartApp() {
364
- await this.appendToQueue(s.restartApp(), "reset-app");
372
+ await this.appendToQueue(i.restartApp(), "reset-app");
365
373
  }
366
374
  async getConfig() {
367
- return await this.appendToQueue(s.getConfig(), "get-config");
375
+ return await this.appendToQueue(i.getConfig(), "get-config");
368
376
  }
369
377
  async hideButtons() {
370
- return await this.appendToQueue(s.hideButtons(), "hide-buttons"), await this.#s();
378
+ return await this.appendToQueue(i.hideButtons(), "hide-buttons"), await this.#s();
371
379
  }
372
380
  async showButtons() {
373
- return await this.appendToQueue(s.showButtons(), "show-buttons"), await this.#a();
381
+ return await this.appendToQueue(i.showButtons(), "show-buttons"), await this.#a();
374
382
  }
375
383
  async demo() {
376
- return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(s.demo(), "demo");
384
+ return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(i.demo(), "demo");
377
385
  }
378
386
  async refund({
379
- amount: i = 0,
387
+ amount: t = 0,
380
388
  folio: e = null,
381
- auth: t = null
389
+ auth: s = null
382
390
  } = {
383
391
  amount: 0,
384
392
  folio: null,
385
393
  auth: null
386
394
  }) {
387
395
  return await this.appendToQueue(
388
- s.refund({
389
- amount: i,
396
+ i.refund({
397
+ amount: t,
390
398
  folio: e,
391
- auth: t
399
+ auth: s
392
400
  }),
393
401
  "refund"
394
402
  );
395
403
  }
396
404
  async readProductionQR() {
397
- return await this.#i({ type: "production" });
405
+ return await this.#t({ type: "production" });
398
406
  }
399
407
  async readQualityAssuranceQR() {
400
- return this.#i({ type: "QA" });
408
+ return this.#t({ type: "QA" });
401
409
  }
402
410
  async exit() {
403
- return await this.appendToQueue(s.exit(), "exit-app");
411
+ return await this.appendToQueue(i.exit(), "exit-app");
404
412
  }
405
413
  async init() {
406
- await this.appendToQueue(s.init(), "init-app");
414
+ await this.appendToQueue(i.init(), "init-app");
407
415
  }
408
416
  async login() {
409
417
  if (!this.apiKey || !this.businessId || !this.encryptionKey || !this.server)
410
418
  throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");
411
- const i = JSON.stringify({
419
+ const t = JSON.stringify({
412
420
  action: "LOGIN_MIT",
413
421
  server: this.__pinpax__.server,
414
422
  business_id: this.__pinpax__.businessId,
415
423
  encryption_key: this.__pinpax__.encryptionKey,
416
424
  api_key: this.__pinpax__.apiKey
417
- }), e = this.parseStringToBytes(i, `\r
425
+ }), e = this.parseStringToBytes(t, `\r
418
426
  `);
419
427
  await this.appendToQueue(e, "login");
420
428
  }
429
+ async stop() {
430
+ await this.appendToQueue(i.stop(), "stop");
431
+ }
432
+ async verifyNetwork() {
433
+ await this.appendToQueue(i.verifyNetwork(), "verify-network");
434
+ }
421
435
  }
422
436
  export {
423
437
  d 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;