@danidoble/webserial 4.1.8 → 4.1.10

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.
@@ -1,14 +1,14 @@
1
- (function(R,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(R=typeof globalThis<"u"?globalThis:R||self,O(R.WebSerial={}))})(this,function(R){"use strict";var Ic=Object.defineProperty;var or=R=>{throw TypeError(R)};var Oc=(R,O,X)=>O in R?Ic(R,O,{enumerable:!0,configurable:!0,writable:!0,value:X}):R[O]=X;var lt=(R,O,X)=>Oc(R,typeof O!="symbol"?O+"":O,X),Cn=(R,O,X)=>O.has(R)||or("Cannot "+X);var I=(R,O,X)=>(Cn(R,O,"read from private field"),X?X.call(R):O.get(R)),tt=(R,O,X)=>O.has(R)?or("Cannot add the same private member more than once"):O instanceof WeakSet?O.add(R):O.set(R,X),L=(R,O,X,ee)=>(Cn(R,O,"write to private field"),ee?ee.call(R,X):O.set(R,X),X),o=(R,O,X)=>(Cn(R,O,"access private method"),X);var ot,pt,d,cr,lr,C,Tn,F,M,Ve,P,Sn,he,le,Ue,hr,rt,J,Tt,D,ur,dr,pr,_r,kn,fr,Vt,qt,qe,je,He,p,br,yr,mr,xn,wr,vr,Er,Pr,Cr,Tr,Sr,kr,xr,Ar,ue,de,Dr,pe,Rr,jt,Ir,Q,Or,Nr,An,Br,Mr,Fr,Dn,Rn,_e,In,Ur,wt,vt,Ke,On,fe,Nn,Bn,Lr,Mn,Fn,Vr,qr,te,Un,jr,Hr,Kr,We,Wr,$r,Ln,zr,Xr,Gr,Jr,Qr,Zr,Yr,ts,es,Vn,qn,ns,is,rs,g,ss,as,os,ht,$e,cs,ls,hs,us,ds,ps,_s,fs,gs,bs,ys,ms,ws,vs,Es,Ps,Cs,Ts,Ss,ks,xs,As,Ds,Rs,Is,Os,gt,et,ze,nt,Et,Ns,Bs,Ms,Fs,ge,jn,Hn,Xe,Ge,Us,Qt,Lt,Zt,w,Ls,Vs,Je,qs,js,Hs,Ks,Ws,$s,zs,Xs,Kn,Gs,Js,Qs,Zs,Ys,ta,ea,na,ia,ra,sa,aa,oa,ca,ut,Qe,la,ha,ua,da,Wn,Ze,pa,_a,$n,zn,Xn,Yt,fa,ga;function O(r=100){return new Promise(n=>setTimeout(()=>n(),r))}function X(){return"serial"in navigator}function ee(){return"geolocation"in navigator}function ba(){return"crypto"in window}function Ye(r=1){return r*1e3}function xt(r){return r==null||r===""}const u=class u{static status(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(I(u,ot)){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+I(u,pt)).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}o(i=u,d,P).call(i,t)}static dispensed(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(I(u,ot)){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}o(i=u,d,P).call(i,t)}static notDispensed(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(I(u,ot)){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}o(i=u,d,P).call(i,t)}static gateInactive(n=null){var t;if(!o(t=u,d,C).call(t,n)||!o(this,d,Tn).call(this))return!1;o(this,d,P).call(this,["0","7","5","5","5"])}static gateConfigured(n=null){var t;if(!o(t=u,d,C).call(t,n)||!o(this,d,Tn).call(this))return!1;o(this,d,P).call(this,["0","6"])}static keyPressed(n=null){var s,a,c;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,M).call(a))return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],e=(128+I(u,pt)).toString(16),i=Math.floor(Math.random()*15);o(c=u,d,P).call(c,["2",e,"54",t[i]])}static doorOpened(n=null){var i,s;if(!o(i=u,d,C).call(i,n)||!o(this,d,Ve).call(this))return!1;let t=[];const e=(128+I(u,pt)).toString(16);switch(I(u,ot)){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",e,"50","4F"];break}o(s=u,d,P).call(s,t)}static doorClosed(n=null){var i,s;if(!o(i=u,d,C).call(i,n)||!o(this,d,Ve).call(this))return!1;let t=[];const e=(128+I(u,pt)).toString(16);switch(I(u,ot)){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",e,"50","43"];break}o(s=u,d,P).call(s,t)}static channelDisconnected(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+I(u,pt)).toString(16);o(s=u,d,P).call(s,["2",t,"43","43","43","FD"])}static channelConnected(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+I(u,pt)).toString(16);o(s=u,d,P).call(s,["2",t,"43","43","43","FC"])}static channelEmpty(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+I(u,pt)).toString(16);o(s=u,d,P).call(s,["2",t,"43","43","43","FF"])}static workingTemperature(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+I(u,pt)).toString(16);o(s=u,d,P).call(s,["2",t,"43","54","16"])}static currentTemperature(n=null){var i,s,a;if(!o(i=u,d,C).call(i,n)||!o(s=u,d,Ve).call(s))return!1;let t=[];const e=(128+I(u,pt)).toString(16);switch(I(u,ot)){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",e,"43","74","2B","30","39","2E","31","7F","43"];break}o(a=u,d,P).call(a,t)}static ready(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","30"])}static busy(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","31"])}static invalidTray(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","32"])}static invalidChannel(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","33"])}static emptyChannel(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","34"])}static elevatorJam(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","35"])}static elevatorMalfunction(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","36"])}static phototransistorFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","37"])}static allChannelsEmpty(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","38"])}static productDetectorFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","39"])}static displayDisconnected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","41"])}static productUnderElevator(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","42"])}static elevatorSettingAlarm(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","43"])}static buttonPanelFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","44"])}static errorWritingEeprom(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","45"])}static errorControlTemperature(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","46"])}static thermometerDisconnected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","47"])}static thermometerMisconfigured(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","48"])}static thermometerFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","49"])}static errorExtractorConsumption(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4A"])}static channelSearchError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4B"])}static productExitMouthSearchError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4C"])}static elevatorInteriorLocked(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4D"])}static productDetectorVerifierError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4E"])}static waitingForProductRecall(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4F"])}static productExpiredByTemperature(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","50"])}static faultyAutomaticDoor(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","51"])}static rejectLever(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","A0","1"])}static resetCoinPurse(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","A0","2"])}static coinInsertedBox(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["40","41","42","43","44","45"],i=o(c=u,d,Sn).call(c,e,t);o(l=u,d,P).call(l,["2","A0",i])}static coinInsertedTube(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["50","51","52","53","54","55"],i=o(c=u,d,Sn).call(c,e,t);o(l=u,d,P).call(l,["2","A0",i])}static banknoteInsertedStacker(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["80","81","82","83","84"],i=o(c=u,d,he).call(c,e,t);o(l=u,d,P).call(l,["2","B0",i])}static banknoteInsertedEscrow(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["90","91","92","93","94"],i=o(c=u,d,he).call(c,e,t);o(l=u,d,P).call(l,["2","B0",i])}static banknoteEjected(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["A0","A1","A2","A3","A4"],i=o(c=u,d,he).call(c,e,t);o(l=u,d,P).call(l,["2","B0",i])}static banknoteInsertedRecycler(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["B0","B1","B2","B3","B4"],i=o(c=u,d,he).call(c,e,t);o(l=u,d,P).call(l,["2","B0",i])}static banknoteTaken(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","B0","2a"])}static coinPurseEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D0","1"])}static coinPurseDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D0","0"])}static billPurseDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D1","0","0"])}static billPurseEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D1","1","1"])}static readTubes(n=null){var h,_,f;if(!o(h=u,d,C).call(h,n)||!o(_=u,d,F).call(_))return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[e,i,s,a,c,l]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];o(f=u,d,P).call(f,["2","D2",e,i,s,a,c,l])}static readBillPurse(n=null,t=null){var i,s,a,c;if(!o(i=u,d,C).call(i,n)||!o(s=u,d,F).call(s))return!1;let e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const l=e[Math.floor(Math.random()*31)];let h="0",_="0",f="0",y="0",E="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":h=l;break;case"50":_=l;break;case"100":f=l;break;case"200":y=l;break;case"500":E=l;break}else switch(n._recycler.bill){case 0:h=l;break;case 1:_=l;break;case 2:f=l;break;case 3:y=l;break;case 4:E=l;break}o(a=u,d,P).call(a,["2","D3",h,_,f,y,E,"0"])}else{const[l,h,_,f,y,E]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];o(c=u,d,P).call(c,["2","D3",l,h,_,f,y,E])}}static banknoteAccepted(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D4","1"])}static banknoteRejected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D4","0"])}static banknotesDispensed(n=null){var e,i,s,a;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,F).call(i))return!1;let t=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const c=t[Math.floor(Math.random()*30)];let l="0",h="0",_="0",f="0",y="0";switch(n._recycler.bill){case 0:l=c;break;case 1:h=c;break;case 2:_=c;break;case 3:f=c;break;case 4:y=c;break}o(s=u,d,P).call(s,["2","D5",l,h,_,f,y,"0"])}else{const[c,l,h,_,f,y]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];o(a=u,d,P).call(a,["2","D5",c,l,h,_,f,y])}}static coinsDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","D6"])}static relayOn(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DA","1"])}static relayOff(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DA","0"])}static nayaxEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","1"])}static nayaxDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","3"])}static nayaxCancelRequest(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","4"])}static nayaxSellApproved(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","5"])}static nayaxSellDenied(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","6"])}static nayaxEndSession(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","7"])}static nayaxCancelled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","8"])}static nayaxDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","A","0"])}static nayaxNotDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,P).call(i,["2","DD","A","1"])}static fullTray(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,P).call(i,["6","4F"])}static setConnection(n=null){var t;if(!o(t=u,d,C).call(t,n))return!1;n.__internal__.serial.connected=!0}};ot=new WeakMap,pt=new WeakMap,d=new WeakSet,cr=function(){if(u.enable===!1)throw new Error("Emulator is disabled");return u.enable},lr=function(n){if(typeof n!="object"||!(n instanceof Dt))throw new Error(`Type ${n.typeDevice} is not supported`);return u.instance=n,L(u,ot,n.typeDevice),L(u,pt,n.deviceNumber),!0},C=function(n=null){var t,e;return!o(t=u,d,cr).call(t)||n===null&&u.instance===null?!1:(u.instance===null&&o(e=u,d,lr).call(e,n),!0)},Tn=function(){if(I(u,ot)!=="locker")throw new Error("This function is only available for Locker devices");return!0},F=function(){if(I(u,ot)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},M=function(){if(I(u,ot)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},Ve=function(){if(I(u,ot)==="locker")throw new Error("This function is not available for Locker devices");return!0},P=function(n){u.instance.__emulate({code:n})},Sn=function(n,t=null){let e=n[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":e=n[1];break;case"1":e=n[2];break;case"2":e=n[3];break;case"5":e=n[4];break;case"10":e=n[5];break}return e},he=function(n,t=null){let e=n[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":e=n[0];break;case"50":e=n[1];break;case"100":e=n[2];break;case"200":e=n[3];break;case"500":e=n[4];break}return e},tt(u,d),lt(u,"enable",!1),lt(u,"instance",null),tt(u,ot,null),tt(u,pt,1);let be=u;var ya=Object.defineProperty,Gn=r=>{throw TypeError(r)},ma=(r,n,t)=>n in r?ya(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,ne=(r,n,t)=>ma(r,typeof n!="symbol"?n+"":n,t),wa=(r,n,t)=>n.has(r)||Gn("Cannot "+t),va=(r,n,t)=>n.has(r)?Gn("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,t),q=(r,n,t)=>(wa(r,n,"access private method"),t);const Z=[];for(let r=0;r<256;++r)Z.push((r+256).toString(16).slice(1));function Ea(r,n=0){return(Z[r[n+0]]+Z[r[n+1]]+Z[r[n+2]]+Z[r[n+3]]+"-"+Z[r[n+4]]+Z[r[n+5]]+"-"+Z[r[n+6]]+Z[r[n+7]]+"-"+Z[r[n+8]]+Z[r[n+9]]+"-"+Z[r[n+10]]+Z[r[n+11]]+Z[r[n+12]]+Z[r[n+13]]+Z[r[n+14]]+Z[r[n+15]]).toLowerCase()}let tn;const Pa=new Uint8Array(16);function Ca(){if(!tn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tn=crypto.getRandomValues.bind(crypto)}return tn(Pa)}const Ta=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Jn={randomUUID:Ta};function Sa(r,n,t){var e;if(Jn.randomUUID&&!r)return Jn.randomUUID();r=r||{};const i=r.random??((e=r.rng)==null?void 0:e.call(r))??Ca();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Ea(i)}class Qn extends CustomEvent{constructor(n,t){super(n,t)}}class Zn extends EventTarget{constructor(){super(...arguments),ne(this,"__listeners__",{debug:!1}),ne(this,"__debug__",!1)}dispatch(n,t=null){const e=new Qn(n,{detail:t});this.dispatchEvent(e),this.__debug__&&this.dispatchEvent(new Qn("debug",{detail:{type:n,data:t}}))}dispatchAsync(n,t=null,e=100){const i=this;setTimeout(()=>{i.dispatch(n,t)},e)}on(n,t){typeof this.__listeners__[n]<"u"&&!this.__listeners__[n]&&(this.__listeners__[n]=!0),this.addEventListener(n,t)}off(n,t){this.removeEventListener(n,t)}serialRegisterAvailableListener(n){this.__listeners__[n]||(this.__listeners__[n]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(n=>({type:n,listening:this.__listeners__[n]}))}}const en=class j extends Zn{constructor(){super(),["change"].forEach(n=>{this.serialRegisterAvailableListener(n)})}static $dispatchChange(n=null){n&&n.$checkAndDispatchConnection(),j.instance.dispatch("change",{devices:j.devices,dispatcher:n})}static typeError(n){const t=new Error;throw t.message=`Type ${n} is not supported`,t.name="DeviceTypeError",t}static registerType(n){typeof j.devices[n]>"u"&&(j.devices[n]={})}static add(n){const t=n.typeDevice;typeof j.devices[t]>"u"&&(j.devices[t]={});const e=n.uuid;if(typeof j.devices[t]>"u"&&j.typeError(t),j.devices[t][e])throw new Error(`Device with id ${e} already exists`);return j.devices[t][e]=n,j.$dispatchChange(n),Object.keys(j.devices[t]).indexOf(e)}static get(n,t){return typeof j.devices[n]>"u"&&(j.devices[n]={}),typeof j.devices[n]>"u"&&j.typeError(n),j.devices[n][t]}static getAll(n=null){return n===null?j.devices:(typeof j.devices[n]>"u"&&j.typeError(n),j.devices[n])}static getList(){return Object.values(j.devices).map(n=>Object.values(n)).flat()}static getByNumber(n,t){return typeof j.devices[n]>"u"&&j.typeError(n),Object.values(j.devices[n]).find(e=>e.deviceNumber===t)??null}static getCustom(n,t=1){return typeof j.devices[n]>"u"&&j.typeError(n),Object.values(j.devices[n]).find(e=>e.deviceNumber===t)??null}};ne(en,"instance"),ne(en,"devices",{});let Pt=en;Pt.instance||(Pt.instance=new Pt);function Yn(r=100){return new Promise(n=>setTimeout(()=>n(),r))}function ka(){return"serial"in navigator}const nn={baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"};var U,Ht,ie,rn,Nt,ti,ei,ni,ii,ri,si,ai,oi,ci,li,hi,ui;class xa extends Zn{constructor({filters:n=null,config_port:t=nn,no_device:e=1,device_listen_on_channel:i=1}={filters:null,config_port:nn,no_device:1,device_listen_on_channel:1}){if(super(),va(this,U),ne(this,"__internal__",{auto_response:!1,device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([]),as:"hex"},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:nn,queue:[],auto_response:["DD","DD"]},device:{type:"unknown",id:Sa(),listen_on_port:null},time:{response_connection:500,response_general:2e3},timeout:{until_response:0},interval:{reconnection:0}}),!("serial"in navigator))throw new Error("Web Serial not supported");n&&(this.serialFilters=n),t&&(this.serialConfigPort=t),e&&q(this,U,hi).call(this,e),i&&["number","string"].includes(typeof i)&&(this.listenOnChannel=i),q(this,U,ai).call(this),q(this,U,oi).call(this)}set listenOnChannel(n){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=n,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(n)}get lastAction(){return this.__internal__.serial.last_action}get listenOnChannel(){return this.__internal__.device.listen_on_port??1}set serialFilters(n){this.__internal__.serial.filters=n}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(n){this.__internal__.serial.config_port=n}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){const n=this.__internal__.serial.connected,t=q(this,U,Ht).call(this,this.__internal__.serial.port);return n&&!t&&q(this,U,ie).call(this,{error:"Port is closed, not readable or writable."}),this.__internal__.serial.connected=t,this.__internal__.serial.connected}get isDisconnected(){const n=this.__internal__.serial.connected,t=q(this,U,Ht).call(this,this.__internal__.serial.port);return!n&&t&&(this.dispatch("serial:connected"),Pt.$dispatchChange(this)),this.__internal__.serial.connected=t,!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}async timeout(n,t){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=t,this.__internal__.last_error.code=n,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),t==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{})):t==="connection:start"&&(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,await this.serialConnect()),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:n,action:t})}async disconnect(n=null){await this.serialDisconnect(),q(this,U,ie).call(this,n)}async connect(){return new Promise((n,t)=>{ka()||t("Web Serial not supported"),setTimeout(async()=>{await Yn(499),await this.serialConnect(),this.isConnected?n(`${this.typeDevice} device ${this.deviceNumber} connected`):t(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const n=this.__internal__.serial.reader,t=this.__internal__.serial.output_stream;n&&(await n.cancel().catch(e=>this.serialErrors(e)),await this.__internal__.serial.input_done),t&&(await t.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&this.__internal__.serial.port&&await this.__internal__.serial.port.close()}catch(n){this.serialErrors(n)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null}}getResponseAsArrayBuffer(){this.__internal__.serial.response.as="arraybuffer"}getResponseAsArrayHex(){this.__internal__.serial.response.as="hex"}getResponseAsUint8Array(){this.__internal__.serial.response.as="uint8"}getResponseAsString(){this.__internal__.serial.response.as="string"}async serialPortsSaved(n){const t=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const e=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[e]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(n){const t=n.toString().toLowerCase();switch(!0){case t.includes("must be handling a user gesture to show a permission request"):case t.includes("the port is closed."):case t.includes("the port is closed or is not writable"):case t.includes("the port is closed or is not readable"):case t.includes("the port is closed or is not readable/writable"):case t.includes("select another port please"):case t.includes("no port selected by the user"):case t.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),Pt.$dispatchChange(this);break;case t.includes("the port is already open."):case t.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case t.includes("cannot read properties of undefined (reading 'writable')"):case t.includes("cannot read properties of null (reading 'writable')"):case t.includes("cannot read property 'writable' of null"):case t.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case t.includes("'close' on 'serialport': a call to close() is already in progress."):break;case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case t.includes("the port is already closed."):break;case t.includes("the device has been lost"):this.dispatch("serial:lost",{}),Pt.$dispatchChange(this);break;case t.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(n);break}this.dispatch("serial:error",n)}async serialConnect(){try{this.dispatch("serial:connecting",{});const n=await q(this,U,ti).call(this);if(n.length>0)await this.serialPortsSaved(n);else{const i=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:i})}const t=this.__internal__.serial.port;if(!t)throw new Error("No port selected by the user");await t.open(this.serialConfigPort);const e=this;t.onconnect=i=>{console.log(i),e.dispatch("serial:connected",i),Pt.$dispatchChange(this),e.__internal__.serial.queue.length>0&&e.dispatch("internal:queue",{})},t.ondisconnect=async()=>{await e.disconnect()},await Yn(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await e.timeout(e.__internal__.serial.bytes_connection??[],"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await q(this,U,rn).call(this,this.__internal__.serial.bytes_connection??[]),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.__internal__.auto_response&&q(this,U,Nt).call(this,this.__internal__.serial.auto_response,null),await q(this,U,ri).call(this)}catch(n){this.serialErrors(n)}}async serialForget(){return await q(this,U,si).call(this)}decToHex(n){return typeof n=="string"&&(n=parseInt(n,10)),n.toString(16)}hexToDec(n){return parseInt(n,16)}hexMaker(n="00",t=2){return n.toString().padStart(t,"0").toLowerCase()}add0x(n){const t=[];return n.forEach((e,i)=>{t[i]="0x"+e}),t}bytesToHex(n){return this.add0x(Array.from(n,t=>this.hexMaker(t)))}async appendToQueue(n,t){const e=this.bytesToHex(n);if(["connect","connection:start"].includes(t)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:e,action:t}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(n=1){throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${n}`)}serialMessage(n){throw console.log(n),new Error("Method not implemented 'serialMessage'")}serialCorruptMessage(n,t){throw console.log(n,t),new Error("Method not implemented 'serialCorruptMessage'")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(n){let t=0;return n.forEach(e=>{t+=parseInt(e,16)}),t.toString(16)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){q(this,U,ui).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){if(!this.__internal__.serial.bytes_connection)throw new Error("No connection bytes defined");await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:n=[]}={code:[]}){if(n===null||n.length===0)throw new Error("No data to send");await this.appendToQueue(n,"custom")}stringToArrayHex(n){return Array.from(n).map(t=>t.charCodeAt(0).toString(16))}stringToArrayBuffer(n,t=`
1
+ (function(I,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(I=typeof globalThis<"u"?globalThis:I||self,B(I.WebSerial={}))})(this,function(I){"use strict";var Rc=Object.defineProperty;var sr=I=>{throw TypeError(I)};var Ic=(I,B,X)=>B in I?Rc(I,B,{enumerable:!0,configurable:!0,writable:!0,value:X}):I[B]=X;var _t=(I,B,X)=>Ic(I,typeof B!="symbol"?B+"":B,X),Pn=(I,B,X)=>B.has(I)||sr("Cannot "+X);var O=(I,B,X)=>(Pn(I,B,"read from private field"),X?X.call(I):B.get(I)),Y=(I,B,X)=>B.has(I)?sr("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(I):B.set(I,X),L=(I,B,X,Yt)=>(Pn(I,B,"write to private field"),Yt?Yt.call(I,X):B.set(I,X),X),o=(I,B,X)=>(Pn(I,B,"access private method"),X);var at,ut,d,ar,or,C,En,F,M,Ue,E,Cn,ce,oe,Me,cr,it,G,Et,R,lr,hr,ur,dr,Tn,pr,Ut,Lt,Le,Ve,qe,p,fr,gr,br,Sn,yr,mr,wr,vr,Pr,Er,Cr,Tr,Sr,kr,le,he,xr,ue,Ar,Vt,Dr,J,Rr,Ir,kn,Or,Br,Nr,xn,An,de,Dn,Mr,mt,wt,je,Rn,pe,In,On,Fr,Bn,Nn,Ur,Lr,Zt,Mn,Vr,qr,jr,He,Hr,Kr,Fn,Wr,$r,zr,Xr,Gr,Jr,Qr,Zr,Yr,Un,Ln,ts,es,ns,g,is,rs,ss,ct,Ke,as,os,cs,ls,hs,us,ds,ps,_s,fs,gs,bs,ys,ms,ws,vs,Ps,Es,Cs,Ts,Ss,ks,xs,As,Ds,Rs,ft,tt,We,et,vt,Is,Os,Bs,Ns,_e,Vn,qn,$e,ze,Ms,Gt,Ft,Jt,w,Fs,Us,Xe,Ls,Vs,qs,js,Hs,Ks,Ws,$s,jn,zs,Xs,Gs,Js,Qs,Zs,Ys,ta,ea,na,ia,ra,sa,aa,lt,Ge,oa,ca,la,ha,Hn,Je,ua,da,Kn,Wn,$n,Qt,pa,_a;function B(r=100){return new Promise(n=>setTimeout(()=>n(),r))}function X(){return"serial"in navigator}function Yt(){return"geolocation"in navigator}function fa(){return"crypto"in window}function Qe(r=1){return r*1e3}function St(r){return r==null||r===""}const u=class u{static status(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(O(u,at)){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+O(u,ut)).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}o(i=u,d,E).call(i,t)}static dispensed(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(O(u,at)){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}o(i=u,d,E).call(i,t)}static notDispensed(n=null){var e,i;if(!o(e=u,d,C).call(e,n))return!1;let t=[];switch(O(u,at)){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}o(i=u,d,E).call(i,t)}static gateInactive(n=null){var t;if(!o(t=u,d,C).call(t,n)||!o(this,d,En).call(this))return!1;o(this,d,E).call(this,["0","7","5","5","5"])}static gateConfigured(n=null){var t;if(!o(t=u,d,C).call(t,n)||!o(this,d,En).call(this))return!1;o(this,d,E).call(this,["0","6"])}static keyPressed(n=null){var s,a,c;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,M).call(a))return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],e=(128+O(u,ut)).toString(16),i=Math.floor(Math.random()*15);o(c=u,d,E).call(c,["2",e,"54",t[i]])}static doorOpened(n=null){var i,s;if(!o(i=u,d,C).call(i,n)||!o(this,d,Ue).call(this))return!1;let t=[];const e=(128+O(u,ut)).toString(16);switch(O(u,at)){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",e,"50","4F"];break}o(s=u,d,E).call(s,t)}static doorClosed(n=null){var i,s;if(!o(i=u,d,C).call(i,n)||!o(this,d,Ue).call(this))return!1;let t=[];const e=(128+O(u,ut)).toString(16);switch(O(u,at)){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",e,"50","43"];break}o(s=u,d,E).call(s,t)}static channelDisconnected(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+O(u,ut)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FD"])}static channelConnected(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+O(u,ut)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FC"])}static channelEmpty(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+O(u,ut)).toString(16);o(s=u,d,E).call(s,["2",t,"43","43","43","FF"])}static workingTemperature(n=null){var e,i,s;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,M).call(i))return!1;const t=(128+O(u,ut)).toString(16);o(s=u,d,E).call(s,["2",t,"43","54","16"])}static currentTemperature(n=null){var i,s,a;if(!o(i=u,d,C).call(i,n)||!o(s=u,d,Ue).call(s))return!1;let t=[];const e=(128+O(u,ut)).toString(16);switch(O(u,at)){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",e,"43","74","2B","30","39","2E","31","7F","43"];break}o(a=u,d,E).call(a,t)}static ready(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","30"])}static busy(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","31"])}static invalidTray(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","32"])}static invalidChannel(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","33"])}static emptyChannel(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","34"])}static elevatorJam(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","35"])}static elevatorMalfunction(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","36"])}static phototransistorFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","37"])}static allChannelsEmpty(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","38"])}static productDetectorFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","39"])}static displayDisconnected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","41"])}static productUnderElevator(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","42"])}static elevatorSettingAlarm(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","43"])}static buttonPanelFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","44"])}static errorWritingEeprom(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","45"])}static errorControlTemperature(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","46"])}static thermometerDisconnected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","47"])}static thermometerMisconfigured(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","48"])}static thermometerFailure(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","49"])}static errorExtractorConsumption(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4A"])}static channelSearchError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4B"])}static productExitMouthSearchError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4C"])}static elevatorInteriorLocked(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4D"])}static productDetectorVerifierError(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4E"])}static waitingForProductRecall(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4F"])}static productExpiredByTemperature(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","50"])}static faultyAutomaticDoor(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","51"])}static rejectLever(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","A0","1"])}static resetCoinPurse(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","A0","2"])}static coinInsertedBox(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["40","41","42","43","44","45"],i=o(c=u,d,Cn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",i])}static coinInsertedTube(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["50","51","52","53","54","55"],i=o(c=u,d,Cn).call(c,e,t);o(l=u,d,E).call(l,["2","A0",i])}static banknoteInsertedStacker(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["80","81","82","83","84"],i=o(c=u,d,ce).call(c,e,t);o(l=u,d,E).call(l,["2","B0",i])}static banknoteInsertedEscrow(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["90","91","92","93","94"],i=o(c=u,d,ce).call(c,e,t);o(l=u,d,E).call(l,["2","B0",i])}static banknoteEjected(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["A0","A1","A2","A3","A4"],i=o(c=u,d,ce).call(c,e,t);o(l=u,d,E).call(l,["2","B0",i])}static banknoteInsertedRecycler(n=null,t=null){var s,a,c,l;if(!o(s=u,d,C).call(s,n)||!o(a=u,d,F).call(a))return!1;const e=["B0","B1","B2","B3","B4"],i=o(c=u,d,ce).call(c,e,t);o(l=u,d,E).call(l,["2","B0",i])}static banknoteTaken(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","B0","2a"])}static coinPurseEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D0","1"])}static coinPurseDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D0","0"])}static billPurseDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D1","0","0"])}static billPurseEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D1","1","1"])}static readTubes(n=null){var h,_,f;if(!o(h=u,d,C).call(h,n)||!o(_=u,d,F).call(_))return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[e,i,s,a,c,l]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];o(f=u,d,E).call(f,["2","D2",e,i,s,a,c,l])}static readBillPurse(n=null,t=null){var i,s,a,c;if(!o(i=u,d,C).call(i,n)||!o(s=u,d,F).call(s))return!1;let e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const l=e[Math.floor(Math.random()*31)];let h="0",_="0",f="0",y="0",P="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":h=l;break;case"50":_=l;break;case"100":f=l;break;case"200":y=l;break;case"500":P=l;break}else switch(n._recycler.bill){case 0:h=l;break;case 1:_=l;break;case 2:f=l;break;case 3:y=l;break;case 4:P=l;break}o(a=u,d,E).call(a,["2","D3",h,_,f,y,P,"0"])}else{const[l,h,_,f,y,P]=[e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*30)],e[Math.floor(Math.random()*2)],e[Math.floor(Math.random())],e[Math.floor(Math.random())]];o(c=u,d,E).call(c,["2","D3",l,h,_,f,y,P])}}static banknoteAccepted(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D4","1"])}static banknoteRejected(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D4","0"])}static banknotesDispensed(n=null){var e,i,s,a;if(!o(e=u,d,C).call(e,n)||!o(i=u,d,F).call(i))return!1;let t=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(n._recycler.ict){const c=t[Math.floor(Math.random()*30)];let l="0",h="0",_="0",f="0",y="0";switch(n._recycler.bill){case 0:l=c;break;case 1:h=c;break;case 2:_=c;break;case 3:f=c;break;case 4:y=c;break}o(s=u,d,E).call(s,["2","D5",l,h,_,f,y,"0"])}else{const[c,l,h,_,f,y]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];o(a=u,d,E).call(a,["2","D5",c,l,h,_,f,y])}}static coinsDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","D6"])}static relayOn(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DA","1"])}static relayOff(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DA","0"])}static nayaxEnabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","1"])}static nayaxDisabled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","3"])}static nayaxCancelRequest(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","4"])}static nayaxSellApproved(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","5"])}static nayaxSellDenied(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","6"])}static nayaxEndSession(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","7"])}static nayaxCancelled(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","8"])}static nayaxDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","A","0"])}static nayaxNotDispensed(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,F).call(e))return!1;o(i=u,d,E).call(i,["2","DD","A","1"])}static fullTray(n=null){var t,e,i;if(!o(t=u,d,C).call(t,n)||!o(e=u,d,M).call(e))return!1;o(i=u,d,E).call(i,["6","4F"])}static setConnection(n=null){var t;if(!o(t=u,d,C).call(t,n))return!1;n.__internal__.serial.connected=!0}};at=new WeakMap,ut=new WeakMap,d=new WeakSet,ar=function(){if(u.enable===!1)throw new Error("Emulator is disabled");return u.enable},or=function(n){if(typeof n!="object"||!(n instanceof xt))throw new Error(`Type ${n.typeDevice} is not supported`);return u.instance=n,L(u,at,n.typeDevice),L(u,ut,n.deviceNumber),!0},C=function(n=null){var t,e;return!o(t=u,d,ar).call(t)||n===null&&u.instance===null?!1:(u.instance===null&&o(e=u,d,or).call(e,n),!0)},En=function(){if(O(u,at)!=="locker")throw new Error("This function is only available for Locker devices");return!0},F=function(){if(O(u,at)!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0},M=function(){if(O(u,at)!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0},Ue=function(){if(O(u,at)==="locker")throw new Error("This function is not available for Locker devices");return!0},E=function(n){u.instance.__emulate({code:n})},Cn=function(n,t=null){let e=n[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":e=n[1];break;case"1":e=n[2];break;case"2":e=n[3];break;case"5":e=n[4];break;case"10":e=n[5];break}return e},ce=function(n,t=null){let e=n[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":e=n[0];break;case"50":e=n[1];break;case"100":e=n[2];break;case"200":e=n[3];break;case"500":e=n[4];break}return e},Y(u,d),_t(u,"enable",!1),_t(u,"instance",null),Y(u,at,null),Y(u,ut,1);let fe=u;var ga=Object.defineProperty,zn=r=>{throw TypeError(r)},ba=(r,n,t)=>n in r?ga(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t,te=(r,n,t)=>ba(r,typeof n!="symbol"?n+"":n,t),ya=(r,n,t)=>n.has(r)||zn("Cannot "+t),ma=(r,n,t)=>n.has(r)?zn("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,t),q=(r,n,t)=>(ya(r,n,"access private method"),t);const Q=[];for(let r=0;r<256;++r)Q.push((r+256).toString(16).slice(1));function wa(r,n=0){return(Q[r[n+0]]+Q[r[n+1]]+Q[r[n+2]]+Q[r[n+3]]+"-"+Q[r[n+4]]+Q[r[n+5]]+"-"+Q[r[n+6]]+Q[r[n+7]]+"-"+Q[r[n+8]]+Q[r[n+9]]+"-"+Q[r[n+10]]+Q[r[n+11]]+Q[r[n+12]]+Q[r[n+13]]+Q[r[n+14]]+Q[r[n+15]]).toLowerCase()}let Ze;const va=new Uint8Array(16);function Pa(){if(!Ze){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ze=crypto.getRandomValues.bind(crypto)}return Ze(va)}const Ea=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Xn={randomUUID:Ea};function Ca(r,n,t){var e;if(Xn.randomUUID&&!r)return Xn.randomUUID();r=r||{};const i=r.random??((e=r.rng)==null?void 0:e.call(r))??Pa();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,wa(i)}class Gn extends CustomEvent{constructor(n,t){super(n,t)}}class Jn extends EventTarget{constructor(){super(...arguments),te(this,"__listeners__",{debug:!1}),te(this,"__debug__",!1)}dispatch(n,t=null){const e=new Gn(n,{detail:t});this.dispatchEvent(e),this.__debug__&&this.dispatchEvent(new Gn("debug",{detail:{type:n,data:t}}))}dispatchAsync(n,t=null,e=100){const i=this;setTimeout(()=>{i.dispatch(n,t)},e)}on(n,t){typeof this.__listeners__[n]<"u"&&!this.__listeners__[n]&&(this.__listeners__[n]=!0),this.addEventListener(n,t)}off(n,t){this.removeEventListener(n,t)}serialRegisterAvailableListener(n){this.__listeners__[n]||(this.__listeners__[n]=!1)}get availableListeners(){return Object.keys(this.__listeners__).sort().map(n=>({type:n,listening:this.__listeners__[n]}))}}const Ye=class j extends Jn{constructor(){super(),["change"].forEach(n=>{this.serialRegisterAvailableListener(n)})}static $dispatchChange(n=null){n&&n.$checkAndDispatchConnection(),j.instance.dispatch("change",{devices:j.devices,dispatcher:n})}static typeError(n){const t=new Error;throw t.message=`Type ${n} is not supported`,t.name="DeviceTypeError",t}static registerType(n){typeof j.devices[n]>"u"&&(j.devices[n]={})}static add(n){const t=n.typeDevice;typeof j.devices[t]>"u"&&(j.devices[t]={});const e=n.uuid;if(typeof j.devices[t]>"u"&&j.typeError(t),j.devices[t][e])throw new Error(`Device with id ${e} already exists`);return j.devices[t][e]=n,j.$dispatchChange(n),Object.keys(j.devices[t]).indexOf(e)}static get(n,t){return typeof j.devices[n]>"u"&&(j.devices[n]={}),typeof j.devices[n]>"u"&&j.typeError(n),j.devices[n][t]}static getAll(n=null){return n===null?j.devices:(typeof j.devices[n]>"u"&&j.typeError(n),j.devices[n])}static getList(){return Object.values(j.devices).map(n=>Object.values(n)).flat()}static getByNumber(n,t){return typeof j.devices[n]>"u"&&j.typeError(n),Object.values(j.devices[n]).find(e=>e.deviceNumber===t)??null}static getCustom(n,t=1){return typeof j.devices[n]>"u"&&j.typeError(n),Object.values(j.devices[n]).find(e=>e.deviceNumber===t)??null}};te(Ye,"instance"),te(Ye,"devices",{});let k=Ye;k.instance||(k.instance=new k);function Qn(r=100){return new Promise(n=>setTimeout(()=>n(),r))}function Ta(){return"serial"in navigator}const tn={baudRate:9600,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"};var U,qt,ee,en,It,Zn,Yn,ti,ei,ni,ii,ri,si,ai,oi,ci,li;class Sa extends Jn{constructor({filters:n=null,config_port:t=tn,no_device:e=1,device_listen_on_channel:i=1}={filters:null,config_port:tn,no_device:1,device_listen_on_channel:1}){if(super(),ma(this,U),te(this,"__internal__",{auto_response:!1,device_number:1,aux_port_connector:0,last_error:{message:null,action:null,code:null,no_code:0},serial:{connected:!1,port:null,last_action:null,response:{length:null,buffer:new Uint8Array([]),as:"hex"},reader:null,input_done:null,output_done:null,input_stream:null,output_stream:null,keep_reading:!0,time_until_send_bytes:void 0,delay_first_connection:200,bytes_connection:null,filters:[],config_port:tn,queue:[],auto_response:["DD","DD"]},device:{type:"unknown",id:Ca(),listen_on_port:null},time:{response_connection:500,response_general:2e3},timeout:{until_response:0},interval:{reconnection:0}}),!("serial"in navigator))throw new Error("Web Serial not supported");n&&(this.serialFilters=n),t&&(this.serialConfigPort=t),e&&q(this,U,ci).call(this,e),i&&["number","string"].includes(typeof i)&&(this.listenOnChannel=i),q(this,U,ri).call(this),q(this,U,si).call(this)}set listenOnChannel(n){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>255)throw new Error("Invalid port number");this.__internal__.device.listen_on_port=n,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(n)}get lastAction(){return this.__internal__.serial.last_action}get listenOnChannel(){return this.__internal__.device.listen_on_port??1}set serialFilters(n){this.__internal__.serial.filters=n}get serialFilters(){return this.__internal__.serial.filters}set serialConfigPort(n){this.__internal__.serial.config_port=n}get serialConfigPort(){return this.__internal__.serial.config_port}get isConnected(){const n=this.__internal__.serial.connected,t=q(this,U,qt).call(this,this.__internal__.serial.port);return n&&!t&&q(this,U,ee).call(this,{error:"Port is closed, not readable or writable."}),this.__internal__.serial.connected=t,this.__internal__.serial.connected}get isDisconnected(){const n=this.__internal__.serial.connected,t=q(this,U,qt).call(this,this.__internal__.serial.port);return!n&&t&&(this.dispatch("serial:connected"),k.$dispatchChange(this)),this.__internal__.serial.connected=t,!this.__internal__.serial.connected}get deviceNumber(){return this.__internal__.device_number}get uuid(){return this.__internal__.device.id}get typeDevice(){return this.__internal__.device.type}get queue(){return this.__internal__.serial.queue}async timeout(n,t){this.__internal__.last_error.message="Operation response timed out.",this.__internal__.last_error.action=t,this.__internal__.last_error.code=n,this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0),t==="connect"?(this.__internal__.serial.connected=!1,this.dispatch("serial:reconnect",{}),k.$dispatchChange(this)):t==="connection:start"&&(await this.serialDisconnect(),this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector+=1,k.$dispatchChange(this),await this.serialConnect()),this.dispatch("serial:timeout",{...this.__internal__.last_error,bytes:n,action:t})}async disconnect(n=null){await this.serialDisconnect(),q(this,U,ee).call(this,n)}async connect(){return new Promise((n,t)=>{Ta()||t("Web Serial not supported"),setTimeout(async()=>{await Qn(499),await this.serialConnect(),this.isConnected?n(`${this.typeDevice} device ${this.deviceNumber} connected`):t(`${this.typeDevice} device ${this.deviceNumber} not connected`)},1)})}async serialDisconnect(){try{const n=this.__internal__.serial.reader,t=this.__internal__.serial.output_stream;n&&(await n.cancel().catch(e=>this.serialErrors(e)),await this.__internal__.serial.input_done),t&&(await t.getWriter().close(),await this.__internal__.serial.output_done),this.__internal__.serial.connected&&this.__internal__.serial&&this.__internal__.serial.port&&await this.__internal__.serial.port.close()}catch(n){this.serialErrors(n)}finally{this.__internal__.serial.reader=null,this.__internal__.serial.input_done=null,this.__internal__.serial.output_stream=null,this.__internal__.serial.output_done=null,this.__internal__.serial.connected=!1,this.__internal__.serial.port=null,k.$dispatchChange(this)}}getResponseAsArrayBuffer(){this.__internal__.serial.response.as="arraybuffer"}getResponseAsArrayHex(){this.__internal__.serial.response.as="hex"}getResponseAsUint8Array(){this.__internal__.serial.response.as="uint8"}getResponseAsString(){this.__internal__.serial.response.as="string"}async serialPortsSaved(n){const t=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const e=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[e]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}serialErrors(n){const t=n.toString().toLowerCase();switch(!0){case t.includes("must be handling a user gesture to show a permission request"):case t.includes("the port is closed."):case t.includes("the port is closed or is not writable"):case t.includes("the port is closed or is not readable"):case t.includes("the port is closed or is not readable/writable"):case t.includes("select another port please"):case t.includes("no port selected by the user"):case t.includes("this readable stream reader has been released and cannot be used to cancel its previous owner stream"):this.dispatch("serial:need-permission",{}),k.$dispatchChange(this);break;case t.includes("the port is already open."):case t.includes("failed to open serial port"):this.serialDisconnect().then(async()=>{this.__internal__.aux_port_connector+=1,await this.serialConnect()});break;case t.includes("cannot read properties of undefined (reading 'writable')"):case t.includes("cannot read properties of null (reading 'writable')"):case t.includes("cannot read property 'writable' of null"):case t.includes("cannot read property 'writable' of undefined"):this.serialDisconnect().then(async()=>{await this.serialConnect()});break;case t.includes("'close' on 'serialport': a call to close() is already in progress."):break;case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):break;case t.includes("the port is already closed."):break;case t.includes("the device has been lost"):this.dispatch("serial:lost",{}),k.$dispatchChange(this);break;case t.includes("navigator.serial is undefined"):this.dispatch("serial:unsupported",{});break;default:console.error(n);break}this.dispatch("serial:error",n)}async serialConnect(){try{this.dispatch("serial:connecting",{});const n=await q(this,U,Zn).call(this);if(n.length>0)await this.serialPortsSaved(n);else{const i=this.serialFilters;this.__internal__.serial.port=await navigator.serial.requestPort({filters:i})}const t=this.__internal__.serial.port;if(!t)throw new Error("No port selected by the user");await t.open(this.serialConfigPort);const e=this;t.onconnect=i=>{console.log(i),e.dispatch("serial:connected",i),k.$dispatchChange(this),e.__internal__.serial.queue.length>0&&e.dispatch("internal:queue",{})},t.ondisconnect=async()=>{await e.disconnect()},await Qn(this.__internal__.serial.delay_first_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await e.timeout(e.__internal__.serial.bytes_connection??[],"connection:start")},this.__internal__.time.response_connection),this.__internal__.serial.last_action="connect",await q(this,U,en).call(this,this.__internal__.serial.bytes_connection??[]),this.dispatch("serial:sent",{action:"connect",bytes:this.__internal__.serial.bytes_connection}),this.__internal__.auto_response&&q(this,U,It).call(this,this.__internal__.serial.auto_response,null),await q(this,U,ni).call(this)}catch(n){this.serialErrors(n)}}async serialForget(){return await q(this,U,ii).call(this)}decToHex(n){return typeof n=="string"&&(n=parseInt(n,10)),n.toString(16)}hexToDec(n){return parseInt(n,16)}hexMaker(n="00",t=2){return n.toString().padStart(t,"0").toLowerCase()}add0x(n){const t=[];return n.forEach((e,i)=>{t[i]="0x"+e}),t}bytesToHex(n){return this.add0x(Array.from(n,t=>this.hexMaker(t)))}async appendToQueue(n,t){const e=this.bytesToHex(n);if(["connect","connection:start"].includes(t)){if(this.__internal__.serial.connected)return;await this.serialConnect();return}this.__internal__.serial.queue.push({bytes:e,action:t}),this.dispatch("internal:queue",{})}serialSetConnectionConstant(n=1){throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${n}`)}serialMessage(n){throw console.log(n),new Error("Method not implemented 'serialMessage'")}serialCorruptMessage(n,t){throw console.log(n,t),new Error("Method not implemented 'serialCorruptMessage'")}clearSerialQueue(){this.__internal__.serial.queue=[]}sumHex(n){let t=0;return n.forEach(e=>{t+=parseInt(e,16)}),t.toString(16)}toString(){return JSON.stringify({__class:this.typeDevice,device_number:this.deviceNumber,uuid:this.uuid,connected:this.isConnected,connection:this.__internal__.serial.bytes_connection})}softReload(){q(this,U,li).call(this),this.dispatch("serial:soft-reload",{})}async sendConnect(){if(!this.__internal__.serial.bytes_connection)throw new Error("No connection bytes defined");await this.appendToQueue(this.__internal__.serial.bytes_connection,"connect")}async sendCustomCode({code:n=[]}={code:[]}){if(n===null||n.length===0)throw new Error("No data to send");await this.appendToQueue(n,"custom")}stringToArrayHex(n){return Array.from(n).map(t=>t.charCodeAt(0).toString(16))}stringToArrayBuffer(n,t=`
2
2
  `){return this.parseStringToTextEncoder(n,t).buffer}parseStringToTextEncoder(n="",t=`
3
3
  `){const e=new TextEncoder;return n+=t,e.encode(n)}parseStringToBytes(n="",t=`
4
- `){const e=this.parseStringToTextEncoder(n,t);return Array.from(e).map(i=>i.toString(16))}parseUint8ToHex(n){return Array.from(n).map(t=>t.toString(16))}parseHexToUint8(n){return new Uint8Array(n.map(t=>parseInt(t,16)))}stringArrayToUint8Array(n){const t=[];return n.forEach(e=>{const i=e.replace("0x","");t.push(parseInt(i,16))}),new Uint8Array(t)}parseUint8ArrayToString(n){const t=this.stringArrayToUint8Array(n);n=this.parseUint8ToHex(t);const e=n.map(i=>parseInt(i,16));return String.fromCharCode(...e).replace(/[\n\r]+/g,"")}hexToAscii(n){const t=n.toString();let e="";for(let i=0;i<t.length;i+=2)e+=String.fromCharCode(parseInt(t.substring(i,2),16));return e}asciiToHex(n){const t=[];for(let e=0,i=n.length;e<i;e++){const s=Number(n.charCodeAt(e)).toString(16);t.push(s)}return t.join("")}$checkAndDispatchConnection(){return this.isConnected}}U=new WeakSet,Ht=function(r){return!!(r&&r.readable&&r.writable)},ie=function(r=null){this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",r),Pt.$dispatchChange(this)},rn=async function(r){const n=this.__internal__.serial.port;if(!n||n&&(!n.readable||!n.writable))throw q(this,U,ie).call(this,{error:"Port is closed, not readable or writable."}),new Error("The port is closed or is not readable/writable");const t=this.stringArrayToUint8Array(r);if(n.writable===null)return;const e=n.writable.getWriter();await e.write(t),e.releaseLock()},Nt=function(r=[],n=null){if(r&&r.length>0){const t=this.__internal__.serial.connected;this.__internal__.serial.connected=q(this,U,Ht).call(this,this.__internal__.serial.port),!t&&this.__internal__.serial.connected&&(this.dispatch("serial:connected"),Pt.$dispatchChange(this)),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const i in r)e.push(r[i].toString().padStart(2,"0").toLowerCase());if(this.__internal__.serial.response.as==="hex")this.serialMessage(e);else if(this.__internal__.serial.response.as==="uint8")this.serialMessage(this.parseHexToUint8(this.add0x(e)));else if(this.__internal__.serial.response.as==="string")this.serialMessage(this.parseUint8ArrayToString(this.add0x(e)));else{const i=this.stringToArrayBuffer(this.parseUint8ArrayToString(this.add0x(e)));this.serialMessage(i)}}else this.serialCorruptMessage(r,n);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},ti=async function(){const r=this.serialFilters,n=await navigator.serial.getPorts({filters:r});return r.length===0?n:n.filter(t=>{const e=t.getInfo();return r.some(i=>e.usbProductId===i.usbProductId&&e.usbVendorId===i.usbVendorId)}).filter(t=>!q(this,U,Ht).call(this,t))},ei=function(r){if(r){const n=this.__internal__.serial.response.buffer,t=new Uint8Array(n.length+r.byteLength);t.set(n,0),t.set(new Uint8Array(r),n.length),this.__internal__.serial.response.buffer=t}},ni=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{const r=[];for(const n in this.__internal__.serial.response.buffer)r.push(this.__internal__.serial.response.buffer[n].toString(16));this.__internal__.serial.response.buffer&&q(this,U,Nt).call(this,r),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},ii=async function(){if(this.__internal__.serial.response.length!==null){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length){const r=[];for(const n in this.__internal__.serial.response.buffer)r.push(this.__internal__.serial.response.buffer[n].toString(16));q(this,U,Nt).call(this,r),this.__internal__.serial.response.buffer=new Uint8Array(0)}else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let r=new Uint8Array(0);for(let t=0;t<this.__internal__.serial.response.length;t++)r[t]=this.__internal__.serial.response.buffer[t];if(r.length===this.__internal__.serial.response.length){const t=[];for(const e in r)t.push(r[e].toString(16));q(this,U,Nt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0);return}r=new Uint8Array(0);const n=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===n){for(let t=14;t<n;t++)r[t-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[t];if(r.length===this.__internal__.serial.response.length){const t=[];for(const e in r)t.push(r[e].toString(16));q(this,U,Nt).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)}}}}},ri=async function(){const r=this.__internal__.serial.port;if(!r||!r.readable)throw new Error("Port is not readable");for(;r.readable&&this.__internal__.serial.keep_reading;){const n=r.readable.getReader();this.__internal__.serial.reader=n;try{let t=!0;for(;t;){const{value:e,done:i}=await n.read();if(i){n.releaseLock(),this.__internal__.serial.keep_reading=!1,t=!1;break}q(this,U,ei).call(this,e),this.__internal__.serial.response.length===null?await q(this,U,ni).call(this):await q(this,U,ii).call(this)}}catch(t){this.serialErrors(t)}finally{n.releaseLock()}}this.__internal__.serial.keep_reading=!0,this.__internal__.serial.port&&await this.__internal__.serial.port.close()},si=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in SerialPort.prototype&&this.__internal__.serial.port?(await this.__internal__.serial.port.forget(),!0):!1},ai=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(r=>{this.serialRegisterAvailableListener(r)})},oi=function(){const r=this;this.on("internal:queue",async()=>{var n;await q(n=r,U,li).call(n)}),q(this,U,ci).call(this)},ci=function(){const r=this;navigator.serial.addEventListener("connect",async()=>{r.isDisconnected&&await r.serialConnect().catch(()=>{})})},li=async function(){if(!q(this,U,Ht).call(this,this.__internal__.serial.port)){q(this,U,ie).call(this,{error:"Port is closed, not readable or writable."}),await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const r=this.__internal__.serial.queue[0];let n=this.__internal__.time.response_general;r.action==="connect"&&(n=this.__internal__.time.response_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(r.bytes,r.action)},n),this.__internal__.serial.last_action=r.action??"unknown",await q(this,U,rn).call(this,r.bytes),this.dispatch("serial:sent",{action:r.action,bytes:r.bytes}),this.__internal__.auto_response&&q(this,U,Nt).call(this,this.__internal__.serial.auto_response,null);const t=[...this.__internal__.serial.queue];this.__internal__.serial.queue=t.splice(1)},hi=function(r=1){this.__internal__.device_number=r,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(r)},ui=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}};const B=class B extends Pt{static typeError(n){const t=new Error;throw t.message=`Type ${n} is not supported`,t.name="DeviceTypeError",t}static addCustom(n,t){typeof B.devices[n]>"u"&&(B.devices[n]=[]),B.add(t)}static add(n){const t=n.typeDevice,e=n.uuid;if(typeof B.devices[t]>"u")return B.typeError(t);if(B.$dispatchChange(n),!B.devices[t][e])return B.devices[t][e]=n,B.$dispatchChange(n),B.devices[t].indexOf(n)}static get(n,t){return typeof B.devices[n]>"u"?B.typeError(n):B.devices[n][t]}static getJofemarByUuid(n){return B.get("jofemar",n)}static getLockerByUuid(n){return B.get("locker",n)}static getRelayByUuid(n){return B.get("relay",n)}static getBoardroidByUuid(n){return B.get("boardroid",n)}static getArduinoByUuid(n){return B.get("arduino",n)}static getPinPadByUuid(n){return B.get("pinpad",n)}static getAll(n=null){return n===null?B.devices:typeof B.devices[n]>"u"?B.typeError(n):B.devices[n]}static getList(){return Object.values(B.devices).map(t=>Object.values(t)).flat()}static getJofemar(n=1){return Object.values(B.devices.jofemar).find(e=>e.deviceNumber===n)??null}static getBoardroid(n=1){return Object.values(B.devices.boardroid).find(e=>e.deviceNumber===n)??null}static getLocker(n=1){return Object.values(B.devices.locker).find(e=>e.deviceNumber===n)??null}static getRelay(n=1){return Object.values(B.devices.relay).find(e=>e.deviceNumber===n)??null}static getArduino(n=1){return Object.values(B.devices.arduino).find(e=>e.deviceNumber===n)??null}static getPinPad(n=1){return Object.values(B.devices.pinpad).find(e=>e.deviceNumber===n)??null}static getCustom(n,t=1){return typeof B.devices[n]>"u"?B.typeError(n):Object.values(B.devices[n]).find(i=>i.deviceNumber===t)??null}};lt(B,"instance",null),lt(B,"devices",{relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[]});let G=B;G.instance||(G.instance=new G);class Dt extends xa{constructor(n){super(n),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,t){await super.timeout(n,t),t==="dispense"&&(this.__internal__.dispense.status="no-response")}async serialPortsSaved(n){const t=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const e=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[e]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await O(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const n=this;return new Promise(t=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(n.__internal__.dispense.status){case null:n.internalDispensingProcess()===!1&&(n.internalClearSensing(),n.dispatch("not-dispensed",{reason:"timeout"}),t({status:!1,error:"timeout"}));break;case!0:n.internalClearSensing(),n.__internal__.dispense.status=!0,n.dispatch("dispensed",{}),t({status:!0,error:null});break;case!1:n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-stock"}),t({status:!1,error:null});break;case"elevator-locked":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"elevator-locked"}),t({status:!1,error:"elevator-locked"});break;case"no-response":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-response"}),t({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!be.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(t=>{const e=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(e),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();t(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),G.$dispatchChange(this),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const t=[];for(const e in n.code)t.push(n.code[e].toString().padStart(2,"0").toLowerCase());this.serialMessage(t)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}}class Aa extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});tt(this,Ue);tt(this,le,{activate:["A0","01","01","A2"],deactivate:["A0","01","00","A1"]});if(this.__internal__.device.type="relay",this.__internal__.auto_response=!0,G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);o(this,Ue,hr).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((i,s)=>{s!==3&&(e+=parseInt(i,16))}),e.toString(16).toUpperCase()}serialSetConnectionConstant(t=1){const e=["A0","01","00","A1"];return e[1]=this.hexMaker(this.decToHex(t.toString())),e[3]=this.serialRelaySumHex(e),this.add0x(e)}async turnOn(){const t=I(this,le).activate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=I(this,le).deactivate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){const i=this;t?(await i.turnOff(),await O(e),await i.turnOn()):(await i.turnOn(),await O(e),await i.turnOff())}}le=new WeakMap,Ue=new WeakSet,hr=function(){G.add(this)};class Da extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1,device_listen_on_port:s=3}={}){super({filters:t,config_port:e,no_device:i,device_listen_on_port:s});tt(this,D);tt(this,rt,!1);tt(this,J,0);tt(this,Tt,0);if(this.__internal__.device.type="locker",G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,o(this,D,dr).call(this),o(this,D,ur).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(t[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),I(this,rt)&&I(this,J)>=89?(e.finished_test=!0,L(this,rt,!1),L(this,J,0)):I(this,rt)&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),I(this,rt)&&I(this,J)>=89?(e.finished_test=!0,L(this,rt,!1),L(this,J,0)):I(this,rt)&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),I(this,rt)&&I(this,J)>=89?(e.finished_test=!0,L(this,rt,!1),L(this,J,0)):I(this,rt)&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=3){return this.add0x(this.serialLockerGetConnectionCmd(t))}serialLockerCmdMaker(t){const e=this.__internal__.device.milliseconds;let i=null;try{i=new Uint8Array(t.length+8),i.set(t,2),i[0]=2,i[1]=t.length+4,i[i.length-2]=3;let s=0;for(let l=1;l<t.length;l++)s+=t[l],s*=parseInt(Math.pow(2,l-1).toString());i[t.length+2]=s%256,i[t.length+3]=e*3%256,i[t.length+4]=e*8%256;let a=0;for(let l=3;l<t.length+5;l++)a+=i[l];i[t.length+5]=a%256;let c=0;for(let l=0;l<i.length-1;l++)c^=i[l];i[i.length-1]=c}catch(s){this.serialErrors(`Error generating command: ${s.message}`),i=null}return i}serialLockerHexCmd(t){const e=this.serialLockerCmdMaker(t),i=[];for(let s=0;s<e.length;s++)i.push(this.decToHex(e[s]));return i}serialLockerGetConnectionCmd(t=3){if(t<1||t>255)throw new Error("Invalid port number");return this.serialLockerHexCmd(new Uint8Array([0,t]))}parseCellToColumnRow(t){const e=Math.floor((t-1)/10)+1;let i=t%8;return i===0&&(i=8),[e,i]}async dispense({cell:t=1}={}){t=o(this,D,Vt).call(this,t);const e=o(this,D,fr).call(this,t);return await this.internalDispense(e)}async status({cell:t=1}={}){t=o(this,D,Vt).call(this,t);const e=o(this,D,pr).call(this,t);return await this.appendToQueue(e,"status")}async lightScan({since:t=0,until:e=10}={}){if(t<0||t>10)throw new Error("Invalid since number");if(e<0||e>10)throw new Error("Invalid until number");const i=o(this,D,_r).call(this,t,e);return await this.appendToQueue(i,"light-scan")}async enable({cell:t=1}={}){t=o(this,D,Vt).call(this,t);const[e,i]=this.parseCellToColumnRow(t),s=o(this,D,kn).call(this,{enable:!0,column:e,row:i});await this.appendToQueue(s,"activate")}async disable({cell:t=1}={}){t=o(this,D,Vt).call(this,t);const[e,i]=this.parseCellToColumnRow(t),s=o(this,D,kn).call(this,{enable:!1,column:e,row:i});await this.appendToQueue(s,"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");o(this,D,qt).call(this),L(this,rt,!0),o(this,D,qe).call(this);const t=[];for(let e=1;e<=90;e++){const i=await this.dispense(e);t.push(i),L(this,J,e),o(this,D,qe).call(this)}L(this,J,90),o(this,D,qe).call(this,t),o(this,D,qt).call(this)}async enableAll(){o(this,D,qt).call(this),L(this,rt,!0),o(this,D,je).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,J,t),o(this,D,je).call(this);L(this,J,90),o(this,D,je).call(this),o(this,D,qt).call(this)}async disableAll(){o(this,D,qt).call(this),L(this,rt,!0),o(this,D,He).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,J,t),o(this,D,He).call(this);L(this,J,90),o(this,D,He).call(this),o(this,D,qt).call(this)}}rt=new WeakMap,J=new WeakMap,Tt=new WeakMap,D=new WeakSet,ur=function(){const t=["percentage:disable","percentage:enable","percentage:open"];for(const e of t)this.serialRegisterAvailableListener(e)},dr=function(){G.add(this)},pr=function(t=1){return t=o(this,D,Vt).call(this,t),this.serialLockerHexCmd(new Uint8Array([16,this.__internal__.device.listen_on_port,t]))},_r=function(t=0,e=10){return this.serialLockerHexCmd(new Uint8Array([32,this.__internal__.device.listen_on_port,t,e]))},kn=function({enable:t=!0,column:e=0,row:i=10}={}){if(e<0||e>8)throw new Error("Invalid column number");if(i<0||i>10)throw new Error("Invalid row number");let s=1;return t||(s=0),this.serialLockerHexCmd(new Uint8Array([48,this.__internal__.device.listen_on_port,e,i,s]))},fr=function(t=1){t=o(this,D,Vt).call(this,t);const e=this.__internal__.device.milliseconds,i=e%256,s=Math.floor(e/3)%256;return this.serialLockerHexCmd(new Uint8Array([64,this.__internal__.device.listen_on_port,t,i,s]))},Vt=function(t){const e=parseInt(t);if(isNaN(e)||e<1||e>90)throw new Error("Invalid cell number");return e},qt=function(){L(this,rt,!1),L(this,J,0),L(this,Tt,0)},qe=function(t=null){L(this,Tt,Math.round(I(this,J)*100/90)),this.dispatch("percentage:open",{percentage:I(this,Tt),dispensed:t})},je=function(){L(this,Tt,Math.round(I(this,J)*100/90)),this.dispatch("percentage:enable",{percentage:I(this,Tt)})},He=function(){L(this,Tt,Math.round(I(this,J)*100/90)),this.dispatch("percentage:disable",{percentage:I(this,Tt)})};var Ra="0123456789abcdefghijklmnopqrstuvwxyz";function At(r){return Ra.charAt(r)}function Ia(r,n){return r&n}function ye(r,n){return r|n}function di(r,n){return r^n}function pi(r,n){return r&~n}function Oa(r){if(r==0)return-1;var n=0;return(r&65535)==0&&(r>>=16,n+=16),(r&255)==0&&(r>>=8,n+=8),(r&15)==0&&(r>>=4,n+=4),(r&3)==0&&(r>>=2,n+=2),(r&1)==0&&++n,n}function Na(r){for(var n=0;r!=0;)r&=r-1,++n;return n}var Kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_i="=";function me(r){var n,t,e="";for(n=0;n+3<=r.length;n+=3)t=parseInt(r.substring(n,n+3),16),e+=Kt.charAt(t>>6)+Kt.charAt(t&63);for(n+1==r.length?(t=parseInt(r.substring(n,n+1),16),e+=Kt.charAt(t<<2)):n+2==r.length&&(t=parseInt(r.substring(n,n+2),16),e+=Kt.charAt(t>>2)+Kt.charAt((t&3)<<4));(e.length&3)>0;)e+=_i;return e}function fi(r){var n="",t,e=0,i=0;for(t=0;t<r.length&&r.charAt(t)!=_i;++t){var s=Kt.indexOf(r.charAt(t));s<0||(e==0?(n+=At(s>>2),i=s&3,e=1):e==1?(n+=At(i<<2|s>>4),i=s&15,e=2):e==2?(n+=At(i),n+=At(s>>2),i=s&3,e=3):(n+=At(i<<2|s>>4),n+=At(s&15),e=0))}return e==1&&(n+=At(i<<2)),n}var Wt,Ba={decode:function(r){var n;if(Wt===void 0){var t="0123456789ABCDEF",e=` \f
5
- \r  \u2028\u2029`;for(Wt={},n=0;n<16;++n)Wt[t.charAt(n)]=n;for(t=t.toLowerCase(),n=10;n<16;++n)Wt[t.charAt(n)]=n;for(n=0;n<e.length;++n)Wt[e.charAt(n)]=-1}var i=[],s=0,a=0;for(n=0;n<r.length;++n){var c=r.charAt(n);if(c=="=")break;if(c=Wt[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+n);s|=c,++a>=2?(i[i.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},Bt,sn={decode:function(r){var n;if(Bt===void 0){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=`= \f
6
- \r  \u2028\u2029`;for(Bt=Object.create(null),n=0;n<64;++n)Bt[t.charAt(n)]=n;for(Bt["-"]=62,Bt._=63,n=0;n<e.length;++n)Bt[e.charAt(n)]=-1}var i=[],s=0,a=0;for(n=0;n<r.length;++n){var c=r.charAt(n);if(c=="=")break;if(c=Bt[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+n);s|=c,++a>=4?(i[i.length]=s>>16,i[i.length]=s>>8&255,i[i.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=s>>10;break;case 3:i[i.length]=s>>16,i[i.length]=s>>8&255;break}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(r){var n=sn.re.exec(r);if(n)if(n[1])r=n[1];else if(n[2])r=n[2];else throw new Error("RegExp out of sync");return sn.decode(r)}},$t=1e13,re=function(){function r(n){this.buf=[+n||0]}return r.prototype.mulAdd=function(n,t){var e=this.buf,i=e.length,s,a;for(s=0;s<i;++s)a=e[s]*n+t,a<$t?t=0:(t=0|a/$t,a-=t*$t),e[s]=a;t>0&&(e[s]=t)},r.prototype.sub=function(n){var t=this.buf,e=t.length,i,s;for(i=0;i<e;++i)s=t[i]-n,s<0?(s+=$t,n=1):n=0,t[i]=s;for(;t[t.length-1]===0;)t.pop()},r.prototype.toString=function(n){if((n||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,e=t[t.length-1].toString(),i=t.length-2;i>=0;--i)e+=($t+t[i]).toString().substring(1);return e},r.prototype.valueOf=function(){for(var n=this.buf,t=0,e=n.length-1;e>=0;--e)t=t*$t+n[e];return t},r.prototype.simplify=function(){var n=this.buf;return n.length==1?n[0]:this},r}(),gi="…",Ma=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Fa=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function zt(r,n){return r.length>n&&(r=r.substring(0,n)+gi),r}var an=function(){function r(n,t){this.hexDigits="0123456789ABCDEF",n instanceof r?(this.enc=n.enc,this.pos=n.pos):(this.enc=n,this.pos=t)}return r.prototype.get=function(n){if(n===void 0&&(n=this.pos++),n>=this.enc.length)throw new Error("Requesting byte offset ".concat(n," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(n):this.enc[n]},r.prototype.hexByte=function(n){return this.hexDigits.charAt(n>>4&15)+this.hexDigits.charAt(n&15)},r.prototype.hexDump=function(n,t,e){for(var i="",s=n;s<t;++s)if(i+=this.hexByte(this.get(s)),e!==!0)switch(s&15){case 7:i+=" ";break;case 15:i+=`
7
- `;break;default:i+=" "}return i},r.prototype.isASCII=function(n,t){for(var e=n;e<t;++e){var i=this.get(e);if(i<32||i>176)return!1}return!0},r.prototype.parseStringISO=function(n,t){for(var e="",i=n;i<t;++i)e+=String.fromCharCode(this.get(i));return e},r.prototype.parseStringUTF=function(n,t){for(var e="",i=n;i<t;){var s=this.get(i++);s<128?e+=String.fromCharCode(s):s>191&&s<224?e+=String.fromCharCode((s&31)<<6|this.get(i++)&63):e+=String.fromCharCode((s&15)<<12|(this.get(i++)&63)<<6|this.get(i++)&63)}return e},r.prototype.parseStringBMP=function(n,t){for(var e="",i,s,a=n;a<t;)i=this.get(a++),s=this.get(a++),e+=String.fromCharCode(i<<8|s);return e},r.prototype.parseTime=function(n,t,e){var i=this.parseStringISO(n,t),s=(e?Ma:Fa).exec(i);return s?(e&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),i=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(i+=":"+s[5],s[6]&&(i+=":"+s[6],s[7]&&(i+="."+s[7]))),s[8]&&(i+=" UTC",s[8]!="Z"&&(i+=s[8],s[9]&&(i+=":"+s[9]))),i):"Unrecognized time: "+i},r.prototype.parseInteger=function(n,t){for(var e=this.get(n),i=e>127,s=i?255:0,a,c="";e==s&&++n<t;)e=this.get(n);if(a=t-n,a===0)return i?-1:0;if(a>4){for(c=e,a<<=3;((+c^s)&128)==0;)c=+c<<1,--a;c="("+a+` bit)
8
- `}i&&(e=e-256);for(var l=new re(e),h=n+1;h<t;++h)l.mulAdd(256,this.get(h));return c+l.toString()},r.prototype.parseBitString=function(n,t,e){for(var i=this.get(n),s=(t-n-1<<3)-i,a="("+s+` bit)
9
- `,c="",l=n+1;l<t;++l){for(var h=this.get(l),_=l==t-1?i:0,f=7;f>=_;--f)c+=h>>f&1?"1":"0";if(c.length>e)return a+zt(c,e)}return a+c},r.prototype.parseOctetString=function(n,t,e){if(this.isASCII(n,t))return zt(this.parseStringISO(n,t),e);var i=t-n,s="("+i+` byte)
10
- `;e/=2,i>e&&(t=n+e);for(var a=n;a<t;++a)s+=this.hexByte(this.get(a));return i>e&&(s+=gi),s},r.prototype.parseOID=function(n,t,e){for(var i="",s=new re,a=0,c=n;c<t;++c){var l=this.get(c);if(s.mulAdd(128,l&127),a+=7,!(l&128)){if(i==="")if(s=s.simplify(),s instanceof re)s.sub(80),i="2."+s.toString();else{var h=s<80?s<40?0:1:2;i=h+"."+(s-h*40)}else i+="."+s.toString();if(i.length>e)return zt(i,e);s=new re,a=0}}return a>0&&(i+=".incomplete"),i},r}(),Ua=function(){function r(n,t,e,i,s){if(!(i instanceof bi))throw new Error("Invalid tag value.");this.stream=n,this.header=t,this.length=e,this.tag=i,this.sub=s}return r.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},r.prototype.content=function(n){if(this.tag===void 0)return null;n===void 0&&(n=1/0);var t=this.posContent(),e=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,n);switch(this.tag.tagNumber){case 1:return this.stream.get(t)===0?"false":"true";case 2:return this.stream.parseInteger(t,t+e);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+e,n);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,n);case 6:return this.stream.parseOID(t,t+e,n);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return zt(this.stream.parseStringUTF(t,t+e),n);case 18:case 19:case 20:case 21:case 22:case 26:return zt(this.stream.parseStringISO(t,t+e),n);case 30:return zt(this.stream.parseStringBMP(t,t+e),n);case 23:case 24:return this.stream.parseTime(t,t+e,this.tag.tagNumber==23)}return null},r.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"},r.prototype.toPrettyString=function(n){n===void 0&&(n="");var t=n+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(t+=" (encapsulates)"),t+=`
11
- `,this.sub!==null){n+=" ";for(var e=0,i=this.sub.length;e<i;++e)t+=this.sub[e].toPrettyString(n)}return t},r.prototype.posStart=function(){return this.stream.pos},r.prototype.posContent=function(){return this.stream.pos+this.header},r.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},r.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},r.decodeLength=function(n){var t=n.get(),e=t&127;if(e==t)return e;if(e>6)throw new Error("Length over 48 bits not supported at position "+(n.pos-1));if(e===0)return null;t=0;for(var i=0;i<e;++i)t=t*256+n.get();return t},r.prototype.getHexStringValue=function(){var n=this.toHexString(),t=this.header*2,e=this.length*2;return n.substr(t,e)},r.decode=function(n){var t;n instanceof an?t=n:t=new an(n,0);var e=new an(t),i=new bi(t),s=r.decodeLength(t),a=t.pos,c=a-e.pos,l=null,h=function(){var f=[];if(s!==null){for(var y=a+s;t.pos<y;)f[f.length]=r.decode(t);if(t.pos!=y)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var E=r.decode(t);if(E.tag.isEOC())break;f[f.length]=E}s=a-t.pos}catch(v){throw new Error("Exception while decoding undefined length content: "+v)}return f};if(i.tagConstructed)l=h();else if(i.isUniversal()&&(i.tagNumber==3||i.tagNumber==4))try{if(i.tagNumber==3&&t.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");l=h();for(var _=0;_<l.length;++_)if(l[_].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{l=null}if(l===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);t.pos=a+Math.abs(s)}return new r(e,c,s,i,l)},r}(),bi=function(){function r(n){var t=n.get();if(this.tagClass=t>>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){var e=new re;do t=n.get(),e.mulAdd(128,t&127);while(t&128);this.tagNumber=e.simplify()}}return r.prototype.isUniversal=function(){return this.tagClass===0},r.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},r}(),Rt,La=0xdeadbeefcafe,yi=(La&16777215)==15715070,st=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Va=(1<<26)/st[st.length-1],A=function(){function r(n,t,e){n!=null&&(typeof n=="number"?this.fromNumber(n,t,e):t==null&&typeof n!="string"?this.fromString(n,256):this.fromString(n,t))}return r.prototype.toString=function(n){if(this.s<0)return"-"+this.negate().toString(n);var t;if(n==16)t=4;else if(n==8)t=3;else if(n==2)t=1;else if(n==32)t=5;else if(n==4)t=2;else return this.toRadix(n);var e=(1<<t)-1,i,s=!1,a="",c=this.t,l=this.DB-c*this.DB%t;if(c-- >0)for(l<this.DB&&(i=this[c]>>l)>0&&(s=!0,a=At(i));c>=0;)l<t?(i=(this[c]&(1<<l)-1)<<t-l,i|=this[--c]>>(l+=this.DB-t)):(i=this[c]>>(l-=t)&e,l<=0&&(l+=this.DB,--c)),i>0&&(s=!0),s&&(a+=At(i));return s?a:"0"},r.prototype.negate=function(){var n=N();return r.ZERO.subTo(this,n),n},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(n){var t=this.s-n.s;if(t!=0)return t;var e=this.t;if(t=e-n.t,t!=0)return this.s<0?-t:t;for(;--e>=0;)if((t=this[e]-n[e])!=0)return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+ve(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(n){var t=N();return this.abs().divRemTo(n,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&n.subTo(t,t),t},r.prototype.modPowInt=function(n,t){var e;return n<256||t.isEven()?e=new mi(t):e=new wi(t),this.exp(n,e)},r.prototype.clone=function(){var n=N();return this.copyTo(n),n},r.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var n=this.t,t=[];t[0]=this.s;var e=this.DB-n*this.DB%8,i,s=0;if(n-- >0)for(e<this.DB&&(i=this[n]>>e)!=(this.s&this.DM)>>e&&(t[s++]=i|this.s<<this.DB-e);n>=0;)e<8?(i=(this[n]&(1<<e)-1)<<8-e,i|=this[--n]>>(e+=this.DB-8)):(i=this[n]>>(e-=8)&255,e<=0&&(e+=this.DB,--n)),(i&128)!=0&&(i|=-256),s==0&&(this.s&128)!=(i&128)&&++s,(s>0||i!=this.s)&&(t[s++]=i);return t},r.prototype.equals=function(n){return this.compareTo(n)==0},r.prototype.min=function(n){return this.compareTo(n)<0?this:n},r.prototype.max=function(n){return this.compareTo(n)>0?this:n},r.prototype.and=function(n){var t=N();return this.bitwiseTo(n,Ia,t),t},r.prototype.or=function(n){var t=N();return this.bitwiseTo(n,ye,t),t},r.prototype.xor=function(n){var t=N();return this.bitwiseTo(n,di,t),t},r.prototype.andNot=function(n){var t=N();return this.bitwiseTo(n,pi,t),t},r.prototype.not=function(){for(var n=N(),t=0;t<this.t;++t)n[t]=this.DM&~this[t];return n.t=this.t,n.s=~this.s,n},r.prototype.shiftLeft=function(n){var t=N();return n<0?this.rShiftTo(-n,t):this.lShiftTo(n,t),t},r.prototype.shiftRight=function(n){var t=N();return n<0?this.lShiftTo(-n,t):this.rShiftTo(n,t),t},r.prototype.getLowestSetBit=function(){for(var n=0;n<this.t;++n)if(this[n]!=0)return n*this.DB+Oa(this[n]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var n=0,t=this.s&this.DM,e=0;e<this.t;++e)n+=Na(this[e]^t);return n},r.prototype.testBit=function(n){var t=Math.floor(n/this.DB);return t>=this.t?this.s!=0:(this[t]&1<<n%this.DB)!=0},r.prototype.setBit=function(n){return this.changeBit(n,ye)},r.prototype.clearBit=function(n){return this.changeBit(n,pi)},r.prototype.flipBit=function(n){return this.changeBit(n,di)},r.prototype.add=function(n){var t=N();return this.addTo(n,t),t},r.prototype.subtract=function(n){var t=N();return this.subTo(n,t),t},r.prototype.multiply=function(n){var t=N();return this.multiplyTo(n,t),t},r.prototype.divide=function(n){var t=N();return this.divRemTo(n,t,null),t},r.prototype.remainder=function(n){var t=N();return this.divRemTo(n,null,t),t},r.prototype.divideAndRemainder=function(n){var t=N(),e=N();return this.divRemTo(n,t,e),[t,e]},r.prototype.modPow=function(n,t){var e=n.bitLength(),i,s=It(1),a;if(e<=0)return s;e<18?i=1:e<48?i=3:e<144?i=4:e<768?i=5:i=6,e<8?a=new mi(t):t.isEven()?a=new ja(t):a=new wi(t);var c=[],l=3,h=i-1,_=(1<<i)-1;if(c[1]=a.convert(this),i>1){var f=N();for(a.sqrTo(c[1],f);l<=_;)c[l]=N(),a.mulTo(f,c[l-2],c[l]),l+=2}var y=n.t-1,E,v=!0,S=N(),T;for(e=ve(n[y])-1;y>=0;){for(e>=h?E=n[y]>>e-h&_:(E=(n[y]&(1<<e+1)-1)<<h-e,y>0&&(E|=n[y-1]>>this.DB+e-h)),l=i;(E&1)==0;)E>>=1,--l;if((e-=l)<0&&(e+=this.DB,--y),v)c[E].copyTo(s),v=!1;else{for(;l>1;)a.sqrTo(s,S),a.sqrTo(S,s),l-=2;l>0?a.sqrTo(s,S):(T=s,s=S,S=T),a.mulTo(S,c[E],s)}for(;y>=0&&(n[y]&1<<e)==0;)a.sqrTo(s,S),T=s,s=S,S=T,--e<0&&(e=this.DB-1,--y)}return a.revert(s)},r.prototype.modInverse=function(n){var t=n.isEven();if(this.isEven()&&t||n.signum()==0)return r.ZERO;for(var e=n.clone(),i=this.clone(),s=It(1),a=It(0),c=It(0),l=It(1);e.signum()!=0;){for(;e.isEven();)e.rShiftTo(1,e),t?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(n,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(n,a),a.rShiftTo(1,a);for(;i.isEven();)i.rShiftTo(1,i),t?((!c.isEven()||!l.isEven())&&(c.addTo(this,c),l.subTo(n,l)),c.rShiftTo(1,c)):l.isEven()||l.subTo(n,l),l.rShiftTo(1,l);e.compareTo(i)>=0?(e.subTo(i,e),t&&s.subTo(c,s),a.subTo(l,a)):(i.subTo(e,i),t&&c.subTo(s,c),l.subTo(a,l))}if(i.compareTo(r.ONE)!=0)return r.ZERO;if(l.compareTo(n)>=0)return l.subtract(n);if(l.signum()<0)l.addTo(n,l);else return l;return l.signum()<0?l.add(n):l},r.prototype.pow=function(n){return this.exp(n,new qa)},r.prototype.gcd=function(n){var t=this.s<0?this.negate():this.clone(),e=n.s<0?n.negate():n.clone();if(t.compareTo(e)<0){var i=t;t=e,e=i}var s=t.getLowestSetBit(),a=e.getLowestSetBit();if(a<0)return t;for(s<a&&(a=s),a>0&&(t.rShiftTo(a,t),e.rShiftTo(a,e));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),t.compareTo(e)>=0?(t.subTo(e,t),t.rShiftTo(1,t)):(e.subTo(t,e),e.rShiftTo(1,e));return a>0&&e.lShiftTo(a,e),e},r.prototype.isProbablePrime=function(n){var t,e=this.abs();if(e.t==1&&e[0]<=st[st.length-1]){for(t=0;t<st.length;++t)if(e[0]==st[t])return!0;return!1}if(e.isEven())return!1;for(t=1;t<st.length;){for(var i=st[t],s=t+1;s<st.length&&i<Va;)i*=st[s++];for(i=e.modInt(i);t<s;)if(i%st[t++]==0)return!1}return e.millerRabin(n)},r.prototype.copyTo=function(n){for(var t=this.t-1;t>=0;--t)n[t]=this[t];n.t=this.t,n.s=this.s},r.prototype.fromInt=function(n){this.t=1,this.s=n<0?-1:0,n>0?this[0]=n:n<-1?this[0]=n+this.DV:this.t=0},r.prototype.fromString=function(n,t){var e;if(t==16)e=4;else if(t==8)e=3;else if(t==256)e=8;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else{this.fromRadix(n,t);return}this.t=0,this.s=0;for(var i=n.length,s=!1,a=0;--i>=0;){var c=e==8?+n[i]&255:Ei(n,i);if(c<0){n.charAt(i)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=c:a+e>this.DB?(this[this.t-1]|=(c&(1<<this.DB-a)-1)<<a,this[this.t++]=c>>this.DB-a):this[this.t-1]|=c<<a,a+=e,a>=this.DB&&(a-=this.DB)}e==8&&(+n[0]&128)!=0&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var n=this.s&this.DM;this.t>0&&this[this.t-1]==n;)--this.t},r.prototype.dlShiftTo=function(n,t){var e;for(e=this.t-1;e>=0;--e)t[e+n]=this[e];for(e=n-1;e>=0;--e)t[e]=0;t.t=this.t+n,t.s=this.s},r.prototype.drShiftTo=function(n,t){for(var e=n;e<this.t;++e)t[e-n]=this[e];t.t=Math.max(this.t-n,0),t.s=this.s},r.prototype.lShiftTo=function(n,t){for(var e=n%this.DB,i=this.DB-e,s=(1<<i)-1,a=Math.floor(n/this.DB),c=this.s<<e&this.DM,l=this.t-1;l>=0;--l)t[l+a+1]=this[l]>>i|c,c=(this[l]&s)<<e;for(var l=a-1;l>=0;--l)t[l]=0;t[a]=c,t.t=this.t+a+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(n,t){t.s=this.s;var e=Math.floor(n/this.DB);if(e>=this.t){t.t=0;return}var i=n%this.DB,s=this.DB-i,a=(1<<i)-1;t[0]=this[e]>>i;for(var c=e+1;c<this.t;++c)t[c-e-1]|=(this[c]&a)<<s,t[c-e]=this[c]>>i;i>0&&(t[this.t-e-1]|=(this.s&a)<<s),t.t=this.t-e,t.clamp()},r.prototype.subTo=function(n,t){for(var e=0,i=0,s=Math.min(n.t,this.t);e<s;)i+=this[e]-n[e],t[e++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i-=n.s;e<this.t;)i+=this[e],t[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<n.t;)i-=n[e],t[e++]=i&this.DM,i>>=this.DB;i-=n.s}t.s=i<0?-1:0,i<-1?t[e++]=this.DV+i:i>0&&(t[e++]=i),t.t=e,t.clamp()},r.prototype.multiplyTo=function(n,t){var e=this.abs(),i=n.abs(),s=e.t;for(t.t=s+i.t;--s>=0;)t[s]=0;for(s=0;s<i.t;++s)t[s+e.t]=e.am(0,i[s],t,s,0,e.t);t.s=0,t.clamp(),this.s!=n.s&&r.ZERO.subTo(t,t)},r.prototype.squareTo=function(n){for(var t=this.abs(),e=n.t=2*t.t;--e>=0;)n[e]=0;for(e=0;e<t.t-1;++e){var i=t.am(e,t[e],n,2*e,0,1);(n[e+t.t]+=t.am(e+1,2*t[e],n,2*e+1,i,t.t-e-1))>=t.DV&&(n[e+t.t]-=t.DV,n[e+t.t+1]=1)}n.t>0&&(n[n.t-1]+=t.am(e,t[e],n,2*e,0,1)),n.s=0,n.clamp()},r.prototype.divRemTo=function(n,t,e){var i=n.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t){t!=null&&t.fromInt(0),e!=null&&this.copyTo(e);return}e==null&&(e=N());var a=N(),c=this.s,l=n.s,h=this.DB-ve(i[i.t-1]);h>0?(i.lShiftTo(h,a),s.lShiftTo(h,e)):(i.copyTo(a),s.copyTo(e));var _=a.t,f=a[_-1];if(f!=0){var y=f*(1<<this.F1)+(_>1?a[_-2]>>this.F2:0),E=this.FV/y,v=(1<<this.F1)/y,S=1<<this.F2,T=e.t,H=T-_,V=t??N();for(a.dlShiftTo(H,V),e.compareTo(V)>=0&&(e[e.t++]=1,e.subTo(V,e)),r.ONE.dlShiftTo(_,V),V.subTo(a,a);a.t<_;)a[a.t++]=0;for(;--H>=0;){var W=e[--T]==f?this.DM:Math.floor(e[T]*E+(e[T-1]+S)*v);if((e[T]+=a.am(0,W,e,H,0,_))<W)for(a.dlShiftTo(H,V),e.subTo(V,e);e[T]<--W;)e.subTo(V,e)}t!=null&&(e.drShiftTo(_,t),c!=l&&r.ZERO.subTo(t,t)),e.t=_,e.clamp(),h>0&&e.rShiftTo(h,e),c<0&&r.ZERO.subTo(e,e)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var n=this[0];if((n&1)==0)return 0;var t=n&3;return t=t*(2-(n&15)*t)&15,t=t*(2-(n&255)*t)&255,t=t*(2-((n&65535)*t&65535))&65535,t=t*(2-n*t%this.DV)%this.DV,t>0?this.DV-t:-t},r.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},r.prototype.exp=function(n,t){if(n>4294967295||n<1)return r.ONE;var e=N(),i=N(),s=t.convert(this),a=ve(n)-1;for(s.copyTo(e);--a>=0;)if(t.sqrTo(e,i),(n&1<<a)>0)t.mulTo(i,s,e);else{var c=e;e=i,i=c}return t.revert(e)},r.prototype.chunkSize=function(n){return Math.floor(Math.LN2*this.DB/Math.log(n))},r.prototype.toRadix=function(n){if(n==null&&(n=10),this.signum()==0||n<2||n>36)return"0";var t=this.chunkSize(n),e=Math.pow(n,t),i=It(e),s=N(),a=N(),c="";for(this.divRemTo(i,s,a);s.signum()>0;)c=(e+a.intValue()).toString(n).substr(1)+c,s.divRemTo(i,s,a);return a.intValue().toString(n)+c},r.prototype.fromRadix=function(n,t){this.fromInt(0),t==null&&(t=10);for(var e=this.chunkSize(t),i=Math.pow(t,e),s=!1,a=0,c=0,l=0;l<n.length;++l){var h=Ei(n,l);if(h<0){n.charAt(l)=="-"&&this.signum()==0&&(s=!0);continue}c=t*c+h,++a>=e&&(this.dMultiply(i),this.dAddOffset(c,0),a=0,c=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(c,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(n,t,e){if(typeof t=="number")if(n<2)this.fromInt(1);else for(this.fromNumber(n,e),this.testBit(n-1)||this.bitwiseTo(r.ONE.shiftLeft(n-1),ye,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>n&&this.subTo(r.ONE.shiftLeft(n-1),this);else{var i=[],s=n&7;i.length=(n>>3)+1,t.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},r.prototype.bitwiseTo=function(n,t,e){var i,s,a=Math.min(n.t,this.t);for(i=0;i<a;++i)e[i]=t(this[i],n[i]);if(n.t<this.t){for(s=n.s&this.DM,i=a;i<this.t;++i)e[i]=t(this[i],s);e.t=this.t}else{for(s=this.s&this.DM,i=a;i<n.t;++i)e[i]=t(s,n[i]);e.t=n.t}e.s=t(this.s,n.s),e.clamp()},r.prototype.changeBit=function(n,t){var e=r.ONE.shiftLeft(n);return this.bitwiseTo(e,t,e),e},r.prototype.addTo=function(n,t){for(var e=0,i=0,s=Math.min(n.t,this.t);e<s;)i+=this[e]+n[e],t[e++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i+=n.s;e<this.t;)i+=this[e],t[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<n.t;)i+=n[e],t[e++]=i&this.DM,i>>=this.DB;i+=n.s}t.s=i<0?-1:0,i>0?t[e++]=i:i<-1&&(t[e++]=this.DV+i),t.t=e,t.clamp()},r.prototype.dMultiply=function(n){this[this.t]=this.am(0,n-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(n,t){if(n!=0){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=n;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.prototype.multiplyLowerTo=function(n,t,e){var i=Math.min(this.t+n.t,t);for(e.s=0,e.t=i;i>0;)e[--i]=0;for(var s=e.t-this.t;i<s;++i)e[i+this.t]=this.am(0,n[i],e,i,0,this.t);for(var s=Math.min(n.t,t);i<s;++i)this.am(0,n[i],e,i,0,t-i);e.clamp()},r.prototype.multiplyUpperTo=function(n,t,e){--t;var i=e.t=this.t+n.t-t;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(t-this.t,0);i<n.t;++i)e[this.t+i-t]=this.am(t-i,n[i],e,0,0,this.t+i-t);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(n){if(n<=0)return 0;var t=this.DV%n,e=this.s<0?n-1:0;if(this.t>0)if(t==0)e=this[0]%n;else for(var i=this.t-1;i>=0;--i)e=(t*e+this[i])%n;return e},r.prototype.millerRabin=function(n){var t=this.subtract(r.ONE),e=t.getLowestSetBit();if(e<=0)return!1;var i=t.shiftRight(e);n=n+1>>1,n>st.length&&(n=st.length);for(var s=N(),a=0;a<n;++a){s.fromInt(st[Math.floor(Math.random()*st.length)]);var c=s.modPow(i,this);if(c.compareTo(r.ONE)!=0&&c.compareTo(t)!=0){for(var l=1;l++<e&&c.compareTo(t)!=0;)if(c=c.modPowInt(2,this),c.compareTo(r.ONE)==0)return!1;if(c.compareTo(t)!=0)return!1}}return!0},r.prototype.square=function(){var n=N();return this.squareTo(n),n},r.prototype.gcda=function(n,t){var e=this.s<0?this.negate():this.clone(),i=n.s<0?n.negate():n.clone();if(e.compareTo(i)<0){var s=e;e=i,i=s}var a=e.getLowestSetBit(),c=i.getLowestSetBit();if(c<0){t(e);return}a<c&&(c=a),c>0&&(e.rShiftTo(c,e),i.rShiftTo(c,i));var l=function(){(a=e.getLowestSetBit())>0&&e.rShiftTo(a,e),(a=i.getLowestSetBit())>0&&i.rShiftTo(a,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i)),e.signum()>0?setTimeout(l,0):(c>0&&i.lShiftTo(c,i),setTimeout(function(){t(i)},0))};setTimeout(l,10)},r.prototype.fromNumberAsync=function(n,t,e,i){if(typeof t=="number")if(n<2)this.fromInt(1);else{this.fromNumber(n,e),this.testBit(n-1)||this.bitwiseTo(r.ONE.shiftLeft(n-1),ye,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>n&&s.subTo(r.ONE.shiftLeft(n-1),s),s.isProbablePrime(t)?setTimeout(function(){i()},0):setTimeout(a,0)};setTimeout(a,0)}else{var c=[],l=n&7;c.length=(n>>3)+1,t.nextBytes(c),l>0?c[0]&=(1<<l)-1:c[0]=0,this.fromString(c,256)}},r}(),qa=function(){function r(){}return r.prototype.convert=function(n){return n},r.prototype.revert=function(n){return n},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e)},r.prototype.sqrTo=function(n,t){n.squareTo(t)},r}(),mi=function(){function r(n){this.m=n}return r.prototype.convert=function(n){return n.s<0||n.compareTo(this.m)>=0?n.mod(this.m):n},r.prototype.revert=function(n){return n},r.prototype.reduce=function(n){n.divRemTo(this.m,null,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}(),wi=function(){function r(n){this.m=n,this.mp=n.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<n.DB-15)-1,this.mt2=2*n.t}return r.prototype.convert=function(n){var t=N();return n.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),n.s<0&&t.compareTo(A.ZERO)>0&&this.m.subTo(t,t),t},r.prototype.revert=function(n){var t=N();return n.copyTo(t),this.reduce(t),t},r.prototype.reduce=function(n){for(;n.t<=this.mt2;)n[n.t++]=0;for(var t=0;t<this.m.t;++t){var e=n[t]&32767,i=e*this.mpl+((e*this.mph+(n[t]>>15)*this.mpl&this.um)<<15)&n.DM;for(e=t+this.m.t,n[e]+=this.m.am(0,i,n,t,0,this.m.t);n[e]>=n.DV;)n[e]-=n.DV,n[++e]++}n.clamp(),n.drShiftTo(this.m.t,n),n.compareTo(this.m)>=0&&n.subTo(this.m,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}(),ja=function(){function r(n){this.m=n,this.r2=N(),this.q3=N(),A.ONE.dlShiftTo(2*n.t,this.r2),this.mu=this.r2.divide(n)}return r.prototype.convert=function(n){if(n.s<0||n.t>2*this.m.t)return n.mod(this.m);if(n.compareTo(this.m)<0)return n;var t=N();return n.copyTo(t),this.reduce(t),t},r.prototype.revert=function(n){return n},r.prototype.reduce=function(n){for(n.drShiftTo(this.m.t-1,this.r2),n.t>this.m.t+1&&(n.t=this.m.t+1,n.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);n.compareTo(this.r2)<0;)n.dAddOffset(1,this.m.t+1);for(n.subTo(this.r2,n);n.compareTo(this.m)>=0;)n.subTo(this.m,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}();function N(){return new A(null)}function $(r,n){return new A(r,n)}var vi=typeof navigator<"u";vi&&yi&&navigator.appName=="Microsoft Internet Explorer"?(A.prototype.am=function(n,t,e,i,s,a){for(var c=t&32767,l=t>>15;--a>=0;){var h=this[n]&32767,_=this[n++]>>15,f=l*h+_*c;h=c*h+((f&32767)<<15)+e[i]+(s&1073741823),s=(h>>>30)+(f>>>15)+l*_+(s>>>30),e[i++]=h&1073741823}return s},Rt=30):vi&&yi&&navigator.appName!="Netscape"?(A.prototype.am=function(n,t,e,i,s,a){for(;--a>=0;){var c=t*this[n++]+e[i]+s;s=Math.floor(c/67108864),e[i++]=c&67108863}return s},Rt=26):(A.prototype.am=function(n,t,e,i,s,a){for(var c=t&16383,l=t>>14;--a>=0;){var h=this[n]&16383,_=this[n++]>>14,f=l*h+_*c;h=c*h+((f&16383)<<14)+e[i]+s,s=(h>>28)+(f>>14)+l*_,e[i++]=h&268435455}return s},Rt=28),A.prototype.DB=Rt,A.prototype.DM=(1<<Rt)-1,A.prototype.DV=1<<Rt;var on=52;A.prototype.FV=Math.pow(2,on),A.prototype.F1=on-Rt,A.prototype.F2=2*Rt-on;var we=[],Xt,ft;for(Xt=48,ft=0;ft<=9;++ft)we[Xt++]=ft;for(Xt=97,ft=10;ft<36;++ft)we[Xt++]=ft;for(Xt=65,ft=10;ft<36;++ft)we[Xt++]=ft;function Ei(r,n){var t=we[r.charCodeAt(n)];return t??-1}function It(r){var n=N();return n.fromInt(r),n}function ve(r){var n=1,t;return(t=r>>>16)!=0&&(r=t,n+=16),(t=r>>8)!=0&&(r=t,n+=8),(t=r>>4)!=0&&(r=t,n+=4),(t=r>>2)!=0&&(r=t,n+=2),(t=r>>1)!=0&&(r=t,n+=1),n}A.ZERO=It(0),A.ONE=It(1);var Ha=function(){function r(){this.i=0,this.j=0,this.S=[]}return r.prototype.init=function(n){var t,e,i;for(t=0;t<256;++t)this.S[t]=t;for(e=0,t=0;t<256;++t)e=e+this.S[t]+n[t%n.length]&255,i=this.S[t],this.S[t]=this.S[e],this.S[e]=i;this.i=0,this.j=0},r.prototype.next=function(){var n;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,n=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=n,this.S[n+this.S[this.i]&255]},r}();function Ka(){return new Ha}var Pi=256,Ee,Ot=null,bt;if(Ot==null){Ot=[],bt=0;var Pe=void 0;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){var cn=new Uint32Array(256);for(window.crypto.getRandomValues(cn),Pe=0;Pe<cn.length;++Pe)Ot[bt++]=cn[Pe]&255}var Ce=0,Te=function(r){if(Ce=Ce||0,Ce>=256||bt>=Pi){window.removeEventListener?window.removeEventListener("mousemove",Te,!1):window.detachEvent&&window.detachEvent("onmousemove",Te);return}try{var n=r.x+r.y;Ot[bt++]=n&255,Ce+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",Te,!1):window.attachEvent&&window.attachEvent("onmousemove",Te))}function Wa(){if(Ee==null){for(Ee=Ka();bt<Pi;){var r=Math.floor(65536*Math.random());Ot[bt++]=r&255}for(Ee.init(Ot),bt=0;bt<Ot.length;++bt)Ot[bt]=0;bt=0}return Ee.next()}var ln=function(){function r(){}return r.prototype.nextBytes=function(n){for(var t=0;t<n.length;++t)n[t]=Wa()},r}();function $a(r,n){if(n<r.length+22)return console.error("Message too long for RSA"),null;for(var t=n-r.length-6,e="",i=0;i<t;i+=2)e+="ff";var s="0001"+e+"00"+r;return $(s,16)}function za(r,n){if(n<r.length+11)return console.error("Message too long for RSA"),null;for(var t=[],e=r.length-1;e>=0&&n>0;){var i=r.charCodeAt(e--);i<128?t[--n]=i:i>127&&i<2048?(t[--n]=i&63|128,t[--n]=i>>6|192):(t[--n]=i&63|128,t[--n]=i>>6&63|128,t[--n]=i>>12|224)}t[--n]=0;for(var s=new ln,a=[];n>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);t[--n]=a[0]}return t[--n]=2,t[--n]=0,new A(t)}var Xa=function(){function r(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return r.prototype.doPublic=function(n){return n.modPowInt(this.e,this.n)},r.prototype.doPrivate=function(n){if(this.p==null||this.q==null)return n.modPow(this.d,this.n);for(var t=n.mod(this.p).modPow(this.dmp1,this.p),e=n.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(e)<0;)t=t.add(this.p);return t.subtract(e).multiply(this.coeff).mod(this.p).multiply(this.q).add(e)},r.prototype.setPublic=function(n,t){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")},r.prototype.encrypt=function(n){var t=this.n.bitLength()+7>>3,e=za(n,t);if(e==null)return null;var i=this.doPublic(e);if(i==null)return null;for(var s=i.toString(16),a=s.length,c=0;c<t*2-a;c++)s="0"+s;return s},r.prototype.setPrivate=function(n,t,e){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16),this.d=$(e,16)):console.error("Invalid RSA private key")},r.prototype.setPrivateEx=function(n,t,e,i,s,a,c,l){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16),this.d=$(e,16),this.p=$(i,16),this.q=$(s,16),this.dmp1=$(a,16),this.dmq1=$(c,16),this.coeff=$(l,16)):console.error("Invalid RSA private key")},r.prototype.generate=function(n,t){var e=new ln,i=n>>1;this.e=parseInt(t,16);for(var s=new A(t,16);;){for(;this.p=new A(n-i,1,e),!(this.p.subtract(A.ONE).gcd(s).compareTo(A.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new A(i,1,e),!(this.q.subtract(A.ONE).gcd(s).compareTo(A.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var c=this.p.subtract(A.ONE),l=this.q.subtract(A.ONE),h=c.multiply(l);if(h.gcd(s).compareTo(A.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(c),this.dmq1=this.d.mod(l),this.coeff=this.q.modInverse(this.p);break}}},r.prototype.decrypt=function(n){var t=$(n,16),e=this.doPrivate(t);return e==null?null:Ga(e,this.n.bitLength()+7>>3)},r.prototype.generateAsync=function(n,t,e){var i=new ln,s=n>>1;this.e=parseInt(t,16);var a=new A(t,16),c=this,l=function(){var h=function(){if(c.p.compareTo(c.q)<=0){var y=c.p;c.p=c.q,c.q=y}var E=c.p.subtract(A.ONE),v=c.q.subtract(A.ONE),S=E.multiply(v);S.gcd(a).compareTo(A.ONE)==0?(c.n=c.p.multiply(c.q),c.d=a.modInverse(S),c.dmp1=c.d.mod(E),c.dmq1=c.d.mod(v),c.coeff=c.q.modInverse(c.p),setTimeout(function(){e()},0)):setTimeout(l,0)},_=function(){c.q=N(),c.q.fromNumberAsync(s,1,i,function(){c.q.subtract(A.ONE).gcda(a,function(y){y.compareTo(A.ONE)==0&&c.q.isProbablePrime(10)?setTimeout(h,0):setTimeout(_,0)})})},f=function(){c.p=N(),c.p.fromNumberAsync(n-s,1,i,function(){c.p.subtract(A.ONE).gcda(a,function(y){y.compareTo(A.ONE)==0&&c.p.isProbablePrime(10)?setTimeout(_,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(l,0)},r.prototype.sign=function(n,t,e){var i=Ja(e),s=i+t(n).toString(),a=$a(s,this.n.bitLength()/4);if(a==null)return null;var c=this.doPrivate(a);if(c==null)return null;var l=c.toString(16);return(l.length&1)==0?l:"0"+l},r.prototype.verify=function(n,t,e){var i=$(t,16),s=this.doPublic(i);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),c=Qa(a);return c==e(n).toString()},r}();function Ga(r,n){for(var t=r.toByteArray(),e=0;e<t.length&&t[e]==0;)++e;if(t.length-e!=n-1||t[e]!=2)return null;for(++e;t[e]!=0;)if(++e>=t.length)return null;for(var i="";++e<t.length;){var s=t[e]&255;s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((s&31)<<6|t[e+1]&63),++e):(i+=String.fromCharCode((s&15)<<12|(t[e+1]&63)<<6|t[e+2]&63),e+=2)}return i}var Se={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function Ja(r){return Se[r]||""}function Qa(r){for(var n in Se)if(Se.hasOwnProperty(n)){var t=Se[n],e=t.length;if(r.substr(0,e)==t)return r.substr(e)}return r}/*!
4
+ `){const e=this.parseStringToTextEncoder(n,t);return Array.from(e).map(i=>i.toString(16))}parseUint8ToHex(n){return Array.from(n).map(t=>t.toString(16))}parseHexToUint8(n){return new Uint8Array(n.map(t=>parseInt(t,16)))}stringArrayToUint8Array(n){const t=[];return n.forEach(e=>{const i=e.replace("0x","");t.push(parseInt(i,16))}),new Uint8Array(t)}parseUint8ArrayToString(n){const t=this.stringArrayToUint8Array(n);n=this.parseUint8ToHex(t);const e=n.map(i=>parseInt(i,16));return String.fromCharCode(...e).replace(/[\n\r]+/g,"")}hexToAscii(n){const t=n.toString();let e="";for(let i=0;i<t.length;i+=2)e+=String.fromCharCode(parseInt(t.substring(i,2),16));return e}asciiToHex(n){const t=[];for(let e=0,i=n.length;e<i;e++){const s=Number(n.charCodeAt(e)).toString(16);t.push(s)}return t.join("")}$checkAndDispatchConnection(){return this.isConnected}}U=new WeakSet,qt=function(r){return!!(r&&r.readable&&r.writable)},ee=function(r=null){this.__internal__.serial.connected=!1,this.__internal__.aux_port_connector=0,this.dispatch("serial:disconnected",r),k.$dispatchChange(this)},en=async function(r){const n=this.__internal__.serial.port;if(!n||n&&(!n.readable||!n.writable))throw q(this,U,ee).call(this,{error:"Port is closed, not readable or writable."}),new Error("The port is closed or is not readable/writable");const t=this.stringArrayToUint8Array(r);if(n.writable===null)return;const e=n.writable.getWriter();await e.write(t),e.releaseLock()},It=function(r=[],n=null){if(r&&r.length>0){const t=this.__internal__.serial.connected;this.__internal__.serial.connected=q(this,U,qt).call(this,this.__internal__.serial.port),k.$dispatchChange(this),!t&&this.__internal__.serial.connected&&this.dispatch("serial:connected"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const e=[];for(const i in r)e.push(r[i].toString().padStart(2,"0").toLowerCase());if(this.__internal__.serial.response.as==="hex")this.serialMessage(e);else if(this.__internal__.serial.response.as==="uint8")this.serialMessage(this.parseHexToUint8(this.add0x(e)));else if(this.__internal__.serial.response.as==="string")this.serialMessage(this.parseUint8ArrayToString(this.add0x(e)));else{const i=this.stringToArrayBuffer(this.parseUint8ArrayToString(this.add0x(e)));this.serialMessage(i)}}else this.serialCorruptMessage(r,n);this.__internal__.serial.queue.length!==0&&this.dispatch("internal:queue",{})},Zn=async function(){const r=this.serialFilters,n=await navigator.serial.getPorts({filters:r});return r.length===0?n:n.filter(t=>{const e=t.getInfo();return r.some(i=>e.usbProductId===i.usbProductId&&e.usbVendorId===i.usbVendorId)}).filter(t=>!q(this,U,qt).call(this,t))},Yn=function(r){if(r){const n=this.__internal__.serial.response.buffer,t=new Uint8Array(n.length+r.byteLength);t.set(n,0),t.set(new Uint8Array(r),n.length),this.__internal__.serial.response.buffer=t}},ti=async function(){this.__internal__.serial.time_until_send_bytes&&(clearTimeout(this.__internal__.serial.time_until_send_bytes),this.__internal__.serial.time_until_send_bytes=0),this.__internal__.serial.time_until_send_bytes=setTimeout(()=>{const r=[];for(const n in this.__internal__.serial.response.buffer)r.push(this.__internal__.serial.response.buffer[n].toString(16));this.__internal__.serial.response.buffer&&q(this,U,It).call(this,r),this.__internal__.serial.response.buffer=new Uint8Array(0)},400)},ei=async function(){if(this.__internal__.serial.response.length!==null){if(this.__internal__.serial.response.length===this.__internal__.serial.response.buffer.length){const r=[];for(const n in this.__internal__.serial.response.buffer)r.push(this.__internal__.serial.response.buffer[n].toString(16));q(this,U,It).call(this,r),this.__internal__.serial.response.buffer=new Uint8Array(0)}else if(this.__internal__.serial.response.length<this.__internal__.serial.response.buffer.length){let r=new Uint8Array(0);for(let t=0;t<this.__internal__.serial.response.length;t++)r[t]=this.__internal__.serial.response.buffer[t];if(r.length===this.__internal__.serial.response.length){const t=[];for(const e in r)t.push(r[e].toString(16));q(this,U,It).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0);return}r=new Uint8Array(0);const n=this.__internal__.serial.response.length*2;if(this.__internal__.serial.response.buffer.length===n){for(let t=14;t<n;t++)r[t-this.__internal__.serial.response.length]=this.__internal__.serial.response.buffer[t];if(r.length===this.__internal__.serial.response.length){const t=[];for(const e in r)t.push(r[e].toString(16));q(this,U,It).call(this,t),this.__internal__.serial.response.buffer=new Uint8Array(0)}}}}},ni=async function(){const r=this.__internal__.serial.port;if(!r||!r.readable)throw new Error("Port is not readable");for(;r.readable&&this.__internal__.serial.keep_reading;){const n=r.readable.getReader();this.__internal__.serial.reader=n;try{let t=!0;for(;t;){const{value:e,done:i}=await n.read();if(i){n.releaseLock(),this.__internal__.serial.keep_reading=!1,t=!1;break}q(this,U,Yn).call(this,e),this.__internal__.serial.response.length===null?await q(this,U,ti).call(this):await q(this,U,ei).call(this)}}catch(t){this.serialErrors(t)}finally{n.releaseLock()}}this.__internal__.serial.keep_reading=!0,this.__internal__.serial.port&&await this.__internal__.serial.port.close()},ii=async function(){return typeof window>"u"?!1:"serial"in navigator&&"forget"in SerialPort.prototype&&this.__internal__.serial.port?(await this.__internal__.serial.port.forget(),!0):!1},ri=function(){["serial:connected","serial:connecting","serial:reconnect","serial:timeout","serial:disconnected","serial:sent","serial:soft-reload","serial:message","unknown","serial:need-permission","serial:lost","serial:unsupported","serial:error","debug"].forEach(r=>{this.serialRegisterAvailableListener(r)})},si=function(){const r=this;this.on("internal:queue",async()=>{var n;await q(n=r,U,oi).call(n)}),q(this,U,ai).call(this)},ai=function(){const r=this;navigator.serial.addEventListener("connect",async()=>{r.isDisconnected&&await r.serialConnect().catch(()=>{})})},oi=async function(){if(!q(this,U,qt).call(this,this.__internal__.serial.port)){q(this,U,ee).call(this,{error:"Port is closed, not readable or writable."}),await this.serialConnect();return}if(this.__internal__.timeout.until_response||this.__internal__.serial.queue.length===0)return;const r=this.__internal__.serial.queue[0];let n=this.__internal__.time.response_general;r.action==="connect"&&(n=this.__internal__.time.response_connection),this.__internal__.timeout.until_response=setTimeout(async()=>{await this.timeout(r.bytes,r.action)},n),this.__internal__.serial.last_action=r.action??"unknown",await q(this,U,en).call(this,r.bytes),this.dispatch("serial:sent",{action:r.action,bytes:r.bytes}),this.__internal__.auto_response&&q(this,U,It).call(this,this.__internal__.serial.auto_response,null);const t=[...this.__internal__.serial.queue];this.__internal__.serial.queue=t.splice(1)},ci=function(r=1){this.__internal__.device_number=r,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(r)},li=function(){this.__internal__.last_error={message:null,action:null,code:null,no_code:0}},k.instance||(k.instance=new k);const ka={relay:[],locker:[],jofemar:[],boardroid:[],arduino:[],pinpad:[]};k.devices={...k.devices,...ka},k.addCustom=(r,n)=>{k.registerType(r),k.add(n)},k.getCustom=(r,n)=>k.get(r,n),k.getJofemarByUuid=r=>k.get("jofemar",r),k.getLockerByUuid=r=>k.get("locker",r),k.getRelayByUuid=r=>k.get("relay",r),k.getBoardroidByUuid=r=>k.get("boardroid",r),k.getArduinoByUuid=r=>k.get("arduino",r),k.getPinPadByUuid=r=>k.get("pinpad",r),k.getJofemar=(r=1)=>Object.values(k.devices.jofemar).find(t=>t.deviceNumber===r)??null,k.getBoardroid=(r=1)=>Object.values(k.devices.boardroid).find(t=>t.deviceNumber===r)??null,k.getLocker=(r=1)=>Object.values(k.devices.locker).find(t=>t.deviceNumber===r)??null,k.getRelay=(r=1)=>Object.values(k.devices.relay).find(t=>t.deviceNumber===r)??null,k.getArduino=(r=1)=>Object.values(k.devices.arduino).find(t=>t.deviceNumber===r)??null,k.getPinPad=(r=1)=>Object.values(k.devices.pinpad).find(t=>t.deviceNumber===r)??null;class xt extends Sa{constructor(n){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,t){await super.timeout(n,t),t==="dispense"&&(this.__internal__.dispense.status="no-response")}async serialPortsSaved(n){const t=this.serialFilters;if(this.__internal__.aux_port_connector<n.length){const e=this.__internal__.aux_port_connector;this.__internal__.serial.port=n[e]}else this.__internal__.aux_port_connector=0,this.__internal__.serial.port=await navigator.serial.requestPort({filters:t});if(!this.__internal__.serial.port)throw new Error("Select another port please")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){if(this.__internal__.dispense.must_response&&(await B(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response"))return this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"};this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{});const n=this;return new Promise(t=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(n.__internal__.dispense.status){case null:n.internalDispensingProcess()===!1&&(n.internalClearSensing(),n.dispatch("not-dispensed",{reason:"timeout"}),t({status:!1,error:"timeout"}));break;case!0:n.internalClearSensing(),n.__internal__.dispense.status=!0,n.dispatch("dispensed",{}),t({status:!0,error:null});break;case!1:n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-stock"}),t({status:!1,error:null});break;case"elevator-locked":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"elevator-locked"}),t({status:!1,error:"elevator-locked"});break;case"no-response":n.internalClearSensing(),n.__internal__.dispense.status=!1,n.dispatch("not-dispensed",{reason:"no-response"}),t({status:!1,error:"no-response"});break}},this.__internal__.time.sense)})}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(!fe.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(t=>{const e=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(e),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();t(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),k.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const t=[];for(const e in n.code)t.push(n.code[e].toString().padStart(2,"0").toLowerCase());this.serialMessage(t)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}}class xa extends xt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});Y(this,Me);Y(this,oe,{activate:["A0","01","01","A2"],deactivate:["A0","01","00","A1"]});if(this.__internal__.device.type="relay",this.__internal__.auto_response=!0,k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);o(this,Me,cr).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((i,s)=>{s!==3&&(e+=parseInt(i,16))}),e.toString(16).toUpperCase()}serialSetConnectionConstant(t=1){const e=["A0","01","00","A1"];return e[1]=this.hexMaker(this.decToHex(t.toString())),e[3]=this.serialRelaySumHex(e),this.add0x(e)}async turnOn(){const t=O(this,oe).activate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=O(this,oe).deactivate;t[3]=this.serialRelaySumHex(t),await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){const i=this;t?(await i.turnOff(),await B(e),await i.turnOn()):(await i.turnOn(),await B(e),await i.turnOff())}}oe=new WeakMap,Me=new WeakSet,cr=function(){k.add(this)};class Aa extends xt{constructor({filters:t=null,config_port:e=null,no_device:i=1,device_listen_on_port:s=3}={}){super({filters:t,config_port:e,no_device:i,device_listen_on_port:s});Y(this,R);Y(this,it,!1);Y(this,G,0);Y(this,Et,0);if(this.__internal__.device.type="locker",k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.device.milliseconds=666,this.__internal__.dispense.limit_counter=1,o(this,R,hr).call(this),o(this,R,lr).call(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1]){case"08":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"07":switch(t[4]){case"00":e.name="Cell closed.",e.description="The selected cell is closed.",e.request="dispense",e.no_code=1102,this.__internal__.dispense.status=!1,this.dispatch("dispensed",{}),O(this,it)&&O(this,G)>=89?(e.finished_test=!0,L(this,it,!1),L(this,G,0)):O(this,it)&&(e.finished_test=!1);break;case"01":case"04":e.name="Cell open.",e.description="The selected cell was open successfully.",e.request="dispense",e.no_code=102,this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),O(this,it)&&O(this,G)>=89?(e.finished_test=!0,L(this,it,!1),L(this,G,0)):O(this,it)&&(e.finished_test=!1);break;case"05":e.name="Cell inactive.",e.description="The selected cell is inactive or doesn't exist.",e.request="dispense",e.no_code=101,this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{}),O(this,it)&&O(this,G)>=89?(e.finished_test=!0,L(this,it,!1),L(this,G,0)):O(this,it)&&(e.finished_test=!1);break}break;case"06":e.name="Configuration applied.",e.description="The configuration was successfully applied.",e.request="configure cell",e.no_code=103;break;default:e.request="undefined",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=3){return this.add0x(this.serialLockerGetConnectionCmd(t))}serialLockerCmdMaker(t){const e=this.__internal__.device.milliseconds;let i=null;try{i=new Uint8Array(t.length+8),i.set(t,2),i[0]=2,i[1]=t.length+4,i[i.length-2]=3;let s=0;for(let l=1;l<t.length;l++)s+=t[l],s*=parseInt(Math.pow(2,l-1).toString());i[t.length+2]=s%256,i[t.length+3]=e*3%256,i[t.length+4]=e*8%256;let a=0;for(let l=3;l<t.length+5;l++)a+=i[l];i[t.length+5]=a%256;let c=0;for(let l=0;l<i.length-1;l++)c^=i[l];i[i.length-1]=c}catch(s){this.serialErrors(`Error generating command: ${s.message}`),i=null}return i}serialLockerHexCmd(t){const e=this.serialLockerCmdMaker(t),i=[];for(let s=0;s<e.length;s++)i.push(this.decToHex(e[s]));return i}serialLockerGetConnectionCmd(t=3){if(t<1||t>255)throw new Error("Invalid port number");return this.serialLockerHexCmd(new Uint8Array([0,t]))}parseCellToColumnRow(t){const e=Math.floor((t-1)/10)+1;let i=t%8;return i===0&&(i=8),[e,i]}async dispense({cell:t=1}={}){t=o(this,R,Ut).call(this,t);const e=o(this,R,pr).call(this,t);return await this.internalDispense(e)}async status({cell:t=1}={}){t=o(this,R,Ut).call(this,t);const e=o(this,R,ur).call(this,t);return await this.appendToQueue(e,"status")}async lightScan({since:t=0,until:e=10}={}){if(t<0||t>10)throw new Error("Invalid since number");if(e<0||e>10)throw new Error("Invalid until number");const i=o(this,R,dr).call(this,t,e);return await this.appendToQueue(i,"light-scan")}async enable({cell:t=1}={}){t=o(this,R,Ut).call(this,t);const[e,i]=this.parseCellToColumnRow(t),s=o(this,R,Tn).call(this,{enable:!0,column:e,row:i});await this.appendToQueue(s,"activate")}async disable({cell:t=1}={}){t=o(this,R,Ut).call(this,t);const[e,i]=this.parseCellToColumnRow(t),s=o(this,R,Tn).call(this,{enable:!1,column:e,row:i});await this.appendToQueue(s,"disable")}async openAll(){if(this.isDispensing)throw new Error("Another dispensing process is running");o(this,R,Lt).call(this),L(this,it,!0),o(this,R,Le).call(this);const t=[];for(let e=1;e<=90;e++){const i=await this.dispense(e);t.push(i),L(this,G,e),o(this,R,Le).call(this)}L(this,G,90),o(this,R,Le).call(this,t),o(this,R,Lt).call(this)}async enableAll(){o(this,R,Lt).call(this),L(this,it,!0),o(this,R,Ve).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,Ve).call(this);L(this,G,90),o(this,R,Ve).call(this),o(this,R,Lt).call(this)}async disableAll(){o(this,R,Lt).call(this),L(this,it,!0),o(this,R,qe).call(this);for(let t=1;t<=90;t++)await this.enable(t),L(this,G,t),o(this,R,qe).call(this);L(this,G,90),o(this,R,qe).call(this),o(this,R,Lt).call(this)}}it=new WeakMap,G=new WeakMap,Et=new WeakMap,R=new WeakSet,lr=function(){const t=["percentage:disable","percentage:enable","percentage:open"];for(const e of t)this.serialRegisterAvailableListener(e)},hr=function(){k.add(this)},ur=function(t=1){return t=o(this,R,Ut).call(this,t),this.serialLockerHexCmd(new Uint8Array([16,this.__internal__.device.listen_on_port,t]))},dr=function(t=0,e=10){return this.serialLockerHexCmd(new Uint8Array([32,this.__internal__.device.listen_on_port,t,e]))},Tn=function({enable:t=!0,column:e=0,row:i=10}={}){if(e<0||e>8)throw new Error("Invalid column number");if(i<0||i>10)throw new Error("Invalid row number");let s=1;return t||(s=0),this.serialLockerHexCmd(new Uint8Array([48,this.__internal__.device.listen_on_port,e,i,s]))},pr=function(t=1){t=o(this,R,Ut).call(this,t);const e=this.__internal__.device.milliseconds,i=e%256,s=Math.floor(e/3)%256;return this.serialLockerHexCmd(new Uint8Array([64,this.__internal__.device.listen_on_port,t,i,s]))},Ut=function(t){const e=parseInt(t);if(isNaN(e)||e<1||e>90)throw new Error("Invalid cell number");return e},Lt=function(){L(this,it,!1),L(this,G,0),L(this,Et,0)},Le=function(t=null){L(this,Et,Math.round(O(this,G)*100/90)),this.dispatch("percentage:open",{percentage:O(this,Et),dispensed:t})},Ve=function(){L(this,Et,Math.round(O(this,G)*100/90)),this.dispatch("percentage:enable",{percentage:O(this,Et)})},qe=function(){L(this,Et,Math.round(O(this,G)*100/90)),this.dispatch("percentage:disable",{percentage:O(this,Et)})};var Da="0123456789abcdefghijklmnopqrstuvwxyz";function kt(r){return Da.charAt(r)}function Ra(r,n){return r&n}function ge(r,n){return r|n}function hi(r,n){return r^n}function ui(r,n){return r&~n}function Ia(r){if(r==0)return-1;var n=0;return(r&65535)==0&&(r>>=16,n+=16),(r&255)==0&&(r>>=8,n+=8),(r&15)==0&&(r>>=4,n+=4),(r&3)==0&&(r>>=2,n+=2),(r&1)==0&&++n,n}function Oa(r){for(var n=0;r!=0;)r&=r-1,++n;return n}var jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",di="=";function be(r){var n,t,e="";for(n=0;n+3<=r.length;n+=3)t=parseInt(r.substring(n,n+3),16),e+=jt.charAt(t>>6)+jt.charAt(t&63);for(n+1==r.length?(t=parseInt(r.substring(n,n+1),16),e+=jt.charAt(t<<2)):n+2==r.length&&(t=parseInt(r.substring(n,n+2),16),e+=jt.charAt(t>>2)+jt.charAt((t&3)<<4));(e.length&3)>0;)e+=di;return e}function pi(r){var n="",t,e=0,i=0;for(t=0;t<r.length&&r.charAt(t)!=di;++t){var s=jt.indexOf(r.charAt(t));s<0||(e==0?(n+=kt(s>>2),i=s&3,e=1):e==1?(n+=kt(i<<2|s>>4),i=s&15,e=2):e==2?(n+=kt(i),n+=kt(s>>2),i=s&3,e=3):(n+=kt(i<<2|s>>4),n+=kt(s&15),e=0))}return e==1&&(n+=kt(i<<2)),n}var Ht,Ba={decode:function(r){var n;if(Ht===void 0){var t="0123456789ABCDEF",e=` \f
5
+ \r  \u2028\u2029`;for(Ht={},n=0;n<16;++n)Ht[t.charAt(n)]=n;for(t=t.toLowerCase(),n=10;n<16;++n)Ht[t.charAt(n)]=n;for(n=0;n<e.length;++n)Ht[e.charAt(n)]=-1}var i=[],s=0,a=0;for(n=0;n<r.length;++n){var c=r.charAt(n);if(c=="=")break;if(c=Ht[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+n);s|=c,++a>=2?(i[i.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return i}},Ot,nn={decode:function(r){var n;if(Ot===void 0){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=`= \f
6
+ \r  \u2028\u2029`;for(Ot=Object.create(null),n=0;n<64;++n)Ot[t.charAt(n)]=n;for(Ot["-"]=62,Ot._=63,n=0;n<e.length;++n)Ot[e.charAt(n)]=-1}var i=[],s=0,a=0;for(n=0;n<r.length;++n){var c=r.charAt(n);if(c=="=")break;if(c=Ot[c],c!=-1){if(c===void 0)throw new Error("Illegal character at offset "+n);s|=c,++a>=4?(i[i.length]=s>>16,i[i.length]=s>>8&255,i[i.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=s>>10;break;case 3:i[i.length]=s>>16,i[i.length]=s>>8&255;break}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(r){var n=nn.re.exec(r);if(n)if(n[1])r=n[1];else if(n[2])r=n[2];else throw new Error("RegExp out of sync");return nn.decode(r)}},Kt=1e13,ne=function(){function r(n){this.buf=[+n||0]}return r.prototype.mulAdd=function(n,t){var e=this.buf,i=e.length,s,a;for(s=0;s<i;++s)a=e[s]*n+t,a<Kt?t=0:(t=0|a/Kt,a-=t*Kt),e[s]=a;t>0&&(e[s]=t)},r.prototype.sub=function(n){var t=this.buf,e=t.length,i,s;for(i=0;i<e;++i)s=t[i]-n,s<0?(s+=Kt,n=1):n=0,t[i]=s;for(;t[t.length-1]===0;)t.pop()},r.prototype.toString=function(n){if((n||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,e=t[t.length-1].toString(),i=t.length-2;i>=0;--i)e+=(Kt+t[i]).toString().substring(1);return e},r.prototype.valueOf=function(){for(var n=this.buf,t=0,e=n.length-1;e>=0;--e)t=t*Kt+n[e];return t},r.prototype.simplify=function(){var n=this.buf;return n.length==1?n[0]:this},r}(),_i="…",Na=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Ma=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Wt(r,n){return r.length>n&&(r=r.substring(0,n)+_i),r}var rn=function(){function r(n,t){this.hexDigits="0123456789ABCDEF",n instanceof r?(this.enc=n.enc,this.pos=n.pos):(this.enc=n,this.pos=t)}return r.prototype.get=function(n){if(n===void 0&&(n=this.pos++),n>=this.enc.length)throw new Error("Requesting byte offset ".concat(n," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(n):this.enc[n]},r.prototype.hexByte=function(n){return this.hexDigits.charAt(n>>4&15)+this.hexDigits.charAt(n&15)},r.prototype.hexDump=function(n,t,e){for(var i="",s=n;s<t;++s)if(i+=this.hexByte(this.get(s)),e!==!0)switch(s&15){case 7:i+=" ";break;case 15:i+=`
7
+ `;break;default:i+=" "}return i},r.prototype.isASCII=function(n,t){for(var e=n;e<t;++e){var i=this.get(e);if(i<32||i>176)return!1}return!0},r.prototype.parseStringISO=function(n,t){for(var e="",i=n;i<t;++i)e+=String.fromCharCode(this.get(i));return e},r.prototype.parseStringUTF=function(n,t){for(var e="",i=n;i<t;){var s=this.get(i++);s<128?e+=String.fromCharCode(s):s>191&&s<224?e+=String.fromCharCode((s&31)<<6|this.get(i++)&63):e+=String.fromCharCode((s&15)<<12|(this.get(i++)&63)<<6|this.get(i++)&63)}return e},r.prototype.parseStringBMP=function(n,t){for(var e="",i,s,a=n;a<t;)i=this.get(a++),s=this.get(a++),e+=String.fromCharCode(i<<8|s);return e},r.prototype.parseTime=function(n,t,e){var i=this.parseStringISO(n,t),s=(e?Na:Ma).exec(i);return s?(e&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),i=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(i+=":"+s[5],s[6]&&(i+=":"+s[6],s[7]&&(i+="."+s[7]))),s[8]&&(i+=" UTC",s[8]!="Z"&&(i+=s[8],s[9]&&(i+=":"+s[9]))),i):"Unrecognized time: "+i},r.prototype.parseInteger=function(n,t){for(var e=this.get(n),i=e>127,s=i?255:0,a,c="";e==s&&++n<t;)e=this.get(n);if(a=t-n,a===0)return i?-1:0;if(a>4){for(c=e,a<<=3;((+c^s)&128)==0;)c=+c<<1,--a;c="("+a+` bit)
8
+ `}i&&(e=e-256);for(var l=new ne(e),h=n+1;h<t;++h)l.mulAdd(256,this.get(h));return c+l.toString()},r.prototype.parseBitString=function(n,t,e){for(var i=this.get(n),s=(t-n-1<<3)-i,a="("+s+` bit)
9
+ `,c="",l=n+1;l<t;++l){for(var h=this.get(l),_=l==t-1?i:0,f=7;f>=_;--f)c+=h>>f&1?"1":"0";if(c.length>e)return a+Wt(c,e)}return a+c},r.prototype.parseOctetString=function(n,t,e){if(this.isASCII(n,t))return Wt(this.parseStringISO(n,t),e);var i=t-n,s="("+i+` byte)
10
+ `;e/=2,i>e&&(t=n+e);for(var a=n;a<t;++a)s+=this.hexByte(this.get(a));return i>e&&(s+=_i),s},r.prototype.parseOID=function(n,t,e){for(var i="",s=new ne,a=0,c=n;c<t;++c){var l=this.get(c);if(s.mulAdd(128,l&127),a+=7,!(l&128)){if(i==="")if(s=s.simplify(),s instanceof ne)s.sub(80),i="2."+s.toString();else{var h=s<80?s<40?0:1:2;i=h+"."+(s-h*40)}else i+="."+s.toString();if(i.length>e)return Wt(i,e);s=new ne,a=0}}return a>0&&(i+=".incomplete"),i},r}(),Fa=function(){function r(n,t,e,i,s){if(!(i instanceof fi))throw new Error("Invalid tag value.");this.stream=n,this.header=t,this.length=e,this.tag=i,this.sub=s}return r.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},r.prototype.content=function(n){if(this.tag===void 0)return null;n===void 0&&(n=1/0);var t=this.posContent(),e=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,n);switch(this.tag.tagNumber){case 1:return this.stream.get(t)===0?"false":"true";case 2:return this.stream.parseInteger(t,t+e);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+e,n);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+e,n);case 6:return this.stream.parseOID(t,t+e,n);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return Wt(this.stream.parseStringUTF(t,t+e),n);case 18:case 19:case 20:case 21:case 22:case 26:return Wt(this.stream.parseStringISO(t,t+e),n);case 30:return Wt(this.stream.parseStringBMP(t,t+e),n);case 23:case 24:return this.stream.parseTime(t,t+e,this.tag.tagNumber==23)}return null},r.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"},r.prototype.toPrettyString=function(n){n===void 0&&(n="");var t=n+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(t+=" (encapsulates)"),t+=`
11
+ `,this.sub!==null){n+=" ";for(var e=0,i=this.sub.length;e<i;++e)t+=this.sub[e].toPrettyString(n)}return t},r.prototype.posStart=function(){return this.stream.pos},r.prototype.posContent=function(){return this.stream.pos+this.header},r.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},r.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},r.decodeLength=function(n){var t=n.get(),e=t&127;if(e==t)return e;if(e>6)throw new Error("Length over 48 bits not supported at position "+(n.pos-1));if(e===0)return null;t=0;for(var i=0;i<e;++i)t=t*256+n.get();return t},r.prototype.getHexStringValue=function(){var n=this.toHexString(),t=this.header*2,e=this.length*2;return n.substr(t,e)},r.decode=function(n){var t;n instanceof rn?t=n:t=new rn(n,0);var e=new rn(t),i=new fi(t),s=r.decodeLength(t),a=t.pos,c=a-e.pos,l=null,h=function(){var f=[];if(s!==null){for(var y=a+s;t.pos<y;)f[f.length]=r.decode(t);if(t.pos!=y)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var P=r.decode(t);if(P.tag.isEOC())break;f[f.length]=P}s=a-t.pos}catch(v){throw new Error("Exception while decoding undefined length content: "+v)}return f};if(i.tagConstructed)l=h();else if(i.isUniversal()&&(i.tagNumber==3||i.tagNumber==4))try{if(i.tagNumber==3&&t.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");l=h();for(var _=0;_<l.length;++_)if(l[_].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{l=null}if(l===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);t.pos=a+Math.abs(s)}return new r(e,c,s,i,l)},r}(),fi=function(){function r(n){var t=n.get();if(this.tagClass=t>>6,this.tagConstructed=(t&32)!==0,this.tagNumber=t&31,this.tagNumber==31){var e=new ne;do t=n.get(),e.mulAdd(128,t&127);while(t&128);this.tagNumber=e.simplify()}}return r.prototype.isUniversal=function(){return this.tagClass===0},r.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},r}(),At,Ua=0xdeadbeefcafe,gi=(Ua&16777215)==15715070,rt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],La=(1<<26)/rt[rt.length-1],D=function(){function r(n,t,e){n!=null&&(typeof n=="number"?this.fromNumber(n,t,e):t==null&&typeof n!="string"?this.fromString(n,256):this.fromString(n,t))}return r.prototype.toString=function(n){if(this.s<0)return"-"+this.negate().toString(n);var t;if(n==16)t=4;else if(n==8)t=3;else if(n==2)t=1;else if(n==32)t=5;else if(n==4)t=2;else return this.toRadix(n);var e=(1<<t)-1,i,s=!1,a="",c=this.t,l=this.DB-c*this.DB%t;if(c-- >0)for(l<this.DB&&(i=this[c]>>l)>0&&(s=!0,a=kt(i));c>=0;)l<t?(i=(this[c]&(1<<l)-1)<<t-l,i|=this[--c]>>(l+=this.DB-t)):(i=this[c]>>(l-=t)&e,l<=0&&(l+=this.DB,--c)),i>0&&(s=!0),s&&(a+=kt(i));return s?a:"0"},r.prototype.negate=function(){var n=N();return r.ZERO.subTo(this,n),n},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(n){var t=this.s-n.s;if(t!=0)return t;var e=this.t;if(t=e-n.t,t!=0)return this.s<0?-t:t;for(;--e>=0;)if((t=this[e]-n[e])!=0)return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+me(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(n){var t=N();return this.abs().divRemTo(n,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&n.subTo(t,t),t},r.prototype.modPowInt=function(n,t){var e;return n<256||t.isEven()?e=new bi(t):e=new yi(t),this.exp(n,e)},r.prototype.clone=function(){var n=N();return this.copyTo(n),n},r.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var n=this.t,t=[];t[0]=this.s;var e=this.DB-n*this.DB%8,i,s=0;if(n-- >0)for(e<this.DB&&(i=this[n]>>e)!=(this.s&this.DM)>>e&&(t[s++]=i|this.s<<this.DB-e);n>=0;)e<8?(i=(this[n]&(1<<e)-1)<<8-e,i|=this[--n]>>(e+=this.DB-8)):(i=this[n]>>(e-=8)&255,e<=0&&(e+=this.DB,--n)),(i&128)!=0&&(i|=-256),s==0&&(this.s&128)!=(i&128)&&++s,(s>0||i!=this.s)&&(t[s++]=i);return t},r.prototype.equals=function(n){return this.compareTo(n)==0},r.prototype.min=function(n){return this.compareTo(n)<0?this:n},r.prototype.max=function(n){return this.compareTo(n)>0?this:n},r.prototype.and=function(n){var t=N();return this.bitwiseTo(n,Ra,t),t},r.prototype.or=function(n){var t=N();return this.bitwiseTo(n,ge,t),t},r.prototype.xor=function(n){var t=N();return this.bitwiseTo(n,hi,t),t},r.prototype.andNot=function(n){var t=N();return this.bitwiseTo(n,ui,t),t},r.prototype.not=function(){for(var n=N(),t=0;t<this.t;++t)n[t]=this.DM&~this[t];return n.t=this.t,n.s=~this.s,n},r.prototype.shiftLeft=function(n){var t=N();return n<0?this.rShiftTo(-n,t):this.lShiftTo(n,t),t},r.prototype.shiftRight=function(n){var t=N();return n<0?this.lShiftTo(-n,t):this.rShiftTo(n,t),t},r.prototype.getLowestSetBit=function(){for(var n=0;n<this.t;++n)if(this[n]!=0)return n*this.DB+Ia(this[n]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var n=0,t=this.s&this.DM,e=0;e<this.t;++e)n+=Oa(this[e]^t);return n},r.prototype.testBit=function(n){var t=Math.floor(n/this.DB);return t>=this.t?this.s!=0:(this[t]&1<<n%this.DB)!=0},r.prototype.setBit=function(n){return this.changeBit(n,ge)},r.prototype.clearBit=function(n){return this.changeBit(n,ui)},r.prototype.flipBit=function(n){return this.changeBit(n,hi)},r.prototype.add=function(n){var t=N();return this.addTo(n,t),t},r.prototype.subtract=function(n){var t=N();return this.subTo(n,t),t},r.prototype.multiply=function(n){var t=N();return this.multiplyTo(n,t),t},r.prototype.divide=function(n){var t=N();return this.divRemTo(n,t,null),t},r.prototype.remainder=function(n){var t=N();return this.divRemTo(n,null,t),t},r.prototype.divideAndRemainder=function(n){var t=N(),e=N();return this.divRemTo(n,t,e),[t,e]},r.prototype.modPow=function(n,t){var e=n.bitLength(),i,s=Dt(1),a;if(e<=0)return s;e<18?i=1:e<48?i=3:e<144?i=4:e<768?i=5:i=6,e<8?a=new bi(t):t.isEven()?a=new qa(t):a=new yi(t);var c=[],l=3,h=i-1,_=(1<<i)-1;if(c[1]=a.convert(this),i>1){var f=N();for(a.sqrTo(c[1],f);l<=_;)c[l]=N(),a.mulTo(f,c[l-2],c[l]),l+=2}var y=n.t-1,P,v=!0,S=N(),T;for(e=me(n[y])-1;y>=0;){for(e>=h?P=n[y]>>e-h&_:(P=(n[y]&(1<<e+1)-1)<<h-e,y>0&&(P|=n[y-1]>>this.DB+e-h)),l=i;(P&1)==0;)P>>=1,--l;if((e-=l)<0&&(e+=this.DB,--y),v)c[P].copyTo(s),v=!1;else{for(;l>1;)a.sqrTo(s,S),a.sqrTo(S,s),l-=2;l>0?a.sqrTo(s,S):(T=s,s=S,S=T),a.mulTo(S,c[P],s)}for(;y>=0&&(n[y]&1<<e)==0;)a.sqrTo(s,S),T=s,s=S,S=T,--e<0&&(e=this.DB-1,--y)}return a.revert(s)},r.prototype.modInverse=function(n){var t=n.isEven();if(this.isEven()&&t||n.signum()==0)return r.ZERO;for(var e=n.clone(),i=this.clone(),s=Dt(1),a=Dt(0),c=Dt(0),l=Dt(1);e.signum()!=0;){for(;e.isEven();)e.rShiftTo(1,e),t?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(n,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(n,a),a.rShiftTo(1,a);for(;i.isEven();)i.rShiftTo(1,i),t?((!c.isEven()||!l.isEven())&&(c.addTo(this,c),l.subTo(n,l)),c.rShiftTo(1,c)):l.isEven()||l.subTo(n,l),l.rShiftTo(1,l);e.compareTo(i)>=0?(e.subTo(i,e),t&&s.subTo(c,s),a.subTo(l,a)):(i.subTo(e,i),t&&c.subTo(s,c),l.subTo(a,l))}if(i.compareTo(r.ONE)!=0)return r.ZERO;if(l.compareTo(n)>=0)return l.subtract(n);if(l.signum()<0)l.addTo(n,l);else return l;return l.signum()<0?l.add(n):l},r.prototype.pow=function(n){return this.exp(n,new Va)},r.prototype.gcd=function(n){var t=this.s<0?this.negate():this.clone(),e=n.s<0?n.negate():n.clone();if(t.compareTo(e)<0){var i=t;t=e,e=i}var s=t.getLowestSetBit(),a=e.getLowestSetBit();if(a<0)return t;for(s<a&&(a=s),a>0&&(t.rShiftTo(a,t),e.rShiftTo(a,e));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),t.compareTo(e)>=0?(t.subTo(e,t),t.rShiftTo(1,t)):(e.subTo(t,e),e.rShiftTo(1,e));return a>0&&e.lShiftTo(a,e),e},r.prototype.isProbablePrime=function(n){var t,e=this.abs();if(e.t==1&&e[0]<=rt[rt.length-1]){for(t=0;t<rt.length;++t)if(e[0]==rt[t])return!0;return!1}if(e.isEven())return!1;for(t=1;t<rt.length;){for(var i=rt[t],s=t+1;s<rt.length&&i<La;)i*=rt[s++];for(i=e.modInt(i);t<s;)if(i%rt[t++]==0)return!1}return e.millerRabin(n)},r.prototype.copyTo=function(n){for(var t=this.t-1;t>=0;--t)n[t]=this[t];n.t=this.t,n.s=this.s},r.prototype.fromInt=function(n){this.t=1,this.s=n<0?-1:0,n>0?this[0]=n:n<-1?this[0]=n+this.DV:this.t=0},r.prototype.fromString=function(n,t){var e;if(t==16)e=4;else if(t==8)e=3;else if(t==256)e=8;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else{this.fromRadix(n,t);return}this.t=0,this.s=0;for(var i=n.length,s=!1,a=0;--i>=0;){var c=e==8?+n[i]&255:wi(n,i);if(c<0){n.charAt(i)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=c:a+e>this.DB?(this[this.t-1]|=(c&(1<<this.DB-a)-1)<<a,this[this.t++]=c>>this.DB-a):this[this.t-1]|=c<<a,a+=e,a>=this.DB&&(a-=this.DB)}e==8&&(+n[0]&128)!=0&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var n=this.s&this.DM;this.t>0&&this[this.t-1]==n;)--this.t},r.prototype.dlShiftTo=function(n,t){var e;for(e=this.t-1;e>=0;--e)t[e+n]=this[e];for(e=n-1;e>=0;--e)t[e]=0;t.t=this.t+n,t.s=this.s},r.prototype.drShiftTo=function(n,t){for(var e=n;e<this.t;++e)t[e-n]=this[e];t.t=Math.max(this.t-n,0),t.s=this.s},r.prototype.lShiftTo=function(n,t){for(var e=n%this.DB,i=this.DB-e,s=(1<<i)-1,a=Math.floor(n/this.DB),c=this.s<<e&this.DM,l=this.t-1;l>=0;--l)t[l+a+1]=this[l]>>i|c,c=(this[l]&s)<<e;for(var l=a-1;l>=0;--l)t[l]=0;t[a]=c,t.t=this.t+a+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(n,t){t.s=this.s;var e=Math.floor(n/this.DB);if(e>=this.t){t.t=0;return}var i=n%this.DB,s=this.DB-i,a=(1<<i)-1;t[0]=this[e]>>i;for(var c=e+1;c<this.t;++c)t[c-e-1]|=(this[c]&a)<<s,t[c-e]=this[c]>>i;i>0&&(t[this.t-e-1]|=(this.s&a)<<s),t.t=this.t-e,t.clamp()},r.prototype.subTo=function(n,t){for(var e=0,i=0,s=Math.min(n.t,this.t);e<s;)i+=this[e]-n[e],t[e++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i-=n.s;e<this.t;)i+=this[e],t[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<n.t;)i-=n[e],t[e++]=i&this.DM,i>>=this.DB;i-=n.s}t.s=i<0?-1:0,i<-1?t[e++]=this.DV+i:i>0&&(t[e++]=i),t.t=e,t.clamp()},r.prototype.multiplyTo=function(n,t){var e=this.abs(),i=n.abs(),s=e.t;for(t.t=s+i.t;--s>=0;)t[s]=0;for(s=0;s<i.t;++s)t[s+e.t]=e.am(0,i[s],t,s,0,e.t);t.s=0,t.clamp(),this.s!=n.s&&r.ZERO.subTo(t,t)},r.prototype.squareTo=function(n){for(var t=this.abs(),e=n.t=2*t.t;--e>=0;)n[e]=0;for(e=0;e<t.t-1;++e){var i=t.am(e,t[e],n,2*e,0,1);(n[e+t.t]+=t.am(e+1,2*t[e],n,2*e+1,i,t.t-e-1))>=t.DV&&(n[e+t.t]-=t.DV,n[e+t.t+1]=1)}n.t>0&&(n[n.t-1]+=t.am(e,t[e],n,2*e,0,1)),n.s=0,n.clamp()},r.prototype.divRemTo=function(n,t,e){var i=n.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t){t!=null&&t.fromInt(0),e!=null&&this.copyTo(e);return}e==null&&(e=N());var a=N(),c=this.s,l=n.s,h=this.DB-me(i[i.t-1]);h>0?(i.lShiftTo(h,a),s.lShiftTo(h,e)):(i.copyTo(a),s.copyTo(e));var _=a.t,f=a[_-1];if(f!=0){var y=f*(1<<this.F1)+(_>1?a[_-2]>>this.F2:0),P=this.FV/y,v=(1<<this.F1)/y,S=1<<this.F2,T=e.t,H=T-_,V=t??N();for(a.dlShiftTo(H,V),e.compareTo(V)>=0&&(e[e.t++]=1,e.subTo(V,e)),r.ONE.dlShiftTo(_,V),V.subTo(a,a);a.t<_;)a[a.t++]=0;for(;--H>=0;){var W=e[--T]==f?this.DM:Math.floor(e[T]*P+(e[T-1]+S)*v);if((e[T]+=a.am(0,W,e,H,0,_))<W)for(a.dlShiftTo(H,V),e.subTo(V,e);e[T]<--W;)e.subTo(V,e)}t!=null&&(e.drShiftTo(_,t),c!=l&&r.ZERO.subTo(t,t)),e.t=_,e.clamp(),h>0&&e.rShiftTo(h,e),c<0&&r.ZERO.subTo(e,e)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var n=this[0];if((n&1)==0)return 0;var t=n&3;return t=t*(2-(n&15)*t)&15,t=t*(2-(n&255)*t)&255,t=t*(2-((n&65535)*t&65535))&65535,t=t*(2-n*t%this.DV)%this.DV,t>0?this.DV-t:-t},r.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},r.prototype.exp=function(n,t){if(n>4294967295||n<1)return r.ONE;var e=N(),i=N(),s=t.convert(this),a=me(n)-1;for(s.copyTo(e);--a>=0;)if(t.sqrTo(e,i),(n&1<<a)>0)t.mulTo(i,s,e);else{var c=e;e=i,i=c}return t.revert(e)},r.prototype.chunkSize=function(n){return Math.floor(Math.LN2*this.DB/Math.log(n))},r.prototype.toRadix=function(n){if(n==null&&(n=10),this.signum()==0||n<2||n>36)return"0";var t=this.chunkSize(n),e=Math.pow(n,t),i=Dt(e),s=N(),a=N(),c="";for(this.divRemTo(i,s,a);s.signum()>0;)c=(e+a.intValue()).toString(n).substr(1)+c,s.divRemTo(i,s,a);return a.intValue().toString(n)+c},r.prototype.fromRadix=function(n,t){this.fromInt(0),t==null&&(t=10);for(var e=this.chunkSize(t),i=Math.pow(t,e),s=!1,a=0,c=0,l=0;l<n.length;++l){var h=wi(n,l);if(h<0){n.charAt(l)=="-"&&this.signum()==0&&(s=!0);continue}c=t*c+h,++a>=e&&(this.dMultiply(i),this.dAddOffset(c,0),a=0,c=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(c,0)),s&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(n,t,e){if(typeof t=="number")if(n<2)this.fromInt(1);else for(this.fromNumber(n,e),this.testBit(n-1)||this.bitwiseTo(r.ONE.shiftLeft(n-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>n&&this.subTo(r.ONE.shiftLeft(n-1),this);else{var i=[],s=n&7;i.length=(n>>3)+1,t.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},r.prototype.bitwiseTo=function(n,t,e){var i,s,a=Math.min(n.t,this.t);for(i=0;i<a;++i)e[i]=t(this[i],n[i]);if(n.t<this.t){for(s=n.s&this.DM,i=a;i<this.t;++i)e[i]=t(this[i],s);e.t=this.t}else{for(s=this.s&this.DM,i=a;i<n.t;++i)e[i]=t(s,n[i]);e.t=n.t}e.s=t(this.s,n.s),e.clamp()},r.prototype.changeBit=function(n,t){var e=r.ONE.shiftLeft(n);return this.bitwiseTo(e,t,e),e},r.prototype.addTo=function(n,t){for(var e=0,i=0,s=Math.min(n.t,this.t);e<s;)i+=this[e]+n[e],t[e++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i+=n.s;e<this.t;)i+=this[e],t[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<n.t;)i+=n[e],t[e++]=i&this.DM,i>>=this.DB;i+=n.s}t.s=i<0?-1:0,i>0?t[e++]=i:i<-1&&(t[e++]=this.DV+i),t.t=e,t.clamp()},r.prototype.dMultiply=function(n){this[this.t]=this.am(0,n-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(n,t){if(n!=0){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=n;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.prototype.multiplyLowerTo=function(n,t,e){var i=Math.min(this.t+n.t,t);for(e.s=0,e.t=i;i>0;)e[--i]=0;for(var s=e.t-this.t;i<s;++i)e[i+this.t]=this.am(0,n[i],e,i,0,this.t);for(var s=Math.min(n.t,t);i<s;++i)this.am(0,n[i],e,i,0,t-i);e.clamp()},r.prototype.multiplyUpperTo=function(n,t,e){--t;var i=e.t=this.t+n.t-t;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(t-this.t,0);i<n.t;++i)e[this.t+i-t]=this.am(t-i,n[i],e,0,0,this.t+i-t);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(n){if(n<=0)return 0;var t=this.DV%n,e=this.s<0?n-1:0;if(this.t>0)if(t==0)e=this[0]%n;else for(var i=this.t-1;i>=0;--i)e=(t*e+this[i])%n;return e},r.prototype.millerRabin=function(n){var t=this.subtract(r.ONE),e=t.getLowestSetBit();if(e<=0)return!1;var i=t.shiftRight(e);n=n+1>>1,n>rt.length&&(n=rt.length);for(var s=N(),a=0;a<n;++a){s.fromInt(rt[Math.floor(Math.random()*rt.length)]);var c=s.modPow(i,this);if(c.compareTo(r.ONE)!=0&&c.compareTo(t)!=0){for(var l=1;l++<e&&c.compareTo(t)!=0;)if(c=c.modPowInt(2,this),c.compareTo(r.ONE)==0)return!1;if(c.compareTo(t)!=0)return!1}}return!0},r.prototype.square=function(){var n=N();return this.squareTo(n),n},r.prototype.gcda=function(n,t){var e=this.s<0?this.negate():this.clone(),i=n.s<0?n.negate():n.clone();if(e.compareTo(i)<0){var s=e;e=i,i=s}var a=e.getLowestSetBit(),c=i.getLowestSetBit();if(c<0){t(e);return}a<c&&(c=a),c>0&&(e.rShiftTo(c,e),i.rShiftTo(c,i));var l=function(){(a=e.getLowestSetBit())>0&&e.rShiftTo(a,e),(a=i.getLowestSetBit())>0&&i.rShiftTo(a,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i)),e.signum()>0?setTimeout(l,0):(c>0&&i.lShiftTo(c,i),setTimeout(function(){t(i)},0))};setTimeout(l,10)},r.prototype.fromNumberAsync=function(n,t,e,i){if(typeof t=="number")if(n<2)this.fromInt(1);else{this.fromNumber(n,e),this.testBit(n-1)||this.bitwiseTo(r.ONE.shiftLeft(n-1),ge,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>n&&s.subTo(r.ONE.shiftLeft(n-1),s),s.isProbablePrime(t)?setTimeout(function(){i()},0):setTimeout(a,0)};setTimeout(a,0)}else{var c=[],l=n&7;c.length=(n>>3)+1,t.nextBytes(c),l>0?c[0]&=(1<<l)-1:c[0]=0,this.fromString(c,256)}},r}(),Va=function(){function r(){}return r.prototype.convert=function(n){return n},r.prototype.revert=function(n){return n},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e)},r.prototype.sqrTo=function(n,t){n.squareTo(t)},r}(),bi=function(){function r(n){this.m=n}return r.prototype.convert=function(n){return n.s<0||n.compareTo(this.m)>=0?n.mod(this.m):n},r.prototype.revert=function(n){return n},r.prototype.reduce=function(n){n.divRemTo(this.m,null,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}(),yi=function(){function r(n){this.m=n,this.mp=n.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<n.DB-15)-1,this.mt2=2*n.t}return r.prototype.convert=function(n){var t=N();return n.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),n.s<0&&t.compareTo(D.ZERO)>0&&this.m.subTo(t,t),t},r.prototype.revert=function(n){var t=N();return n.copyTo(t),this.reduce(t),t},r.prototype.reduce=function(n){for(;n.t<=this.mt2;)n[n.t++]=0;for(var t=0;t<this.m.t;++t){var e=n[t]&32767,i=e*this.mpl+((e*this.mph+(n[t]>>15)*this.mpl&this.um)<<15)&n.DM;for(e=t+this.m.t,n[e]+=this.m.am(0,i,n,t,0,this.m.t);n[e]>=n.DV;)n[e]-=n.DV,n[++e]++}n.clamp(),n.drShiftTo(this.m.t,n),n.compareTo(this.m)>=0&&n.subTo(this.m,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}(),qa=function(){function r(n){this.m=n,this.r2=N(),this.q3=N(),D.ONE.dlShiftTo(2*n.t,this.r2),this.mu=this.r2.divide(n)}return r.prototype.convert=function(n){if(n.s<0||n.t>2*this.m.t)return n.mod(this.m);if(n.compareTo(this.m)<0)return n;var t=N();return n.copyTo(t),this.reduce(t),t},r.prototype.revert=function(n){return n},r.prototype.reduce=function(n){for(n.drShiftTo(this.m.t-1,this.r2),n.t>this.m.t+1&&(n.t=this.m.t+1,n.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);n.compareTo(this.r2)<0;)n.dAddOffset(1,this.m.t+1);for(n.subTo(this.r2,n);n.compareTo(this.m)>=0;)n.subTo(this.m,n)},r.prototype.mulTo=function(n,t,e){n.multiplyTo(t,e),this.reduce(e)},r.prototype.sqrTo=function(n,t){n.squareTo(t),this.reduce(t)},r}();function N(){return new D(null)}function $(r,n){return new D(r,n)}var mi=typeof navigator<"u";mi&&gi&&navigator.appName=="Microsoft Internet Explorer"?(D.prototype.am=function(n,t,e,i,s,a){for(var c=t&32767,l=t>>15;--a>=0;){var h=this[n]&32767,_=this[n++]>>15,f=l*h+_*c;h=c*h+((f&32767)<<15)+e[i]+(s&1073741823),s=(h>>>30)+(f>>>15)+l*_+(s>>>30),e[i++]=h&1073741823}return s},At=30):mi&&gi&&navigator.appName!="Netscape"?(D.prototype.am=function(n,t,e,i,s,a){for(;--a>=0;){var c=t*this[n++]+e[i]+s;s=Math.floor(c/67108864),e[i++]=c&67108863}return s},At=26):(D.prototype.am=function(n,t,e,i,s,a){for(var c=t&16383,l=t>>14;--a>=0;){var h=this[n]&16383,_=this[n++]>>14,f=l*h+_*c;h=c*h+((f&16383)<<14)+e[i]+s,s=(h>>28)+(f>>14)+l*_,e[i++]=h&268435455}return s},At=28),D.prototype.DB=At,D.prototype.DM=(1<<At)-1,D.prototype.DV=1<<At;var sn=52;D.prototype.FV=Math.pow(2,sn),D.prototype.F1=sn-At,D.prototype.F2=2*At-sn;var ye=[],$t,pt;for($t=48,pt=0;pt<=9;++pt)ye[$t++]=pt;for($t=97,pt=10;pt<36;++pt)ye[$t++]=pt;for($t=65,pt=10;pt<36;++pt)ye[$t++]=pt;function wi(r,n){var t=ye[r.charCodeAt(n)];return t??-1}function Dt(r){var n=N();return n.fromInt(r),n}function me(r){var n=1,t;return(t=r>>>16)!=0&&(r=t,n+=16),(t=r>>8)!=0&&(r=t,n+=8),(t=r>>4)!=0&&(r=t,n+=4),(t=r>>2)!=0&&(r=t,n+=2),(t=r>>1)!=0&&(r=t,n+=1),n}D.ZERO=Dt(0),D.ONE=Dt(1);var ja=function(){function r(){this.i=0,this.j=0,this.S=[]}return r.prototype.init=function(n){var t,e,i;for(t=0;t<256;++t)this.S[t]=t;for(e=0,t=0;t<256;++t)e=e+this.S[t]+n[t%n.length]&255,i=this.S[t],this.S[t]=this.S[e],this.S[e]=i;this.i=0,this.j=0},r.prototype.next=function(){var n;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,n=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=n,this.S[n+this.S[this.i]&255]},r}();function Ha(){return new ja}var vi=256,we,Rt=null,gt;if(Rt==null){Rt=[],gt=0;var ve=void 0;if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){var an=new Uint32Array(256);for(window.crypto.getRandomValues(an),ve=0;ve<an.length;++ve)Rt[gt++]=an[ve]&255}var Pe=0,Ee=function(r){if(Pe=Pe||0,Pe>=256||gt>=vi){window.removeEventListener?window.removeEventListener("mousemove",Ee,!1):window.detachEvent&&window.detachEvent("onmousemove",Ee);return}try{var n=r.x+r.y;Rt[gt++]=n&255,Pe+=1}catch{}};typeof window<"u"&&(window.addEventListener?window.addEventListener("mousemove",Ee,!1):window.attachEvent&&window.attachEvent("onmousemove",Ee))}function Ka(){if(we==null){for(we=Ha();gt<vi;){var r=Math.floor(65536*Math.random());Rt[gt++]=r&255}for(we.init(Rt),gt=0;gt<Rt.length;++gt)Rt[gt]=0;gt=0}return we.next()}var on=function(){function r(){}return r.prototype.nextBytes=function(n){for(var t=0;t<n.length;++t)n[t]=Ka()},r}();function Wa(r,n){if(n<r.length+22)return console.error("Message too long for RSA"),null;for(var t=n-r.length-6,e="",i=0;i<t;i+=2)e+="ff";var s="0001"+e+"00"+r;return $(s,16)}function $a(r,n){if(n<r.length+11)return console.error("Message too long for RSA"),null;for(var t=[],e=r.length-1;e>=0&&n>0;){var i=r.charCodeAt(e--);i<128?t[--n]=i:i>127&&i<2048?(t[--n]=i&63|128,t[--n]=i>>6|192):(t[--n]=i&63|128,t[--n]=i>>6&63|128,t[--n]=i>>12|224)}t[--n]=0;for(var s=new on,a=[];n>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);t[--n]=a[0]}return t[--n]=2,t[--n]=0,new D(t)}var za=function(){function r(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return r.prototype.doPublic=function(n){return n.modPowInt(this.e,this.n)},r.prototype.doPrivate=function(n){if(this.p==null||this.q==null)return n.modPow(this.d,this.n);for(var t=n.mod(this.p).modPow(this.dmp1,this.p),e=n.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(e)<0;)t=t.add(this.p);return t.subtract(e).multiply(this.coeff).mod(this.p).multiply(this.q).add(e)},r.prototype.setPublic=function(n,t){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")},r.prototype.encrypt=function(n){var t=this.n.bitLength()+7>>3,e=$a(n,t);if(e==null)return null;var i=this.doPublic(e);if(i==null)return null;for(var s=i.toString(16),a=s.length,c=0;c<t*2-a;c++)s="0"+s;return s},r.prototype.setPrivate=function(n,t,e){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16),this.d=$(e,16)):console.error("Invalid RSA private key")},r.prototype.setPrivateEx=function(n,t,e,i,s,a,c,l){n!=null&&t!=null&&n.length>0&&t.length>0?(this.n=$(n,16),this.e=parseInt(t,16),this.d=$(e,16),this.p=$(i,16),this.q=$(s,16),this.dmp1=$(a,16),this.dmq1=$(c,16),this.coeff=$(l,16)):console.error("Invalid RSA private key")},r.prototype.generate=function(n,t){var e=new on,i=n>>1;this.e=parseInt(t,16);for(var s=new D(t,16);;){for(;this.p=new D(n-i,1,e),!(this.p.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new D(i,1,e),!(this.q.subtract(D.ONE).gcd(s).compareTo(D.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var c=this.p.subtract(D.ONE),l=this.q.subtract(D.ONE),h=c.multiply(l);if(h.gcd(s).compareTo(D.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(c),this.dmq1=this.d.mod(l),this.coeff=this.q.modInverse(this.p);break}}},r.prototype.decrypt=function(n){var t=$(n,16),e=this.doPrivate(t);return e==null?null:Xa(e,this.n.bitLength()+7>>3)},r.prototype.generateAsync=function(n,t,e){var i=new on,s=n>>1;this.e=parseInt(t,16);var a=new D(t,16),c=this,l=function(){var h=function(){if(c.p.compareTo(c.q)<=0){var y=c.p;c.p=c.q,c.q=y}var P=c.p.subtract(D.ONE),v=c.q.subtract(D.ONE),S=P.multiply(v);S.gcd(a).compareTo(D.ONE)==0?(c.n=c.p.multiply(c.q),c.d=a.modInverse(S),c.dmp1=c.d.mod(P),c.dmq1=c.d.mod(v),c.coeff=c.q.modInverse(c.p),setTimeout(function(){e()},0)):setTimeout(l,0)},_=function(){c.q=N(),c.q.fromNumberAsync(s,1,i,function(){c.q.subtract(D.ONE).gcda(a,function(y){y.compareTo(D.ONE)==0&&c.q.isProbablePrime(10)?setTimeout(h,0):setTimeout(_,0)})})},f=function(){c.p=N(),c.p.fromNumberAsync(n-s,1,i,function(){c.p.subtract(D.ONE).gcda(a,function(y){y.compareTo(D.ONE)==0&&c.p.isProbablePrime(10)?setTimeout(_,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(l,0)},r.prototype.sign=function(n,t,e){var i=Ga(e),s=i+t(n).toString(),a=Wa(s,this.n.bitLength()/4);if(a==null)return null;var c=this.doPrivate(a);if(c==null)return null;var l=c.toString(16);return(l.length&1)==0?l:"0"+l},r.prototype.verify=function(n,t,e){var i=$(t,16),s=this.doPublic(i);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),c=Ja(a);return c==e(n).toString()},r}();function Xa(r,n){for(var t=r.toByteArray(),e=0;e<t.length&&t[e]==0;)++e;if(t.length-e!=n-1||t[e]!=2)return null;for(++e;t[e]!=0;)if(++e>=t.length)return null;for(var i="";++e<t.length;){var s=t[e]&255;s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((s&31)<<6|t[e+1]&63),++e):(i+=String.fromCharCode((s&15)<<12|(t[e+1]&63)<<6|t[e+2]&63),e+=2)}return i}var Ce={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function Ga(r){return Ce[r]||""}function Ja(r){for(var n in Ce)if(Ce.hasOwnProperty(n)){var t=Ce[n],e=t.length;if(r.substr(0,e)==t)return r.substr(e)}return r}/*!
12
12
  Copyright (c) 2011, Yahoo! Inc. All rights reserved.
13
13
  Code licensed under the BSD License:
14
14
  http://developer.yahoo.com/yui/license.html
@@ -20,18 +20,18 @@ version: 2.9.0
20
20
  * @version asn1 1.0.13 (2017-Jun-02)
21
21
  * @since jsrsasign 2.1
22
22
  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
23
- */var m={};(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={}),m.asn1.ASN1Util=new function(){this.integerToByteHex=function(r){var n=r.toString(16);return n.length%2==1&&(n="0"+n),n},this.bigIntToMinTwosComplementsHex=function(r){var n=r.toString(16);if(n.substr(0,1)!="-")n.length%2==1?n="0"+n:n.match(/^[0-7]/)||(n="00"+n);else{var t=n.substr(1),e=t.length;e%2==1?e+=1:n.match(/^[0-7]/)||(e+=2);for(var i="",s=0;s<e;s++)i+="f";var a=new A(i,16),c=a.xor(r).add(A.ONE);n=c.toString(16).replace(/^-/,"")}return n},this.getPEMStringFromHex=function(r,n){return hextopem(r,n)},this.newObject=function(r){var n=m,t=n.asn1,e=t.DERBoolean,i=t.DERInteger,s=t.DERBitString,a=t.DEROctetString,c=t.DERNull,l=t.DERObjectIdentifier,h=t.DEREnumerated,_=t.DERUTF8String,f=t.DERNumericString,y=t.DERPrintableString,E=t.DERTeletexString,v=t.DERIA5String,S=t.DERUTCTime,T=t.DERGeneralizedTime,H=t.DERSequence,V=t.DERSet,W=t.DERTaggedObject,ct=t.ASN1Util.newObject,Y=Object.keys(r);if(Y.length!=1)throw"key of param shall be only one.";var k=Y[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+k+":")==-1)throw"undefined key: "+k;if(k=="bool")return new e(r[k]);if(k=="int")return new i(r[k]);if(k=="bitstr")return new s(r[k]);if(k=="octstr")return new a(r[k]);if(k=="null")return new c(r[k]);if(k=="oid")return new l(r[k]);if(k=="enum")return new h(r[k]);if(k=="utf8str")return new _(r[k]);if(k=="numstr")return new f(r[k]);if(k=="prnstr")return new y(r[k]);if(k=="telstr")return new E(r[k]);if(k=="ia5str")return new v(r[k]);if(k=="utctime")return new S(r[k]);if(k=="gentime")return new T(r[k]);if(k=="seq"){for(var _t=r[k],St=[],kt=0;kt<_t.length;kt++){var Pn=ct(_t[kt]);St.push(Pn)}return new H({array:St})}if(k=="set"){for(var _t=r[k],St=[],kt=0;kt<_t.length;kt++){var Pn=ct(_t[kt]);St.push(Pn)}return new V({array:St})}if(k=="tag"){var mt=r[k];if(Object.prototype.toString.call(mt)==="[object Array]"&&mt.length==3){var Rc=ct(mt[2]);return new W({tag:mt[0],explicit:mt[1],obj:Rc})}else{var Le={};if(mt.explicit!==void 0&&(Le.explicit=mt.explicit),mt.tag!==void 0&&(Le.tag=mt.tag),mt.obj===void 0)throw"obj shall be specified for 'tag'.";return Le.obj=ct(mt.obj),new W(Le)}}},this.jsonToASN1HEX=function(r){var n=this.newObject(r);return n.getEncodedHex()}},m.asn1.ASN1Util.oidHexToInt=function(r){for(var i="",n=parseInt(r.substr(0,2),16),t=Math.floor(n/40),e=n%40,i=t+"."+e,s="",a=2;a<r.length;a+=2){var c=parseInt(r.substr(a,2),16),l=("00000000"+c.toString(2)).slice(-8);if(s=s+l.substr(1,7),l.substr(0,1)=="0"){var h=new A(s,2);i=i+"."+h.toString(10),s=""}}return i},m.asn1.ASN1Util.oidIntToHex=function(r){var n=function(c){var l=c.toString(16);return l.length==1&&(l="0"+l),l},t=function(c){var l="",h=new A(c,10),_=h.toString(2),f=7-_.length%7;f==7&&(f=0);for(var y="",E=0;E<f;E++)y+="0";_=y+_;for(var E=0;E<_.length-1;E+=7){var v=_.substr(E,7);E!=_.length-7&&(v="1"+v),l+=n(parseInt(v,2))}return l};if(!r.match(/^[0-9.]+$/))throw"malformed oid string: "+r;var e="",i=r.split("."),s=parseInt(i[0])*40+parseInt(i[1]);e+=n(s),i.splice(0,2);for(var a=0;a<i.length;a++)e+=t(i[a]);return e},m.asn1.ASN1Object=function(){var r="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+r.length+",v="+this.hV;var n=this.hV.length/2,t=n.toString(16);if(t.length%2==1&&(t="0"+t),n<128)return t;var e=t.length/2;if(e>15)throw"ASN.1 length too long to represent by 8x: n = "+n.toString(16);var i=128+e;return i.toString(16)+t},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},m.asn1.DERAbstractString=function(r){m.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=stohex(this.s)},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"?this.setString(r):typeof r.str<"u"?this.setString(r.str):typeof r.hex<"u"&&this.setStringHex(r.hex))},z.lang.extend(m.asn1.DERAbstractString,m.asn1.ASN1Object),m.asn1.DERAbstractTime=function(r){m.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(n){utc=n.getTime()+n.getTimezoneOffset()*6e4;var t=new Date(utc);return t},this.formatDate=function(n,t,e){var i=this.zeroPadding,s=this.localDateToUTC(n),a=String(s.getFullYear());t=="utc"&&(a=a.substr(2,2));var c=i(String(s.getMonth()+1),2),l=i(String(s.getDate()),2),h=i(String(s.getHours()),2),_=i(String(s.getMinutes()),2),f=i(String(s.getSeconds()),2),y=a+c+l+h+_+f;if(e===!0){var E=s.getMilliseconds();if(E!=0){var v=i(String(E),3);v=v.replace(/[0]+$/,""),y=y+"."+v}}return y+"Z"},this.zeroPadding=function(n,t){return n.length>=t?n:new Array(t-n.length+1).join("0")+n},this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=stohex(n)},this.setByDateValue=function(n,t,e,i,s,a){var c=new Date(Date.UTC(n,t-1,e,i,s,a,0));this.setByDate(c)},this.getFreshValueHex=function(){return this.hV}},z.lang.extend(m.asn1.DERAbstractTime,m.asn1.ASN1Object),m.asn1.DERAbstractStructured=function(r){m.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(n){this.hTLV=null,this.isModified=!0,this.asn1Array=n},this.appendASN1Object=function(n){this.hTLV=null,this.isModified=!0,this.asn1Array.push(n)},this.asn1Array=new Array,typeof r<"u"&&typeof r.array<"u"&&(this.asn1Array=r.array)},z.lang.extend(m.asn1.DERAbstractStructured,m.asn1.ASN1Object),m.asn1.DERBoolean=function(){m.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},z.lang.extend(m.asn1.DERBoolean,m.asn1.ASN1Object),m.asn1.DERInteger=function(r){m.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(n){this.hTLV=null,this.isModified=!0,this.hV=m.asn1.ASN1Util.bigIntToMinTwosComplementsHex(n)},this.setByInteger=function(n){var t=new A(String(n),10);this.setByBigInteger(t)},this.setValueHex=function(n){this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.bigint<"u"?this.setByBigInteger(r.bigint):typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(m.asn1.DERInteger,m.asn1.ASN1Object),m.asn1.DERBitString=function(r){if(r!==void 0&&typeof r.obj<"u"){var n=m.asn1.ASN1Util.newObject(r.obj);r.hex="00"+n.getEncodedHex()}m.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;e==8&&(e=0);for(var i=0;i<=e;i++)t+="0";for(var s="",i=0;i<t.length-1;i+=8){var a=t.substr(i,8),c=parseInt(a,2).toString(16);c.length==1&&(c="0"+c),s+=c}this.hTLV=null,this.isModified=!0,this.hV="0"+e+s},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)t[i]==!0?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"&&r.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(r):typeof r.hex<"u"?this.setHexValueIncludingUnusedBits(r.hex):typeof r.bin<"u"?this.setByBinaryString(r.bin):typeof r.array<"u"&&this.setByBooleanArray(r.array))},z.lang.extend(m.asn1.DERBitString,m.asn1.ASN1Object),m.asn1.DEROctetString=function(r){if(r!==void 0&&typeof r.obj<"u"){var n=m.asn1.ASN1Util.newObject(r.obj);r.hex=n.getEncodedHex()}m.asn1.DEROctetString.superclass.constructor.call(this,r),this.hT="04"},z.lang.extend(m.asn1.DEROctetString,m.asn1.DERAbstractString),m.asn1.DERNull=function(){m.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},z.lang.extend(m.asn1.DERNull,m.asn1.ASN1Object),m.asn1.DERObjectIdentifier=function(r){var n=function(e){var i=e.toString(16);return i.length==1&&(i="0"+i),i},t=function(e){var i="",s=new A(e,10),a=s.toString(2),c=7-a.length%7;c==7&&(c=0);for(var l="",h=0;h<c;h++)l+="0";a=l+a;for(var h=0;h<a.length-1;h+=7){var _=a.substr(h,7);h!=a.length-7&&(_="1"+_),i+=n(parseInt(_,2))}return i};m.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var i="",s=e.split("."),a=parseInt(s[0])*40+parseInt(s[1]);i+=n(a),s.splice(0,2);for(var c=0;c<s.length;c++)i+=t(s[c]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(e){var i=m.asn1.x509.OID.name2oid(e);if(i!=="")this.setValueOidString(i);else throw"DERObjectIdentifier oidName undefined: "+e},this.getFreshValueHex=function(){return this.hV},r!==void 0&&(typeof r=="string"?r.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(r):this.setValueName(r):r.oid!==void 0?this.setValueOidString(r.oid):r.hex!==void 0?this.setValueHex(r.hex):r.name!==void 0&&this.setValueName(r.name))},z.lang.extend(m.asn1.DERObjectIdentifier,m.asn1.ASN1Object),m.asn1.DEREnumerated=function(r){m.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(n){this.hTLV=null,this.isModified=!0,this.hV=m.asn1.ASN1Util.bigIntToMinTwosComplementsHex(n)},this.setByInteger=function(n){var t=new A(String(n),10);this.setByBigInteger(t)},this.setValueHex=function(n){this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(m.asn1.DEREnumerated,m.asn1.ASN1Object),m.asn1.DERUTF8String=function(r){m.asn1.DERUTF8String.superclass.constructor.call(this,r),this.hT="0c"},z.lang.extend(m.asn1.DERUTF8String,m.asn1.DERAbstractString),m.asn1.DERNumericString=function(r){m.asn1.DERNumericString.superclass.constructor.call(this,r),this.hT="12"},z.lang.extend(m.asn1.DERNumericString,m.asn1.DERAbstractString),m.asn1.DERPrintableString=function(r){m.asn1.DERPrintableString.superclass.constructor.call(this,r),this.hT="13"},z.lang.extend(m.asn1.DERPrintableString,m.asn1.DERAbstractString),m.asn1.DERTeletexString=function(r){m.asn1.DERTeletexString.superclass.constructor.call(this,r),this.hT="14"},z.lang.extend(m.asn1.DERTeletexString,m.asn1.DERAbstractString),m.asn1.DERIA5String=function(r){m.asn1.DERIA5String.superclass.constructor.call(this,r),this.hT="16"},z.lang.extend(m.asn1.DERIA5String,m.asn1.DERAbstractString),m.asn1.DERUTCTime=function(r){m.asn1.DERUTCTime.superclass.constructor.call(this,r),this.hT="17",this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.date=n,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{12}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date))},z.lang.extend(m.asn1.DERUTCTime,m.asn1.DERAbstractTime),m.asn1.DERGeneralizedTime=function(r){m.asn1.DERGeneralizedTime.superclass.constructor.call(this,r),this.hT="18",this.withMillis=!1,this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.date=n,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{14}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date),r.millis===!0&&(this.withMillis=!0))},z.lang.extend(m.asn1.DERGeneralizedTime,m.asn1.DERAbstractTime),m.asn1.DERSequence=function(r){m.asn1.DERSequence.superclass.constructor.call(this,r),this.hT="30",this.getFreshValueHex=function(){for(var n="",t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];n+=e.getEncodedHex()}return this.hV=n,this.hV}},z.lang.extend(m.asn1.DERSequence,m.asn1.DERAbstractStructured),m.asn1.DERSet=function(r){m.asn1.DERSet.superclass.constructor.call(this,r),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var n=new Array,t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];n.push(e.getEncodedHex())}return this.sortFlag==!0&&n.sort(),this.hV=n.join(""),this.hV},typeof r<"u"&&typeof r.sortflag<"u"&&r.sortflag==!1&&(this.sortFlag=!1)},z.lang.extend(m.asn1.DERSet,m.asn1.DERAbstractStructured),m.asn1.DERTaggedObject=function(r){m.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(n,t,e){this.hT=t,this.isExplicit=n,this.asn1Object=e,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=e.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.tag<"u"&&(this.hT=r.tag),typeof r.explicit<"u"&&(this.isExplicit=r.explicit),typeof r.obj<"u"&&(this.asn1Object=r.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},z.lang.extend(m.asn1.DERTaggedObject,m.asn1.ASN1Object);var Za=function(){var r=function(n,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},r(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}(),Ci=function(r){Za(n,r);function n(t){var e=r.call(this)||this;return t&&(typeof t=="string"?e.parseKey(t):(n.hasPrivateKeyProperty(t)||n.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return n.prototype.parseKey=function(t){try{var e=0,i=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(t)?Ba.decode(t):sn.unarmor(t),c=Ua.decode(a);if(c.sub.length===3&&(c=c.sub[2].sub[0]),c.sub.length===9){e=c.sub[1].getHexStringValue(),this.n=$(e,16),i=c.sub[2].getHexStringValue(),this.e=parseInt(i,16);var l=c.sub[3].getHexStringValue();this.d=$(l,16);var h=c.sub[4].getHexStringValue();this.p=$(h,16);var _=c.sub[5].getHexStringValue();this.q=$(_,16);var f=c.sub[6].getHexStringValue();this.dmp1=$(f,16);var y=c.sub[7].getHexStringValue();this.dmq1=$(y,16);var E=c.sub[8].getHexStringValue();this.coeff=$(E,16)}else if(c.sub.length===2)if(c.sub[0].sub){var v=c.sub[1],S=v.sub[0];e=S.sub[0].getHexStringValue(),this.n=$(e,16),i=S.sub[1].getHexStringValue(),this.e=parseInt(i,16)}else e=c.sub[0].getHexStringValue(),this.n=$(e,16),i=c.sub[1].getHexStringValue(),this.e=parseInt(i,16);else return!1;return!0}catch{return!1}},n.prototype.getPrivateBaseKey=function(){var t={array:[new m.asn1.DERInteger({int:0}),new m.asn1.DERInteger({bigint:this.n}),new m.asn1.DERInteger({int:this.e}),new m.asn1.DERInteger({bigint:this.d}),new m.asn1.DERInteger({bigint:this.p}),new m.asn1.DERInteger({bigint:this.q}),new m.asn1.DERInteger({bigint:this.dmp1}),new m.asn1.DERInteger({bigint:this.dmq1}),new m.asn1.DERInteger({bigint:this.coeff})]},e=new m.asn1.DERSequence(t);return e.getEncodedHex()},n.prototype.getPrivateBaseKeyB64=function(){return me(this.getPrivateBaseKey())},n.prototype.getPublicBaseKey=function(){var t=new m.asn1.DERSequence({array:[new m.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new m.asn1.DERNull]}),e=new m.asn1.DERSequence({array:[new m.asn1.DERInteger({bigint:this.n}),new m.asn1.DERInteger({int:this.e})]}),i=new m.asn1.DERBitString({hex:"00"+e.getEncodedHex()}),s=new m.asn1.DERSequence({array:[t,i]});return s.getEncodedHex()},n.prototype.getPublicBaseKeyB64=function(){return me(this.getPublicBaseKey())},n.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+`})( +|$
23
+ */var m={};(typeof m.asn1>"u"||!m.asn1)&&(m.asn1={}),m.asn1.ASN1Util=new function(){this.integerToByteHex=function(r){var n=r.toString(16);return n.length%2==1&&(n="0"+n),n},this.bigIntToMinTwosComplementsHex=function(r){var n=r.toString(16);if(n.substr(0,1)!="-")n.length%2==1?n="0"+n:n.match(/^[0-7]/)||(n="00"+n);else{var t=n.substr(1),e=t.length;e%2==1?e+=1:n.match(/^[0-7]/)||(e+=2);for(var i="",s=0;s<e;s++)i+="f";var a=new D(i,16),c=a.xor(r).add(D.ONE);n=c.toString(16).replace(/^-/,"")}return n},this.getPEMStringFromHex=function(r,n){return hextopem(r,n)},this.newObject=function(r){var n=m,t=n.asn1,e=t.DERBoolean,i=t.DERInteger,s=t.DERBitString,a=t.DEROctetString,c=t.DERNull,l=t.DERObjectIdentifier,h=t.DEREnumerated,_=t.DERUTF8String,f=t.DERNumericString,y=t.DERPrintableString,P=t.DERTeletexString,v=t.DERIA5String,S=t.DERUTCTime,T=t.DERGeneralizedTime,H=t.DERSequence,V=t.DERSet,W=t.DERTaggedObject,ot=t.ASN1Util.newObject,Z=Object.keys(r);if(Z.length!=1)throw"key of param shall be only one.";var x=Z[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+x+":")==-1)throw"undefined key: "+x;if(x=="bool")return new e(r[x]);if(x=="int")return new i(r[x]);if(x=="bitstr")return new s(r[x]);if(x=="octstr")return new a(r[x]);if(x=="null")return new c(r[x]);if(x=="oid")return new l(r[x]);if(x=="enum")return new h(r[x]);if(x=="utf8str")return new _(r[x]);if(x=="numstr")return new f(r[x]);if(x=="prnstr")return new y(r[x]);if(x=="telstr")return new P(r[x]);if(x=="ia5str")return new v(r[x]);if(x=="utctime")return new S(r[x]);if(x=="gentime")return new T(r[x]);if(x=="seq"){for(var dt=r[x],Ct=[],Tt=0;Tt<dt.length;Tt++){var vn=ot(dt[Tt]);Ct.push(vn)}return new H({array:Ct})}if(x=="set"){for(var dt=r[x],Ct=[],Tt=0;Tt<dt.length;Tt++){var vn=ot(dt[Tt]);Ct.push(vn)}return new V({array:Ct})}if(x=="tag"){var yt=r[x];if(Object.prototype.toString.call(yt)==="[object Array]"&&yt.length==3){var Dc=ot(yt[2]);return new W({tag:yt[0],explicit:yt[1],obj:Dc})}else{var Fe={};if(yt.explicit!==void 0&&(Fe.explicit=yt.explicit),yt.tag!==void 0&&(Fe.tag=yt.tag),yt.obj===void 0)throw"obj shall be specified for 'tag'.";return Fe.obj=ot(yt.obj),new W(Fe)}}},this.jsonToASN1HEX=function(r){var n=this.newObject(r);return n.getEncodedHex()}},m.asn1.ASN1Util.oidHexToInt=function(r){for(var i="",n=parseInt(r.substr(0,2),16),t=Math.floor(n/40),e=n%40,i=t+"."+e,s="",a=2;a<r.length;a+=2){var c=parseInt(r.substr(a,2),16),l=("00000000"+c.toString(2)).slice(-8);if(s=s+l.substr(1,7),l.substr(0,1)=="0"){var h=new D(s,2);i=i+"."+h.toString(10),s=""}}return i},m.asn1.ASN1Util.oidIntToHex=function(r){var n=function(c){var l=c.toString(16);return l.length==1&&(l="0"+l),l},t=function(c){var l="",h=new D(c,10),_=h.toString(2),f=7-_.length%7;f==7&&(f=0);for(var y="",P=0;P<f;P++)y+="0";_=y+_;for(var P=0;P<_.length-1;P+=7){var v=_.substr(P,7);P!=_.length-7&&(v="1"+v),l+=n(parseInt(v,2))}return l};if(!r.match(/^[0-9.]+$/))throw"malformed oid string: "+r;var e="",i=r.split("."),s=parseInt(i[0])*40+parseInt(i[1]);e+=n(s),i.splice(0,2);for(var a=0;a<i.length;a++)e+=t(i[a]);return e},m.asn1.ASN1Object=function(){var r="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+r.length+",v="+this.hV;var n=this.hV.length/2,t=n.toString(16);if(t.length%2==1&&(t="0"+t),n<128)return t;var e=t.length/2;if(e>15)throw"ASN.1 length too long to represent by 8x: n = "+n.toString(16);var i=128+e;return i.toString(16)+t},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},m.asn1.DERAbstractString=function(r){m.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=stohex(this.s)},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"?this.setString(r):typeof r.str<"u"?this.setString(r.str):typeof r.hex<"u"&&this.setStringHex(r.hex))},z.lang.extend(m.asn1.DERAbstractString,m.asn1.ASN1Object),m.asn1.DERAbstractTime=function(r){m.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(n){utc=n.getTime()+n.getTimezoneOffset()*6e4;var t=new Date(utc);return t},this.formatDate=function(n,t,e){var i=this.zeroPadding,s=this.localDateToUTC(n),a=String(s.getFullYear());t=="utc"&&(a=a.substr(2,2));var c=i(String(s.getMonth()+1),2),l=i(String(s.getDate()),2),h=i(String(s.getHours()),2),_=i(String(s.getMinutes()),2),f=i(String(s.getSeconds()),2),y=a+c+l+h+_+f;if(e===!0){var P=s.getMilliseconds();if(P!=0){var v=i(String(P),3);v=v.replace(/[0]+$/,""),y=y+"."+v}}return y+"Z"},this.zeroPadding=function(n,t){return n.length>=t?n:new Array(t-n.length+1).join("0")+n},this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=stohex(n)},this.setByDateValue=function(n,t,e,i,s,a){var c=new Date(Date.UTC(n,t-1,e,i,s,a,0));this.setByDate(c)},this.getFreshValueHex=function(){return this.hV}},z.lang.extend(m.asn1.DERAbstractTime,m.asn1.ASN1Object),m.asn1.DERAbstractStructured=function(r){m.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(n){this.hTLV=null,this.isModified=!0,this.asn1Array=n},this.appendASN1Object=function(n){this.hTLV=null,this.isModified=!0,this.asn1Array.push(n)},this.asn1Array=new Array,typeof r<"u"&&typeof r.array<"u"&&(this.asn1Array=r.array)},z.lang.extend(m.asn1.DERAbstractStructured,m.asn1.ASN1Object),m.asn1.DERBoolean=function(){m.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},z.lang.extend(m.asn1.DERBoolean,m.asn1.ASN1Object),m.asn1.DERInteger=function(r){m.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(n){this.hTLV=null,this.isModified=!0,this.hV=m.asn1.ASN1Util.bigIntToMinTwosComplementsHex(n)},this.setByInteger=function(n){var t=new D(String(n),10);this.setByBigInteger(t)},this.setValueHex=function(n){this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.bigint<"u"?this.setByBigInteger(r.bigint):typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(m.asn1.DERInteger,m.asn1.ASN1Object),m.asn1.DERBitString=function(r){if(r!==void 0&&typeof r.obj<"u"){var n=m.asn1.ASN1Util.newObject(r.obj);r.hex="00"+n.getEncodedHex()}m.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){t=t.replace(/0+$/,"");var e=8-t.length%8;e==8&&(e=0);for(var i=0;i<=e;i++)t+="0";for(var s="",i=0;i<t.length-1;i+=8){var a=t.substr(i,8),c=parseInt(a,2).toString(16);c.length==1&&(c="0"+c),s+=c}this.hTLV=null,this.isModified=!0,this.hV="0"+e+s},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)t[i]==!0?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r=="string"&&r.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(r):typeof r.hex<"u"?this.setHexValueIncludingUnusedBits(r.hex):typeof r.bin<"u"?this.setByBinaryString(r.bin):typeof r.array<"u"&&this.setByBooleanArray(r.array))},z.lang.extend(m.asn1.DERBitString,m.asn1.ASN1Object),m.asn1.DEROctetString=function(r){if(r!==void 0&&typeof r.obj<"u"){var n=m.asn1.ASN1Util.newObject(r.obj);r.hex=n.getEncodedHex()}m.asn1.DEROctetString.superclass.constructor.call(this,r),this.hT="04"},z.lang.extend(m.asn1.DEROctetString,m.asn1.DERAbstractString),m.asn1.DERNull=function(){m.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},z.lang.extend(m.asn1.DERNull,m.asn1.ASN1Object),m.asn1.DERObjectIdentifier=function(r){var n=function(e){var i=e.toString(16);return i.length==1&&(i="0"+i),i},t=function(e){var i="",s=new D(e,10),a=s.toString(2),c=7-a.length%7;c==7&&(c=0);for(var l="",h=0;h<c;h++)l+="0";a=l+a;for(var h=0;h<a.length-1;h+=7){var _=a.substr(h,7);h!=a.length-7&&(_="1"+_),i+=n(parseInt(_,2))}return i};m.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var i="",s=e.split("."),a=parseInt(s[0])*40+parseInt(s[1]);i+=n(a),s.splice(0,2);for(var c=0;c<s.length;c++)i+=t(s[c]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(e){var i=m.asn1.x509.OID.name2oid(e);if(i!=="")this.setValueOidString(i);else throw"DERObjectIdentifier oidName undefined: "+e},this.getFreshValueHex=function(){return this.hV},r!==void 0&&(typeof r=="string"?r.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(r):this.setValueName(r):r.oid!==void 0?this.setValueOidString(r.oid):r.hex!==void 0?this.setValueHex(r.hex):r.name!==void 0&&this.setValueName(r.name))},z.lang.extend(m.asn1.DERObjectIdentifier,m.asn1.ASN1Object),m.asn1.DEREnumerated=function(r){m.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(n){this.hTLV=null,this.isModified=!0,this.hV=m.asn1.ASN1Util.bigIntToMinTwosComplementsHex(n)},this.setByInteger=function(n){var t=new D(String(n),10);this.setByBigInteger(t)},this.setValueHex=function(n){this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.int<"u"?this.setByInteger(r.int):typeof r=="number"?this.setByInteger(r):typeof r.hex<"u"&&this.setValueHex(r.hex))},z.lang.extend(m.asn1.DEREnumerated,m.asn1.ASN1Object),m.asn1.DERUTF8String=function(r){m.asn1.DERUTF8String.superclass.constructor.call(this,r),this.hT="0c"},z.lang.extend(m.asn1.DERUTF8String,m.asn1.DERAbstractString),m.asn1.DERNumericString=function(r){m.asn1.DERNumericString.superclass.constructor.call(this,r),this.hT="12"},z.lang.extend(m.asn1.DERNumericString,m.asn1.DERAbstractString),m.asn1.DERPrintableString=function(r){m.asn1.DERPrintableString.superclass.constructor.call(this,r),this.hT="13"},z.lang.extend(m.asn1.DERPrintableString,m.asn1.DERAbstractString),m.asn1.DERTeletexString=function(r){m.asn1.DERTeletexString.superclass.constructor.call(this,r),this.hT="14"},z.lang.extend(m.asn1.DERTeletexString,m.asn1.DERAbstractString),m.asn1.DERIA5String=function(r){m.asn1.DERIA5String.superclass.constructor.call(this,r),this.hT="16"},z.lang.extend(m.asn1.DERIA5String,m.asn1.DERAbstractString),m.asn1.DERUTCTime=function(r){m.asn1.DERUTCTime.superclass.constructor.call(this,r),this.hT="17",this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.date=n,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{12}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date))},z.lang.extend(m.asn1.DERUTCTime,m.asn1.DERAbstractTime),m.asn1.DERGeneralizedTime=function(r){m.asn1.DERGeneralizedTime.superclass.constructor.call(this,r),this.hT="18",this.withMillis=!1,this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.date=n,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},r!==void 0&&(r.str!==void 0?this.setString(r.str):typeof r=="string"&&r.match(/^[0-9]{14}Z$/)?this.setString(r):r.hex!==void 0?this.setStringHex(r.hex):r.date!==void 0&&this.setByDate(r.date),r.millis===!0&&(this.withMillis=!0))},z.lang.extend(m.asn1.DERGeneralizedTime,m.asn1.DERAbstractTime),m.asn1.DERSequence=function(r){m.asn1.DERSequence.superclass.constructor.call(this,r),this.hT="30",this.getFreshValueHex=function(){for(var n="",t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];n+=e.getEncodedHex()}return this.hV=n,this.hV}},z.lang.extend(m.asn1.DERSequence,m.asn1.DERAbstractStructured),m.asn1.DERSet=function(r){m.asn1.DERSet.superclass.constructor.call(this,r),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var n=new Array,t=0;t<this.asn1Array.length;t++){var e=this.asn1Array[t];n.push(e.getEncodedHex())}return this.sortFlag==!0&&n.sort(),this.hV=n.join(""),this.hV},typeof r<"u"&&typeof r.sortflag<"u"&&r.sortflag==!1&&(this.sortFlag=!1)},z.lang.extend(m.asn1.DERSet,m.asn1.DERAbstractStructured),m.asn1.DERTaggedObject=function(r){m.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(n,t,e){this.hT=t,this.isExplicit=n,this.asn1Object=e,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=e.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof r<"u"&&(typeof r.tag<"u"&&(this.hT=r.tag),typeof r.explicit<"u"&&(this.isExplicit=r.explicit),typeof r.obj<"u"&&(this.asn1Object=r.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},z.lang.extend(m.asn1.DERTaggedObject,m.asn1.ASN1Object);var Qa=function(){var r=function(n,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},r(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}(),Pi=function(r){Qa(n,r);function n(t){var e=r.call(this)||this;return t&&(typeof t=="string"?e.parseKey(t):(n.hasPrivateKeyProperty(t)||n.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return n.prototype.parseKey=function(t){try{var e=0,i=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(t)?Ba.decode(t):nn.unarmor(t),c=Fa.decode(a);if(c.sub.length===3&&(c=c.sub[2].sub[0]),c.sub.length===9){e=c.sub[1].getHexStringValue(),this.n=$(e,16),i=c.sub[2].getHexStringValue(),this.e=parseInt(i,16);var l=c.sub[3].getHexStringValue();this.d=$(l,16);var h=c.sub[4].getHexStringValue();this.p=$(h,16);var _=c.sub[5].getHexStringValue();this.q=$(_,16);var f=c.sub[6].getHexStringValue();this.dmp1=$(f,16);var y=c.sub[7].getHexStringValue();this.dmq1=$(y,16);var P=c.sub[8].getHexStringValue();this.coeff=$(P,16)}else if(c.sub.length===2)if(c.sub[0].sub){var v=c.sub[1],S=v.sub[0];e=S.sub[0].getHexStringValue(),this.n=$(e,16),i=S.sub[1].getHexStringValue(),this.e=parseInt(i,16)}else e=c.sub[0].getHexStringValue(),this.n=$(e,16),i=c.sub[1].getHexStringValue(),this.e=parseInt(i,16);else return!1;return!0}catch{return!1}},n.prototype.getPrivateBaseKey=function(){var t={array:[new m.asn1.DERInteger({int:0}),new m.asn1.DERInteger({bigint:this.n}),new m.asn1.DERInteger({int:this.e}),new m.asn1.DERInteger({bigint:this.d}),new m.asn1.DERInteger({bigint:this.p}),new m.asn1.DERInteger({bigint:this.q}),new m.asn1.DERInteger({bigint:this.dmp1}),new m.asn1.DERInteger({bigint:this.dmq1}),new m.asn1.DERInteger({bigint:this.coeff})]},e=new m.asn1.DERSequence(t);return e.getEncodedHex()},n.prototype.getPrivateBaseKeyB64=function(){return be(this.getPrivateBaseKey())},n.prototype.getPublicBaseKey=function(){var t=new m.asn1.DERSequence({array:[new m.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new m.asn1.DERNull]}),e=new m.asn1.DERSequence({array:[new m.asn1.DERInteger({bigint:this.n}),new m.asn1.DERInteger({int:this.e})]}),i=new m.asn1.DERBitString({hex:"00"+e.getEncodedHex()}),s=new m.asn1.DERSequence({array:[t,i]});return s.getEncodedHex()},n.prototype.getPublicBaseKeyB64=function(){return be(this.getPublicBaseKey())},n.wordwrap=function(t,e){if(e=e||64,!t)return t;var i="(.{1,"+e+`})( +|$
24
24
  ?)|(.{1,`+e+"})";return t.match(RegExp(i,"g")).join(`
25
25
  `)},n.prototype.getPrivateKey=function(){var t=`-----BEGIN RSA PRIVATE KEY-----
26
26
  `;return t+=n.wordwrap(this.getPrivateBaseKeyB64())+`
27
27
  `,t+="-----END RSA PRIVATE KEY-----",t},n.prototype.getPublicKey=function(){var t=`-----BEGIN PUBLIC KEY-----
28
28
  `;return t+=n.wordwrap(this.getPublicBaseKeyB64())+`
29
- `,t+="-----END PUBLIC KEY-----",t},n.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},n.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},n.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},n}(Xa),hn,Ya=typeof process<"u"?(hn=process.env)===null||hn===void 0?void 0:hn.npm_package_version:void 0,to=function(){function r(n){n===void 0&&(n={}),n=n||{},this.default_key_size=n.default_key_size?parseInt(n.default_key_size,10):1024,this.default_public_exponent=n.default_public_exponent||"010001",this.log=n.log||!1,this.key=null}return r.prototype.setKey=function(n){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Ci(n)},r.prototype.setPrivateKey=function(n){this.setKey(n)},r.prototype.setPublicKey=function(n){this.setKey(n)},r.prototype.decrypt=function(n){try{return this.getKey().decrypt(fi(n))}catch{return!1}},r.prototype.encrypt=function(n){try{return me(this.getKey().encrypt(n))}catch{return!1}},r.prototype.sign=function(n,t,e){try{return me(this.getKey().sign(n,t,e))}catch{return!1}},r.prototype.verify=function(n,t,e){try{return this.getKey().verify(n,fi(t),e)}catch{return!1}},r.prototype.getKey=function(n){if(!this.key){if(this.key=new Ci,n&&{}.toString.call(n)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,n);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},r.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},r.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},r.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},r.version=Ya,r}();function Ti(r,n){return function(){return r.apply(n,arguments)}}const{toString:eo}=Object.prototype,{getPrototypeOf:un}=Object,ke=(r=>n=>{const t=eo.call(n);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),yt=r=>(r=r.toLowerCase(),n=>ke(n)===r),xe=r=>n=>typeof n===r,{isArray:Gt}=Array,se=xe("undefined");function no(r){return r!==null&&!se(r)&&r.constructor!==null&&!se(r.constructor)&&dt(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Si=yt("ArrayBuffer");function io(r){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(r):n=r&&r.buffer&&Si(r.buffer),n}const ro=xe("string"),dt=xe("function"),ki=xe("number"),Ae=r=>r!==null&&typeof r=="object",so=r=>r===!0||r===!1,De=r=>{if(ke(r)!=="object")return!1;const n=un(r);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},ao=yt("Date"),oo=yt("File"),co=yt("Blob"),lo=yt("FileList"),ho=r=>Ae(r)&&dt(r.pipe),uo=r=>{let n;return r&&(typeof FormData=="function"&&r instanceof FormData||dt(r.append)&&((n=ke(r))==="formdata"||n==="object"&&dt(r.toString)&&r.toString()==="[object FormData]"))},po=yt("URLSearchParams"),[_o,fo,go,bo]=["ReadableStream","Request","Response","Headers"].map(yt),yo=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ae(r,n,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let e,i;if(typeof r!="object"&&(r=[r]),Gt(r))for(e=0,i=r.length;e<i;e++)n.call(null,r[e],e,r);else{const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let c;for(e=0;e<a;e++)c=s[e],n.call(null,r[c],c,r)}}function xi(r,n){n=n.toLowerCase();const t=Object.keys(r);let e=t.length,i;for(;e-- >0;)if(i=t[e],n===i.toLowerCase())return i;return null}const Mt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ai=r=>!se(r)&&r!==Mt;function dn(){const{caseless:r}=Ai(this)&&this||{},n={},t=(e,i)=>{const s=r&&xi(n,i)||i;De(n[s])&&De(e)?n[s]=dn(n[s],e):De(e)?n[s]=dn({},e):Gt(e)?n[s]=e.slice():n[s]=e};for(let e=0,i=arguments.length;e<i;e++)arguments[e]&&ae(arguments[e],t);return n}const mo=(r,n,t,{allOwnKeys:e}={})=>(ae(n,(i,s)=>{t&&dt(i)?r[s]=Ti(i,t):r[s]=i},{allOwnKeys:e}),r),wo=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),vo=(r,n,t,e)=>{r.prototype=Object.create(n.prototype,e),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:n.prototype}),t&&Object.assign(r.prototype,t)},Eo=(r,n,t,e)=>{let i,s,a;const c={};if(n=n||{},r==null)return n;do{for(i=Object.getOwnPropertyNames(r),s=i.length;s-- >0;)a=i[s],(!e||e(a,r,n))&&!c[a]&&(n[a]=r[a],c[a]=!0);r=t!==!1&&un(r)}while(r&&(!t||t(r,n))&&r!==Object.prototype);return n},Po=(r,n,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=n.length;const e=r.indexOf(n,t);return e!==-1&&e===t},Co=r=>{if(!r)return null;if(Gt(r))return r;let n=r.length;if(!ki(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=r[n];return t},To=(r=>n=>r&&n instanceof r)(typeof Uint8Array<"u"&&un(Uint8Array)),So=(r,n)=>{const e=(r&&r[Symbol.iterator]).call(r);let i;for(;(i=e.next())&&!i.done;){const s=i.value;n.call(r,s[0],s[1])}},ko=(r,n)=>{let t;const e=[];for(;(t=r.exec(n))!==null;)e.push(t);return e},xo=yt("HTMLFormElement"),Ao=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,i){return e.toUpperCase()+i}),Di=(({hasOwnProperty:r})=>(n,t)=>r.call(n,t))(Object.prototype),Do=yt("RegExp"),Ri=(r,n)=>{const t=Object.getOwnPropertyDescriptors(r),e={};ae(t,(i,s)=>{let a;(a=n(i,s,r))!==!1&&(e[s]=a||i)}),Object.defineProperties(r,e)},Ro=r=>{Ri(r,(n,t)=>{if(dt(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const e=r[t];if(dt(e)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Io=(r,n)=>{const t={},e=i=>{i.forEach(s=>{t[s]=!0})};return Gt(r)?e(r):e(String(r).split(n)),t},Oo=()=>{},No=(r,n)=>r!=null&&Number.isFinite(r=+r)?r:n;function Bo(r){return!!(r&&dt(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const Mo=r=>{const n=new Array(10),t=(e,i)=>{if(Ae(e)){if(n.indexOf(e)>=0)return;if(!("toJSON"in e)){n[i]=e;const s=Gt(e)?[]:{};return ae(e,(a,c)=>{const l=t(a,i+1);!se(l)&&(s[c]=l)}),n[i]=void 0,s}}return e};return t(r,0)},Fo=yt("AsyncFunction"),Uo=r=>r&&(Ae(r)||dt(r))&&dt(r.then)&&dt(r.catch),Ii=((r,n)=>r?setImmediate:n?((t,e)=>(Mt.addEventListener("message",({source:i,data:s})=>{i===Mt&&s===t&&e.length&&e.shift()()},!1),i=>{e.push(i),Mt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",dt(Mt.postMessage)),Lo=typeof queueMicrotask<"u"?queueMicrotask.bind(Mt):typeof process<"u"&&process.nextTick||Ii,b={isArray:Gt,isArrayBuffer:Si,isBuffer:no,isFormData:uo,isArrayBufferView:io,isString:ro,isNumber:ki,isBoolean:so,isObject:Ae,isPlainObject:De,isReadableStream:_o,isRequest:fo,isResponse:go,isHeaders:bo,isUndefined:se,isDate:ao,isFile:oo,isBlob:co,isRegExp:Do,isFunction:dt,isStream:ho,isURLSearchParams:po,isTypedArray:To,isFileList:lo,forEach:ae,merge:dn,extend:mo,trim:yo,stripBOM:wo,inherits:vo,toFlatObject:Eo,kindOf:ke,kindOfTest:yt,endsWith:Po,toArray:Co,forEachEntry:So,matchAll:ko,isHTMLForm:xo,hasOwnProperty:Di,hasOwnProp:Di,reduceDescriptors:Ri,freezeMethods:Ro,toObjectSet:Io,toCamelCase:Ao,noop:Oo,toFiniteNumber:No,findKey:xi,global:Mt,isContextDefined:Ai,isSpecCompliantForm:Bo,toJSONObject:Mo,isAsyncFn:Fo,isThenable:Uo,setImmediate:Ii,asap:Lo};function x(r,n,t,e,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),e&&(this.request=e),i&&(this.response=i,this.status=i.status?i.status:null)}b.inherits(x,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.status}}});const Oi=x.prototype,Ni={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Ni[r]={value:r}}),Object.defineProperties(x,Ni),Object.defineProperty(Oi,"isAxiosError",{value:!0}),x.from=(r,n,t,e,i,s)=>{const a=Object.create(Oi);return b.toFlatObject(r,a,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),x.call(a,r.message,n,t,e,i),a.cause=r,a.name=r.name,s&&Object.assign(a,s),a};const Vo=null;function pn(r){return b.isPlainObject(r)||b.isArray(r)}function Bi(r){return b.endsWith(r,"[]")?r.slice(0,-2):r}function Mi(r,n,t){return r?r.concat(n).map(function(i,s){return i=Bi(i),!t&&s?"["+i+"]":i}).join(t?".":""):n}function qo(r){return b.isArray(r)&&!r.some(pn)}const jo=b.toFlatObject(b,{},null,function(n){return/^is[A-Z]/.test(n)});function Re(r,n,t){if(!b.isObject(r))throw new TypeError("target must be an object");n=n||new FormData,t=b.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,T){return!b.isUndefined(T[S])});const e=t.metaTokens,i=t.visitor||_,s=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(n);if(!b.isFunction(i))throw new TypeError("visitor must be a function");function h(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!l&&b.isBlob(v))throw new x("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function _(v,S,T){let H=v;if(v&&!T&&typeof v=="object"){if(b.endsWith(S,"{}"))S=e?S:S.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&qo(v)||(b.isFileList(v)||b.endsWith(S,"[]"))&&(H=b.toArray(v)))return S=Bi(S),H.forEach(function(W,ct){!(b.isUndefined(W)||W===null)&&n.append(a===!0?Mi([S],ct,s):a===null?S:S+"[]",h(W))}),!1}return pn(v)?!0:(n.append(Mi(T,S,s),h(v)),!1)}const f=[],y=Object.assign(jo,{defaultVisitor:_,convertValue:h,isVisitable:pn});function E(v,S){if(!b.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));f.push(v),b.forEach(v,function(H,V){(!(b.isUndefined(H)||H===null)&&i.call(n,H,b.isString(V)?V.trim():V,S,y))===!0&&E(H,S?S.concat(V):[V])}),f.pop()}}if(!b.isObject(r))throw new TypeError("data must be an object");return E(r),n}function Fi(r){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(e){return n[e]})}function _n(r,n){this._pairs=[],r&&Re(r,this,n)}const Ui=_n.prototype;Ui.append=function(n,t){this._pairs.push([n,t])},Ui.toString=function(n){const t=n?function(e){return n.call(this,e,Fi)}:Fi;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Ho(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Li(r,n,t){if(!n)return r;const e=t&&t.encode||Ho;b.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(n,t):s=b.isURLSearchParams(n)?n.toString():new _n(n,t).toString(e),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Vi{constructor(){this.handlers=[]}use(n,t,e){return this.handlers.push({fulfilled:n,rejected:t,synchronous:e?e.synchronous:!1,runWhen:e?e.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){b.forEach(this.handlers,function(e){e!==null&&n(e)})}}const qi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ko={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:_n,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},fn=typeof window<"u"&&typeof document<"u",gn=typeof navigator=="object"&&navigator||void 0,Wo=fn&&(!gn||["ReactNative","NativeScript","NS"].indexOf(gn.product)<0),$o=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",zo=fn&&window.location.href||"http://localhost",it={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:fn,hasStandardBrowserEnv:Wo,hasStandardBrowserWebWorkerEnv:$o,navigator:gn,origin:zo},Symbol.toStringTag,{value:"Module"})),...Ko};function Xo(r,n){return Re(r,new it.classes.URLSearchParams,Object.assign({visitor:function(t,e,i,s){return it.isNode&&b.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},n))}function Go(r){return b.matchAll(/\w+|\[(\w*)]/g,r).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Jo(r){const n={},t=Object.keys(r);let e;const i=t.length;let s;for(e=0;e<i;e++)s=t[e],n[s]=r[s];return n}function ji(r){function n(t,e,i,s){let a=t[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),l=s>=t.length;return a=!a&&b.isArray(i)?i.length:a,l?(b.hasOwnProp(i,a)?i[a]=[i[a],e]:i[a]=e,!c):((!i[a]||!b.isObject(i[a]))&&(i[a]=[]),n(t,e,i[a],s)&&b.isArray(i[a])&&(i[a]=Jo(i[a])),!c)}if(b.isFormData(r)&&b.isFunction(r.entries)){const t={};return b.forEachEntry(r,(e,i)=>{n(Go(e),i,t,0)}),t}return null}function Qo(r,n,t){if(b.isString(r))try{return(n||JSON.parse)(r),b.trim(r)}catch(e){if(e.name!=="SyntaxError")throw e}return(t||JSON.stringify)(r)}const oe={transitional:qi,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const e=t.getContentType()||"",i=e.indexOf("application/json")>-1,s=b.isObject(n);if(s&&b.isHTMLForm(n)&&(n=new FormData(n)),b.isFormData(n))return i?JSON.stringify(ji(n)):n;if(b.isArrayBuffer(n)||b.isBuffer(n)||b.isStream(n)||b.isFile(n)||b.isBlob(n)||b.isReadableStream(n))return n;if(b.isArrayBufferView(n))return n.buffer;if(b.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(s){if(e.indexOf("application/x-www-form-urlencoded")>-1)return Xo(n,this.formSerializer).toString();if((c=b.isFileList(n))||e.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Re(c?{"files[]":n}:n,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),Qo(n)):n}],transformResponse:[function(n){const t=this.transitional||oe.transitional,e=t&&t.forcedJSONParsing,i=this.responseType==="json";if(b.isResponse(n)||b.isReadableStream(n))return n;if(n&&b.isString(n)&&(e&&!this.responseType||i)){const a=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(c){if(a)throw c.name==="SyntaxError"?x.from(c,x.ERR_BAD_RESPONSE,this,null,this.response):c}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:it.classes.FormData,Blob:it.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],r=>{oe.headers[r]={}});const Zo=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Yo=r=>{const n={};let t,e,i;return r&&r.split(`
30
- `).forEach(function(a){i=a.indexOf(":"),t=a.substring(0,i).trim().toLowerCase(),e=a.substring(i+1).trim(),!(!t||n[t]&&Zo[t])&&(t==="set-cookie"?n[t]?n[t].push(e):n[t]=[e]:n[t]=n[t]?n[t]+", "+e:e)}),n},Hi=Symbol("internals");function ce(r){return r&&String(r).trim().toLowerCase()}function Ie(r){return r===!1||r==null?r:b.isArray(r)?r.map(Ie):String(r)}function tc(r){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let e;for(;e=t.exec(r);)n[e[1]]=e[2];return n}const ec=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function bn(r,n,t,e,i){if(b.isFunction(e))return e.call(this,n,t);if(i&&(n=t),!!b.isString(n)){if(b.isString(e))return n.indexOf(e)!==-1;if(b.isRegExp(e))return e.test(n)}}function nc(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,e)=>t.toUpperCase()+e)}function ic(r,n){const t=b.toCamelCase(" "+n);["get","set","has"].forEach(e=>{Object.defineProperty(r,e+t,{value:function(i,s,a){return this[e].call(this,n,i,s,a)},configurable:!0})})}let at=class{constructor(n){n&&this.set(n)}set(n,t,e){const i=this;function s(c,l,h){const _=ce(l);if(!_)throw new Error("header name must be a non-empty string");const f=b.findKey(i,_);(!f||i[f]===void 0||h===!0||h===void 0&&i[f]!==!1)&&(i[f||l]=Ie(c))}const a=(c,l)=>b.forEach(c,(h,_)=>s(h,_,l));if(b.isPlainObject(n)||n instanceof this.constructor)a(n,t);else if(b.isString(n)&&(n=n.trim())&&!ec(n))a(Yo(n),t);else if(b.isHeaders(n))for(const[c,l]of n.entries())s(l,c,e);else n!=null&&s(t,n,e);return this}get(n,t){if(n=ce(n),n){const e=b.findKey(this,n);if(e){const i=this[e];if(!t)return i;if(t===!0)return tc(i);if(b.isFunction(t))return t.call(this,i,e);if(b.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=ce(n),n){const e=b.findKey(this,n);return!!(e&&this[e]!==void 0&&(!t||bn(this,this[e],e,t)))}return!1}delete(n,t){const e=this;let i=!1;function s(a){if(a=ce(a),a){const c=b.findKey(e,a);c&&(!t||bn(e,e[c],c,t))&&(delete e[c],i=!0)}}return b.isArray(n)?n.forEach(s):s(n),i}clear(n){const t=Object.keys(this);let e=t.length,i=!1;for(;e--;){const s=t[e];(!n||bn(this,this[s],s,n,!0))&&(delete this[s],i=!0)}return i}normalize(n){const t=this,e={};return b.forEach(this,(i,s)=>{const a=b.findKey(e,s);if(a){t[a]=Ie(i),delete t[s];return}const c=n?nc(s):String(s).trim();c!==s&&delete t[s],t[c]=Ie(i),e[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return b.forEach(this,(e,i)=>{e!=null&&e!==!1&&(t[i]=n&&b.isArray(e)?e.join(", "):e)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
31
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const e=new this(n);return t.forEach(i=>e.set(i)),e}static accessor(n){const e=(this[Hi]=this[Hi]={accessors:{}}).accessors,i=this.prototype;function s(a){const c=ce(a);e[c]||(ic(i,a),e[c]=!0)}return b.isArray(n)?n.forEach(s):s(n),this}};at.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(at.prototype,({value:r},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>r,set(e){this[t]=e}}}),b.freezeMethods(at);function yn(r,n){const t=this||oe,e=n||t,i=at.from(e.headers);let s=e.data;return b.forEach(r,function(c){s=c.call(t,s,i.normalize(),n?n.status:void 0)}),i.normalize(),s}function Ki(r){return!!(r&&r.__CANCEL__)}function Jt(r,n,t){x.call(this,r??"canceled",x.ERR_CANCELED,n,t),this.name="CanceledError"}b.inherits(Jt,x,{__CANCEL__:!0});function Wi(r,n,t){const e=t.config.validateStatus;!t.status||!e||e(t.status)?r(t):n(new x("Request failed with status code "+t.status,[x.ERR_BAD_REQUEST,x.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function rc(r){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return n&&n[1]||""}function sc(r,n){r=r||10;const t=new Array(r),e=new Array(r);let i=0,s=0,a;return n=n!==void 0?n:1e3,function(l){const h=Date.now(),_=e[s];a||(a=h),t[i]=l,e[i]=h;let f=s,y=0;for(;f!==i;)y+=t[f++],f=f%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),h-a<n)return;const E=_&&h-_;return E?Math.round(y*1e3/E):void 0}}function ac(r,n){let t=0,e=1e3/n,i,s;const a=(h,_=Date.now())=>{t=_,i=null,s&&(clearTimeout(s),s=null),r.apply(null,h)};return[(...h)=>{const _=Date.now(),f=_-t;f>=e?a(h,_):(i=h,s||(s=setTimeout(()=>{s=null,a(i)},e-f)))},()=>i&&a(i)]}const Oe=(r,n,t=3)=>{let e=0;const i=sc(50,250);return ac(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,l=a-e,h=i(l),_=a<=c;e=a;const f={loaded:a,total:c,progress:c?a/c:void 0,bytes:l,rate:h||void 0,estimated:h&&c&&_?(c-a)/h:void 0,event:s,lengthComputable:c!=null,[n?"download":"upload"]:!0};r(f)},t)},$i=(r,n)=>{const t=r!=null;return[e=>n[0]({lengthComputable:t,total:r,loaded:e}),n[1]]},zi=r=>(...n)=>b.asap(()=>r(...n)),oc=it.hasStandardBrowserEnv?((r,n)=>t=>(t=new URL(t,it.origin),r.protocol===t.protocol&&r.host===t.host&&(n||r.port===t.port)))(new URL(it.origin),it.navigator&&/(msie|trident)/i.test(it.navigator.userAgent)):()=>!0,cc=it.hasStandardBrowserEnv?{write(r,n,t,e,i,s){const a=[r+"="+encodeURIComponent(n)];b.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),b.isString(e)&&a.push("path="+e),b.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function lc(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function hc(r,n){return n?r.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):r}function Xi(r,n,t){let e=!lc(n);return r&&e||t==!1?hc(r,n):n}const Gi=r=>r instanceof at?{...r}:r;function Ft(r,n){n=n||{};const t={};function e(h,_,f,y){return b.isPlainObject(h)&&b.isPlainObject(_)?b.merge.call({caseless:y},h,_):b.isPlainObject(_)?b.merge({},_):b.isArray(_)?_.slice():_}function i(h,_,f,y){if(b.isUndefined(_)){if(!b.isUndefined(h))return e(void 0,h,f,y)}else return e(h,_,f,y)}function s(h,_){if(!b.isUndefined(_))return e(void 0,_)}function a(h,_){if(b.isUndefined(_)){if(!b.isUndefined(h))return e(void 0,h)}else return e(void 0,_)}function c(h,_,f){if(f in n)return e(h,_);if(f in r)return e(void 0,h)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(h,_,f)=>i(Gi(h),Gi(_),f,!0)};return b.forEach(Object.keys(Object.assign({},r,n)),function(_){const f=l[_]||i,y=f(r[_],n[_],_);b.isUndefined(y)&&f!==c||(t[_]=y)}),t}const Ji=r=>{const n=Ft({},r);let{data:t,withXSRFToken:e,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:c}=n;n.headers=a=at.from(a),n.url=Li(Xi(n.baseURL,n.url),r.params,r.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(b.isFormData(t)){if(it.hasStandardBrowserEnv||it.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[h,..._]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([h||"multipart/form-data",..._].join("; "))}}if(it.hasStandardBrowserEnv&&(e&&b.isFunction(e)&&(e=e(n)),e||e!==!1&&oc(n.url))){const h=i&&s&&cc.read(s);h&&a.set(i,h)}return n},uc=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,e){const i=Ji(r);let s=i.data;const a=at.from(i.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:h}=i,_,f,y,E,v;function S(){E&&E(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(_),i.signal&&i.signal.removeEventListener("abort",_)}let T=new XMLHttpRequest;T.open(i.method.toUpperCase(),i.url,!0),T.timeout=i.timeout;function H(){if(!T)return;const W=at.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),Y={data:!c||c==="text"||c==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:W,config:r,request:T};Wi(function(_t){t(_t),S()},function(_t){e(_t),S()},Y),T=null}"onloadend"in T?T.onloadend=H:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(H)},T.onabort=function(){T&&(e(new x("Request aborted",x.ECONNABORTED,r,T)),T=null)},T.onerror=function(){e(new x("Network Error",x.ERR_NETWORK,r,T)),T=null},T.ontimeout=function(){let ct=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const Y=i.transitional||qi;i.timeoutErrorMessage&&(ct=i.timeoutErrorMessage),e(new x(ct,Y.clarifyTimeoutError?x.ETIMEDOUT:x.ECONNABORTED,r,T)),T=null},s===void 0&&a.setContentType(null),"setRequestHeader"in T&&b.forEach(a.toJSON(),function(ct,Y){T.setRequestHeader(Y,ct)}),b.isUndefined(i.withCredentials)||(T.withCredentials=!!i.withCredentials),c&&c!=="json"&&(T.responseType=i.responseType),h&&([y,v]=Oe(h,!0),T.addEventListener("progress",y)),l&&T.upload&&([f,E]=Oe(l),T.upload.addEventListener("progress",f),T.upload.addEventListener("loadend",E)),(i.cancelToken||i.signal)&&(_=W=>{T&&(e(!W||W.type?new Jt(null,r,T):W),T.abort(),T=null)},i.cancelToken&&i.cancelToken.subscribe(_),i.signal&&(i.signal.aborted?_():i.signal.addEventListener("abort",_)));const V=rc(i.url);if(V&&it.protocols.indexOf(V)===-1){e(new x("Unsupported protocol "+V+":",x.ERR_BAD_REQUEST,r));return}T.send(s||null)})},dc=(r,n)=>{const{length:t}=r=r?r.filter(Boolean):[];if(n||t){let e=new AbortController,i;const s=function(h){if(!i){i=!0,c();const _=h instanceof Error?h:this.reason;e.abort(_ instanceof x?_:new Jt(_ instanceof Error?_.message:_))}};let a=n&&setTimeout(()=>{a=null,s(new x(`timeout ${n} of ms exceeded`,x.ETIMEDOUT))},n);const c=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=e;return l.unsubscribe=()=>b.asap(c),l}},pc=function*(r,n){let t=r.byteLength;if(t<n){yield r;return}let e=0,i;for(;e<t;)i=e+n,yield r.slice(e,i),e=i},_c=async function*(r,n){for await(const t of fc(r))yield*pc(t,n)},fc=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const n=r.getReader();try{for(;;){const{done:t,value:e}=await n.read();if(t)break;yield e}}finally{await n.cancel()}},Qi=(r,n,t,e)=>{const i=_c(r,n);let s=0,a,c=l=>{a||(a=!0,e&&e(l))};return new ReadableStream({async pull(l){try{const{done:h,value:_}=await i.next();if(h){c(),l.close();return}let f=_.byteLength;if(t){let y=s+=f;t(y)}l.enqueue(new Uint8Array(_))}catch(h){throw c(h),h}},cancel(l){return c(l),i.return()}},{highWaterMark:2})},Ne=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Zi=Ne&&typeof ReadableStream=="function",gc=Ne&&(typeof TextEncoder=="function"?(r=>n=>r.encode(n))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Yi=(r,...n)=>{try{return!!r(...n)}catch{return!1}},bc=Zi&&Yi(()=>{let r=!1;const n=new Request(it.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!n}),tr=64*1024,mn=Zi&&Yi(()=>b.isReadableStream(new Response("").body)),Be={stream:mn&&(r=>r.body)};Ne&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Be[n]&&(Be[n]=b.isFunction(r[n])?t=>t[n]():(t,e)=>{throw new x(`Response type '${n}' is not supported`,x.ERR_NOT_SUPPORT,e)})})})(new Response);const yc=async r=>{if(r==null)return 0;if(b.isBlob(r))return r.size;if(b.isSpecCompliantForm(r))return(await new Request(it.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(b.isArrayBufferView(r)||b.isArrayBuffer(r))return r.byteLength;if(b.isURLSearchParams(r)&&(r=r+""),b.isString(r))return(await gc(r)).byteLength},mc=async(r,n)=>{const t=b.toFiniteNumber(r.getContentLength());return t??yc(n)},wn={http:Vo,xhr:uc,fetch:Ne&&(async r=>{let{url:n,method:t,data:e,signal:i,cancelToken:s,timeout:a,onDownloadProgress:c,onUploadProgress:l,responseType:h,headers:_,withCredentials:f="same-origin",fetchOptions:y}=Ji(r);h=h?(h+"").toLowerCase():"text";let E=dc([i,s&&s.toAbortSignal()],a),v;const S=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let T;try{if(l&&bc&&t!=="get"&&t!=="head"&&(T=await mc(_,e))!==0){let Y=new Request(n,{method:"POST",body:e,duplex:"half"}),k;if(b.isFormData(e)&&(k=Y.headers.get("content-type"))&&_.setContentType(k),Y.body){const[_t,St]=$i(T,Oe(zi(l)));e=Qi(Y.body,tr,_t,St)}}b.isString(f)||(f=f?"include":"omit");const H="credentials"in Request.prototype;v=new Request(n,{...y,signal:E,method:t.toUpperCase(),headers:_.normalize().toJSON(),body:e,duplex:"half",credentials:H?f:void 0});let V=await fetch(v);const W=mn&&(h==="stream"||h==="response");if(mn&&(c||W&&S)){const Y={};["status","statusText","headers"].forEach(kt=>{Y[kt]=V[kt]});const k=b.toFiniteNumber(V.headers.get("content-length")),[_t,St]=c&&$i(k,Oe(zi(c),!0))||[];V=new Response(Qi(V.body,tr,_t,()=>{St&&St(),S&&S()}),Y)}h=h||"text";let ct=await Be[b.findKey(Be,h)||"text"](V,r);return!W&&S&&S(),await new Promise((Y,k)=>{Wi(Y,k,{data:ct,headers:at.from(V.headers),status:V.status,statusText:V.statusText,config:r,request:v})})}catch(H){throw S&&S(),H&&H.name==="TypeError"&&/fetch/i.test(H.message)?Object.assign(new x("Network Error",x.ERR_NETWORK,r,v),{cause:H.cause||H}):x.from(H,H&&H.code,r,v)}})};b.forEach(wn,(r,n)=>{if(r){try{Object.defineProperty(r,"name",{value:n})}catch{}Object.defineProperty(r,"adapterName",{value:n})}});const er=r=>`- ${r}`,wc=r=>b.isFunction(r)||r===null||r===!1,nr={getAdapter:r=>{r=b.isArray(r)?r:[r];const{length:n}=r;let t,e;const i={};for(let s=0;s<n;s++){t=r[s];let a;if(e=t,!wc(t)&&(e=wn[(a=String(t)).toLowerCase()],e===void 0))throw new x(`Unknown adapter '${a}'`);if(e)break;i[a||"#"+s]=e}if(!e){const s=Object.entries(i).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?s.length>1?`since :
32
- `+s.map(er).join(`
33
- `):" "+er(s[0]):"as no adapter specified";throw new x("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return e},adapters:wn};function vn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Jt(null,r)}function ir(r){return vn(r),r.headers=at.from(r.headers),r.data=yn.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),nr.getAdapter(r.adapter||oe.adapter)(r).then(function(e){return vn(r),e.data=yn.call(r,r.transformResponse,e),e.headers=at.from(e.headers),e},function(e){return Ki(e)||(vn(r),e&&e.response&&(e.response.data=yn.call(r,r.transformResponse,e.response),e.response.headers=at.from(e.response.headers))),Promise.reject(e)})}const rr="1.8.2",Me={};["object","boolean","number","function","string","symbol"].forEach((r,n)=>{Me[r]=function(e){return typeof e===r||"a"+(n<1?"n ":" ")+r}});const sr={};Me.transitional=function(n,t,e){function i(s,a){return"[Axios v"+rr+"] Transitional option '"+s+"'"+a+(e?". "+e:"")}return(s,a,c)=>{if(n===!1)throw new x(i(a," has been removed"+(t?" in "+t:"")),x.ERR_DEPRECATED);return t&&!sr[a]&&(sr[a]=!0,console.warn(i(a," has been deprecated since v"+t+" and will be removed in the near future"))),n?n(s,a,c):!0}},Me.spelling=function(n){return(t,e)=>(console.warn(`${e} is likely a misspelling of ${n}`),!0)};function vc(r,n,t){if(typeof r!="object")throw new x("options must be an object",x.ERR_BAD_OPTION_VALUE);const e=Object.keys(r);let i=e.length;for(;i-- >0;){const s=e[i],a=n[s];if(a){const c=r[s],l=c===void 0||a(c,s,r);if(l!==!0)throw new x("option "+s+" must be "+l,x.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new x("Unknown option "+s,x.ERR_BAD_OPTION)}}const Fe={assertOptions:vc,validators:Me},Ct=Fe.validators;let Ut=class{constructor(n){this.defaults=n,this.interceptors={request:new Vi,response:new Vi}}async request(n,t){try{return await this._request(n,t)}catch(e){if(e instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{e.stack?s&&!String(e.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(e.stack+=`
34
- `+s):e.stack=s}catch{}}throw e}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=Ft(this.defaults,t);const{transitional:e,paramsSerializer:i,headers:s}=t;e!==void 0&&Fe.assertOptions(e,{silentJSONParsing:Ct.transitional(Ct.boolean),forcedJSONParsing:Ct.transitional(Ct.boolean),clarifyTimeoutError:Ct.transitional(Ct.boolean)},!1),i!=null&&(b.isFunction(i)?t.paramsSerializer={serialize:i}:Fe.assertOptions(i,{encode:Ct.function,serialize:Ct.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fe.assertOptions(t,{baseUrl:Ct.spelling("baseURL"),withXsrfToken:Ct.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=s&&b.merge(s.common,s[t.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),t.headers=at.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(t)===!1||(l=l&&S.synchronous,c.unshift(S.fulfilled,S.rejected))});const h=[];this.interceptors.response.forEach(function(S){h.push(S.fulfilled,S.rejected)});let _,f=0,y;if(!l){const v=[ir.bind(this),void 0];for(v.unshift.apply(v,c),v.push.apply(v,h),y=v.length,_=Promise.resolve(t);f<y;)_=_.then(v[f++],v[f++]);return _}y=c.length;let E=t;for(f=0;f<y;){const v=c[f++],S=c[f++];try{E=v(E)}catch(T){S.call(this,T);break}}try{_=ir.call(this,E)}catch(v){return Promise.reject(v)}for(f=0,y=h.length;f<y;)_=_.then(h[f++],h[f++]);return _}getUri(n){n=Ft(this.defaults,n);const t=Xi(n.baseURL,n.url,n.allowAbsoluteUrls);return Li(t,n.params,n.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(n){Ut.prototype[n]=function(t,e){return this.request(Ft(e||{},{method:n,url:t,data:(e||{}).data}))}}),b.forEach(["post","put","patch"],function(n){function t(e){return function(s,a,c){return this.request(Ft(c||{},{method:n,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Ut.prototype[n]=t(),Ut.prototype[n+"Form"]=t(!0)});let Ec=class gr{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const e=this;this.promise.then(i=>{if(!e._listeners)return;let s=e._listeners.length;for(;s-- >0;)e._listeners[s](i);e._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(c=>{e.subscribe(c),s=c}).then(i);return a.cancel=function(){e.unsubscribe(s)},a},n(function(s,a,c){e.reason||(e.reason=new Jt(s,a,c),t(e.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=e=>{n.abort(e)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new gr(function(i){n=i}),cancel:n}}};function Pc(r){return function(t){return r.apply(null,t)}}function Cc(r){return b.isObject(r)&&r.isAxiosError===!0}const En={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(En).forEach(([r,n])=>{En[n]=r});function ar(r){const n=new Ut(r),t=Ti(Ut.prototype.request,n);return b.extend(t,Ut.prototype,n,{allOwnKeys:!0}),b.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return ar(Ft(r,i))},t}const K=ar(oe);K.Axios=Ut,K.CanceledError=Jt,K.CancelToken=Ec,K.isCancel=Ki,K.VERSION=rr,K.toFormData=Re,K.AxiosError=x,K.Cancel=K.CanceledError,K.all=function(n){return Promise.all(n)},K.spread=Pc,K.isAxiosError=Cc,K.mergeConfig=Ft,K.AxiosHeaders=at,K.formToJSON=r=>ji(b.isHTMLForm(r)?new FormData(r):r),K.getAdapter=nr.getAdapter,K.HttpStatusCode=En,K.default=K;const{Axios:Vc,AxiosError:qc,CanceledError:jc,isCancel:Hc,CancelToken:Kc,VERSION:Wc,all:$c,Cancel:zc,isAxiosError:Xc,spread:Gc,toFormData:Jc,AxiosHeaders:Qc,HttpStatusCode:Zc,formToJSON:Yc,getAdapter:tl,mergeConfig:el}=K;class Tc extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1,username:s=null,password:a=null,environment:c="production"}={}){super({filters:t,config_port:e,no_device:i});tt(this,p);lt(this,"__pinPad__",{buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:0,reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null}});if(this.__internal__.device.type="pinpad",!ba())throw new Error("Crypto not supported in this browser");if(G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.config_port.baudRate=19200,this.environment=c,s&&(this.username=s),a&&(this.password=a),o(this,p,yr).call(this),o(this,p,br).call(this)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},i=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(i);let a=o(this,p,mr).call(this,s);switch(this.__pinPad__.buffer=s,e.parsed=a,e.code=s,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,o(this,p,xn).call(this,a,s);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,o(this,p,xn).call(this,a,s);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,o(this,p,wr).call(this,a,s);break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,o(this,p,vr).call(this,a,s);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,o(this,p,Er).call(this,a,s);break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,o(this,p,Pr).call(this,a,s);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,o(this,p,Cr).call(this,a,s);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":o(this,p,kr).call(this,a,s),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":o(this,p,Sr).call(this,a,s),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":o(this,p,xr).call(this,a,s),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":o(this,p,Ar).call(this,a,s),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){const e="",i="";let s="C56AABOUT";s=e+s.length.toString().padStart(3,"0")+s+i;let a=0;for(let l=0;l<s.length;l++)a^=s.charCodeAt(l);s=s+String.fromCharCode(a);const c=this.parseStringToBytes(s,"");return this.add0x(c)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!o(this,p,In).call(this,t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}async login({force:t=!1}={}){return await o(this,p,Nr).call(this,t)}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}async checkPositionPermission(){if(!ee())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(i=>{i.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let s=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(s.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}s=o(this,p,Ir).call(this,s),s=o(this,p,Or).call(this,s,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let a="C59A"+s;a=e+o(this,p,wt).call(this,a)+a+i,a=a+o(this,p,vt).call(this,a),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"print")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async consult({reference:t=null}){return t||(t=this.reference),xt(t)&&(t="--",this.reference=t),o(this,p,Ur).call(this,this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,fe).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),o(this,p,te).call(this,this.url+this.__pinPad__.constants.uris.consult,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async rePrint({folio:t=null}={}){t===null&&(t=this.__pinPad__.operation.folio||""),o(this,p,Nn).call(this,t),await o(this,p,fe).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:t});const e=await o(this,p,te).call(this,this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},no_operacion:t,crypto:"2"}});let i=e.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",i&&(e.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=e.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,e.voucher_comercio)),i=e.voucher_cliente,this.__pinPad__.operation.clientVoucher="",i&&(e.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=e.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,e.voucher_cliente)),e}async cancelPurchase({amount:t=0,authorization:e="",folio:i=""}={}){if(!o(this,p,On).call(this,t))throw new Error("Invalid amount");if(!o(this,p,Qr).call(this,e))throw new Error("Invalid authorization");if(!o(this,p,Nn).call(this,i))throw new Error("Invalid folio");t=o(this,p,Ln).call(this,t,2);const s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:i,Tx_Auth:e,Amount:t};await o(this,p,fe).call(this,s);const a=o(this,p,te).call(this,this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:i,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,jt).call(this,this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||xt(e)||!o(this,p,In).call(this,e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");let i={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await o(this,p,$r).call(this),!await o(this,p,zr).call(this)||!await o(this,p,Hr).call(this)?i:await o(this,p,Yr).call(this)}catch(s){console.warn(s),i.error=!0,i.message=s.message,i.approved=!1,i.object=s}return i}}p=new WeakSet,br=function(){G.addCustom("pinpad",this)},yr=function(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response","pp:error","pp:finish-emv"];for(const e of t)this.serialRegisterAvailableListener(e)},mr=function(t){const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const c=t.split(i);t=c[0];const l=t.split(s);l.push(...c[1].split(s));const h={};return l.map((_,f)=>{const y=f>0?_.substring(0,1):"A",E=f>0?_.substring(1):_;return{[y]:E.replace(new RegExp(a,"g"),"")}}).forEach(_=>Object.assign(h,_)),h},xn=function(t,e){const i=this.__pinPad__.constants.ETX,s=e.substring(e.indexOf("D")+2,e.indexOf("E"));let a=0;const c=e.indexOf("N")>0,l=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(l&&l!=="undefined"&&l.toUpperCase()==="VERIFONE"){const _=s.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");a=parseInt(_),a>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=c,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M")),this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N")):(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(i)),this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(i)),this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=l,this.__pinPad__.about.appVersion=s;const h=e.substring(e.indexOf("K")+2,e.indexOf("L"));this.__pinPad__.about.pp={brand:l,appVersion:s,versionInt:a,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT,hasDUKPTKeys:h,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")},wr=function(t,e){this.__pinPad__.waiting.statusInjectWaiting="resolved"},vr=function(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"},Er=function(t,e){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"},Pr=function(t,e){const i=this.__pinPad__.about.brand.toLowerCase(),s=this.__pinPad__.about.model.toLowerCase(),a=i==="ingenico"&&s==="ipp320"?500:350;if(e.length<a){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=o(this,p,qn).call(this,this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="p400"||e.includes("P93A800")&&e.length>=406&&s==="p400"||e.includes("P93A022")&&e.length>=406&&s==="v205c"||e.includes("P93A800")&&e.length>=406&&s==="v205c"||e.includes("P93A022")&&e.length>=406&&s==="move2500"||e.includes("P93A800")&&e.length>=406&&s==="move2500"||e.includes("P93A022")&&e.length>=406&&s==="lane3000"||e.includes("P93A800")&&e.length>=406&&s==="lane3000"){let c=e;i==="verifone"&&(c=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||c.includes("P93A022")||c.includes("P81AINSERTE CHIP O DESLICE TARJETA")||c.includes("ACERQUE, INSERTE CHIP O DESLICE")||c.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>a&&o(this,p,Tr).call(this,e)}},Cr=function(t,e){const i=this.__pinPad__.constants.ETX;let s=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");s=s.substring(s.indexOf("B")+2,s.indexOf(i)),s.includes("006E93A16")&&(s="01"),this.__pinPad__.operation.applyReverse=s==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"},Tr=function(t){const e=this.__pinPad__.constants.ETX,i=this.__pinPad__.about.brand.toLowerCase();let s,a,c,l,h;i==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const _=this.__pinPad__.config.read.POSEM;if(_==="051"||_==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf("N")),this.__pinPad__.operation.hasQPS=f.substring(f.indexOf("N")+2,f.indexOf("O"))==="1",this.__pinPad__.operation.bin8=f.substring(f.indexOf("O")+2,f.indexOf(e))}else if(t.includes("N")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf("N")),this.__pinPad__.operation.hasQPS=f.substring(f.indexOf("N")+2,f.indexOf(e))==="1"}else{const f=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),a=t.substring(t.indexOf("I")+2,t.indexOf("J")),c=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=c,s=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let f;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),_==="022")if(t.includes("O")){const y=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=y.substring(y.indexOf("O")+2,y.indexOf(e)),f=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.lastIndexOf(""))}else f=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.indexOf(e));else f=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.indexOf(e));this.__pinPad__.config.read.NB_ksn=f,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),a=t.substring(t.indexOf("F")+2,t.indexOf("G")),s=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model.toLowerCase()==="vx520"?(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c):(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c)}s.includes("/")&&(s=s.replace("/","")),s.toString().length===4?(h=s.toString().substring(0,2),l=s.toString().substring(2)):(h="",l=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=a,a.length>6&&(this.__pinPad__.operation.bin=a.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:a,name:c,month:h,year:l})},Sr=function(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))},kr=function(t,e){const i=this;if(this.__pinPad__.about.model.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){i.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){i.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}},xr=function(t,e){},Ar=function(t,e){},ue=function(t,e){const i=new to;return i.setPublicKey(t),i.encrypt(e)},de=function(t){const e="0123456789ABCDEF";let i="";for(let s=0;s<t;s++){const a=Math.floor(Math.random()*e.length);i+=e.substring(a,a+1)}return i},Dr=function(t){const e="0123456789abcdef",i=[],s=[];for(let a=0;a<256;a++)i[a]=e.charAt(a>>4)+e.charAt(a&15);for(let a=0;a<t.length;a++)s[a]=i[t.charCodeAt(a)];return s.join("")},pe=async function(t,e){const i=new Uint8Array(t.match(/.{1,2}/g).map(y=>parseInt(y,16))),s=crypto.getRandomValues(new Uint8Array(16)),c=new TextEncoder().encode(e),l=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["encrypt"]),h=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},l,c),_=btoa(String.fromCharCode(...s)),f=btoa(String.fromCharCode(...new Uint8Array(h)));return _+f},Rr=function(t,e,i=!1){const s=[];for(let _=0;_<256;_++)s[_]=_;let a=0;for(let _=0;_<256;_++)a=(a+s[_]+t.charCodeAt(_%t.length))%256,[s[_],s[a]]=[s[a],s[_]];let c=0,l=0,h="";for(const _ of e){c=(c+1)%256,l=(l+s[c])%256,[s[c],s[l]]=[s[l],s[c]];let f=s[(s[c]+s[l])%256];h+=String.fromCharCode(_.charCodeAt(0)^f)}return i?o(this,p,Dr).call(this,h).toUpperCase():h},jt=function(t,e){return o(this,p,Rr).call(this,t,this.hexToAscii(e))},Ir=function(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t},Q=function(t,e,i){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",i),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const s=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,s)}return t.trim()+"@br @br @br @br @br"},Or=function(t,e){const i="@logo3 @br",s="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),o(this,p,Q).call(this,t,i,s)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),o(this,p,Q).call(this,t,i,s)):o(this,p,Q).call(this,t,i,s)},Nr=async function(t=!1){if(o(this,p,Mr).call(this),this.__pinPad__.config.loginResponse&&!t)return await o(this,p,An).call(this);const e=this.url+this.__pinPad__.constants.uris.login,i={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await o(this,p,_e).call(this),o(this,p,Dn).call(this))throw new Error("Empty RSA Key");const s=o(this,p,de).call(this,32),a=o(this,p,ue).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,pe).call(this,s,JSON.stringify(i)),l=await K.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:a||""}}).catch(_=>{var f;throw new Error(`Error in request, verify internet connection: ${(f=_.response)==null?void 0:f.status} ${_.message}`)});let h=o(this,p,Bn).call(this,JSON.stringify(l.data));if(typeof h=="string"&&(h=JSON.parse(h)),!h)throw new Error("Invalid response JSON");if(h.RESPUESTA==="error")throw new Error(h);return this.__pinPad__.config.loginResponse=h,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:h})),await o(this,p,An).call(this)},An=async function(){await o(this,p,qr).call(this);try{await o(this,p,Vr).call(this)}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},o(this,p,Br).call(this,this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin},Br=function(t){var a,c,l,h,_,f;let e="",i="";(c=(a=t.xml)==null?void 0:a.ventaspropias)!=null&&c.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),(h=(l=t.xml)==null?void 0:l.ventaspropias)!=null&&h.merchant_currencym&&(i=t.xml.ventaspropias.merchant_currencym);let s=(_=t.xml)==null?void 0:_.emvReverso;s||(s="0"),this.__pinPad__.config.internal.stTokenization=(f=t.xml)==null?void 0:f.st_tokenizacion,!this.__pinPad__.config.internal.stTokenization||this.__pinPad__.config.internal.stTokenization==="false"||this.__pinPad__.config.internal.stTokenization==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:i,executeReverse:s}},Mr=function(){let t=localStorage.getItem("ppLoginResponse");t&&(t=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=t.data),new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))},Fr=async function(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await K.get(t).catch(i=>{throw new Error(`Error in request, verify internet connection: ${i.response.status} ${i.message}`)});if(e.headers.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA},Dn=function(){let t=localStorage.getItem("ppRSAKey");return!t||(t=JSON.parse(t),this.__pinPad__.config.publicKeyRSA=t.data,new Date().getTime()-t.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA},Rn=async function(){return o(this,p,Dn).call(this)?await o(this,p,Fr).call(this):this.__pinPad__.config.publicKeyRSA},_e=async function(){if(!await o(this,p,Rn).call(this))throw new Error("RSA public key is empty")},In=function(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)},Ur=function(t){if(xt(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e},wt=function(t){return t.length.toString().padStart(3,"0")},vt=function(t){let e=0;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i);return String.fromCharCode(e)},Ke=function(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")},On=function(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)},fe=async function(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t},Nn=function(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t},Bn=function(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t},Lr=async function(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let i="C55ACANCEL";i=t+o(this,p,wt).call(this,i)+i+e,i=i+o(this,p,vt).call(this,i);const s=this.parseStringToBytes(i,"");await this.appendToQueue(s,"cancel")},Mn=function(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear().toString().substring(2);return e+i+s},Fn=function(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return e+i},Vr=async function(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,ee()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)},qr=async function(){let t=localStorage.getItem("ppPublicIP");if(t&&(t=JSON.parse(t),this.__pinPad__.config.publicIP=t.data,new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)),this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const i=await K.get("https://api.ipify.org?format=json").catch(()=>e=!0);return e?null:(this.__pinPad__.config.publicIP=i.data.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:i.data.ip})),this.__pinPad__.config.publicIP)},te=async function(t,e){await o(this,p,_e).call(this);const i=o(this,p,de).call(this,32);let s=o(this,p,ue).call(this,this.__pinPad__.config.publicKeyRSA,i),a=await o(this,p,pe).call(this,i,JSON.stringify(e));return(await K.post(t,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(l=>{var h;throw l.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):l.response.status>=500&&l.response.status<=599?new Error(`Service Temporarily Unavailable ${l.message}`):new Error(`Error in request, verify internet connection: ${(h=l.response)==null?void 0:h.status} ${l.message}`)})).data},Un=async function({data:t,url:e,cancelable:i=!1}={}){await o(this,p,_e).call(this);const s=o(this,p,de).call(this,32),a=o(this,p,ue).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,pe).call(this,s,JSON.stringify(t)),l=this;return(await K.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:a||""}}).catch(async _=>{var y;let f=`Error in request, verify internet connection: ${_.status} ${_.message}`;throw _.response.status>=500&&_.response.status<=599?f="Service Temporarily Unavailable":_.response.status>=400&&_.response.status<=499&&(f="Bad Request"),i&&await o(y=l,p,Lr).call(y),new Error(f)})).data},jr=async function(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,i=this.__pinPad__.constants.STX;let s="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(s=s+t+"B"+this.__pinPad__.config.internal.qpsInternational,s=s+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,s=s+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,s=s+t+"E"+this.__pinPad__.config.internal.cvmlAmex,s=s+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,s=s+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,s=i+o(this,p,wt).call(this,s)+s+e,s=s+o(this,p,vt).call(this,s),!this.__pinPad__.about.injectedValues){const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"inject")}},Hr=async function(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await o(this,p,Un).call(this,{data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;e=i+o(this,p,wt).call(this,e)+e+s,e=e+o(this,p,vt).call(this,e);const a=this.parseStringToBytes(e,"");return await this.appendToQueue(a,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0},Kr=async function(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;let s="C56AABOUT";if(s=e+o(this,p,wt).call(this,s)+s+i,s=s+o(this,p,vt).call(this,s),xt(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const l=this.parseStringToBytes(s,"");await this.appendToQueue(l,"about")}else return t?t(this.__pinPad__.about.pp.supportDUKPT,this.__pinPad__.about.pp.hasDUKPTKeys):!0;const a=this;let c=0;return new Promise((l,h)=>{c=setInterval(()=>{if(a.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,xt(a.__pinPad__.about.pp))return;t||l(!0),l(t(a.__pinPad__.about.pp.supportDUKPT,a.__pinPad__.about.pp.hasDUKPTKeys))}else a.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,h("Error"))},500)})},We=async function(t,e){if(t=t?t.toString():"",e=e?e.toString():"",xt(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(xt(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const i=o(this,p,Mn).call(this),s=o(this,p,Fn).call(this),a=this.__pinPad__.constants.FS,c=this.__pinPad__.constants.ETX,l=this.__pinPad__.constants.STX;let h="C91A"+i+a+"B"+s;h=l+o(this,p,wt).call(this,h)+h+c,h=h+o(this,p,vt).call(this,h);const _=this.parseStringToBytes(h,"");await this.appendToQueue(_,"init-dukpt");let f=0;this.__pinPad__.waiting.statusinitDUKPTWaiting="pending";const y=this;return new Promise((E,v)=>{f=setInterval(async()=>{var S;y.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(f),y.__pinPad__.waiting.statusinitDUKPTWaiting=null,y.dispatch("pp:dukpt",{status:"charged",already:!1}),await o(S=y,p,Wr).call(S),E(!0)):y.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(f),y.__pinPad__.waiting.statusinitDUKPTWaiting=null,v("Error"))},500)})},Wr=async function(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await o(this,p,Un).call(this,{data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await o(this,p,is).call(this,e)},$r=async function(){if(!await o(this,p,Rn).call(this))throw new Error("RSA public key is empty");const e=this;await o(this,p,Kr).call(this,async function(s,a){var l,h;if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await o(l=e,p,We).call(l,s,a),!0;let c=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await o(h=e,p,jr).call(h),new Promise((_,f)=>{c=setInterval(async()=>{var y;e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,await o(y=e,p,We).call(y,s,a),_(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,f("Error"))},500)})})},Ln=function(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);let i=t.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),i.join(".")},zr=async function(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),xt(this.amount)||this.amount<=0)throw new Error("Amount required");if(o(this,p,On).call(this,this.amount)===!1)throw new Error("Invalid amount required");if(o(this,p,Ke).call(this,this.amount,2)<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+t;a=a+e+"B"+o(this,p,Mn).call(this),a=a+e+"C"+o(this,p,Fn).call(this),a=a+e+"D"+o(this,p,Ke).call(this,this.amount,2),a=a+e+"E0.00",a=a+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"J"+this.__pinPad__.config.forceOnline,a=a+e+"K"+this.__pinPad__.about.supportContactless,a=a+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(a=a+e+"M0",a=a+e+"N00")):(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(a=a+e+"O"+this.__pinPad__.config.validateQPS)),a=i+o(this,p,wt).call(this,a)+a+s,a=a+o(this,p,vt).call(this,a),o(this,p,rs).call(this);const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"read-card");let l=0;const h=this;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((_,f)=>{l=setInterval(()=>{if(h.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null,_(!0);else if(h.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null;const y=h.__pinPad__.operation.last_error;f(y??"Error reading card")}},500)})},Xr=async function(t){return await O(t*1e3)},Gr=async function(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,te).call(this,e,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})},Jr=async function(t="",e={}){let i=1,s=null;do{i>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await o(this,p,Xr).call(this,5)),await o(this,p,_e).call(this);const a=o(this,p,de).call(this,32),c=o(this,p,ue).call(this,this.__pinPad__.config.publicKeyRSA,a),l=await o(this,p,pe).call(this,a,JSON.stringify(e));let h=!1;const _=await K.post(t,l,{headers:{"Content-Type":"application/json",data:c||""}}).catch(async f=>{let y=`Error in request, verify internet connection: ${f.status} ${f.message}`;f.response.status>=500&&f.response.status<=599?y="Service Temporarily Unavailable":f.response.status>=400&&f.response.status<=499&&(y="Bad Request"),console.warn(f),s=y;const E=await o(this,p,Gr).call(this,i);E&&E!=="{}"&&!E.includes('"transacciones":""')&&E.includes("nu_operaion")&&(i=5,s="EE32"),h=!0});if(!h)return _.data}while(i++<=3);return s?Promise.reject(s):Promise.reject("Communication error with CDP. IL/MTY")},Qr=function(t){if(xt(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0},Zr=function(t){var s,a;const e=this;this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let i=(s=t.cd_response)==null?void 0:s.toUpperCase();return i.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?i="00":(i!=="Z3"&&i!=="05"||t.cd_error==="92")&&(i="01"),this.__pinPad__.operation.responseMit._cdResponse=i,this.__pinPad__.finishCommand.A=i,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:i,cd_error:t.cd_error,nb_error:o(a=e,p,Bn).call(a,t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}},Yr=async function(){var s,a;const t=this;this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const e=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(e)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";let i={error:!1,message:null,approved:!1,object:{}};try{const c=await o(this,p,Ln).call(this,this.amount,2);await o(this,p,fe).call(this,{Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:c,Currency:this.__pinPad__.config.currency,Merchant:e,Reverse:this.__pinPad__.config.otherLogin.executeReverse});const l=this.__pinPad__.about.supportContactless&&this.__pinPad__.about.supportContactless!=="0"?"1":"0",h=await o(this,p,Jr).call(this,this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:c,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:l,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});h.response==="error"&&(i.error=!0,i.message=h.nb_error||"Error in response");const _=o(this,p,Zr).call(this,h);return i.object=_,await o(this,p,ts).call(this,_),i.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=_,i}catch(c){throw t.__pinPad__.finishCommand.A="01",t.__pinPad__.finishCommand.B="",t.__pinPad__.finishCommand.C="",t.__pinPad__.finishCommand.D="",t.__pinPad__.finishCommand.E="",t.__pinPad__.finishCommand.F="",t.__pinPad__.finishCommand.G="",t.__pinPad__.finishCommand.H="",t.__pinPad__.finishCommand.I="",t.__pinPad__.finishCommand.J="",t.__pinPad__.finishCommand.K="",await o(a=t,p,ns).call(a,o(s=t,p,qn).call(s,c)),c}},ts=async function(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=i+o(this,p,wt).call(this,a)+a+s,a=a+o(this,p,vt).call(this,a);const c=this.parseStringToBytes(a,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(c,"second-generate");let l=0;const h=this;return new Promise((_,f)=>{l=setInterval(async()=>{var y,E;if(h.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,h.__pinPad__.operation.applyReverse){const v=await o(y=h,p,te).call(y,h.url+h.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),country:this.__pinPad__.config.country.toUpperCase(),user:this.username.toUpperCase(),pwd:this.password.toUpperCase()},transacction:{amount:o(this,p,Ke).call(this,this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization.toUpperCase(),tracks:"",usrtransacction:this.username.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),S=JSON.parse(v);let T;S.response==="approved"?T={message:"Transaction rejected by PinPad."}:T={message:"No communication, please check your report."},h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",T),h.__pinPad__.operation.ignore.counterSale=!0)}else h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",t),h.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await o(E=h,p,es).call(E,t,a),_(!0)}else h.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,f("There is no response from the reader, check that it is connected."))},500)})},es=async function(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await o(this,p,We).call(this,1,0)},Vn=async function(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await O(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}},qn=function(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."};let i=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",i),i},ns=async function(t){const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;if(a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=i+o(this,p,wt).call(this,a)+a+s,a=a+o(this,p,vt).call(this,a),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"finish-emv-end")},is=async function(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await o(this,p,Vn).call(this);return}const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.STX,a=t.nb_ksn,c=t.nb_kcv||"",l=t.nb_ipek||"";let h="C92A"+a+e+"B"+c+e+"C"+l;h=s+o(this,p,wt).call(this,h)+h+i,h=h+o(this,p,vt).call(this,h);const _=this.parseStringToBytes(h,"");await this.appendToQueue(_,"dukpt");let f=0;this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending";const y=this;return new Promise((E,v)=>{f=setInterval(async()=>{var S;y.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(f),y.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await o(S=y,p,Vn).call(S),E(!0)):y.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(f),y.__pinPad__.waiting.statuswritingDUKPTWaiting=null,v("Error writing DUKPT keys"))},500)})},rs=function(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1};class Sc extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1,device_listen_on_port:s=1,type:a="esplus",support_cart:c=!0}={}){super({filters:t,config_port:e,no_device:i,device_listen_on_port:s});tt(this,g);lt(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnChannel).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=c,o(this,g,ss).call(this),o(this,g,os).call(this),o(this,g,as).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}serialJofemarMakeBytes(t){let e=this.hexToDec(this.sumHex(t)),i=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(i[s]));return t.push("03"),this.add0x(t)}calcCheckSums(t){t=this.add0x([this.decToHex(parseInt(t).toString())]);let e=[];return e.push((t&255|240).toString(16).toUpperCase()),e.push((t&255|15).toString(16).toUpperCase()),e}serialSetConnectionConstant(t=1){let e=["02","30","30",(128+t).toString(16),"53","FF","FF"],i=[];return e.forEach(s=>{i.push(this.hexMaker(s))}),this.serialJofemarMakeBytes(i)}serialMessage(t){let i={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":i=o(this,g,Os).call(this,t,i,128);break;case"06":i=o(this,g,Ns).call(this,t,i);break;case"15":i.name="Checksum error",i.description="The calculated checksum does not match the received checksum",i.no_code=38,o(this,g,et).call(this);break;default:i.name="unknown",i.description="The message received is unknown",i.no_code=404;break}this.dispatch("serial:message",i)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>130)throw new Error("Invalid selection");const{channel:i,tray:s}=o(this,g,Bs).call(this,t);this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:i,tray:s};let c=["02","30","30",this.__internal__.device.hex_number,"56",s,i];e&&(c[4]="4D"),c=o(this,g,$e).call(this,c);let l;do l=await this.internalDispense(c),o(this,g,Ms).call(this),l.error==="elevator-locked"?await o(this,g,cs).call(this):l.error==="no-response"&&await O(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){let e=["02","30","30",this.__internal__.device.hex_number,"4D","80","80"];return e=o(this,g,$e).call(this,e),await this.internalDispense(e)}async collect(){const t=["02","30","30","81","4E","FF","FF"];return await o(this,g,ht).call(this,t,"collect")}async resetSoldOutErrors(){return await o(this,g,ge).call(this,"80")}async resetWaitingProductRemovedError(){return await o(this,g,ge).call(this,"81")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(o(this,g,jn).call(this),await o(this,g,ge).call(this,"FF")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await o(this,g,ge).call(this,"FF"),o(this,g,jn).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await O(100),await this.resetWaitingProductRemovedError(),await O(100),await this.resetMachineErrors()}async status(){const t=["02","30","30","81","53","FF","FF"];return await o(this,g,ht).call(this,t,"status")}async lightsOn(){return await o(this,g,Hn).call(this,"81")}async lightsOff(){return await o(this,g,Hn).call(this,"80")}async program(t,e){const i=["02","30","30","81","50",t,e];return await o(this,g,ht).call(this,i,"program")}async programDisplayLanguage({language:t="spanish"}={}){const e={spanish:"30",english:"31",french:"32"};if(!e[t])throw new Error("Invalid language");return await this.program("49",e[t])}async programBeeper({enable:t=!0}={}){const e=t?"31":"30";return await this.program("5A",e)}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.program("54","80")}async programDisableThermometer(){return await this.programDisableWorkingTemperature()}async programWorkingTemperature({degrees:t=.5}={}){t=parseFloat(t);const e=this.__device.type==="iceplus"?6.5:32,i=this.__device.type==="iceplus"?-25:.5;if(isNaN(t)||t<i||t>e||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let s=t*2+128;return this.__device.type==="iceplus"&&(s+=51),s=Math.ceil(s),await this.program("54",s.toString(16))}async programIsolationTray({tray:t=0}={}){if(t=parseInt(t),isNaN(t)||t<0||t>12)throw new Error("Invalid tray, valid range is 0 to 12");const e=t===0?"80":(t+139).toString(16);return this.program("42",e)}async programTimeToStandbyAfterCollect({seconds:t=15}={}){if(t=parseInt(t),isNaN(t)||t<15||t>120)throw new Error("Invalid seconds, valid range is 15 to 120");const e=(128+t).toString(16);return await this.program("46",e)}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>10)throw new Error("Invalid minutes, valid range is 1 to 10");const e=(128+t).toString(16);return await this.program("48",e)}async programElevatorSpeed({speed:t="high"}={}){const e={high:"31",low:"30"};if(!e[t])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return await this.program("76",e[t])}async programTemperatureExpiration({enable:t=!1}={}){const e=t?"31":"30";return await this.program("63",e)}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid address, valid range is 1 to 31");const e=(128+t).toString(16);return await this.program("64",e)}async programTemperatureBeforeExpiration({degrees:t=.5}={}){if(t=parseFloat(t),isNaN(t)||t<.5||t>30||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const e=(128+t*2).toString(16);return await this.program("65",e)}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>120)throw new Error("Invalid minutes, valid range is 1 to 120");const e=(128+t).toString(16);return await this.program("66",e)}async programTemperatureScale({scale:t="c"}={}){const e={c:"43",f:"46"};if(!e[t])throw new Error("Invalid scale, valid scales are 'c' for celsius and 'f' for fahrenheit");return await this.program("67",e[t])}async programVoltageEngine({selection:t=1,voltage:e=5}={}){if(e=parseFloat(e),t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<5||e>9.5||e%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const i=109+t,a=(128+(e-5)*2).toString(16),c=["02","30","30","81","47",i,a];return await o(this,g,ht).call(this,c,"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);const a=["02","30","30","81","4F",109+t,e?"31":"30"];return await o(this,g,ht).call(this,a,"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){if(t=parseInt(t),e=parseFloat(e),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<0||e>10||e%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const i=109+t;e=e.toFixed(1);const s=128+e*10,a=["02","30","30","81","45",i,s];return await o(this,g,ht).call(this,a,"channel-running-after-dispense")}async checkData(t,e="FF"){const i=["02","30","30","81","43",t,e];return await o(this,g,ht).call(this,i,"check-data")}async getDisplayLanguage(){return await this.checkData("49")}async getBeeper(){return await this.checkData("5A")}async getWorkingTemperature(){return await this.checkData("54")}async getIsolationTray(){return await this.checkData("42")}async getProgramVersion(){return await this.checkData("50")}async getFaults(){return await this.checkData("53")}async getMachineId(){return await this.checkData("4E")}async getCurrentTemperature(){return await this.checkData("74")}async getTimeToStandbyAfterCollect(){return await this.checkData("46")}async getTimeToStandbyWithoutCollect(){return await this.checkData("48")}async getElevatorSpeed(){return await this.checkData("76")}async getTemperatureExpiration(){return await this.checkData("63")}async getTemperatureBeforeExpiration(){return await this.checkData("65")}async getTimeBeforeExpirationByTemperature(){return await this.checkData("66")}async getTemperatureScale(){return await this.checkData("67")}async getClockRegisters(){return await this.checkData("72")}async getMachineActivity(){return await this.checkData("41")}async getVoltageEngine({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("47",e)}async getChannelPresence({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("43",e)}async getPushOverProducts({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("4F",e)}async getChannelRunningAfterDispense({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("45",e)}async setDisplayStandbyMessage({message:t=""}={}){t=t.substring(0,32);const e=o(this,g,Ge).call(this,t);return await o(this,g,Xe).call(this,"80",e)}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){if(t=t.substring(0,32),e=parseInt(e),isNaN(e)||e<1||e>125)throw new Error("Invalid seconds, valid range is 1 to 125");const i=o(this,g,Ge).call(this,t),s=(128+e).toString(16);return await o(this,g,Xe).call(this,s,i)}async setDisplayMessageUnlimited({message:t=""}){t=t.substring(0,32);const e=o(this,g,Ge).call(this,t);return await o(this,g,Xe).call(this,"FF",e)}async programClock({date:t=new Date}={}){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=["02","30","30","81","72",...o(this,g,Us).call(this,t)];return await o(this,g,ht).call(this,e,"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){if(t===null)throw new Error("Invalid event");const s=["02","30","30","81","41",t,e?"31":"30"];return await o(this,g,ht).call(this,s,"events-config")}async eventEnable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!0})}async eventDisable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!1})}async sendCustomCode({code:t=[]}={}){if(t.length<5)throw new Error("Invalid code, minimum length is 5");return await o(this,g,ht).call(this,t,"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let i=t;i<=e;i++)this.__device.channels.verification.current=i,await this.getChannelPresence({selection:i});return new Promise(i=>{let s=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(s),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),i(!0))},500)})}}g=new WeakSet,ss=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},as=function(){this.on("internal:dispense:running",o(this,g,Fs).bind(this))},os=function(){G.add(this)},ht=function(t,e){return t[3]=this.__internal__.device.hex_number,this.appendToQueue(o(this,g,$e).call(this,t),e)},$e=function(t){let e=this.hexToDec(this.sumHex(t)),i=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(i[s]));return t.push("03"),t},cs=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await O(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},ls=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},hs=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const i={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=i[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},us=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},ds=function(t,e){e.no_code=404;let i=t[5]??null;return i&&this.listenOnChannel>1&&(i=this.hexToDec(i)-this.listenOnChannel+1,i=this.decToHex(i)),i&&(i==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):i==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},ps=function(t,e){e.no_code=39,e.name="Program version";const i=t.slice(4,12),s=i.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:s,hex:i},e.description=`The program version is ${s}`,this.dispatch("program:version",e.additional),e},_s=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const i=t.slice(4,-3);if(i.length>1&&i[0]!=="30"){e.description="Machine has faults";const s={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of i)s[a]&&(e.additional.faults.push(s[a]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},fs=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const i=t.slice(4,-3),s=i.map(v=>String.fromCharCode(this.hexToDec(v))).join(""),[a,c]=s.split(" "),[l,h]=a.split(":"),[_,f,y]=c.split("-"),E=new Date(2e3+parseInt(y),parseInt(f)-1,parseInt(_),parseInt(l),parseInt(h));return e.additional={day:_,month:f,year:y,hours:l,minutes:h,formatted:s,date:E,hex:i},this.dispatch("clock:registers",e.additional),e},gs=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const i=String.fromCharCode(this.hexToDec(t[4]));if(i!=="0"){const s=t.slice(5,-3);if(i==="T"&&s.length===4){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[3]));e.additional={ascii:i,type:"DU.d",dozens:a,units:c,decimals:l,time:parseFloat(`${a}${c}.${l}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(i)&&s.length===3){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[2])),h=parseInt(`${a}${c}${l}`),_={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:c,decimals:l,channel:h,selection:h-109,ascii:i,meaning:_[i]??"Unknown"}}else if(s.length===13){const a=s.map(S=>String.fromCharCode(this.hexToDec(S))).join(""),c=parseInt(a.slice(0,2)),l=parseInt(a.slice(2,4)),h=parseInt(a.slice(4,6)),_=parseInt(a.slice(7,9)),f=parseInt(a.slice(9,11))-1,y=2e3+parseInt(a.slice(11,13)),E=new Date(y,f,_,c,l,h),v={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:E,hex:s,formatted:E.toLocaleString(),ascii:i,meaning:v[i]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},bs=function(t,e){const i={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${i[t]??"unknown"}`,e.additional={hex:t,language:i[t]??"unknown"},this.dispatch("check:language",e.additional),e},ys=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},ms=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const i=this.hexToDec(t)-139;return e.additional={hex:t,tray:i},this.dispatch("check:isolation-tray",e.additional),e},ws=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const i=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:i},this.dispatch("check:engine-voltage",e.additional),e},vs=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const i=t==="30";return e.additional={hex:t,push:i},this.dispatch("check:push-over",e.additional),e},Es=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const i=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:i},this.dispatch("check:extractor-after-dispense",e.additional),e},Ps=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const i=this.hexToDec(t)-128;return e.additional={hex:t,seconds:i},this.dispatch("check:standby-after-collect",e.additional),e},Cs=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const i=this.hexToDec(t)-128;return e.additional={hex:t,minutes:i},this.dispatch("check:standby-without-collect",e.additional),e},Ts=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const i=t==="30"?"low":"high";return e.additional={hex:t,speed:i},this.dispatch("check:elevator-speed",e.additional),e},Ss=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const i=t==="31";return e.additional={hex:t,enabled:i},this.dispatch("check:expiration-by-temperature",e.additional),e},ks=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const i=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:i},this.dispatch("check:temperature-before-expiration",e.additional),e},xs=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const i=this.hexToDec(t)-128;return e.additional={hex:t,minutes:i},this.dispatch("check:expiration-after",e.additional),e},As=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const i=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:i},this.dispatch("check:temperature-scale",e.additional),e},Ds=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},Rs=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},Is=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},Os=function(t,e,i=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-i),!(t[1]&&t[2]))e=o(this,g,ls).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=o(this,g,hs).call(this,t[3],e);break;case"50":e.request="--automatic",e=o(this,g,us).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=o(this,g,gs).call(this,t,e);break;case"43":e.request="channel-status",e=o(this,g,ds).call(this,t,e);break;case"50":e=o(this,g,ps).call(this,t,e);break;case"53":e=o(this,g,_s).call(this,t,e);break;case"54":e.request="working-temperature",e=o(this,g,Rs).call(this,t[4],e);break;case"72":e=o(this,g,fs).call(this,t,e);break;case"74":e.request="current-temperature",e=o(this,g,Is).call(this,t,e);break;case"49":e=o(this,g,bs).call(this,t[4],e);break;case"5a":e=o(this,g,ys).call(this,t[4],e);break;case"42":e=o(this,g,ms).call(this,t[4],e);break;case"47":e=o(this,g,ws).call(this,t[4],e);break;case"4e":e=o(this,g,Ds).call(this,t,e);break;case"4f":e=o(this,g,vs).call(this,t[4],e);break;case"45":e=o(this,g,Es).call(this,t[4],e);break;case"46":e=o(this,g,Ps).call(this,t[4],e);break;case"48":e=o(this,g,Cs).call(this,t[4],e);break;case"76":e=o(this,g,Ts).call(this,t[4],e);break;case"63":e=o(this,g,Ss).call(this,t[4],e);break;case"65":e=o(this,g,ks).call(this,t[4],e);break;case"66":e=o(this,g,xs).call(this,t[4],e);break;case"67":e=o(this,g,As).call(this,t[4],e);break}break}return e},gt=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},et=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},ze=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},nt=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},Et=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},Ns=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,o(this,g,gt).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,o(this,g,et).call(this),o(this,g,nt).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,o(this,g,et).call(this),o(this,g,nt).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,o(this,g,et).call(this),o(this,g,nt).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,o(this,g,ze).call(this),o(this,g,nt).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,o(this,g,et).call(this),o(this,g,nt).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,o(this,g,et).call(this),o(this,g,nt).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,o(this,g,ze).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),o(this,g,Et).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,o(this,g,et).call(this),o(this,g,Et).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,o(this,g,ze).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,o(this,g,gt).call(this),o(this,g,nt).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&o(this,g,et).call(this);return e},Bs=function(t){if(t=parseInt(t)+109,t=t.toString(),t.length!==3)throw new Error("Invalid selection");const e=(parseInt(t.substring(0,2))+128).toString(16).padStart(2,"0");return{channel:(parseInt(t.substring(2,3))+128).toString(16).padStart(2,"0"),tray:e}},Ms=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},Fs=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},ge=async function(t){const e=["02","30","30","81","52",t,"FF"];return await o(this,g,ht).call(this,e,"reset")},jn=function(){const t=this.__device.type==="iceplus"?Ye(40):Ye(25),e=new Date,i=1e3*t+e.getTime(),s=new Date(i);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:s})},Hn=async function(t){const e=["02","30","30","81","4C",t,"FF"];return await o(this,g,ht).call(this,e,"lights")},Xe=async function(t="80",e=[]){const i=["02","30","30","81","44",t,...e];return await o(this,g,ht).call(this,i,"display")},Ge=function(t=""){t=t.padEnd(32," ");const e=[];for(let i=0;i<32;i++)e.push(t.charCodeAt(i).toString(16));return e},Us=function(t){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getFullYear().toString().substring(2,4),l=`${e}:${i} ${s}-${a}-${c}`,h=[];for(let _=0;_<14;_++)h.push(l.charCodeAt(_).toString(16));return h};class kc extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});tt(this,w);lt(this,"__coin_purse",{available:!0});lt(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});lt(this,"__sale",{price:0,change:0,change_verified:0,dispense_all:!0,last_change:0,clear(){this.price=0,this.change=0,this.change_verified=0,this.dispense_all=!0,this.last_change=0}});lt(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});lt(this,"coins",{tubes:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},box:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},totals:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},total:0});lt(this,"banknotes",{stacker:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},recycler:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},out:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},totals:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},total:0});lt(this,"card_reader",{available:!1,max_pre_credit:0});tt(this,Qt,!1);tt(this,Lt,0);tt(this,Zt,0);if(this.__internal__.device.type="boardroid",G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.serial.config_port.baudRate=115200,this.__internal__.serial.response.length=14,this.__internal__.time.response_connection=600,this.__internal__.time.response_general=4e3,this.__internal__.time.response_engines=15e3,this.__internal__.dispense.limit_counter=15,this.__internal__.dispense.custom_limit_counter=null,this.__internal__.dispense.backup_dispense={channel:1,second_channel:null,sensor:!0,seconds:null},o(this,w,Ls).call(this),o(this,w,Vs).call(this)}get totalInTubes(){return this.coins.tubes.g50*.5+this.coins.tubes.c50*.5+this.coins.tubes.p1+this.coins.tubes.p2*2+this.coins.tubes.p5*5+this.coins.tubes.p10*10}get totalInRecycler(){return this.banknotes.recycler.p20*20+this.banknotes.recycler.p50*50+this.banknotes.recycler.p100*100+this.banknotes.recycler.p200*200+this.banknotes.recycler.p500*500+this.banknotes.recycler.p1000*1e3}get hasRecycler(){return this.__banknote_purse.available&&this.__banknote_purse.isRecycler}set hasRecycler(t){this.__banknote_purse.isRecycler=t}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(t){this.__banknote_purse.recycler.ict=t}set banknoteICT(t){if(![20,50,100,200,500].includes(t))throw new Error(`Invalid banknote value: ${t}`);t=[20,50,100,200,500].indexOf(t),this.__banknote_purse.recycler.banknote=t}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set hasCoinPurse(t){if(typeof t!="boolean")throw new Error(`Invalid value: ${t}`);this.__coin_purse.available=t}set price(t){let e=parseFloat(t);(isNaN(e)||e<0)&&(e=0),this.__sale.price=e}get price(){return this.__sale.price}get change(){return this.__sale.price<=0||this.__money_session.inserted<=this.__sale.price?0:this.__money_session.inserted-this.__sale.price}softReload(){super.softReload(),this.__sale.clear(),this.__money_session.clear()}serialBoardroidSumHex(t){let e=0;return t.forEach((i,s)=>{s!==0&&s!==11&&(e+=parseInt(i,16))}),e.toString(16).toUpperCase()}serialMessage(t){let e={code:t,name:null,description:null,request:null,no_code:0};const i=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(t[1]){case i:e.request="connect",e=o(this,w,js).call(this,e);break;case"a0":e.request="--automatic",e=o(this,w,Gs).call(this,t,e);break;case"b0":e.request="--automatic",e=o(this,w,Js).call(this,t,e);break;case"d0":e.request="coin-purse:config",e=o(this,w,Qs).call(this,t[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=o(this,w,Zs).call(this,t,e);break;case"d2":e.request="coin-purse:read-tubes",e=o(this,w,Ys).call(this,t,e);break;case"d3":e.request="banknote-purse:read-recycler",e=o(this,w,ta).call(this,t,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=o(this,w,ea).call(this,t[2],e);break;case"d5":e.request="banknote-purse:dispense",e=o(this,w,na).call(this,t,e);break;case"d6":e.request="coin-purse:dispense",e=o(this,w,ia).call(this,t,e);break;case"d7":e.request="dispense",e=o(this,w,ra).call(this,t[5],e);break;case"d8":e.request="--automatic",e=o(this,w,sa).call(this,t[13],e);break;case"d9":e.request="status:temperature",e=o(this,w,aa).call(this,t,e);break;case"da":e.request="status:relay",e=o(this,w,oa).call(this,t[2],e);break;case"db":e.request="banknote-purse:save-memory",e.no_code=18,e.name="Bill purse memory saved?",e.description="The memory of bill purse was saved successfully?",this.dispatch("banknote-purse:save-memory",{message:e});break;case"dc":e.request="coin-purse:read-memory",e.no_code=19,e.name="Coin purse memory read?",e.description="The memory of coin purse was read successfully?",this.dispatch("banknote-purse:read-memory",{message:e});break;case"dd":e.request="card-reader",o(this,w,ca).call(this,t,e);break;default:e.request="--unknown",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400,this.dispatch("unknown",e);break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){let e=["F1","06","00","00","00","00","00","00","00","00","F2","F8"];return e[1]=this.hexMaker(this.decToHex((5+t).toString())),e[11]=this.serialBoardroidSumHex(e),this.add0x(e)}async coinPurseConfigure({enable:t=!1,high:e="FF",low:i="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");const a=["F1","C1",t?"01":"00",e,i,"00","00","00","00","00","F2","00"];await o(this,w,ut).call(this,a,"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:t=0,$_1:e=0,$_2:i=0,$_5:s=0,$_10:a=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");if([t,e,i,s,a].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&i<1&&s<1&&a<1)throw new Error("No coins to dispense");[t,e,i,s,a]=[this.decToHex(t),this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a)];let c=["F1","C6",t,e,i,s,a,"00","00","00","F2","00"];await o(this,w,ut).call(this,c,"coin-purse:dispense")}async coinPurseReadTubes(){const t=["F1","C2","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ut).call(this,t,"coin-purse:read-tubes")}async banknotePurseConfigure({enable:t=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let i;return o(this,w,Je).call(this)?i=o(this,w,la).call(this,{enable:t,scrow:e}):i=o(this,w,ha).call(this,{enable:t,scrow:e}),await o(this,w,ut).call(this,i,"banknote-purse:config")}async banknotePurseDispense({$_20:t=0,$_50:e=0,$_100:i=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");let l;if(o(this,w,Je).call(this)){const h=[t,e,i,s,a];l=o(this,w,ua).call(this,h[this.__banknote_purse.recycler.banknote])}else l=o(this,w,da).call(this,{$_20:t,$_50:e,$_100:i,$_200:s,$_500:a,$_1000:c});await o(this,w,ut).call(this,l,"banknote-purse:dispense")}async banknotePurseEnable({scrow:t=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:t})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","01","00","00","00","00","00","00","00","F2","00"];await o(this,w,ut).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,ut).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:t=null,$_20:e=null,$_50:i=null,$_100:s=null,$_200:a=null,$_500:c=null,$_1000:l=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(t===null||e===null||i===null||s===null||a===null||c===null||l===null)throw new Error("One of the values is not defined");const h=["F1","C8",this.decToHex(t),"00",this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a),this.decToHex(c),this.decToHex(l),"F2","00"];await o(this,w,ut).call(this,h,"banknote-purse:save-memory")}async banknotePurseReadRecycler(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");const t=["F1","C3","00","00","00","00","00","00","00","00","F2","B5"];return await o(this,w,ut).call(this,t,"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");const t=["F1","CD","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ut).call(this,t,"card-reader:disable")}async cardReaderDispense({channel:t=1,second_channel:e=null,sensor:i=!0,seconds:s=null,price:a=0}={}){if(!this.card_reader.available)throw new Error("Card reader not available");if(isNaN(this.card_reader.max_pre_credit)||this.card_reader.max_pre_credit===0)throw new Error("Card reader pre-credit not configured");if(isNaN(a)||a<=0)throw new Error("Price must be greater than 0");if(a>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!i&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");const c=this.decToHex(a/256),l=this.decToHex(a%256),h=this.decToHex(t+9);let _="00";e&&(_=this.decToHex(e+9));let f="00";i||(f=this.decToHex(s*10));const y=["F1","CD","01",h,_,f,c,l,"00","00","F2","00"];await o(this,w,ut).call(this,y,"card-reader:dispense")}async paymentPursesDisable({coin:t=!0,banknote:e=!0,cardReader:i=!1}={}){t&&await this.coinPurseDisable(),e&&await this.banknotePurseDisable(),i&&await this.cardReaderDisable()}async paymentPursesEnable({coin:t=!0,banknote:e=!0,scrowBanknote:i=!1}={}){t&&await this.coinPurseEnable(),e&&await this.banknotePurseEnable({scrow:i})}async coolingRelayConfigure({enable:t=!1}={}){const i=["F1","CC",t?"01":"00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ut).call(this,i,"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){const t=["F1","CB","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,ut).call(this,t,"status:temperature")}async dispense({selection:t=1,second_selection:e=null,sensor:i=!0,seconds:s=null,retry:a=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===t))throw new Error("Invalid second channel number");if(!i&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");a&&(this.__internal__.dispense.backup_dispense={selection:t,second_selection:e,sensor:i,seconds:s}),t+=9;const c=this.decToHex(t);let l="00";e&&(e+=9,l=this.decToHex(e));let h="00";i||(h=this.decToHex(Math.round(s*6.2)),this.__internal__.dispense.custom_limit_counter=s);const _=o(this,w,Qe).call(this,["F1","C7",c,l,h,"00","00","00","00","00","F2","00"]);let f=await this.internalDispense(_);return!f.dispensed&&a&&(f=await this.internalDispense(_)),this.__internal__.dispense.custom_limit_counter=null,f}async testEngines({singleEngine:t=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(I(this,Qt))throw new Error("Another test is running");o(this,w,Wn).call(this),L(this,Qt,!0);const e=[];o(this,w,Ze).call(this);for(let i=1;i<=80;i++){const s=await this.dispense({selection:i,second_selection:t?null:i+1,sensor:!1,seconds:.4,retry:!1});e.push(s),L(this,Lt,i),o(this,w,Ze).call(this),t||i++}L(this,Lt,80),o(this,w,Ze).call(this,{dispensed:e}),o(this,w,Wn).call(this)}async sendCustomCode({code:t=[]}={}){if(t.length===0)throw new Error("Invalid code");const e=o(this,w,Qe).call(this,t);await this.appendToQueue(e,"custom")}hasToReturnChange(t=0){let e=t;return e<=0?!0:(e=o(this,w,$n).call(this,e).pending,e=o(this,w,zn).call(this,e).pending,!(e>0))}async returnChange(){return await o(this,w,Xn).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await o(this,w,Xn).call(this,this.__money_session.inserted)}async serialCorruptMessage(t,e){this.dispatch("corrupt:message",{data:t,message:e})}}Qt=new WeakMap,Lt=new WeakMap,Zt=new WeakMap,w=new WeakSet,Ls=function(){const t=["banknote-purse:banknote-scrow-status","banknote-purse:config","banknote-purse:event-banknote","banknote-purse:read-memory","banknote-purse:recycler","banknote-purse:save-memory","card-reader:event","change:pending","change:dispense","coin-purse:coin-event","coin-purse:config","coin-purse:reject-lever","coin-purse:reset","coin-purse:tubes","percentage:test","run:default-load","session:money-dispensed","session:money-request","event:door","door:event","status:relay","status:temperature"];for(const e of t)this.serialRegisterAvailableListener(e)},Vs=function(){G.add(this)},Je=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},qs=function(){return this.hasCoinPurse||this.hasRecycler},js=function(t){return t.name="Connection with the serial device completed.",t.description="Your connection with the serial device was successfully completed.",t.no_code=1,this.dispatch("run:default-load",{}),t},Hs=function(t){const e={g50:["40","50","60","70","90"],c50:["41","51","61","71","91"],p1:["42","52","62","72","92"],p2:["43","53","63","73","93"],p5:["44","54","64","74","94"],p10:["45","55","65","75","95"],p20:["47","57","67","77","97"]};let i=null;for(let a in e)if(e[a].includes(t)){i=a;break}return i?[{g50:"50 pennies (the big one)",c0:"50 pennies (the little one)",p1:"1 peso",p2:"2 pesos",p5:"5 pesos",p10:"10 pesos",p20:"20 pesos"}[i],i]:[`Undefined value: ¿${t}?`,null]},Ks=function(t){return["g50","c50","p1","p2","p5","p10","p20"].includes(t)},Ws=function(t){const e={p20:["80","90","a0","b0"],p50:["81","91","a1","b1"],p100:["82","92","a2","b2"],p200:["83","93","a3","b3"],p500:["84","94","a4","b4"],p1000:["85","95","a5","b5"]};let i=null;for(let a in e)if(e[a].includes(t)){i=a;break}return i?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[i],i]:[`Undefined value: ¿${t}?`,null]},$s=function(t){return["p20","p50","p100","p200","p500","p1000"].includes(t)},zs=function(t){return["r20","r50","r100"].includes(t)},Xs=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},Kn=function(t,e,i){if(!t)return;let s=!0;if(o(this,w,Ks).call(this,t)&&i==="coin"){if(typeof this.coins.tubes[t]>"u")return;e==="tube"?this.coins.tubes[t]+=1:e==="box"&&(this.coins.box[t]+=1);let a=0;["g50","c50"].includes(t)?a=.5:a+=parseInt(t.slice(1)),this.coins.totals[t]+=a,this.__money_session.inserted+=a,this.coins.total+=a}else if(o(this,w,$s).call(this,t)&&i==="banknote"){if(typeof this.banknotes.recycler[t]>"u")return;e==="recycler"?this.banknotes.recycler[t]+=1:e==="stacker"&&(this.banknotes.stacker[t]+=1);let a=parseInt(t.slice(1));this.banknotes.totals[t]+=a,this.__money_session.inserted+=a,this.banknotes.total+=a}else if(o(this,w,zs).call(this,t)&&e==="out"&&i==="banknote"){if(typeof this.banknotes.out[t.replace("r","p")]>"u")return;this.banknotes.out[t.replace("r","p")]+=1;let a=parseInt(t.slice(1));this.__money_session.retired+=a,this.banknotes.recycler[t.replace("r","p")]-=1,this.banknotes.total-=a,s=!1,this.dispatch("session:money-dispensed",{type_money:t,retired:a,finish:!1,type:"banknotes"})}s&&this.dispatch("session:money-request",{})},Gs=function(t,e){const i=parseInt(t[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},i===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):i===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):i>=64&&i<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):i>=80&&i<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):i>=96&&i<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):i>=112&&i<=127?(e.name="Coin rejected",e.additional.where="rejected"):i>=144&&i<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${t[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),i===1||i===2||i>=160||i>=128&&i<=143||([e.description,e.additional.coin]=o(this,w,Hs).call(this,t[2]),e.no_code=38+i,o(this,w,Kn).call(this,e.additional.coin,e.additional.where,"coin"),["tube","out"].includes(e.additional.where)&&this.dispatch("coin-purse:tubes",this.coins.tubes),this.dispatch("coin-purse:coin-event",this.coins)),e},Js=function(t,e){const i=parseInt(t[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},i===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=o(this,w,Xs).call(this),e.additional.where="out",e.no_code=200):i>=128&&i<=143?(e.name="Banknote inserted",e.additional.where="stacker"):i>=144&&i<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):i>=160&&i<=175?(e.name="Banknote rejected",e.additional.where="nothing"):i>=176&&i<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),i>=128&&i<=191&&([e.description,e.additional.banknote]=o(this,w,Ws).call(this,t[2]),e.no_code=74+i),o(this,w,Kn).call(this,e.additional.banknote,e.additional.where,"banknote"),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},Qs=function(t,e){const i=parseInt(t,16);return i===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):i===0?(e.name="Coin purse disabled",e.description="Disabled by system request",e.no_code=4):(e.name="Status unknown",e.description="The response of coin purse doesn't identify successfully",e.no_code=400),this.dispatch("coin-purse:config",{enabled:i===1}),e},Zs=function(t,e){const i=parseInt(t[2],16),s=parseInt(t[3],16);return i===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):i===1&&(e.name="Bill purse enabled",e.description="Configuration complete, enabled"),s===0?e.additional.scrow="Scrow disabled, banknote received automatic":s===1&&(e.additional.scrow="Scrow enabled, require manual action"),e.no_code=5,this.dispatch("banknote-purse:config",{enabled:i===1,scrow:s===1}),e},Ys=function(t,e){e.no_code=6;const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={coins:{g50:i,c50:s,p1:a,p2:c,p5:l,p10:h}},this.coins.tubes.g50=i,this.coins.tubes.c50=s,this.coins.tubes.p1=a,this.coins.tubes.p2=c,this.coins.tubes.p5=l,this.coins.tubes.p10=h,this.coins.totals.g50=(this.coins.box.g50+i)*.5,this.coins.totals.c50=(this.coins.box.c50+s)*.5,this.coins.totals.p1=this.coins.box.p1+a,this.coins.totals.p2=(this.coins.box.p2+c)*2,this.coins.totals.p5=(this.coins.box.p5+l)*5,this.coins.totals.p10=(this.coins.box.p10+h)*10,this.coins.total=this.coins.totals.g50+this.coins.totals.c50+this.coins.totals.p1+this.coins.totals.p2+this.coins.totals.p5+this.coins.totals.p10,e.name="Read tubes",e.description="Quantity of coins approximated",this.dispatch("coin-purse:tubes",this.coins.tubes),e},ta=function(t,e){e.no_code=7;const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={banknotes:{b20:i,b50:s,b100:a,b200:c,b500:l,b1000:h}},this.banknotes.recycler.p20=i,this.banknotes.recycler.p50=s,this.banknotes.recycler.p100=a,this.banknotes.recycler.p200=c,this.banknotes.recycler.p500=l,this.banknotes.recycler.p1000=h,this.banknotes.totals.p20=(this.banknotes.stacker.p20+i)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+s)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+a)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+c)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+l)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+h)*1e3,this.banknotes.total=this.banknotes.totals.p20+this.banknotes.totals.p50+this.banknotes.totals.p100+this.banknotes.totals.p200+this.banknotes.totals.p500+this.banknotes.totals.p1000,e.name="Read recycler",e.description="Quantity of banknotes approximated",this.dispatch("banknote-purse:recycler",this.banknotes.recycler),e},ea=function(t,e){const i=parseInt(t,16);return i===1?e.name="Banknote accepted":i===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:i===1}),e},na=function(t,e){const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)],_=i*20+s*50+a*100+c*200+l*500+h*1e3;return e.name="Banknotes dispensed",e.description=_>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:i,b50:s,b100:a,b200:c,b500:l,b1000:h},total_dispensed:_},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},ia=function(t,e){return e.name="Coins dispensed",e.no_code=10,e.description="Coins dispensed by request",isNaN(this.__sale.last_change)&&(this.__sale.last_change=0),this.__money_session.retired+=this.__sale.last_change,this.dispatchAsync("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"coins"},500),e},ra=function(t,e){const i=parseInt(t,16);return i===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):i===0?(e.name="Product delivered",e.description="The product requested was delivered",e.no_code=12,this.__internal__.dispense.status=!0):(e.name="Unknown status product",e.description="The response of product doesn't identify successfully",e.no_code=400,this.__internal__.dispense.status=!1),this.dispatch("dispensed",{}),e},sa=function(t,e){let i="closed";return t==="db"?(e.name="Door closed",e.no_code=13):t==="dc"?(e.name="Door open",e.no_code=14,i="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,i="unknown"),this.__internal__.device.door_open=i==="open",this.dispatch("event:door",{open:i==="open"}),this.dispatch("door:event",{open:i==="open"}),e},aa=function(t,e){const i=parseInt(t[2],16)*255,s=parseInt(t[3],16),a=(i+s)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${a}`,e.additional={high:i,low:s,temperature:parseFloat(a.toString())},this.dispatch("status:temperature",e.additional),e},oa=function(t,e){const i=parseInt(t,16);let s="unknown";return i===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,s="on"):i===0?(e.name="Relay off",e.description="Relay off",e.no_code=17,s="off"):(e.name="Status unknown",e.description="Status unknown",e.no_code=400),this.dispatch("status:relay",{enabled:s==="on"}),e},ca=function(t,e){const i=parseInt(t[2],16);if(e.no_code=20+i,e.name="Status unknown",e.description="The status of card reader does not identified correctly",i===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(i===1||i===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(i===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(i===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(i===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(i===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(i===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(i===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(i===10){const s=parseInt(t[8],16);s===1?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):s===0?(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered"):(e.name="finished-unknown",e.no_code=400)}else e.no_code=400;return this.dispatch("card-reader:event",e),e},ut=function(t,e){return this.appendToQueue(o(this,w,Qe).call(this,t),e)},Qe=function(t){return t[11]=this.serialBoardroidSumHex(t),t.map((e,i)=>{t[i]=this.hexMaker(e)}),t},la=function({enable:t=!1,scrow:e=!1}={}){const i=t?"FF":"00",s=e?"FF":"00";return["F1","C0",i,i,s,s,"00","00","00","00","F2","00"]},ha=function({enable:t=!1,scrow:e=!1}={}){return["F1","C0",t?"01":"00",e?"01":"00","00","00","00","00","00","00","F2","00"]},ua=function(t=1){if(t<1)throw new Error("No banknotes to dispense");return t=this.decToHex(t),["F1","C5",this.decToHex(this.__banknote_purse.recycler.banknote.toString()),t,"00","00","00","00","00","00","F2","00"]},da=function({$_20:t=0,$_50:e=0,$_100:i=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if([t,e,i,s,a,c].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&i<1&&s<1&&a<1&&c<1)throw new Error("No banknotes to dispense");return[t,e,i,s,a,c]=[this.decToHex(t),this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a),this.decToHex(c)],["F1","C5",t,e,i,s,a,c,"00","00","F2","00"]},Wn=function(){L(this,Qt,!1),L(this,Lt,0),L(this,Zt,0)},Ze=function({dispensed:t=null,limit:e=80}={}){L(this,Zt,Math.round(I(this,Lt)*100/e)),this.dispatch("percentage:test",{percentage:I(this,Zt),dispensed:t})},pa=function(t){const e=["20","50","100","200","500"],i=this.__banknote_purse.recycler.banknote,s="$_"+e[i],a=parseInt(e[i]),c=this.banknotes.recycler[`p${e[i]}`],l=Math.min(Math.floor(t/a),c),h={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:l>0};return this.totalInRecycler===0||l<1||t===0||(h.banknotes[s]=l,h.pending=parseFloat((t-l*a).toFixed(2))),h},_a=function(t){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1};if(this.totalInRecycler===0||t===0)return e;const i=(s,a)=>{if(this.banknotes.recycler[a]>0){const c=Math.floor(e.pending/s),l=Math.min(c,this.banknotes.recycler[a]);e.banknotes[`$_${s}`]=l,e.pending=parseFloat((e.pending-l*s).toFixed(2))}};return i(1e3,"p1000"),i(500,"p500"),i(200,"p200"),i(100,"p100"),i(50,"p50"),i(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(s=>s>0),e},$n=function(t){return this.hasRecycler?o(this,w,Je).call(this)?o(this,w,pa).call(this,t):o(this,w,_a).call(this,t):{banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1}},zn=function(t){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:t,will_dispense:!1};if(!this.hasCoinPurse||t<=0||this.totalInTubes===0)return e;const i=(s,a,c=null)=>{if(this.coins.tubes[a]>0){c===null&&(c="$_"+s);const l=Math.floor(e.pending/s),h=Math.min(l,this.coins.tubes[a]);e.coins[c]=h,e.pending=parseFloat((e.pending-h*s).toFixed(2))}};return i(10,"p10"),i(5,"p5"),i(2,"p2"),i(1,"p1"),i(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(s=>s>0),e},Xn=async function(t=null){if(!o(this,w,qs).call(this))throw new Error("Change not available");let e=this.change,i=this.change;if(t!==null&&(e=t,i=t),i<=0)return!1;const s=o(this,w,$n).call(this,i);i=s.pending;const a=o(this,w,zn).call(this,i);return i=a.pending,i>0&&this.dispatch("change:pending",{pending:i}),this.dispatch("change:dispense",{recycler:s.banknotes,coins:a.coins,pending:i,delivery:e-i}),i===e?!1:(s.will_dispense&&await this.banknotePurseDispense(s.banknotes),a.will_dispense&&await this.coinPurseDispense(a.coins),!0)};class xc extends Dt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});tt(this,Yt);if(this.__internal__.device.type="arduino",G.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,o(this,Yt,ga).call(this),o(this,Yt,fa).call(this),this.getResponseAsString()}serialMessage(t){const e=this.stringToArrayHex(t),i=this.stringToArrayBuffer(t),s={original_code:e,arrayBuffer:i,code:null,name:null,description:null,request:null,no_code:0};switch(s.code=t,t){case"connected":s.name="connected",s.description="Connection established",s.request="connect",s.no_code=100;break;case"created by danidoble":s.name="thanks",s.description="thanks for using this software",s.request="credits",s.no_code=101;break;case"hello there":s.name="hello there",s.description="hi human",s.request="hi",s.no_code=102;break;case"ara ara":s.name="ara ara",s.description="troll",s.request="ara ara",s.no_code=404;break;default:s.name="unknown",s.description="Unknown command",s.request="unknown",s.no_code=400;break}this.dispatch("serial:message",s)}serialSetConnectionConstant(t=1){return this.add0x(this.parseStringToBytes("CONNECT"))}async sayCredits(){const t=this.parseStringToBytes("CREDITS");await this.appendToQueue(t,"credits")}async sayHi(){const t=this.parseStringToBytes("HI");await this.appendToQueue(t,"hi")}async sayAra(){const t=this.parseStringToBytes("OTHER");await this.appendToQueue(t,"ara")}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}Yt=new WeakSet,fa=function(){G.addCustom("arduino",this)},ga=function(){};/**
29
+ `,t+="-----END PUBLIC KEY-----",t},n.hasPublicKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")},n.hasPrivateKeyProperty=function(t){return t=t||{},t.hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},n.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},n}(za),cn,Za=typeof process<"u"?(cn=process.env)===null||cn===void 0?void 0:cn.npm_package_version:void 0,Ya=function(){function r(n){n===void 0&&(n={}),n=n||{},this.default_key_size=n.default_key_size?parseInt(n.default_key_size,10):1024,this.default_public_exponent=n.default_public_exponent||"010001",this.log=n.log||!1,this.key=null}return r.prototype.setKey=function(n){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Pi(n)},r.prototype.setPrivateKey=function(n){this.setKey(n)},r.prototype.setPublicKey=function(n){this.setKey(n)},r.prototype.decrypt=function(n){try{return this.getKey().decrypt(pi(n))}catch{return!1}},r.prototype.encrypt=function(n){try{return be(this.getKey().encrypt(n))}catch{return!1}},r.prototype.sign=function(n,t,e){try{return be(this.getKey().sign(n,t,e))}catch{return!1}},r.prototype.verify=function(n,t,e){try{return this.getKey().verify(n,pi(t),e)}catch{return!1}},r.prototype.getKey=function(n){if(!this.key){if(this.key=new Pi,n&&{}.toString.call(n)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,n);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},r.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},r.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},r.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},r.version=Za,r}();function Ei(r,n){return function(){return r.apply(n,arguments)}}const{toString:to}=Object.prototype,{getPrototypeOf:ln}=Object,Te=(r=>n=>{const t=to.call(n);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),bt=r=>(r=r.toLowerCase(),n=>Te(n)===r),Se=r=>n=>typeof n===r,{isArray:zt}=Array,ie=Se("undefined");function eo(r){return r!==null&&!ie(r)&&r.constructor!==null&&!ie(r.constructor)&&ht(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Ci=bt("ArrayBuffer");function no(r){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(r):n=r&&r.buffer&&Ci(r.buffer),n}const io=Se("string"),ht=Se("function"),Ti=Se("number"),ke=r=>r!==null&&typeof r=="object",ro=r=>r===!0||r===!1,xe=r=>{if(Te(r)!=="object")return!1;const n=ln(r);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},so=bt("Date"),ao=bt("File"),oo=bt("Blob"),co=bt("FileList"),lo=r=>ke(r)&&ht(r.pipe),ho=r=>{let n;return r&&(typeof FormData=="function"&&r instanceof FormData||ht(r.append)&&((n=Te(r))==="formdata"||n==="object"&&ht(r.toString)&&r.toString()==="[object FormData]"))},uo=bt("URLSearchParams"),[po,_o,fo,go]=["ReadableStream","Request","Response","Headers"].map(bt),bo=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function re(r,n,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let e,i;if(typeof r!="object"&&(r=[r]),zt(r))for(e=0,i=r.length;e<i;e++)n.call(null,r[e],e,r);else{const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let c;for(e=0;e<a;e++)c=s[e],n.call(null,r[c],c,r)}}function Si(r,n){n=n.toLowerCase();const t=Object.keys(r);let e=t.length,i;for(;e-- >0;)if(i=t[e],n===i.toLowerCase())return i;return null}const Bt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ki=r=>!ie(r)&&r!==Bt;function hn(){const{caseless:r}=ki(this)&&this||{},n={},t=(e,i)=>{const s=r&&Si(n,i)||i;xe(n[s])&&xe(e)?n[s]=hn(n[s],e):xe(e)?n[s]=hn({},e):zt(e)?n[s]=e.slice():n[s]=e};for(let e=0,i=arguments.length;e<i;e++)arguments[e]&&re(arguments[e],t);return n}const yo=(r,n,t,{allOwnKeys:e}={})=>(re(n,(i,s)=>{t&&ht(i)?r[s]=Ei(i,t):r[s]=i},{allOwnKeys:e}),r),mo=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),wo=(r,n,t,e)=>{r.prototype=Object.create(n.prototype,e),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:n.prototype}),t&&Object.assign(r.prototype,t)},vo=(r,n,t,e)=>{let i,s,a;const c={};if(n=n||{},r==null)return n;do{for(i=Object.getOwnPropertyNames(r),s=i.length;s-- >0;)a=i[s],(!e||e(a,r,n))&&!c[a]&&(n[a]=r[a],c[a]=!0);r=t!==!1&&ln(r)}while(r&&(!t||t(r,n))&&r!==Object.prototype);return n},Po=(r,n,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=n.length;const e=r.indexOf(n,t);return e!==-1&&e===t},Eo=r=>{if(!r)return null;if(zt(r))return r;let n=r.length;if(!Ti(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=r[n];return t},Co=(r=>n=>r&&n instanceof r)(typeof Uint8Array<"u"&&ln(Uint8Array)),To=(r,n)=>{const e=(r&&r[Symbol.iterator]).call(r);let i;for(;(i=e.next())&&!i.done;){const s=i.value;n.call(r,s[0],s[1])}},So=(r,n)=>{let t;const e=[];for(;(t=r.exec(n))!==null;)e.push(t);return e},ko=bt("HTMLFormElement"),xo=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,e,i){return e.toUpperCase()+i}),xi=(({hasOwnProperty:r})=>(n,t)=>r.call(n,t))(Object.prototype),Ao=bt("RegExp"),Ai=(r,n)=>{const t=Object.getOwnPropertyDescriptors(r),e={};re(t,(i,s)=>{let a;(a=n(i,s,r))!==!1&&(e[s]=a||i)}),Object.defineProperties(r,e)},Do=r=>{Ai(r,(n,t)=>{if(ht(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const e=r[t];if(ht(e)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Ro=(r,n)=>{const t={},e=i=>{i.forEach(s=>{t[s]=!0})};return zt(r)?e(r):e(String(r).split(n)),t},Io=()=>{},Oo=(r,n)=>r!=null&&Number.isFinite(r=+r)?r:n;function Bo(r){return!!(r&&ht(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const No=r=>{const n=new Array(10),t=(e,i)=>{if(ke(e)){if(n.indexOf(e)>=0)return;if(!("toJSON"in e)){n[i]=e;const s=zt(e)?[]:{};return re(e,(a,c)=>{const l=t(a,i+1);!ie(l)&&(s[c]=l)}),n[i]=void 0,s}}return e};return t(r,0)},Mo=bt("AsyncFunction"),Fo=r=>r&&(ke(r)||ht(r))&&ht(r.then)&&ht(r.catch),Di=((r,n)=>r?setImmediate:n?((t,e)=>(Bt.addEventListener("message",({source:i,data:s})=>{i===Bt&&s===t&&e.length&&e.shift()()},!1),i=>{e.push(i),Bt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ht(Bt.postMessage)),Uo=typeof queueMicrotask<"u"?queueMicrotask.bind(Bt):typeof process<"u"&&process.nextTick||Di,b={isArray:zt,isArrayBuffer:Ci,isBuffer:eo,isFormData:ho,isArrayBufferView:no,isString:io,isNumber:Ti,isBoolean:ro,isObject:ke,isPlainObject:xe,isReadableStream:po,isRequest:_o,isResponse:fo,isHeaders:go,isUndefined:ie,isDate:so,isFile:ao,isBlob:oo,isRegExp:Ao,isFunction:ht,isStream:lo,isURLSearchParams:uo,isTypedArray:Co,isFileList:co,forEach:re,merge:hn,extend:yo,trim:bo,stripBOM:mo,inherits:wo,toFlatObject:vo,kindOf:Te,kindOfTest:bt,endsWith:Po,toArray:Eo,forEachEntry:To,matchAll:So,isHTMLForm:ko,hasOwnProperty:xi,hasOwnProp:xi,reduceDescriptors:Ai,freezeMethods:Do,toObjectSet:Ro,toCamelCase:xo,noop:Io,toFiniteNumber:Oo,findKey:Si,global:Bt,isContextDefined:ki,isSpecCompliantForm:Bo,toJSONObject:No,isAsyncFn:Mo,isThenable:Fo,setImmediate:Di,asap:Uo};function A(r,n,t,e,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),e&&(this.request=e),i&&(this.response=i,this.status=i.status?i.status:null)}b.inherits(A,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.status}}});const Ri=A.prototype,Ii={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Ii[r]={value:r}}),Object.defineProperties(A,Ii),Object.defineProperty(Ri,"isAxiosError",{value:!0}),A.from=(r,n,t,e,i,s)=>{const a=Object.create(Ri);return b.toFlatObject(r,a,function(l){return l!==Error.prototype},c=>c!=="isAxiosError"),A.call(a,r.message,n,t,e,i),a.cause=r,a.name=r.name,s&&Object.assign(a,s),a};const Lo=null;function un(r){return b.isPlainObject(r)||b.isArray(r)}function Oi(r){return b.endsWith(r,"[]")?r.slice(0,-2):r}function Bi(r,n,t){return r?r.concat(n).map(function(i,s){return i=Oi(i),!t&&s?"["+i+"]":i}).join(t?".":""):n}function Vo(r){return b.isArray(r)&&!r.some(un)}const qo=b.toFlatObject(b,{},null,function(n){return/^is[A-Z]/.test(n)});function Ae(r,n,t){if(!b.isObject(r))throw new TypeError("target must be an object");n=n||new FormData,t=b.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(S,T){return!b.isUndefined(T[S])});const e=t.metaTokens,i=t.visitor||_,s=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&b.isSpecCompliantForm(n);if(!b.isFunction(i))throw new TypeError("visitor must be a function");function h(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!l&&b.isBlob(v))throw new A("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function _(v,S,T){let H=v;if(v&&!T&&typeof v=="object"){if(b.endsWith(S,"{}"))S=e?S:S.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&Vo(v)||(b.isFileList(v)||b.endsWith(S,"[]"))&&(H=b.toArray(v)))return S=Oi(S),H.forEach(function(W,ot){!(b.isUndefined(W)||W===null)&&n.append(a===!0?Bi([S],ot,s):a===null?S:S+"[]",h(W))}),!1}return un(v)?!0:(n.append(Bi(T,S,s),h(v)),!1)}const f=[],y=Object.assign(qo,{defaultVisitor:_,convertValue:h,isVisitable:un});function P(v,S){if(!b.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+S.join("."));f.push(v),b.forEach(v,function(H,V){(!(b.isUndefined(H)||H===null)&&i.call(n,H,b.isString(V)?V.trim():V,S,y))===!0&&P(H,S?S.concat(V):[V])}),f.pop()}}if(!b.isObject(r))throw new TypeError("data must be an object");return P(r),n}function Ni(r){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(e){return n[e]})}function dn(r,n){this._pairs=[],r&&Ae(r,this,n)}const Mi=dn.prototype;Mi.append=function(n,t){this._pairs.push([n,t])},Mi.toString=function(n){const t=n?function(e){return n.call(this,e,Ni)}:Ni;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function jo(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Fi(r,n,t){if(!n)return r;const e=t&&t.encode||jo;b.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(n,t):s=b.isURLSearchParams(n)?n.toString():new dn(n,t).toString(e),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Ui{constructor(){this.handlers=[]}use(n,t,e){return this.handlers.push({fulfilled:n,rejected:t,synchronous:e?e.synchronous:!1,runWhen:e?e.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){b.forEach(this.handlers,function(e){e!==null&&n(e)})}}const Li={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ho={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:dn,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},pn=typeof window<"u"&&typeof document<"u",_n=typeof navigator=="object"&&navigator||void 0,Ko=pn&&(!_n||["ReactNative","NativeScript","NS"].indexOf(_n.product)<0),Wo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",$o=pn&&window.location.href||"http://localhost",nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:pn,hasStandardBrowserEnv:Ko,hasStandardBrowserWebWorkerEnv:Wo,navigator:_n,origin:$o},Symbol.toStringTag,{value:"Module"})),...Ho};function zo(r,n){return Ae(r,new nt.classes.URLSearchParams,Object.assign({visitor:function(t,e,i,s){return nt.isNode&&b.isBuffer(t)?(this.append(e,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},n))}function Xo(r){return b.matchAll(/\w+|\[(\w*)]/g,r).map(n=>n[0]==="[]"?"":n[1]||n[0])}function Go(r){const n={},t=Object.keys(r);let e;const i=t.length;let s;for(e=0;e<i;e++)s=t[e],n[s]=r[s];return n}function Vi(r){function n(t,e,i,s){let a=t[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),l=s>=t.length;return a=!a&&b.isArray(i)?i.length:a,l?(b.hasOwnProp(i,a)?i[a]=[i[a],e]:i[a]=e,!c):((!i[a]||!b.isObject(i[a]))&&(i[a]=[]),n(t,e,i[a],s)&&b.isArray(i[a])&&(i[a]=Go(i[a])),!c)}if(b.isFormData(r)&&b.isFunction(r.entries)){const t={};return b.forEachEntry(r,(e,i)=>{n(Xo(e),i,t,0)}),t}return null}function Jo(r,n,t){if(b.isString(r))try{return(n||JSON.parse)(r),b.trim(r)}catch(e){if(e.name!=="SyntaxError")throw e}return(t||JSON.stringify)(r)}const se={transitional:Li,adapter:["xhr","http","fetch"],transformRequest:[function(n,t){const e=t.getContentType()||"",i=e.indexOf("application/json")>-1,s=b.isObject(n);if(s&&b.isHTMLForm(n)&&(n=new FormData(n)),b.isFormData(n))return i?JSON.stringify(Vi(n)):n;if(b.isArrayBuffer(n)||b.isBuffer(n)||b.isStream(n)||b.isFile(n)||b.isBlob(n)||b.isReadableStream(n))return n;if(b.isArrayBufferView(n))return n.buffer;if(b.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(s){if(e.indexOf("application/x-www-form-urlencoded")>-1)return zo(n,this.formSerializer).toString();if((c=b.isFileList(n))||e.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ae(c?{"files[]":n}:n,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),Jo(n)):n}],transformResponse:[function(n){const t=this.transitional||se.transitional,e=t&&t.forcedJSONParsing,i=this.responseType==="json";if(b.isResponse(n)||b.isReadableStream(n))return n;if(n&&b.isString(n)&&(e&&!this.responseType||i)){const a=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(n)}catch(c){if(a)throw c.name==="SyntaxError"?A.from(c,A.ERR_BAD_RESPONSE,this,null,this.response):c}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nt.classes.FormData,Blob:nt.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],r=>{se.headers[r]={}});const Qo=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Zo=r=>{const n={};let t,e,i;return r&&r.split(`
30
+ `).forEach(function(a){i=a.indexOf(":"),t=a.substring(0,i).trim().toLowerCase(),e=a.substring(i+1).trim(),!(!t||n[t]&&Qo[t])&&(t==="set-cookie"?n[t]?n[t].push(e):n[t]=[e]:n[t]=n[t]?n[t]+", "+e:e)}),n},qi=Symbol("internals");function ae(r){return r&&String(r).trim().toLowerCase()}function De(r){return r===!1||r==null?r:b.isArray(r)?r.map(De):String(r)}function Yo(r){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let e;for(;e=t.exec(r);)n[e[1]]=e[2];return n}const tc=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function fn(r,n,t,e,i){if(b.isFunction(e))return e.call(this,n,t);if(i&&(n=t),!!b.isString(n)){if(b.isString(e))return n.indexOf(e)!==-1;if(b.isRegExp(e))return e.test(n)}}function ec(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,e)=>t.toUpperCase()+e)}function nc(r,n){const t=b.toCamelCase(" "+n);["get","set","has"].forEach(e=>{Object.defineProperty(r,e+t,{value:function(i,s,a){return this[e].call(this,n,i,s,a)},configurable:!0})})}let st=class{constructor(n){n&&this.set(n)}set(n,t,e){const i=this;function s(c,l,h){const _=ae(l);if(!_)throw new Error("header name must be a non-empty string");const f=b.findKey(i,_);(!f||i[f]===void 0||h===!0||h===void 0&&i[f]!==!1)&&(i[f||l]=De(c))}const a=(c,l)=>b.forEach(c,(h,_)=>s(h,_,l));if(b.isPlainObject(n)||n instanceof this.constructor)a(n,t);else if(b.isString(n)&&(n=n.trim())&&!tc(n))a(Zo(n),t);else if(b.isHeaders(n))for(const[c,l]of n.entries())s(l,c,e);else n!=null&&s(t,n,e);return this}get(n,t){if(n=ae(n),n){const e=b.findKey(this,n);if(e){const i=this[e];if(!t)return i;if(t===!0)return Yo(i);if(b.isFunction(t))return t.call(this,i,e);if(b.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=ae(n),n){const e=b.findKey(this,n);return!!(e&&this[e]!==void 0&&(!t||fn(this,this[e],e,t)))}return!1}delete(n,t){const e=this;let i=!1;function s(a){if(a=ae(a),a){const c=b.findKey(e,a);c&&(!t||fn(e,e[c],c,t))&&(delete e[c],i=!0)}}return b.isArray(n)?n.forEach(s):s(n),i}clear(n){const t=Object.keys(this);let e=t.length,i=!1;for(;e--;){const s=t[e];(!n||fn(this,this[s],s,n,!0))&&(delete this[s],i=!0)}return i}normalize(n){const t=this,e={};return b.forEach(this,(i,s)=>{const a=b.findKey(e,s);if(a){t[a]=De(i),delete t[s];return}const c=n?ec(s):String(s).trim();c!==s&&delete t[s],t[c]=De(i),e[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return b.forEach(this,(e,i)=>{e!=null&&e!==!1&&(t[i]=n&&b.isArray(e)?e.join(", "):e)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
31
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const e=new this(n);return t.forEach(i=>e.set(i)),e}static accessor(n){const e=(this[qi]=this[qi]={accessors:{}}).accessors,i=this.prototype;function s(a){const c=ae(a);e[c]||(nc(i,a),e[c]=!0)}return b.isArray(n)?n.forEach(s):s(n),this}};st.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),b.reduceDescriptors(st.prototype,({value:r},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>r,set(e){this[t]=e}}}),b.freezeMethods(st);function gn(r,n){const t=this||se,e=n||t,i=st.from(e.headers);let s=e.data;return b.forEach(r,function(c){s=c.call(t,s,i.normalize(),n?n.status:void 0)}),i.normalize(),s}function ji(r){return!!(r&&r.__CANCEL__)}function Xt(r,n,t){A.call(this,r??"canceled",A.ERR_CANCELED,n,t),this.name="CanceledError"}b.inherits(Xt,A,{__CANCEL__:!0});function Hi(r,n,t){const e=t.config.validateStatus;!t.status||!e||e(t.status)?r(t):n(new A("Request failed with status code "+t.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function ic(r){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return n&&n[1]||""}function rc(r,n){r=r||10;const t=new Array(r),e=new Array(r);let i=0,s=0,a;return n=n!==void 0?n:1e3,function(l){const h=Date.now(),_=e[s];a||(a=h),t[i]=l,e[i]=h;let f=s,y=0;for(;f!==i;)y+=t[f++],f=f%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),h-a<n)return;const P=_&&h-_;return P?Math.round(y*1e3/P):void 0}}function sc(r,n){let t=0,e=1e3/n,i,s;const a=(h,_=Date.now())=>{t=_,i=null,s&&(clearTimeout(s),s=null),r.apply(null,h)};return[(...h)=>{const _=Date.now(),f=_-t;f>=e?a(h,_):(i=h,s||(s=setTimeout(()=>{s=null,a(i)},e-f)))},()=>i&&a(i)]}const Re=(r,n,t=3)=>{let e=0;const i=rc(50,250);return sc(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,l=a-e,h=i(l),_=a<=c;e=a;const f={loaded:a,total:c,progress:c?a/c:void 0,bytes:l,rate:h||void 0,estimated:h&&c&&_?(c-a)/h:void 0,event:s,lengthComputable:c!=null,[n?"download":"upload"]:!0};r(f)},t)},Ki=(r,n)=>{const t=r!=null;return[e=>n[0]({lengthComputable:t,total:r,loaded:e}),n[1]]},Wi=r=>(...n)=>b.asap(()=>r(...n)),ac=nt.hasStandardBrowserEnv?((r,n)=>t=>(t=new URL(t,nt.origin),r.protocol===t.protocol&&r.host===t.host&&(n||r.port===t.port)))(new URL(nt.origin),nt.navigator&&/(msie|trident)/i.test(nt.navigator.userAgent)):()=>!0,oc=nt.hasStandardBrowserEnv?{write(r,n,t,e,i,s){const a=[r+"="+encodeURIComponent(n)];b.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),b.isString(e)&&a.push("path="+e),b.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function cc(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function lc(r,n){return n?r.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):r}function $i(r,n,t){let e=!cc(n);return r&&e||t==!1?lc(r,n):n}const zi=r=>r instanceof st?{...r}:r;function Nt(r,n){n=n||{};const t={};function e(h,_,f,y){return b.isPlainObject(h)&&b.isPlainObject(_)?b.merge.call({caseless:y},h,_):b.isPlainObject(_)?b.merge({},_):b.isArray(_)?_.slice():_}function i(h,_,f,y){if(b.isUndefined(_)){if(!b.isUndefined(h))return e(void 0,h,f,y)}else return e(h,_,f,y)}function s(h,_){if(!b.isUndefined(_))return e(void 0,_)}function a(h,_){if(b.isUndefined(_)){if(!b.isUndefined(h))return e(void 0,h)}else return e(void 0,_)}function c(h,_,f){if(f in n)return e(h,_);if(f in r)return e(void 0,h)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(h,_,f)=>i(zi(h),zi(_),f,!0)};return b.forEach(Object.keys(Object.assign({},r,n)),function(_){const f=l[_]||i,y=f(r[_],n[_],_);b.isUndefined(y)&&f!==c||(t[_]=y)}),t}const Xi=r=>{const n=Nt({},r);let{data:t,withXSRFToken:e,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:c}=n;n.headers=a=st.from(a),n.url=Fi($i(n.baseURL,n.url,n.allowAbsoluteUrls),r.params,r.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(b.isFormData(t)){if(nt.hasStandardBrowserEnv||nt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[h,..._]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([h||"multipart/form-data",..._].join("; "))}}if(nt.hasStandardBrowserEnv&&(e&&b.isFunction(e)&&(e=e(n)),e||e!==!1&&ac(n.url))){const h=i&&s&&oc.read(s);h&&a.set(i,h)}return n},hc=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,e){const i=Xi(r);let s=i.data;const a=st.from(i.headers).normalize();let{responseType:c,onUploadProgress:l,onDownloadProgress:h}=i,_,f,y,P,v;function S(){P&&P(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(_),i.signal&&i.signal.removeEventListener("abort",_)}let T=new XMLHttpRequest;T.open(i.method.toUpperCase(),i.url,!0),T.timeout=i.timeout;function H(){if(!T)return;const W=st.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),Z={data:!c||c==="text"||c==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:W,config:r,request:T};Hi(function(dt){t(dt),S()},function(dt){e(dt),S()},Z),T=null}"onloadend"in T?T.onloadend=H:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(H)},T.onabort=function(){T&&(e(new A("Request aborted",A.ECONNABORTED,r,T)),T=null)},T.onerror=function(){e(new A("Network Error",A.ERR_NETWORK,r,T)),T=null},T.ontimeout=function(){let ot=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const Z=i.transitional||Li;i.timeoutErrorMessage&&(ot=i.timeoutErrorMessage),e(new A(ot,Z.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,r,T)),T=null},s===void 0&&a.setContentType(null),"setRequestHeader"in T&&b.forEach(a.toJSON(),function(ot,Z){T.setRequestHeader(Z,ot)}),b.isUndefined(i.withCredentials)||(T.withCredentials=!!i.withCredentials),c&&c!=="json"&&(T.responseType=i.responseType),h&&([y,v]=Re(h,!0),T.addEventListener("progress",y)),l&&T.upload&&([f,P]=Re(l),T.upload.addEventListener("progress",f),T.upload.addEventListener("loadend",P)),(i.cancelToken||i.signal)&&(_=W=>{T&&(e(!W||W.type?new Xt(null,r,T):W),T.abort(),T=null)},i.cancelToken&&i.cancelToken.subscribe(_),i.signal&&(i.signal.aborted?_():i.signal.addEventListener("abort",_)));const V=ic(i.url);if(V&&nt.protocols.indexOf(V)===-1){e(new A("Unsupported protocol "+V+":",A.ERR_BAD_REQUEST,r));return}T.send(s||null)})},uc=(r,n)=>{const{length:t}=r=r?r.filter(Boolean):[];if(n||t){let e=new AbortController,i;const s=function(h){if(!i){i=!0,c();const _=h instanceof Error?h:this.reason;e.abort(_ instanceof A?_:new Xt(_ instanceof Error?_.message:_))}};let a=n&&setTimeout(()=>{a=null,s(new A(`timeout ${n} of ms exceeded`,A.ETIMEDOUT))},n);const c=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=e;return l.unsubscribe=()=>b.asap(c),l}},dc=function*(r,n){let t=r.byteLength;if(t<n){yield r;return}let e=0,i;for(;e<t;)i=e+n,yield r.slice(e,i),e=i},pc=async function*(r,n){for await(const t of _c(r))yield*dc(t,n)},_c=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const n=r.getReader();try{for(;;){const{done:t,value:e}=await n.read();if(t)break;yield e}}finally{await n.cancel()}},Gi=(r,n,t,e)=>{const i=pc(r,n);let s=0,a,c=l=>{a||(a=!0,e&&e(l))};return new ReadableStream({async pull(l){try{const{done:h,value:_}=await i.next();if(h){c(),l.close();return}let f=_.byteLength;if(t){let y=s+=f;t(y)}l.enqueue(new Uint8Array(_))}catch(h){throw c(h),h}},cancel(l){return c(l),i.return()}},{highWaterMark:2})},Ie=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ji=Ie&&typeof ReadableStream=="function",fc=Ie&&(typeof TextEncoder=="function"?(r=>n=>r.encode(n))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Qi=(r,...n)=>{try{return!!r(...n)}catch{return!1}},gc=Ji&&Qi(()=>{let r=!1;const n=new Request(nt.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!n}),Zi=64*1024,bn=Ji&&Qi(()=>b.isReadableStream(new Response("").body)),Oe={stream:bn&&(r=>r.body)};Ie&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(n=>{!Oe[n]&&(Oe[n]=b.isFunction(r[n])?t=>t[n]():(t,e)=>{throw new A(`Response type '${n}' is not supported`,A.ERR_NOT_SUPPORT,e)})})})(new Response);const bc=async r=>{if(r==null)return 0;if(b.isBlob(r))return r.size;if(b.isSpecCompliantForm(r))return(await new Request(nt.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(b.isArrayBufferView(r)||b.isArrayBuffer(r))return r.byteLength;if(b.isURLSearchParams(r)&&(r=r+""),b.isString(r))return(await fc(r)).byteLength},yc=async(r,n)=>{const t=b.toFiniteNumber(r.getContentLength());return t??bc(n)},yn={http:Lo,xhr:hc,fetch:Ie&&(async r=>{let{url:n,method:t,data:e,signal:i,cancelToken:s,timeout:a,onDownloadProgress:c,onUploadProgress:l,responseType:h,headers:_,withCredentials:f="same-origin",fetchOptions:y}=Xi(r);h=h?(h+"").toLowerCase():"text";let P=uc([i,s&&s.toAbortSignal()],a),v;const S=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let T;try{if(l&&gc&&t!=="get"&&t!=="head"&&(T=await yc(_,e))!==0){let Z=new Request(n,{method:"POST",body:e,duplex:"half"}),x;if(b.isFormData(e)&&(x=Z.headers.get("content-type"))&&_.setContentType(x),Z.body){const[dt,Ct]=Ki(T,Re(Wi(l)));e=Gi(Z.body,Zi,dt,Ct)}}b.isString(f)||(f=f?"include":"omit");const H="credentials"in Request.prototype;v=new Request(n,{...y,signal:P,method:t.toUpperCase(),headers:_.normalize().toJSON(),body:e,duplex:"half",credentials:H?f:void 0});let V=await fetch(v);const W=bn&&(h==="stream"||h==="response");if(bn&&(c||W&&S)){const Z={};["status","statusText","headers"].forEach(Tt=>{Z[Tt]=V[Tt]});const x=b.toFiniteNumber(V.headers.get("content-length")),[dt,Ct]=c&&Ki(x,Re(Wi(c),!0))||[];V=new Response(Gi(V.body,Zi,dt,()=>{Ct&&Ct(),S&&S()}),Z)}h=h||"text";let ot=await Oe[b.findKey(Oe,h)||"text"](V,r);return!W&&S&&S(),await new Promise((Z,x)=>{Hi(Z,x,{data:ot,headers:st.from(V.headers),status:V.status,statusText:V.statusText,config:r,request:v})})}catch(H){throw S&&S(),H&&H.name==="TypeError"&&/fetch/i.test(H.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,r,v),{cause:H.cause||H}):A.from(H,H&&H.code,r,v)}})};b.forEach(yn,(r,n)=>{if(r){try{Object.defineProperty(r,"name",{value:n})}catch{}Object.defineProperty(r,"adapterName",{value:n})}});const Yi=r=>`- ${r}`,mc=r=>b.isFunction(r)||r===null||r===!1,tr={getAdapter:r=>{r=b.isArray(r)?r:[r];const{length:n}=r;let t,e;const i={};for(let s=0;s<n;s++){t=r[s];let a;if(e=t,!mc(t)&&(e=yn[(a=String(t)).toLowerCase()],e===void 0))throw new A(`Unknown adapter '${a}'`);if(e)break;i[a||"#"+s]=e}if(!e){const s=Object.entries(i).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?s.length>1?`since :
32
+ `+s.map(Yi).join(`
33
+ `):" "+Yi(s[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return e},adapters:yn};function mn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Xt(null,r)}function er(r){return mn(r),r.headers=st.from(r.headers),r.data=gn.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),tr.getAdapter(r.adapter||se.adapter)(r).then(function(e){return mn(r),e.data=gn.call(r,r.transformResponse,e),e.headers=st.from(e.headers),e},function(e){return ji(e)||(mn(r),e&&e.response&&(e.response.data=gn.call(r,r.transformResponse,e.response),e.response.headers=st.from(e.response.headers))),Promise.reject(e)})}const nr="1.8.3",Be={};["object","boolean","number","function","string","symbol"].forEach((r,n)=>{Be[r]=function(e){return typeof e===r||"a"+(n<1?"n ":" ")+r}});const ir={};Be.transitional=function(n,t,e){function i(s,a){return"[Axios v"+nr+"] Transitional option '"+s+"'"+a+(e?". "+e:"")}return(s,a,c)=>{if(n===!1)throw new A(i(a," has been removed"+(t?" in "+t:"")),A.ERR_DEPRECATED);return t&&!ir[a]&&(ir[a]=!0,console.warn(i(a," has been deprecated since v"+t+" and will be removed in the near future"))),n?n(s,a,c):!0}},Be.spelling=function(n){return(t,e)=>(console.warn(`${e} is likely a misspelling of ${n}`),!0)};function wc(r,n,t){if(typeof r!="object")throw new A("options must be an object",A.ERR_BAD_OPTION_VALUE);const e=Object.keys(r);let i=e.length;for(;i-- >0;){const s=e[i],a=n[s];if(a){const c=r[s],l=c===void 0||a(c,s,r);if(l!==!0)throw new A("option "+s+" must be "+l,A.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new A("Unknown option "+s,A.ERR_BAD_OPTION)}}const Ne={assertOptions:wc,validators:Be},Pt=Ne.validators;let Mt=class{constructor(n){this.defaults=n,this.interceptors={request:new Ui,response:new Ui}}async request(n,t){try{return await this._request(n,t)}catch(e){if(e instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{e.stack?s&&!String(e.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(e.stack+=`
34
+ `+s):e.stack=s}catch{}}throw e}}_request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=Nt(this.defaults,t);const{transitional:e,paramsSerializer:i,headers:s}=t;e!==void 0&&Ne.assertOptions(e,{silentJSONParsing:Pt.transitional(Pt.boolean),forcedJSONParsing:Pt.transitional(Pt.boolean),clarifyTimeoutError:Pt.transitional(Pt.boolean)},!1),i!=null&&(b.isFunction(i)?t.paramsSerializer={serialize:i}:Ne.assertOptions(i,{encode:Pt.function,serialize:Pt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Ne.assertOptions(t,{baseUrl:Pt.spelling("baseURL"),withXsrfToken:Pt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=s&&b.merge(s.common,s[t.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),t.headers=st.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(t)===!1||(l=l&&S.synchronous,c.unshift(S.fulfilled,S.rejected))});const h=[];this.interceptors.response.forEach(function(S){h.push(S.fulfilled,S.rejected)});let _,f=0,y;if(!l){const v=[er.bind(this),void 0];for(v.unshift.apply(v,c),v.push.apply(v,h),y=v.length,_=Promise.resolve(t);f<y;)_=_.then(v[f++],v[f++]);return _}y=c.length;let P=t;for(f=0;f<y;){const v=c[f++],S=c[f++];try{P=v(P)}catch(T){S.call(this,T);break}}try{_=er.call(this,P)}catch(v){return Promise.reject(v)}for(f=0,y=h.length;f<y;)_=_.then(h[f++],h[f++]);return _}getUri(n){n=Nt(this.defaults,n);const t=$i(n.baseURL,n.url,n.allowAbsoluteUrls);return Fi(t,n.params,n.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(n){Mt.prototype[n]=function(t,e){return this.request(Nt(e||{},{method:n,url:t,data:(e||{}).data}))}}),b.forEach(["post","put","patch"],function(n){function t(e){return function(s,a,c){return this.request(Nt(c||{},{method:n,headers:e?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Mt.prototype[n]=t(),Mt.prototype[n+"Form"]=t(!0)});let vc=class _r{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const e=this;this.promise.then(i=>{if(!e._listeners)return;let s=e._listeners.length;for(;s-- >0;)e._listeners[s](i);e._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(c=>{e.subscribe(c),s=c}).then(i);return a.cancel=function(){e.unsubscribe(s)},a},n(function(s,a,c){e.reason||(e.reason=new Xt(s,a,c),t(e.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const n=new AbortController,t=e=>{n.abort(e)};return this.subscribe(t),n.signal.unsubscribe=()=>this.unsubscribe(t),n.signal}static source(){let n;return{token:new _r(function(i){n=i}),cancel:n}}};function Pc(r){return function(t){return r.apply(null,t)}}function Ec(r){return b.isObject(r)&&r.isAxiosError===!0}const wn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(wn).forEach(([r,n])=>{wn[n]=r});function rr(r){const n=new Mt(r),t=Ei(Mt.prototype.request,n);return b.extend(t,Mt.prototype,n,{allOwnKeys:!0}),b.extend(t,n,null,{allOwnKeys:!0}),t.create=function(i){return rr(Nt(r,i))},t}const K=rr(se);K.Axios=Mt,K.CanceledError=Xt,K.CancelToken=vc,K.isCancel=ji,K.VERSION=nr,K.toFormData=Ae,K.AxiosError=A,K.Cancel=K.CanceledError,K.all=function(n){return Promise.all(n)},K.spread=Pc,K.isAxiosError=Ec,K.mergeConfig=Nt,K.AxiosHeaders=st,K.formToJSON=r=>Vi(b.isHTMLForm(r)?new FormData(r):r),K.getAdapter=tr.getAdapter,K.HttpStatusCode=wn,K.default=K;const{Axios:Lc,AxiosError:Vc,CanceledError:qc,isCancel:jc,CancelToken:Hc,VERSION:Kc,all:Wc,Cancel:$c,isAxiosError:zc,spread:Xc,toFormData:Gc,AxiosHeaders:Jc,HttpStatusCode:Qc,formToJSON:Zc,getAdapter:Yc,mergeConfig:tl}=K;class Cc extends xt{constructor({filters:t=null,config_port:e={baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:i=1,device_listen_on_channel:s=1,username:a=null,password:c=null,environment:l="production"}={filters:null,config_port:{baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,username:null,password:null,environment:"production"}){super({filters:t,config_port:e,no_device:i,device_listen_on_channel:s});Y(this,p);_t(this,"__pinPad__",{buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:0,reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null}});if(this.__internal__.device.type="pinpad",!fa())throw new Error("Crypto not supported in this browser");if(k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.environment=l,a&&(this.username=a),c&&(this.password=c),o(this,p,gr).call(this),o(this,p,fr).call(this)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},i=this.parseHexToUint8(t),s=this.parseUint8ArrayToString(i);let a=o(this,p,br).call(this,s);switch(this.__pinPad__.buffer=s,e.parsed=a,e.code=s,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,o(this,p,Sn).call(this,a,s);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,o(this,p,Sn).call(this,a,s);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,o(this,p,yr).call(this,a,s);break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,o(this,p,mr).call(this,a,s);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,o(this,p,wr).call(this,a,s);break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,o(this,p,vr).call(this,a,s);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,o(this,p,Pr).call(this,a,s);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":o(this,p,Tr).call(this,a,s),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":o(this,p,Cr).call(this,a,s),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":o(this,p,Sr).call(this,a,s),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":o(this,p,kr).call(this,a,s),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){const e="",i="";let s="C56AABOUT";s=e+s.length.toString().padStart(3,"0")+s+i;let a=0;for(let l=0;l<s.length;l++)a^=s.charCodeAt(l);s=s+String.fromCharCode(a);const c=this.parseStringToBytes(s,"");return this.add0x(c)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!o(this,p,Dn).call(this,t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}async login({force:t=!1}={}){return await o(this,p,Ir).call(this,t)}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}async checkPositionPermission(){if(!Yt())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(i=>{i.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let s=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(s.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}s=o(this,p,Dr).call(this,s),s=o(this,p,Rr).call(this,s,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let a="C59A"+s;a=e+o(this,p,mt).call(this,a)+a+i,a=a+o(this,p,wt).call(this,a),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"print")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async consult({reference:t=null}){return t||(t=this.reference),St(t)&&(t="--",this.reference=t),o(this,p,Mr).call(this,this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,pe).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),o(this,p,Zt).call(this,this.url+this.__pinPad__.constants.uris.consult,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async rePrint({folio:t=null}={}){t===null&&(t=this.__pinPad__.operation.folio||""),o(this,p,In).call(this,t),await o(this,p,pe).call(this,{Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:t});const e=await o(this,p,Zt).call(this,this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},no_operacion:t,crypto:"2"}});let i=e.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",i&&(e.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=e.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,e.voucher_comercio)),i=e.voucher_cliente,this.__pinPad__.operation.clientVoucher="",i&&(e.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=e.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,e.voucher_cliente)),e}async cancelPurchase({amount:t=0,authorization:e="",folio:i=""}={}){if(!o(this,p,Rn).call(this,t))throw new Error("Invalid amount");if(!o(this,p,Gr).call(this,e))throw new Error("Invalid authorization");if(!o(this,p,In).call(this,i))throw new Error("Invalid folio");t=o(this,p,Fn).call(this,t,2);const s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:i,Tx_Auth:e,Amount:t};await o(this,p,pe).call(this,s);const a=o(this,p,Zt).call(this,this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:i,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=o(this,p,Vt).call(this,this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||St(e)||!o(this,p,Dn).call(this,e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");let i={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await o(this,p,Kr).call(this),!await o(this,p,Wr).call(this)||!await o(this,p,qr).call(this)?i:await o(this,p,Qr).call(this)}catch(s){console.warn(s),i.error=!0,i.message=s.message,i.approved=!1,i.object=s}return i}}p=new WeakSet,fr=function(){k.add(this)},gr=function(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response"];for(const e of t)this.serialRegisterAvailableListener(e)},br=function(t){const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const c=t.split(i);t=c[0];const l=t.split(s);l.push(...c[1].split(s));const h={};return l.map((_,f)=>{const y=f>0?_.substring(0,1):"A",P=f>0?_.substring(1):_;return{[y]:P.replace(new RegExp(a,"g"),"")}}).forEach(_=>Object.assign(h,_)),h},Sn=function(t,e){const i=this.__pinPad__.constants.ETX,s=e.substring(e.indexOf("D")+2,e.indexOf("E"));let a=0;const c=e.indexOf("N")>0,l=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(l&&l!=="undefined"&&l.toUpperCase()==="VERIFONE"){const _=s.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");a=parseInt(_),a>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=c,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M")),this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N")):(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(i)),this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(i)),this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=l,this.__pinPad__.about.appVersion=s;const h=e.substring(e.indexOf("K")+2,e.indexOf("L"));this.__pinPad__.about.pp={brand:l,appVersion:s,versionInt:a,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT,hasDUKPTKeys:h,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")},yr=function(t,e){this.__pinPad__.waiting.statusInjectWaiting="resolved"},mr=function(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"},wr=function(t,e){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"},vr=function(t,e){const i=this.__pinPad__.about.brand.toLowerCase(),s=this.__pinPad__.about.model.toLowerCase(),a=i==="ingenico"&&s==="ipp320"?500:350;if(e.length<a){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=o(this,p,Ln).call(this,this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx520"||e.includes("P93A800")&&e.length>=406&&s==="vx820"||e.includes("P93A022")&&e.length>=406&&s==="p400"||e.includes("P93A800")&&e.length>=406&&s==="p400"||e.includes("P93A022")&&e.length>=406&&s==="v205c"||e.includes("P93A800")&&e.length>=406&&s==="v205c"||e.includes("P93A022")&&e.length>=406&&s==="move2500"||e.includes("P93A800")&&e.length>=406&&s==="move2500"||e.includes("P93A022")&&e.length>=406&&s==="lane3000"||e.includes("P93A800")&&e.length>=406&&s==="lane3000"){let c=e;i==="verifone"&&(c=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||c.includes("P93A022")||c.includes("P81AINSERTE CHIP O DESLICE TARJETA")||c.includes("ACERQUE, INSERTE CHIP O DESLICE")||c.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>a&&o(this,p,Er).call(this,e)}},Pr=function(t,e){const i=this.__pinPad__.constants.ETX;let s=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");s=s.substring(s.indexOf("B")+2,s.indexOf(i)),s.includes("006E93A16")&&(s="01"),this.__pinPad__.operation.applyReverse=s==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"},Er=function(t){const e=this.__pinPad__.constants.ETX,i=this.__pinPad__.about.brand.toLowerCase();let s,a,c,l,h;i==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const _=this.__pinPad__.config.read.POSEM;if(_==="051"||_==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf("N")),this.__pinPad__.operation.hasQPS=f.substring(f.indexOf("N")+2,f.indexOf("O"))==="1",this.__pinPad__.operation.bin8=f.substring(f.indexOf("O")+2,f.indexOf(e))}else if(t.includes("N")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf("N")),this.__pinPad__.operation.hasQPS=f.substring(f.indexOf("N")+2,f.indexOf(e))==="1"}else{const f=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=f.substring(f.indexOf("M")+2,f.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),a=t.substring(t.indexOf("I")+2,t.indexOf("J")),c=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=c,s=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let f;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),_==="022")if(t.includes("O")){const y=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=y.substring(y.indexOf("O")+2,y.indexOf(e)),f=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.lastIndexOf(""))}else f=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.indexOf(e));else f=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),f=f.substring(f.indexOf("I")+2,f.indexOf(e));this.__pinPad__.config.read.NB_ksn=f,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),a=t.substring(t.indexOf("F")+2,t.indexOf("G")),s=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model.toLowerCase()==="vx520"?(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c):(c=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=c)}s.includes("/")&&(s=s.replace("/","")),s.toString().length===4?(h=s.toString().substring(0,2),l=s.toString().substring(2)):(h="",l=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=a,a.length>6&&(this.__pinPad__.operation.bin=a.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:a,name:c,month:h,year:l})},Cr=function(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))},Tr=function(t,e){const i=this;if(this.__pinPad__.about.model.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){i.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(function(){i.print("client").then(()=>{}).catch(s=>{console.error(s)})},1e3):this.dispatch("pp:print",{type:"success"});else{const s=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",s)}},Sr=function(t,e){},kr=function(t,e){},le=function(t,e){const i=new Ya;return i.setPublicKey(t),i.encrypt(e)},he=function(t){const e="0123456789ABCDEF";let i="";for(let s=0;s<t;s++){const a=Math.floor(Math.random()*e.length);i+=e.substring(a,a+1)}return i},xr=function(t){const e="0123456789abcdef",i=[],s=[];for(let a=0;a<256;a++)i[a]=e.charAt(a>>4)+e.charAt(a&15);for(let a=0;a<t.length;a++)s[a]=i[t.charCodeAt(a)];return s.join("")},ue=async function(t,e){const i=new Uint8Array(t.match(/.{1,2}/g).map(y=>parseInt(y,16))),s=crypto.getRandomValues(new Uint8Array(16)),c=new TextEncoder().encode(e),l=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["encrypt"]),h=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},l,c),_=btoa(String.fromCharCode(...s)),f=btoa(String.fromCharCode(...new Uint8Array(h)));return _+f},Ar=function(t,e,i=!1){const s=[];for(let _=0;_<256;_++)s[_]=_;let a=0;for(let _=0;_<256;_++)a=(a+s[_]+t.charCodeAt(_%t.length))%256,[s[_],s[a]]=[s[a],s[_]];let c=0,l=0,h="";for(const _ of e){c=(c+1)%256,l=(l+s[c])%256,[s[c],s[l]]=[s[l],s[c]];let f=s[(s[c]+s[l])%256];h+=String.fromCharCode(_.charCodeAt(0)^f)}return i?o(this,p,xr).call(this,h).toUpperCase():h},Vt=function(t,e){return o(this,p,Ar).call(this,t,this.hexToAscii(e))},Dr=function(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t},J=function(t,e,i){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",i),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const s=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,s)}return t.trim()+"@br @br @br @br @br"},Rr=function(t,e){const i="@logo3 @br",s="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),o(this,p,J).call(this,t,i,s)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),o(this,p,J).call(this,t,i,s)):o(this,p,J).call(this,t,i,s)},Ir=async function(t=!1){if(o(this,p,Br).call(this),this.__pinPad__.config.loginResponse&&!t)return await o(this,p,kn).call(this);const e=this.url+this.__pinPad__.constants.uris.login,i={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await o(this,p,de).call(this),o(this,p,xn).call(this))throw new Error("Empty RSA Key");const s=o(this,p,he).call(this,32),a=o(this,p,le).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ue).call(this,s,JSON.stringify(i)),l=await K.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:a||""}}).catch(_=>{var f;throw new Error(`Error in request, verify internet connection: ${(f=_.response)==null?void 0:f.status} ${_.message}`)});let h=o(this,p,On).call(this,JSON.stringify(l.data));if(typeof h=="string"&&(h=JSON.parse(h)),!h)throw new Error("Invalid response JSON");if(h.RESPUESTA==="error")throw new Error(h);return this.__pinPad__.config.loginResponse=h,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:h})),await o(this,p,kn).call(this)},kn=async function(){await o(this,p,Lr).call(this);try{await o(this,p,Ur).call(this)}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},o(this,p,Or).call(this,this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin},Or=function(t){var a,c,l,h,_,f;let e="",i="";(c=(a=t.xml)==null?void 0:a.ventaspropias)!=null&&c.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),(h=(l=t.xml)==null?void 0:l.ventaspropias)!=null&&h.merchant_currencym&&(i=t.xml.ventaspropias.merchant_currencym);let s=(_=t.xml)==null?void 0:_.emvReverso;s||(s="0"),this.__pinPad__.config.internal.stTokenization=(f=t.xml)==null?void 0:f.st_tokenizacion,!this.__pinPad__.config.internal.stTokenization||this.__pinPad__.config.internal.stTokenization==="false"||this.__pinPad__.config.internal.stTokenization==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:i,executeReverse:s}},Br=function(){let t=localStorage.getItem("ppLoginResponse");t&&(t=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=t.data),new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))},Nr=async function(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await K.get(t).catch(i=>{throw new Error(`Error in request, verify internet connection: ${i.response.status} ${i.message}`)});if(e.headers.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA},xn=function(){let t=localStorage.getItem("ppRSAKey");return!t||(t=JSON.parse(t),this.__pinPad__.config.publicKeyRSA=t.data,new Date().getTime()-t.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA},An=async function(){return o(this,p,xn).call(this)?await o(this,p,Nr).call(this):this.__pinPad__.config.publicKeyRSA},de=async function(){if(!await o(this,p,An).call(this))throw new Error("RSA public key is empty")},Dn=function(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)},Mr=function(t){if(St(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e},mt=function(t){return t.length.toString().padStart(3,"0")},wt=function(t){let e=0;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i);return String.fromCharCode(e)},je=function(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")},Rn=function(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)},pe=async function(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t},In=function(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t},On=function(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t},Fr=async function(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let i="C55ACANCEL";i=t+o(this,p,mt).call(this,i)+i+e,i=i+o(this,p,wt).call(this,i);const s=this.parseStringToBytes(i,"");await this.appendToQueue(s,"cancel")},Bn=function(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getFullYear().toString().substring(2);return e+i+s},Nn=function(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return e+i},Ur=async function(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,Yt()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)},Lr=async function(){let t=localStorage.getItem("ppPublicIP");if(t&&(t=JSON.parse(t),this.__pinPad__.config.publicIP=t.data,new Date().getTime()-t.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)),this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const i=await K.get("https://api.ipify.org?format=json").catch(()=>e=!0);return e?null:(this.__pinPad__.config.publicIP=i.data.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:i.data.ip})),this.__pinPad__.config.publicIP)},Zt=async function(t,e){await o(this,p,de).call(this);const i=o(this,p,he).call(this,32);let s=o(this,p,le).call(this,this.__pinPad__.config.publicKeyRSA,i),a=await o(this,p,ue).call(this,i,JSON.stringify(e));return(await K.post(t,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(l=>{var h;throw l.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):l.response.status>=500&&l.response.status<=599?new Error(`Service Temporarily Unavailable ${l.message}`):new Error(`Error in request, verify internet connection: ${(h=l.response)==null?void 0:h.status} ${l.message}`)})).data},Mn=async function({data:t,url:e,cancelable:i=!1}={}){await o(this,p,de).call(this);const s=o(this,p,he).call(this,32),a=o(this,p,le).call(this,this.__pinPad__.config.publicKeyRSA,s),c=await o(this,p,ue).call(this,s,JSON.stringify(t)),l=this;return(await K.post(e,c,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:a||""}}).catch(async _=>{var y;let f=`Error in request, verify internet connection: ${_.status} ${_.message}`;throw _.response.status>=500&&_.response.status<=599?f="Service Temporarily Unavailable":_.response.status>=400&&_.response.status<=499&&(f="Bad Request"),i&&await o(y=l,p,Fr).call(y),new Error(f)})).data},Vr=async function(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,i=this.__pinPad__.constants.STX;let s="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(s=s+t+"B"+this.__pinPad__.config.internal.qpsInternational,s=s+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,s=s+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,s=s+t+"E"+this.__pinPad__.config.internal.cvmlAmex,s=s+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,s=s+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,s=i+o(this,p,mt).call(this,s)+s+e,s=s+o(this,p,wt).call(this,s),!this.__pinPad__.about.injectedValues){const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"inject")}},qr=async function(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await o(this,p,Mn).call(this,{data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;e=i+o(this,p,mt).call(this,e)+e+s,e=e+o(this,p,wt).call(this,e);const a=this.parseStringToBytes(e,"");return await this.appendToQueue(a,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0},jr=async function(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;let s="C56AABOUT";if(s=e+o(this,p,mt).call(this,s)+s+i,s=s+o(this,p,wt).call(this,s),St(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const l=this.parseStringToBytes(s,"");await this.appendToQueue(l,"about")}else return t?t(this.__pinPad__.about.pp.supportDUKPT,this.__pinPad__.about.pp.hasDUKPTKeys):!0;const a=this;let c=0;return new Promise((l,h)=>{c=setInterval(()=>{if(a.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,St(a.__pinPad__.about.pp))return;t||l(!0),l(t(a.__pinPad__.about.pp.supportDUKPT,a.__pinPad__.about.pp.hasDUKPTKeys))}else a.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(c),a.__pinPad__.waiting.statusAboutWaiting=null,h("Error"))},500)})},He=async function(t,e){if(t=t?t.toString():"",e=e?e.toString():"",St(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(St(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const i=o(this,p,Bn).call(this),s=o(this,p,Nn).call(this),a=this.__pinPad__.constants.FS,c=this.__pinPad__.constants.ETX,l=this.__pinPad__.constants.STX;let h="C91A"+i+a+"B"+s;h=l+o(this,p,mt).call(this,h)+h+c,h=h+o(this,p,wt).call(this,h);const _=this.parseStringToBytes(h,"");await this.appendToQueue(_,"init-dukpt");let f=0;this.__pinPad__.waiting.statusinitDUKPTWaiting="pending";const y=this;return new Promise((P,v)=>{f=setInterval(async()=>{var S;y.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(f),y.__pinPad__.waiting.statusinitDUKPTWaiting=null,y.dispatch("pp:dukpt",{status:"charged",already:!1}),await o(S=y,p,Hr).call(S),P(!0)):y.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(f),y.__pinPad__.waiting.statusinitDUKPTWaiting=null,v("Error"))},500)})},Hr=async function(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await o(this,p,Mn).call(this,{data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await o(this,p,es).call(this,e)},Kr=async function(){if(!await o(this,p,An).call(this))throw new Error("RSA public key is empty");const e=this;await o(this,p,jr).call(this,async function(s,a){var l,h;if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await o(l=e,p,He).call(l,s,a),!0;let c=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await o(h=e,p,Vr).call(h),new Promise((_,f)=>{c=setInterval(async()=>{var y;e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,await o(y=e,p,He).call(y,s,a),_(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(c),e.__pinPad__.waiting.statusInjectWaiting=null,f("Error"))},500)})})},Fn=function(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);let i=t.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),i.join(".")},Wr=async function(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),St(this.amount)||this.amount<=0)throw new Error("Amount required");if(o(this,p,Rn).call(this,this.amount)===!1)throw new Error("Invalid amount required");if(o(this,p,je).call(this,this.amount,2)<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+t;a=a+e+"B"+o(this,p,Bn).call(this),a=a+e+"C"+o(this,p,Nn).call(this),a=a+e+"D"+o(this,p,je).call(this,this.amount,2),a=a+e+"E0.00",a=a+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"J"+this.__pinPad__.config.forceOnline,a=a+e+"K"+this.__pinPad__.about.supportContactless,a=a+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(a=a+e+"M0",a=a+e+"N00")):(a=a+e+"G"+this.timeoutPinPad,a=a+e+"HTAGS",a=a+e+"I"+this.__pinPad__.config.requireCVVAmex,a=a+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(a=a+e+"O"+this.__pinPad__.config.validateQPS)),a=i+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,wt).call(this,a),o(this,p,ns).call(this);const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"read-card");let l=0;const h=this;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((_,f)=>{l=setInterval(()=>{if(h.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null,_(!0);else if(h.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(l),h.__pinPad__.waiting.statusReadCardWaiting=null;const y=h.__pinPad__.operation.last_error;f(y??"Error reading card")}},500)})},$r=async function(t){return await B(t*1e3)},zr=async function(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await o(this,p,Zt).call(this,e,{user:this.username.toUpperCase(),pwd:this.password.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})},Xr=async function(t="",e={}){let i=1,s=null;do{i>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await o(this,p,$r).call(this,5)),await o(this,p,de).call(this);const a=o(this,p,he).call(this,32),c=o(this,p,le).call(this,this.__pinPad__.config.publicKeyRSA,a),l=await o(this,p,ue).call(this,a,JSON.stringify(e));let h=!1;const _=await K.post(t,l,{headers:{"Content-Type":"application/json",data:c||""}}).catch(async f=>{let y=`Error in request, verify internet connection: ${f.status} ${f.message}`;f.response.status>=500&&f.response.status<=599?y="Service Temporarily Unavailable":f.response.status>=400&&f.response.status<=499&&(y="Bad Request"),console.warn(f),s=y;const P=await o(this,p,zr).call(this,i);P&&P!=="{}"&&!P.includes('"transacciones":""')&&P.includes("nu_operaion")&&(i=5,s="EE32"),h=!0});if(!h)return _.data}while(i++<=3);return s?Promise.reject(s):Promise.reject("Communication error with CDP. IL/MTY")},Gr=function(t){if(St(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0},Jr=function(t){var s,a;const e=this;this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let i=(s=t.cd_response)==null?void 0:s.toUpperCase();return i.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?i="00":(i!=="Z3"&&i!=="05"||t.cd_error==="92")&&(i="01"),this.__pinPad__.operation.responseMit._cdResponse=i,this.__pinPad__.finishCommand.A=i,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:i,cd_error:t.cd_error,nb_error:o(a=e,p,On).call(a,t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}},Qr=async function(){var s,a;const t=this;this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const e=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(e)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";let i={error:!1,message:null,approved:!1,object:{}};try{const c=await o(this,p,Fn).call(this,this.amount,2);await o(this,p,pe).call(this,{Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:c,Currency:this.__pinPad__.config.currency,Merchant:e,Reverse:this.__pinPad__.config.otherLogin.executeReverse});const l=this.__pinPad__.about.supportContactless&&this.__pinPad__.about.supportContactless!=="0"?"1":"0",h=await o(this,p,Xr).call(this,this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),id_company:this.__pinPad__.config.idCompany.toUpperCase(),pwd:this.password.toUpperCase(),user:this.username.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:c,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:l,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});h.response==="error"&&(i.error=!0,i.message=h.nb_error||"Error in response");const _=o(this,p,Jr).call(this,h);return i.object=_,await o(this,p,Zr).call(this,_),i.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=_,i}catch(c){throw t.__pinPad__.finishCommand.A="01",t.__pinPad__.finishCommand.B="",t.__pinPad__.finishCommand.C="",t.__pinPad__.finishCommand.D="",t.__pinPad__.finishCommand.E="",t.__pinPad__.finishCommand.F="",t.__pinPad__.finishCommand.G="",t.__pinPad__.finishCommand.H="",t.__pinPad__.finishCommand.I="",t.__pinPad__.finishCommand.J="",t.__pinPad__.finishCommand.K="",await o(a=t,p,ts).call(a,o(s=t,p,Ln).call(s,c)),c}},Zr=async function(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=i+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,wt).call(this,a);const c=this.parseStringToBytes(a,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(c,"second-generate");let l=0;const h=this;return new Promise((_,f)=>{l=setInterval(async()=>{var y,P;if(h.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,h.__pinPad__.operation.applyReverse){const v=await o(y=h,p,Zt).call(y,h.url+h.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany.toUpperCase(),id_branch:this.__pinPad__.config.idBranch.toUpperCase(),country:this.__pinPad__.config.country.toUpperCase(),user:this.username.toUpperCase(),pwd:this.password.toUpperCase()},transacction:{amount:o(this,p,je).call(this,this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization.toUpperCase(),tracks:"",usrtransacction:this.username.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),S=JSON.parse(v);let T;S.response==="approved"?T={message:"Transaction rejected by PinPad."}:T={message:"No communication, please check your report."},h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",T),h.__pinPad__.operation.ignore.counterSale=!0)}else h.__pinPad__.operation.ignore.counterSale||(h.dispatch("pp:finish-emv",t),h.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await o(P=h,p,Yr).call(P,t,a),_(!0)}else h.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(l),h.__pinPad__.waiting.statusSecondGenerateWaiting=null,f("There is no response from the reader, check that it is connected."))},500)})},Yr=async function(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await o(this,p,He).call(this,1,0)},Un=async function(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await B(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}},Ln=function(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."};let i=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",i),i},ts=async function(t){const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,s=this.__pinPad__.constants.ETX;let a="C93A"+this.__pinPad__.finishCommand.A;if(a=a+e+"B"+this.__pinPad__.finishCommand.B,a=a+e+"C"+this.__pinPad__.finishCommand.C,a=a+e+"D"+this.__pinPad__.finishCommand.D,a=a+e+"E"+this.__pinPad__.finishCommand.E,a=a+e+"F"+this.__pinPad__.finishCommand.F,a=a+e+"G"+this.__pinPad__.finishCommand.G,a=a+e+"H"+this.__pinPad__.finishCommand.H,a=a+e+"I"+this.__pinPad__.finishCommand.I,a=a+e+"J"+this.__pinPad__.finishCommand.J,a=a+e+"K"+this.__pinPad__.finishCommand.K,a=i+o(this,p,mt).call(this,a)+a+s,a=a+o(this,p,wt).call(this,a),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const c=this.parseStringToBytes(a,"");await this.appendToQueue(c,"finish-emv-end")},es=async function(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await o(this,p,Un).call(this);return}const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.ETX,s=this.__pinPad__.constants.STX,a=t.nb_ksn,c=t.nb_kcv||"",l=t.nb_ipek||"";let h="C92A"+a+e+"B"+c+e+"C"+l;h=s+o(this,p,mt).call(this,h)+h+i,h=h+o(this,p,wt).call(this,h);const _=this.parseStringToBytes(h,"");await this.appendToQueue(_,"dukpt");let f=0;this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending";const y=this;return new Promise((P,v)=>{f=setInterval(async()=>{var S;y.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(f),y.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await o(S=y,p,Un).call(S),P(!0)):y.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(f),y.__pinPad__.waiting.statuswritingDUKPTWaiting=null,v("Error writing DUKPT keys"))},500)})},ns=function(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1};class Tc extends xt{constructor({filters:t=null,config_port:e=null,no_device:i=1,device_listen_on_port:s=1,type:a="esplus",support_cart:c=!0}={}){super({filters:t,config_port:e,no_device:i,device_listen_on_port:s});Y(this,g);_t(this,"__device",{type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}});if(this.__internal__.device.type="jofemar",k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.dispense.must_response=!0,this.__internal__.time.response_general=800,this.__internal__.time.response_engines=800,this.__internal__.dispense.limit_counter=40,this.__internal__.dispense.timeout=0,this.__internal__.dispense.timeout_time=4e3,this.__internal__.dispense.interval=0,this.__internal__.dispense.interval_time=1e3,this.__internal__.device.hex_number=(128+this.listenOnChannel).toString(16),this.__internal__.device.door_open=!1,this.__internal__.dispense.elevator={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=c,o(this,g,is).call(this),o(this,g,ss).call(this),o(this,g,rs).call(this)}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}serialJofemarMakeBytes(t){let e=this.hexToDec(this.sumHex(t)),i=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(i[s]));return t.push("03"),this.add0x(t)}calcCheckSums(t){t=this.add0x([this.decToHex(parseInt(t).toString())]);let e=[];return e.push((t&255|240).toString(16).toUpperCase()),e.push((t&255|15).toString(16).toUpperCase()),e}serialSetConnectionConstant(t=1){let e=["02","30","30",(128+t).toString(16),"53","FF","FF"],i=[];return e.forEach(s=>{i.push(this.hexMaker(s))}),this.serialJofemarMakeBytes(i)}serialMessage(t){let i={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":i=o(this,g,Rs).call(this,t,i,128);break;case"06":i=o(this,g,Is).call(this,t,i);break;case"15":i.name="Checksum error",i.description="The calculated checksum does not match the received checksum",i.no_code=38,o(this,g,tt).call(this);break;default:i.name="unknown",i.description="The message received is unknown",i.no_code=404;break}this.dispatch("serial:message",i)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>130)throw new Error("Invalid selection");const{channel:i,tray:s}=o(this,g,Os).call(this,t);this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:i,tray:s};let c=["02","30","30",this.__internal__.device.hex_number,"56",s,i];e&&(c[4]="4D"),c=o(this,g,Ke).call(this,c);let l;do l=await this.internalDispense(c),o(this,g,Bs).call(this),l.error==="elevator-locked"?await o(this,g,as).call(this):l.error==="no-response"&&await B(1e3);while(["elevator-locked","no-response"].includes(l.error));return this.__internal__.dispense.backup_dispense={},l}internalClearSensing(){super.internalClearSensing(),this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.serial.queue.length>0&&(this.__internal__.serial.queue=this.__internal__.serial.queue.filter(t=>t.type!=="status"))}async endDispense(){let e=["02","30","30",this.__internal__.device.hex_number,"4D","80","80"];return e=o(this,g,Ke).call(this,e),await this.internalDispense(e)}async collect(){const t=["02","30","30","81","4E","FF","FF"];return await o(this,g,ct).call(this,t,"collect")}async resetSoldOutErrors(){return await o(this,g,_e).call(this,"80")}async resetWaitingProductRemovedError(){return await o(this,g,_e).call(this,"81")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(o(this,g,Vn).call(this),await o(this,g,_e).call(this,"FF")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await o(this,g,_e).call(this,"FF"),o(this,g,Vn).call(this),t(!0))},100)})}async resetAllErrors(){return await this.resetSoldOutErrors(),await B(100),await this.resetWaitingProductRemovedError(),await B(100),await this.resetMachineErrors()}async status(){const t=["02","30","30","81","53","FF","FF"];return await o(this,g,ct).call(this,t,"status")}async lightsOn(){return await o(this,g,qn).call(this,"81")}async lightsOff(){return await o(this,g,qn).call(this,"80")}async program(t,e){const i=["02","30","30","81","50",t,e];return await o(this,g,ct).call(this,i,"program")}async programDisplayLanguage({language:t="spanish"}={}){const e={spanish:"30",english:"31",french:"32"};if(!e[t])throw new Error("Invalid language");return await this.program("49",e[t])}async programBeeper({enable:t=!0}={}){const e=t?"31":"30";return await this.program("5A",e)}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.program("54","80")}async programDisableThermometer(){return await this.programDisableWorkingTemperature()}async programWorkingTemperature({degrees:t=.5}={}){t=parseFloat(t);const e=this.__device.type==="iceplus"?6.5:32,i=this.__device.type==="iceplus"?-25:.5;if(isNaN(t)||t<i||t>e||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let s=t*2+128;return this.__device.type==="iceplus"&&(s+=51),s=Math.ceil(s),await this.program("54",s.toString(16))}async programIsolationTray({tray:t=0}={}){if(t=parseInt(t),isNaN(t)||t<0||t>12)throw new Error("Invalid tray, valid range is 0 to 12");const e=t===0?"80":(t+139).toString(16);return this.program("42",e)}async programTimeToStandbyAfterCollect({seconds:t=15}={}){if(t=parseInt(t),isNaN(t)||t<15||t>120)throw new Error("Invalid seconds, valid range is 15 to 120");const e=(128+t).toString(16);return await this.program("46",e)}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>10)throw new Error("Invalid minutes, valid range is 1 to 10");const e=(128+t).toString(16);return await this.program("48",e)}async programElevatorSpeed({speed:t="high"}={}){const e={high:"31",low:"30"};if(!e[t])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return await this.program("76",e[t])}async programTemperatureExpiration({enable:t=!1}={}){const e=t?"31":"30";return await this.program("63",e)}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid address, valid range is 1 to 31");const e=(128+t).toString(16);return await this.program("64",e)}async programTemperatureBeforeExpiration({degrees:t=.5}={}){if(t=parseFloat(t),isNaN(t)||t<.5||t>30||t%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const e=(128+t*2).toString(16);return await this.program("65",e)}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>120)throw new Error("Invalid minutes, valid range is 1 to 120");const e=(128+t).toString(16);return await this.program("66",e)}async programTemperatureScale({scale:t="c"}={}){const e={c:"43",f:"46"};if(!e[t])throw new Error("Invalid scale, valid scales are 'c' for celsius and 'f' for fahrenheit");return await this.program("67",e[t])}async programVoltageEngine({selection:t=1,voltage:e=5}={}){if(e=parseFloat(e),t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<5||e>9.5||e%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const i=109+t,a=(128+(e-5)*2).toString(16),c=["02","30","30","81","47",i,a];return await o(this,g,ct).call(this,c,"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);const a=["02","30","30","81","4F",109+t,e?"31":"30"];return await o(this,g,ct).call(this,a,"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){if(t=parseInt(t),e=parseFloat(e),isNaN(t)||t<1||t>this.__device.channels.verification.end)throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);if(isNaN(e)||e<0||e>10||e%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const i=109+t;e=e.toFixed(1);const s=128+e*10,a=["02","30","30","81","45",i,s];return await o(this,g,ct).call(this,a,"channel-running-after-dispense")}async checkData(t,e="FF"){const i=["02","30","30","81","43",t,e];return await o(this,g,ct).call(this,i,"check-data")}async getDisplayLanguage(){return await this.checkData("49")}async getBeeper(){return await this.checkData("5A")}async getWorkingTemperature(){return await this.checkData("54")}async getIsolationTray(){return await this.checkData("42")}async getProgramVersion(){return await this.checkData("50")}async getFaults(){return await this.checkData("53")}async getMachineId(){return await this.checkData("4E")}async getCurrentTemperature(){return await this.checkData("74")}async getTimeToStandbyAfterCollect(){return await this.checkData("46")}async getTimeToStandbyWithoutCollect(){return await this.checkData("48")}async getElevatorSpeed(){return await this.checkData("76")}async getTemperatureExpiration(){return await this.checkData("63")}async getTemperatureBeforeExpiration(){return await this.checkData("65")}async getTimeBeforeExpirationByTemperature(){return await this.checkData("66")}async getTemperatureScale(){return await this.checkData("67")}async getClockRegisters(){return await this.checkData("72")}async getMachineActivity(){return await this.checkData("41")}async getVoltageEngine({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("47",e)}async getChannelPresence({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("43",e)}async getPushOverProducts({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("4F",e)}async getChannelRunningAfterDispense({selection:t=1}={}){if(t=parseInt(t),isNaN(t)||t<1||t>126)throw new Error("Invalid selection, valid range is 1 to 126");const e=(109+t).toString(16);return await this.checkData("45",e)}async setDisplayStandbyMessage({message:t=""}={}){t=t.substring(0,32);const e=o(this,g,ze).call(this,t);return await o(this,g,$e).call(this,"80",e)}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){if(t=t.substring(0,32),e=parseInt(e),isNaN(e)||e<1||e>125)throw new Error("Invalid seconds, valid range is 1 to 125");const i=o(this,g,ze).call(this,t),s=(128+e).toString(16);return await o(this,g,$e).call(this,s,i)}async setDisplayMessageUnlimited({message:t=""}){t=t.substring(0,32);const e=o(this,g,ze).call(this,t);return await o(this,g,$e).call(this,"FF",e)}async programClock({date:t=new Date}={}){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=["02","30","30","81","72",...o(this,g,Ms).call(this,t)];return await o(this,g,ct).call(this,e,"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){if(t===null)throw new Error("Invalid event");const s=["02","30","30","81","41",t,e?"31":"30"];return await o(this,g,ct).call(this,s,"events-config")}async eventEnable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!0})}async eventDisable({event:t=null}={}){if(t===null)throw new Error("Invalid event");const e=parseInt(t,16);if(isNaN(e)||e<38||e>100)throw new Error("Invalid event");return await this.eventsConfig({event:t,enable:!1})}async sendCustomCode({code:t=[]}={}){if(t.length<5)throw new Error("Invalid code, minimum length is 5");return await o(this,g,ct).call(this,t,"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let i=t;i<=e;i++)this.__device.channels.verification.current=i,await this.getChannelPresence({selection:i});return new Promise(i=>{let s=setInterval(()=>{this.__device.channels.verification.channels.length===e-t+1&&(clearInterval(s),this.dispatch("channels",{channels:this.__device.channels.verification.channels}),this.__device.channels.verification.clear(),i(!0))},500)})}}g=new WeakSet,is=function(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)},rs=function(){this.on("internal:dispense:running",o(this,g,Ns).bind(this))},ss=function(){k.add(this)},ct=function(t,e){return t[3]=this.__internal__.device.hex_number,this.appendToQueue(o(this,g,Ke).call(this,t),e)},Ke=function(t){let e=this.hexToDec(this.sumHex(t)),i=this.calcCheckSums(e.toString());for(let s=0;s<2;s++)t.push(this.hexMaker(i[s]));return t.push("03"),t},as=async function(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await B(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),t.__internal__.dispense.elevator.locking_time-=1,t.__internal__.dispense.elevator.locking_time<=0&&(clearInterval(t.__internal__.dispense.elevator.locking_interval),t.__internal__.dispense.elevator.locking_interval=0,e(!0))},1e3)})},os=function(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e},cs=function(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const i={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=i[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e},ls=function(t,e){return e.additional={open:!1},e.no_code=3,t==="4f"?(e.name="door open",e.description="The door was opened",e.additional.open=!0,this.__internal__.device.door_open=!0,this.dispatch("door:event",e.additional)):t==="43"?(e.name="door close",e.description="The door was closed",e.additional.open=!1,this.__internal__.device.door_open=!1,this.dispatch("door:event",e.additional)):(e.name="door event",e.description="The door event received is unknown",this.dispatch("door:event",{open:e.additional.open,message:e})),e},hs=function(t,e){e.no_code=404;let i=t[5]??null;return i&&this.listenOnChannel>1&&(i=this.hexToDec(i)-this.listenOnChannel+1,i=this.decToHex(i)),i&&(i==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):i==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e},us=function(t,e){e.no_code=39,e.name="Program version";const i=t.slice(4,12),s=i.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:s,hex:i},e.description=`The program version is ${s}`,this.dispatch("program:version",e.additional),e},ds=function(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const i=t.slice(4,-3);if(i.length>1&&i[0]!=="30"){e.description="Machine has faults";const s={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of i)s[a]&&(e.additional.faults.push(s[a]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e},ps=function(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const i=t.slice(4,-3),s=i.map(v=>String.fromCharCode(this.hexToDec(v))).join(""),[a,c]=s.split(" "),[l,h]=a.split(":"),[_,f,y]=c.split("-"),P=new Date(2e3+parseInt(y),parseInt(f)-1,parseInt(_),parseInt(l),parseInt(h));return e.additional={day:_,month:f,year:y,hours:l,minutes:h,formatted:s,date:P,hex:i},this.dispatch("clock:registers",e.additional),e},_s=function(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const i=String.fromCharCode(this.hexToDec(t[4]));if(i!=="0"){const s=t.slice(5,-3);if(i==="T"&&s.length===4){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[3]));e.additional={ascii:i,type:"DU.d",dozens:a,units:c,decimals:l,time:parseFloat(`${a}${c}.${l}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(i)&&s.length===3){const a=String.fromCharCode(this.hexToDec(s[0])),c=String.fromCharCode(this.hexToDec(s[1])),l=String.fromCharCode(this.hexToDec(s[2])),h=parseInt(`${a}${c}${l}`),_={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:c,decimals:l,channel:h,selection:h-109,ascii:i,meaning:_[i]??"Unknown"}}else if(s.length===13){const a=s.map(S=>String.fromCharCode(this.hexToDec(S))).join(""),c=parseInt(a.slice(0,2)),l=parseInt(a.slice(2,4)),h=parseInt(a.slice(4,6)),_=parseInt(a.slice(7,9)),f=parseInt(a.slice(9,11))-1,y=2e3+parseInt(a.slice(11,13)),P=new Date(y,f,_,c,l,h),v={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:P,hex:s,formatted:P.toLocaleString(),ascii:i,meaning:v[i]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e},fs=function(t,e){const i={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${i[t]??"unknown"}`,e.additional={hex:t,language:i[t]??"unknown"},this.dispatch("check:language",e.additional),e},gs=function(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e},bs=function(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const i=this.hexToDec(t)-139;return e.additional={hex:t,tray:i},this.dispatch("check:isolation-tray",e.additional),e},ys=function(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const i=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:i},this.dispatch("check:engine-voltage",e.additional),e},ms=function(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const i=t==="30";return e.additional={hex:t,push:i},this.dispatch("check:push-over",e.additional),e},ws=function(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const i=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:i},this.dispatch("check:extractor-after-dispense",e.additional),e},vs=function(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const i=this.hexToDec(t)-128;return e.additional={hex:t,seconds:i},this.dispatch("check:standby-after-collect",e.additional),e},Ps=function(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const i=this.hexToDec(t)-128;return e.additional={hex:t,minutes:i},this.dispatch("check:standby-without-collect",e.additional),e},Es=function(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const i=t==="30"?"low":"high";return e.additional={hex:t,speed:i},this.dispatch("check:elevator-speed",e.additional),e},Cs=function(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const i=t==="31";return e.additional={hex:t,enabled:i},this.dispatch("check:expiration-by-temperature",e.additional),e},Ts=function(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const i=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:i},this.dispatch("check:temperature-before-expiration",e.additional),e},Ss=function(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const i=this.hexToDec(t)-128;return e.additional={hex:t,minutes:i},this.dispatch("check:expiration-after",e.additional),e},ks=function(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const i=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:i},this.dispatch("check:temperature-scale",e.additional),e},xs=function(t,e){return e.no_code=54,e.name="Machine ID",e.description="Machine ID",e.additional={hex:t[4],full_hex:t},this.dispatch("check:machine-id",e.additional),e},As=function(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e},Ds=function(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},t[4]==="2b"?e.additional.sign=t[4]="+":["2e","2d"].includes(t[4])?e.additional.sign=t[4]="-":t[4]==="20"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[5])>=48&&this.hexToDec(t[5])<=57?e.additional.tens=this.hexToDec(t[5])-48:t[5]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[6])>=48&&this.hexToDec(t[6])<=57?e.additional.units=this.hexToDec(t[6])-48:t[6]==="2a"&&(e.additional.error="Error in thermometer"),this.hexToDec(t[8])>=48&&this.hexToDec(t[8])<=57?e.additional.decimals=this.hexToDec(t[8])-48:t[8]==="2a"&&(e.additional.error="Error in thermometer"),t[10]==="43"?e.additional.type_degrees="C":t[10]==="46"&&(e.additional.type_degrees="F"),e.additional.error==="Error in thermometer"?(e.additional.formatted="Error in thermometer",e.description="The current temperature cannot be read because there is an error in the thermometer"):(e.additional.formatted=(e.additional.sign??"")+(e.additional.tens??"")+(e.additional.units??"")+(e.additional.decimal_point??"")+(e.additional.decimals??"")+(e.additional.degrees??"")+(e.additional.type_degrees??""),e.description=`The current temperature is ${e.additional.formatted}`),this.dispatch("temperature:current",e.additional),e},Rs=function(t,e,i=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-i),!(t[1]&&t[2]))e=o(this,g,os).call(this,t,e);else switch(t[2]){case"54":e.request="--automatic",e=o(this,g,cs).call(this,t[3],e);break;case"50":e.request="--automatic",e=o(this,g,ls).call(this,t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=o(this,g,_s).call(this,t,e);break;case"43":e.request="channel-status",e=o(this,g,hs).call(this,t,e);break;case"50":e=o(this,g,us).call(this,t,e);break;case"53":e=o(this,g,ds).call(this,t,e);break;case"54":e.request="working-temperature",e=o(this,g,As).call(this,t[4],e);break;case"72":e=o(this,g,ps).call(this,t,e);break;case"74":e.request="current-temperature",e=o(this,g,Ds).call(this,t,e);break;case"49":e=o(this,g,fs).call(this,t[4],e);break;case"5a":e=o(this,g,gs).call(this,t[4],e);break;case"42":e=o(this,g,bs).call(this,t[4],e);break;case"47":e=o(this,g,ys).call(this,t[4],e);break;case"4e":e=o(this,g,xs).call(this,t,e);break;case"4f":e=o(this,g,ms).call(this,t[4],e);break;case"45":e=o(this,g,ws).call(this,t[4],e);break;case"46":e=o(this,g,vs).call(this,t[4],e);break;case"48":e=o(this,g,Ps).call(this,t[4],e);break;case"76":e=o(this,g,Es).call(this,t[4],e);break;case"63":e=o(this,g,Cs).call(this,t[4],e);break;case"65":e=o(this,g,Ts).call(this,t[4],e);break;case"66":e=o(this,g,Ss).call(this,t[4],e);break;case"67":e=o(this,g,ks).call(this,t[4],e);break}break}return e},ft=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)},tt=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)},We=function(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")},et=function({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})},vt=function({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})},Is=function(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,o(this,g,ft).call(this);break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,o(this,g,tt).call(this),o(this,g,et).call(this,{type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,o(this,g,tt).call(this),o(this,g,et).call(this,{type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,o(this,g,tt).call(this),o(this,g,et).call(this,{type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,o(this,g,We).call(this),o(this,g,et).call(this,{type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,o(this,g,tt).call(this),o(this,g,et).call(this,{type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,o(this,g,tt).call(this),o(this,g,et).call(this,{type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,o(this,g,We).call(this),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),o(this,g,vt).call(this,{type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,o(this,g,tt).call(this),o(this,g,vt).call(this,{type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,o(this,g,We).call(this);break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,o(this,g,ft).call(this),o(this,g,et).call(this,{type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&o(this,g,tt).call(this);return e},Os=function(t){if(t=parseInt(t)+109,t=t.toString(),t.length!==3)throw new Error("Invalid selection");const e=(parseInt(t.substring(0,2))+128).toString(16).padStart(2,"0");return{channel:(parseInt(t.substring(2,3))+128).toString(16).padStart(2,"0"),tray:e}},Bs=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=0,this.__internal__.dispense.interval=0},Ns=function(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)},_e=async function(t){const e=["02","30","30","81","52",t,"FF"];return await o(this,g,ct).call(this,e,"reset")},Vn=function(){const t=this.__device.type==="iceplus"?Qe(40):Qe(25),e=new Date,i=1e3*t+e.getTime(),s=new Date(i);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:s})},qn=async function(t){const e=["02","30","30","81","4C",t,"FF"];return await o(this,g,ct).call(this,e,"lights")},$e=async function(t="80",e=[]){const i=["02","30","30","81","44",t,...e];return await o(this,g,ct).call(this,i,"display")},ze=function(t=""){t=t.padEnd(32," ");const e=[];for(let i=0;i<32;i++)e.push(t.charCodeAt(i).toString(16));return e},Ms=function(t){if(!(t instanceof Date))throw new Error("Invalid date, must be an instance of Date");const e=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getFullYear().toString().substring(2,4),l=`${e}:${i} ${s}-${a}-${c}`,h=[];for(let _=0;_<14;_++)h.push(l.charCodeAt(_).toString(16));return h};class Sc extends xt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});Y(this,w);_t(this,"__coin_purse",{available:!0});_t(this,"__banknote_purse",{available:!0,isRecycler:!0,recycler:{ict:!0,banknote:1}});_t(this,"__sale",{price:0,change:0,change_verified:0,dispense_all:!0,last_change:0,clear(){this.price=0,this.change=0,this.change_verified=0,this.dispense_all=!0,this.last_change=0}});_t(this,"__money_session",{inserted:0,retired:0,clear(){this.inserted=0,this.retired=0}});_t(this,"coins",{tubes:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},box:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},totals:{g50:0,c50:0,p1:0,p2:0,p5:0,p10:0},total:0});_t(this,"banknotes",{stacker:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},recycler:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},out:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},totals:{p20:0,p50:0,p100:0,p200:0,p500:0,p1000:0},total:0});_t(this,"card_reader",{available:!1,max_pre_credit:0});Y(this,Gt,!1);Y(this,Ft,0);Y(this,Jt,0);if(this.__internal__.device.type="boardroid",k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.serial.config_port.baudRate=115200,this.__internal__.serial.response.length=14,this.__internal__.time.response_connection=600,this.__internal__.time.response_general=4e3,this.__internal__.time.response_engines=15e3,this.__internal__.dispense.limit_counter=15,this.__internal__.dispense.custom_limit_counter=null,this.__internal__.dispense.backup_dispense={channel:1,second_channel:null,sensor:!0,seconds:null},o(this,w,Fs).call(this),o(this,w,Us).call(this)}get totalInTubes(){return this.coins.tubes.g50*.5+this.coins.tubes.c50*.5+this.coins.tubes.p1+this.coins.tubes.p2*2+this.coins.tubes.p5*5+this.coins.tubes.p10*10}get totalInRecycler(){return this.banknotes.recycler.p20*20+this.banknotes.recycler.p50*50+this.banknotes.recycler.p100*100+this.banknotes.recycler.p200*200+this.banknotes.recycler.p500*500+this.banknotes.recycler.p1000*1e3}get hasRecycler(){return this.__banknote_purse.available&&this.__banknote_purse.isRecycler}set hasRecycler(t){this.__banknote_purse.isRecycler=t}get hasICT(){return this.hasRecycler&&this.__banknote_purse.recycler.ict}set hasICT(t){this.__banknote_purse.recycler.ict=t}set banknoteICT(t){if(![20,50,100,200,500].includes(t))throw new Error(`Invalid banknote value: ${t}`);t=[20,50,100,200,500].indexOf(t),this.__banknote_purse.recycler.banknote=t}get banknoteICT(){return[20,50,100,200,500][this.__banknote_purse.recycler.banknote]}get hasCoinPurse(){return this.__coin_purse.available}set hasCoinPurse(t){if(typeof t!="boolean")throw new Error(`Invalid value: ${t}`);this.__coin_purse.available=t}set price(t){let e=parseFloat(t);(isNaN(e)||e<0)&&(e=0),this.__sale.price=e}get price(){return this.__sale.price}get change(){return this.__sale.price<=0||this.__money_session.inserted<=this.__sale.price?0:this.__money_session.inserted-this.__sale.price}softReload(){super.softReload(),this.__sale.clear(),this.__money_session.clear()}serialBoardroidSumHex(t){let e=0;return t.forEach((i,s)=>{s!==0&&s!==11&&(e+=parseInt(i,16))}),e.toString(16).toUpperCase()}serialMessage(t){let e={code:t,name:null,description:null,request:null,no_code:0};const i=(5+this.deviceNumber).toString(16).padStart(2,"0").toLowerCase();switch(t[1]){case i:e.request="connect",e=o(this,w,Vs).call(this,e);break;case"a0":e.request="--automatic",e=o(this,w,zs).call(this,t,e);break;case"b0":e.request="--automatic",e=o(this,w,Xs).call(this,t,e);break;case"d0":e.request="coin-purse:config",e=o(this,w,Gs).call(this,t[2],e);break;case"d1":e.request="banknote-purse:config",e.additional={scrow:null},e=o(this,w,Js).call(this,t,e);break;case"d2":e.request="coin-purse:read-tubes",e=o(this,w,Qs).call(this,t,e);break;case"d3":e.request="banknote-purse:read-recycler",e=o(this,w,Zs).call(this,t,e);break;case"d4":e.request="banknote-purse:banknote-scrow-status",e=o(this,w,Ys).call(this,t[2],e);break;case"d5":e.request="banknote-purse:dispense",e=o(this,w,ta).call(this,t,e);break;case"d6":e.request="coin-purse:dispense",e=o(this,w,ea).call(this,t,e);break;case"d7":e.request="dispense",e=o(this,w,na).call(this,t[5],e);break;case"d8":e.request="--automatic",e=o(this,w,ia).call(this,t[13],e);break;case"d9":e.request="status:temperature",e=o(this,w,ra).call(this,t,e);break;case"da":e.request="status:relay",e=o(this,w,sa).call(this,t[2],e);break;case"db":e.request="banknote-purse:save-memory",e.no_code=18,e.name="Bill purse memory saved?",e.description="The memory of bill purse was saved successfully?",this.dispatch("banknote-purse:save-memory",{message:e});break;case"dc":e.request="coin-purse:read-memory",e.no_code=19,e.name="Coin purse memory read?",e.description="The memory of coin purse was read successfully?",this.dispatch("banknote-purse:read-memory",{message:e});break;case"dd":e.request="card-reader",o(this,w,aa).call(this,t,e);break;default:e.request="--unknown",e.name="Response unrecognized",e.description="The response of application was received, but dont identify with any of current parameters",e.no_code=400,this.dispatch("unknown",e);break}this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){let e=["F1","06","00","00","00","00","00","00","00","00","F2","F8"];return e[1]=this.hexMaker(this.decToHex((5+t).toString())),e[11]=this.serialBoardroidSumHex(e),this.add0x(e)}async coinPurseConfigure({enable:t=!1,high:e="FF",low:i="FF"}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");const a=["F1","C1",t?"01":"00",e,i,"00","00","00","00","00","F2","00"];await o(this,w,lt).call(this,a,"coin-purse:config")}async coinPurseEnable(){await this.coinPurseConfigure({enable:!0})}async coinPurseDisable(){await this.coinPurseConfigure({enable:!1})}async coinPurseDispense({$_50c:t=0,$_1:e=0,$_2:i=0,$_5:s=0,$_10:a=0}={}){if(!this.__coin_purse.available)throw new Error("Coin purse not available");if([t,e,i,s,a].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&i<1&&s<1&&a<1)throw new Error("No coins to dispense");[t,e,i,s,a]=[this.decToHex(t),this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a)];let c=["F1","C6",t,e,i,s,a,"00","00","00","F2","00"];await o(this,w,lt).call(this,c,"coin-purse:dispense")}async coinPurseReadTubes(){const t=["F1","C2","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,lt).call(this,t,"coin-purse:read-tubes")}async banknotePurseConfigure({enable:t=!1,scrow:e=!1}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");let i;return o(this,w,Xe).call(this)?i=o(this,w,oa).call(this,{enable:t,scrow:e}):i=o(this,w,ca).call(this,{enable:t,scrow:e}),await o(this,w,lt).call(this,i,"banknote-purse:config")}async banknotePurseDispense({$_20:t=0,$_50:e=0,$_100:i=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");let l;if(o(this,w,Xe).call(this)){const h=[t,e,i,s,a];l=o(this,w,la).call(this,h[this.__banknote_purse.recycler.banknote])}else l=o(this,w,ha).call(this,{$_20:t,$_50:e,$_100:i,$_200:s,$_500:a,$_1000:c});await o(this,w,lt).call(this,l,"banknote-purse:dispense")}async banknotePurseEnable({scrow:t=!1}){return await this.banknotePurseConfigure({enable:!0,scrow:t})}async banknotePurseDisable(){return await this.banknotePurseConfigure({enable:!1})}async banknotePurseAcceptInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","01","00","00","00","00","00","00","00","F2","00"];await o(this,w,lt).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseRejectInScrow(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");const t=["F1","C4","00","00","00","00","00","00","00","00","F2","00"];await o(this,w,lt).call(this,t,"banknote-purse:banknote-scrow-status")}async banknotePurseSaveMemory({channel:t=null,$_20:e=null,$_50:i=null,$_100:s=null,$_200:a=null,$_500:c=null,$_1000:l=null}={}){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(t===null||e===null||i===null||s===null||a===null||c===null||l===null)throw new Error("One of the values is not defined");const h=["F1","C8",this.decToHex(t),"00",this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a),this.decToHex(c),this.decToHex(l),"F2","00"];await o(this,w,lt).call(this,h,"banknote-purse:save-memory")}async banknotePurseReadRecycler(){if(!this.__banknote_purse.available)throw new Error("Banknote purse not available");if(!this.__banknote_purse.isRecycler)throw new Error("Banknote purse is not recycler");const t=["F1","C3","00","00","00","00","00","00","00","00","F2","B5"];return await o(this,w,lt).call(this,t,"banknote-purse:read-recycler")}async cardReaderDisable(){if(!this.card_reader.available)throw new Error("Card reader not available");const t=["F1","CD","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,lt).call(this,t,"card-reader:disable")}async cardReaderDispense({channel:t=1,second_channel:e=null,sensor:i=!0,seconds:s=null,price:a=0}={}){if(!this.card_reader.available)throw new Error("Card reader not available");if(isNaN(this.card_reader.max_pre_credit)||this.card_reader.max_pre_credit===0)throw new Error("Card reader pre-credit not configured");if(isNaN(a)||a<=0)throw new Error("Price must be greater than 0");if(a>this.card_reader.max_pre_credit)throw new Error("Price is greater than pre-credit configured");if(!i&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");const c=this.decToHex(a/256),l=this.decToHex(a%256),h=this.decToHex(t+9);let _="00";e&&(_=this.decToHex(e+9));let f="00";i||(f=this.decToHex(s*10));const y=["F1","CD","01",h,_,f,c,l,"00","00","F2","00"];await o(this,w,lt).call(this,y,"card-reader:dispense")}async paymentPursesDisable({coin:t=!0,banknote:e=!0,cardReader:i=!1}={}){t&&await this.coinPurseDisable(),e&&await this.banknotePurseDisable(),i&&await this.cardReaderDisable()}async paymentPursesEnable({coin:t=!0,banknote:e=!0,scrowBanknote:i=!1}={}){t&&await this.coinPurseEnable(),e&&await this.banknotePurseEnable({scrow:i})}async coolingRelayConfigure({enable:t=!1}={}){const i=["F1","CC",t?"01":"00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,lt).call(this,i,"status:relay")}async coolingRelayEnable(){return await this.coolingRelayConfigure({enable:!0})}async coolingRelayDisable(){return await this.coolingRelayConfigure({enable:!1})}async readTemperature(){const t=["F1","CB","00","00","00","00","00","00","00","00","F2","00"];return await o(this,w,lt).call(this,t,"status:temperature")}async dispense({selection:t=1,second_selection:e=null,sensor:i=!0,seconds:s=null,retry:a=!0}={}){if(t=parseInt(t),isNaN(t)||t<1||t>80)throw new Error("Invalid channel number");if(e!==null&&(e<1||e>80||e===t))throw new Error("Invalid second channel number");if(!i&&(s===null||s<=0||s>40))throw new Error("Invalid time to dispense without sensor, must be between 0.1 and 40.0 seconds");a&&(this.__internal__.dispense.backup_dispense={selection:t,second_selection:e,sensor:i,seconds:s}),t+=9;const c=this.decToHex(t);let l="00";e&&(e+=9,l=this.decToHex(e));let h="00";i||(h=this.decToHex(Math.round(s*6.2)),this.__internal__.dispense.custom_limit_counter=s);const _=o(this,w,Ge).call(this,["F1","C7",c,l,h,"00","00","00","00","00","F2","00"]);let f=await this.internalDispense(_);return!f.dispensed&&a&&(f=await this.internalDispense(_)),this.__internal__.dispense.custom_limit_counter=null,f}async testEngines({singleEngine:t=!1}={}){if(this.isDispensing)throw new Error("Another dispensing process is running");if(O(this,Gt))throw new Error("Another test is running");o(this,w,Hn).call(this),L(this,Gt,!0);const e=[];o(this,w,Je).call(this);for(let i=1;i<=80;i++){const s=await this.dispense({selection:i,second_selection:t?null:i+1,sensor:!1,seconds:.4,retry:!1});e.push(s),L(this,Ft,i),o(this,w,Je).call(this),t||i++}L(this,Ft,80),o(this,w,Je).call(this,{dispensed:e}),o(this,w,Hn).call(this)}async sendCustomCode({code:t=[]}={}){if(t.length===0)throw new Error("Invalid code");const e=o(this,w,Ge).call(this,t);await this.appendToQueue(e,"custom")}hasToReturnChange(t=0){let e=t;return e<=0?!0:(e=o(this,w,Kn).call(this,e).pending,e=o(this,w,Wn).call(this,e).pending,!(e>0))}async returnChange(){return await o(this,w,$n).call(this)}async returnInsertedMoney(){return this.__money_session.inserted<=0?!1:await o(this,w,$n).call(this,this.__money_session.inserted)}async serialCorruptMessage(t,e){this.dispatch("corrupt:message",{data:t,message:e})}}Gt=new WeakMap,Ft=new WeakMap,Jt=new WeakMap,w=new WeakSet,Fs=function(){const t=["banknote-purse:banknote-scrow-status","banknote-purse:config","banknote-purse:event-banknote","banknote-purse:read-memory","banknote-purse:recycler","banknote-purse:save-memory","card-reader:event","change:pending","change:dispense","coin-purse:coin-event","coin-purse:config","coin-purse:reject-lever","coin-purse:reset","coin-purse:tubes","percentage:test","run:default-load","session:money-dispensed","session:money-request","event:door","door:event","status:relay","status:temperature"];for(const e of t)this.serialRegisterAvailableListener(e)},Us=function(){k.add(this)},Xe=function(){return this.__banknote_purse.isRecycler&&this.__banknote_purse.recycler.ict},Ls=function(){return this.hasCoinPurse||this.hasRecycler},Vs=function(t){return t.name="Connection with the serial device completed.",t.description="Your connection with the serial device was successfully completed.",t.no_code=1,this.dispatch("run:default-load",{}),t},qs=function(t){const e={g50:["40","50","60","70","90"],c50:["41","51","61","71","91"],p1:["42","52","62","72","92"],p2:["43","53","63","73","93"],p5:["44","54","64","74","94"],p10:["45","55","65","75","95"],p20:["47","57","67","77","97"]};let i=null;for(let a in e)if(e[a].includes(t)){i=a;break}return i?[{g50:"50 pennies (the big one)",c0:"50 pennies (the little one)",p1:"1 peso",p2:"2 pesos",p5:"5 pesos",p10:"10 pesos",p20:"20 pesos"}[i],i]:[`Undefined value: ¿${t}?`,null]},js=function(t){return["g50","c50","p1","p2","p5","p10","p20"].includes(t)},Hs=function(t){const e={p20:["80","90","a0","b0"],p50:["81","91","a1","b1"],p100:["82","92","a2","b2"],p200:["83","93","a3","b3"],p500:["84","94","a4","b4"],p1000:["85","95","a5","b5"]};let i=null;for(let a in e)if(e[a].includes(t)){i=a;break}return i?[{p20:"20 pesos",p50:"50 pesos",p100:"100 pesos",p200:"200 pesos",p500:"500 pesos",p1000:"1000 pesos"}[i],i]:[`Undefined value: ¿${t}?`,null]},Ks=function(t){return["p20","p50","p100","p200","p500","p1000"].includes(t)},Ws=function(t){return["r20","r50","r100"].includes(t)},$s=function(){return["r20","r50","r100","r200","r500"][this.__banknote_purse.recycler.banknote]},jn=function(t,e,i){if(!t)return;let s=!0;if(o(this,w,js).call(this,t)&&i==="coin"){if(typeof this.coins.tubes[t]>"u")return;e==="tube"?this.coins.tubes[t]+=1:e==="box"&&(this.coins.box[t]+=1);let a=0;["g50","c50"].includes(t)?a=.5:a+=parseInt(t.slice(1)),this.coins.totals[t]+=a,this.__money_session.inserted+=a,this.coins.total+=a}else if(o(this,w,Ks).call(this,t)&&i==="banknote"){if(typeof this.banknotes.recycler[t]>"u")return;e==="recycler"?this.banknotes.recycler[t]+=1:e==="stacker"&&(this.banknotes.stacker[t]+=1);let a=parseInt(t.slice(1));this.banknotes.totals[t]+=a,this.__money_session.inserted+=a,this.banknotes.total+=a}else if(o(this,w,Ws).call(this,t)&&e==="out"&&i==="banknote"){if(typeof this.banknotes.out[t.replace("r","p")]>"u")return;this.banknotes.out[t.replace("r","p")]+=1;let a=parseInt(t.slice(1));this.__money_session.retired+=a,this.banknotes.recycler[t.replace("r","p")]-=1,this.banknotes.total-=a,s=!1,this.dispatch("session:money-dispensed",{type_money:t,retired:a,finish:!1,type:"banknotes"})}s&&this.dispatch("session:money-request",{})},zs=function(t,e){const i=parseInt(t[2],16);return e.name="Coin Inserted",e.no_code=2,e.additional={where:null,coin:null},i===1?(e.name="Lever pressed",e.description="Reject lever",e.no_code=100,this.dispatch("coin-purse:reject-lever",{})):i===2?(e.name="Reset coin purse",e.description="The configuration of coin purse was reset",e.no_code=101,this.dispatch("coin-purse:reset",{})):i>=64&&i<=79?(e.name="Coin inserted in profit box",e.additional.where="box"):i>=80&&i<=95?(e.name="Coin inserted in tube",e.additional.where="tube"):i>=96&&i<=111?(e.name="Unused coin",e.description="Something come from coin changer but in MDB Docs is unused",e.additional.where="unused"):i>=112&&i<=127?(e.name="Coin rejected",e.additional.where="rejected"):i>=144&&i<=159?(e.name="Coin dispensed",e.additional.where="out",e.description=`Undefined value: ¿${t[2]}?`):(e.name="Coin inserted",e.description="Undefined status. Without information of this",e.no_code=400),i===1||i===2||i>=160||i>=128&&i<=143||([e.description,e.additional.coin]=o(this,w,qs).call(this,t[2]),e.no_code=38+i,o(this,w,jn).call(this,e.additional.coin,e.additional.where,"coin"),["tube","out"].includes(e.additional.where)&&this.dispatch("coin-purse:tubes",this.coins.tubes),this.dispatch("coin-purse:coin-event",this.coins)),e},Xs=function(t,e){const i=parseInt(t[2],16);return e.name="Banknote Inserted",e.no_code=2,e.additional={where:null,banknote:null},i===42?(e.name="Banknote dispensed",e.description="Banknote dispensed by request.",e.additional.banknote=o(this,w,$s).call(this),e.additional.where="out",e.no_code=200):i>=128&&i<=143?(e.name="Banknote inserted",e.additional.where="stacker"):i>=144&&i<=159?(e.name="Banknote inserted in pre stacker",e.additional.where="tmp"):i>=160&&i<=175?(e.name="Banknote rejected",e.additional.where="nothing"):i>=176&&i<=191&&(e.name="Banknote inserted",e.additional.where="recycler"),i>=128&&i<=191&&([e.description,e.additional.banknote]=o(this,w,Hs).call(this,t[2]),e.no_code=74+i),o(this,w,jn).call(this,e.additional.banknote,e.additional.where,"banknote"),this.dispatch("banknote-purse:event-banknote",this.banknotes),e},Gs=function(t,e){const i=parseInt(t,16);return i===1?(e.name="Coin purse enabled",e.description="Configuration complete, enabled",e.no_code=3):i===0?(e.name="Coin purse disabled",e.description="Disabled by system request",e.no_code=4):(e.name="Status unknown",e.description="The response of coin purse doesn't identify successfully",e.no_code=400),this.dispatch("coin-purse:config",{enabled:i===1}),e},Js=function(t,e){const i=parseInt(t[2],16),s=parseInt(t[3],16);return i===0?(e.name="Bill purse disabled",e.description="Configuration complete, disabled"):i===1&&(e.name="Bill purse enabled",e.description="Configuration complete, enabled"),s===0?e.additional.scrow="Scrow disabled, banknote received automatic":s===1&&(e.additional.scrow="Scrow enabled, require manual action"),e.no_code=5,this.dispatch("banknote-purse:config",{enabled:i===1,scrow:s===1}),e},Qs=function(t,e){e.no_code=6;const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={coins:{g50:i,c50:s,p1:a,p2:c,p5:l,p10:h}},this.coins.tubes.g50=i,this.coins.tubes.c50=s,this.coins.tubes.p1=a,this.coins.tubes.p2=c,this.coins.tubes.p5=l,this.coins.tubes.p10=h,this.coins.totals.g50=(this.coins.box.g50+i)*.5,this.coins.totals.c50=(this.coins.box.c50+s)*.5,this.coins.totals.p1=this.coins.box.p1+a,this.coins.totals.p2=(this.coins.box.p2+c)*2,this.coins.totals.p5=(this.coins.box.p5+l)*5,this.coins.totals.p10=(this.coins.box.p10+h)*10,this.coins.total=this.coins.totals.g50+this.coins.totals.c50+this.coins.totals.p1+this.coins.totals.p2+this.coins.totals.p5+this.coins.totals.p10,e.name="Read tubes",e.description="Quantity of coins approximated",this.dispatch("coin-purse:tubes",this.coins.tubes),e},Zs=function(t,e){e.no_code=7;const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)];return e.additional={banknotes:{b20:i,b50:s,b100:a,b200:c,b500:l,b1000:h}},this.banknotes.recycler.p20=i,this.banknotes.recycler.p50=s,this.banknotes.recycler.p100=a,this.banknotes.recycler.p200=c,this.banknotes.recycler.p500=l,this.banknotes.recycler.p1000=h,this.banknotes.totals.p20=(this.banknotes.stacker.p20+i)*20,this.banknotes.totals.p50=(this.banknotes.stacker.p50+s)*50,this.banknotes.totals.p100=(this.banknotes.stacker.p100+a)*100,this.banknotes.totals.p200=(this.banknotes.stacker.p200+c)*200,this.banknotes.totals.p500=(this.banknotes.stacker.p500+l)*500,this.banknotes.totals.p1000=(this.banknotes.stacker.p1000+h)*1e3,this.banknotes.total=this.banknotes.totals.p20+this.banknotes.totals.p50+this.banknotes.totals.p100+this.banknotes.totals.p200+this.banknotes.totals.p500+this.banknotes.totals.p1000,e.name="Read recycler",e.description="Quantity of banknotes approximated",this.dispatch("banknote-purse:recycler",this.banknotes.recycler),e},Ys=function(t,e){const i=parseInt(t,16);return i===1?e.name="Banknote accepted":i===0?e.name="Banknote rejected":e.name="Unknown status banknote",e.no_code=8,this.dispatch("banknote-purse:banknote-scrow-status",{status:i===1}),e},ta=function(t,e){const[i,s,a,c,l,h]=[parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16)],_=i*20+s*50+a*100+c*200+l*500+h*1e3;return e.name="Banknotes dispensed",e.description=_>0?"Banknotes dispensed by request":"No banknotes dispensed, recycler empty",e.no_code=9,e.additional={banknotes:{b20:i,b50:s,b100:a,b200:c,b500:l,b1000:h},total_dispensed:_},this.dispatch("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"banknotes",data:e}),e},ea=function(t,e){return e.name="Coins dispensed",e.no_code=10,e.description="Coins dispensed by request",isNaN(this.__sale.last_change)&&(this.__sale.last_change=0),this.__money_session.retired+=this.__sale.last_change,this.dispatchAsync("session:money-dispensed",{type_money:null,retired:null,finish:!1,type:"coins"},500),e},na=function(t,e){const i=parseInt(t,16);return i===1?(e.name="Product not delivered",e.description="The product requested wasn't delivered",e.no_code=11,this.__internal__.dispense.status=!1):i===0?(e.name="Product delivered",e.description="The product requested was delivered",e.no_code=12,this.__internal__.dispense.status=!0):(e.name="Unknown status product",e.description="The response of product doesn't identify successfully",e.no_code=400,this.__internal__.dispense.status=!1),this.dispatch("dispensed",{}),e},ia=function(t,e){let i="closed";return t==="db"?(e.name="Door closed",e.no_code=13):t==="dc"?(e.name="Door open",e.no_code=14,i="open"):(e.name="Unknown status door",e.description="The response of door doesn't identify successfully",e.no_code=400,i="unknown"),this.__internal__.device.door_open=i==="open",this.dispatch("event:door",{open:i==="open"}),this.dispatch("door:event",{open:i==="open"}),e},ra=function(t,e){const i=parseInt(t[2],16)*255,s=parseInt(t[3],16),a=(i+s)*.1;return e.no_code=15,e.name="Temperature status",e.description=`Temperature: ${a}`,e.additional={high:i,low:s,temperature:parseFloat(a.toString())},this.dispatch("status:temperature",e.additional),e},sa=function(t,e){const i=parseInt(t,16);let s="unknown";return i===1?(e.name="Relay on",e.description="Relay on",e.no_code=16,s="on"):i===0?(e.name="Relay off",e.description="Relay off",e.no_code=17,s="off"):(e.name="Status unknown",e.description="Status unknown",e.no_code=400),this.dispatch("status:relay",{enabled:s==="on"}),e},aa=function(t,e){const i=parseInt(t[2],16);if(e.no_code=20+i,e.name="Status unknown",e.description="The status of card reader does not identified correctly",i===0)e.request+=":disable",e.name="Card reader disabled",e.description="Card reader device was disabled successfully";else if(i===1||i===2)e.request+=":dispense",e.name="Card reader enabled",e.description="Card reader device is now enabled";else if(i===3)e.request+=":pre-authorize",e.name="Pre-authorized credit",e.description="The pre credit was authorized successfully";else if(i===4)e.request+=":cancel",e.name="Cancellation in progress",e.description="Cancellation request done successfully";else if(i===5)e.request+=":sell",e.name="Sell approved",e.description="Sell approved, starting dispense product";else if(i===6)e.request+=":sell",e.name="Sell denied",e.description="This sell was denied, try again";else if(i===7)e.request+=":end",e.name="Session ended",e.description="The session ended";else if(i===8)e.request+=":cancel",e.name="Cancelled",e.description="Cancellation complete";else if(i===10){const s=parseInt(t[8],16);s===1?(e.no_code=30,e.name="product not dispensed",e.description="The product requested wasn't delivered"):s===0?(e.no_code=31,e.name="product dispensed",e.description="The product requested was delivered"):(e.name="finished-unknown",e.no_code=400)}else e.no_code=400;return this.dispatch("card-reader:event",e),e},lt=function(t,e){return this.appendToQueue(o(this,w,Ge).call(this,t),e)},Ge=function(t){return t[11]=this.serialBoardroidSumHex(t),t.map((e,i)=>{t[i]=this.hexMaker(e)}),t},oa=function({enable:t=!1,scrow:e=!1}={}){const i=t?"FF":"00",s=e?"FF":"00";return["F1","C0",i,i,s,s,"00","00","00","00","F2","00"]},ca=function({enable:t=!1,scrow:e=!1}={}){return["F1","C0",t?"01":"00",e?"01":"00","00","00","00","00","00","00","F2","00"]},la=function(t=1){if(t<1)throw new Error("No banknotes to dispense");return t=this.decToHex(t),["F1","C5",this.decToHex(this.__banknote_purse.recycler.banknote.toString()),t,"00","00","00","00","00","00","F2","00"]},ha=function({$_20:t=0,$_50:e=0,$_100:i=0,$_200:s=0,$_500:a=0,$_1000:c=0}={}){if([t,e,i,s,a,c].some(l=>isNaN(l)||typeof l=="string"))throw new Error("One of the values is not a number");if(t<1&&e<1&&i<1&&s<1&&a<1&&c<1)throw new Error("No banknotes to dispense");return[t,e,i,s,a,c]=[this.decToHex(t),this.decToHex(e),this.decToHex(i),this.decToHex(s),this.decToHex(a),this.decToHex(c)],["F1","C5",t,e,i,s,a,c,"00","00","F2","00"]},Hn=function(){L(this,Gt,!1),L(this,Ft,0),L(this,Jt,0)},Je=function({dispensed:t=null,limit:e=80}={}){L(this,Jt,Math.round(O(this,Ft)*100/e)),this.dispatch("percentage:test",{percentage:O(this,Jt),dispensed:t})},ua=function(t){const e=["20","50","100","200","500"],i=this.__banknote_purse.recycler.banknote,s="$_"+e[i],a=parseInt(e[i]),c=this.banknotes.recycler[`p${e[i]}`],l=Math.min(Math.floor(t/a),c),h={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:l>0};return this.totalInRecycler===0||l<1||t===0||(h.banknotes[s]=l,h.pending=parseFloat((t-l*a).toFixed(2))),h},da=function(t){const e={banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1};if(this.totalInRecycler===0||t===0)return e;const i=(s,a)=>{if(this.banknotes.recycler[a]>0){const c=Math.floor(e.pending/s),l=Math.min(c,this.banknotes.recycler[a]);e.banknotes[`$_${s}`]=l,e.pending=parseFloat((e.pending-l*s).toFixed(2))}};return i(1e3,"p1000"),i(500,"p500"),i(200,"p200"),i(100,"p100"),i(50,"p50"),i(20,"p20"),e.will_dispense=Object.values(e.banknotes).some(s=>s>0),e},Kn=function(t){return this.hasRecycler?o(this,w,Xe).call(this)?o(this,w,ua).call(this,t):o(this,w,da).call(this,t):{banknotes:{$_20:0,$_50:0,$_100:0,$_200:0,$_500:0,$_1000:0},pending:t,will_dispense:!1}},Wn=function(t){const e={coins:{$_50c:0,$_1:0,$_2:0,$_5:0,$_10:0},pending:t,will_dispense:!1};if(!this.hasCoinPurse||t<=0||this.totalInTubes===0)return e;const i=(s,a,c=null)=>{if(this.coins.tubes[a]>0){c===null&&(c="$_"+s);const l=Math.floor(e.pending/s),h=Math.min(l,this.coins.tubes[a]);e.coins[c]=h,e.pending=parseFloat((e.pending-h*s).toFixed(2))}};return i(10,"p10"),i(5,"p5"),i(2,"p2"),i(1,"p1"),i(.5,"g50","$_50c"),e.will_dispense=Object.values(e.coins).some(s=>s>0),e},$n=async function(t=null){if(!o(this,w,Ls).call(this))throw new Error("Change not available");let e=this.change,i=this.change;if(t!==null&&(e=t,i=t),i<=0)return!1;const s=o(this,w,Kn).call(this,i);i=s.pending;const a=o(this,w,Wn).call(this,i);return i=a.pending,i>0&&this.dispatch("change:pending",{pending:i}),this.dispatch("change:dispense",{recycler:s.banknotes,coins:a.coins,pending:i,delivery:e-i}),i===e?!1:(s.will_dispense&&await this.banknotePurseDispense(s.banknotes),a.will_dispense&&await this.coinPurseDispense(a.coins),!0)};class kc extends xt{constructor({filters:t=null,config_port:e=null,no_device:i=1}={}){super({filters:t,config_port:e,no_device:i});Y(this,Qt);if(this.__internal__.device.type="arduino",k.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=2e3,this.__internal__.time.response_general=2e3,this.__internal__.serial.delay_first_connection=1e3,o(this,Qt,_a).call(this),o(this,Qt,pa).call(this),this.getResponseAsString()}serialMessage(t){const e=this.stringToArrayHex(t),i=this.stringToArrayBuffer(t),s={original_code:e,arrayBuffer:i,code:null,name:null,description:null,request:null,no_code:0};switch(s.code=t,t){case"connected":s.name="connected",s.description="Connection established",s.request="connect",s.no_code=100;break;case"created by danidoble":s.name="thanks",s.description="thanks for using this software",s.request="credits",s.no_code=101;break;case"hello there":s.name="hello there",s.description="hi human",s.request="hi",s.no_code=102;break;case"ara ara":s.name="ara ara",s.description="troll",s.request="ara ara",s.no_code=404;break;default:s.name="unknown",s.description="Unknown command",s.request="unknown",s.no_code=400;break}this.dispatch("serial:message",s)}serialSetConnectionConstant(t=1){return this.add0x(this.parseStringToBytes("CONNECT"))}async sayCredits(){const t=this.parseStringToBytes("CREDITS");await this.appendToQueue(t,"credits")}async sayHi(){const t=this.parseStringToBytes("HI");await this.appendToQueue(t,"hi")}async sayAra(){const t=this.parseStringToBytes("OTHER");await this.appendToQueue(t,"ara")}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}async doSomething(){await this.sayCredits(),await this.sayAra(),await this.sayHi()}}Qt=new WeakSet,pa=function(){k.add(this)},_a=function(){};/**
35
35
  * @license Webserial
36
36
  * webserial
37
37
  *
@@ -39,4 +39,4 @@ version: 2.9.0
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
41
  * LICENSE file in the root directory of this source tree.
42
- */const Ac={wait:O,getSeconds:Ye,supportWebSerial:X},Dc="4.1.8";R.Arduino=xc,R.Boardroid=kc,R.Devices=G,R.Emulator=be,R.Jofemar=Sc,R.Kernel=Dt,R.Locker=Da,R.PinPad=Tc,R.Relay=Aa,R.utils=Ac,R.version=Dc,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
42
+ */const xc={wait:B,getSeconds:Qe,supportWebSerial:X},Ac="4.1.9";I.Arduino=kc,I.Boardroid=Sc,I.Devices=k,I.Emulator=fe,I.Jofemar=Tc,I.Kernel=xt,I.Locker=Aa,I.PinPad=Cc,I.Relay=xa,I.utils=xc,I.version=Ac,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});