!function(t,e){for(var r in e)t[r]=e[r]}(window,function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){t.exports=r(7)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,c,"next",t)}function c(t){r(a,o,i,s,c,"throw",t)}s(void 0)}))}}},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){function r(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),u}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){var n=r(5);t.exports=function(t){if(Array.isArray(t))return n(t)}},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}},function(t,e,r){var n=r(5);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,r){"use strict";r.r(e),r.d(e,"process",(function(){return lt})),r.d(e,"getSignature",(function(){return pt})),r.d(e,"cancel",(function(){return mt}));var n=r(0),o=r.n(n),i=r(2),a=r.n(i),s=r(3),c=r.n(s),u=r(1),h=r.n(u),l=r(4),f=r.n(l),p=r(6),d=r.n(p),m="",v="";function g(t){if("string"==typeof t)return(new TextDecoder).decode(g("string"!=typeof(e=t)?null:(new TextEncoder).encode(e)));var e;if(t.length<0)return t;var r=[2];r.push.apply(r,d()(t)),r.push(3);var n=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0,o=e;o-1))if("0,65535"===n[o]){var i=new D(n[o+1]);r.moveTo(i.x-1,i.y-1)}else{var a=new D(n[o]);r.lineTo(a.x,a.y)}return r.stroke(),e.toDataURL("image/png").replace("data:image/png;base64,","")}}]),t}(),D=function t(e){h()(this,t),c()(this,"x",0),c()(this,"y",0),e.indexOf(",")>=0&&(this.x=e.split(",")[0],this.y=e.split(",")[1])},N="cc:sale",j="cc:credit",P="cc:authonly",M="cc:capture",_="cc:postauth",B="cc:void",F="cc:voidrelease",U="cc:voidrefund",G="cc:balance",H="ebtfs:sale",Z="ebtfs:credit",Y="ebtfs:balance",W="ebtcb:sale",q="ebtcb:balance",z="gift:redeem",J="gift:issue",V="gift:balance";function $(t){var e,r,n,o,i,a,s,c,u,h,l,f,p,d,y=function(t,e){var r=t.xCommand;if(r.toLowerCase().indexOf("cc")>=0)return e?"T02":"T00";if(r.toLowerCase().indexOf("ebt")>=0)return"T04";if(r.toLowerCase().indexOf("gift")>=0)return"T06";throw"Unsupported command: "+r}(t),w=function(t){var e=t.xCommand;switch(e){case N:case H:case W:case z:return"01";case j:case Z:return"02";case P:return"03";case M:return"04";case _:return"05";case J:return"10";case B:case F:case U:return"16";case G:case Y:case q:case V:return"23"}throw"Unsupported command: "+e}(t),b=[y,"1.28",w,function(t,e){var r=t.xAmount,n=t.xTax;switch(e){case"01":case"04":case"05":return[Q(r),"","","",Q(n)].join(v);case"03":case"02":case"06":case"10":return Q(r);case"16":case"18":case"19":case"20":case"21":case"23":case"24":default:return""}}(t,w),(r=(e=t).xExp,n=e.xCommand,o=e.xAllowDuplicate,i=e.xBillFirstName,a=e.xBillLastName,s=e.xCity,c=e.xEmail,["",r,"",K(n),"",o?1:"",i,a,"","",s,c].join(v)),(h=(u=t).xInvoice,l=u.xRefnum,f=u.xZip,p=u.xStreet,[l,h,"","",(d=new Date,"".concat(d.getFullYear()).concat(x(d.getMonth()+1,2)).concat(x(d.getDate(),2)).concat(x(d.getHours(),2)).concat(x(d.getMinutes(),2)).concat(x(d.getSeconds(),2))),"","",f,p,"",""].join(v))];return["T00","T06"].includes(y)?b.push(function(t,e){var r=t.xZip,n=t.xStreet,o=function(t){return function(t){return["01","03","10"].includes(t)}(t)}(e);return[o?r:"",o?n:""].join(v)}(t,w)+m+m+m+m):b.push(""),g(b.join(m))}function K(t){if(t.toLowerCase().indexOf("ebt")<0)return"";if(t.toLowerCase().indexOf("ebtfs")>=0)return"F";if(t.toLowerCase().indexOf("ebtcb")>=0)return"C";throw"Unsupported EBT Type: "+t}function Q(t){return Math.round(100*t)}var X=function t(e){h()(this,t),c()(this,"hostInformation",{}),c()(this,"amountInformation",{}),c()(this,"accountInformation",{}),c()(this,"traceInformation",{}),c()(this,"avsInformation",{});var r=(e=e.substr(0,e.length-2)).split(m);r.length<1||(this.status=r[0].trim(),r.length<2||(this.command=r[1].trim(),r.length<4||(this.responseCode=r[3].trim(),r.length<5||(this.responseMessage=r[4].trim(),r.length<6||(this.hostInformation=new tt(r[5].trim()),r.length<7||(this.transactionType=r[6].trim(),r.length<8||(this.amountInformation=new et(r[7].trim()),r.length<9||(this.accountInformation=new rt(r[8].trim()),r.length<10||(this.traceInformation=new nt(r[9].trim()),r.length<11||(this.avsInformation=new ot(r[10].trim()),r.length<14||(this.additionalInformation=r[13].trim())))))))))))},tt=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.hostResponseCode=r[0].trim(),r.length<2||(this.hostResponseMessage=r[1].trim(),r.length<3||(this.authCode=r[2].trim(),r.length<4||(this.hostReferenceNumber=r[3].trim(),r.length<5||(this.traceNumber=r[4].trim(),r.length<6||(this.batchNumber=r[5].trim(),r.length<7||(this.transactionIdentifier=r[6].trim(),r.length<8||(this.gatewayTransactionID=r[7].trim()))))))))},et=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.approveAmount=r[0].trim(),r.length<2||(this.amountDue=r[1].trim(),r.length<3||(this.tipAmount=r[2].trim(),r.length<4||(this.cashbackAmount=r[3].trim(),r.length<5||(this.fee=r[4].trim(),r.length<6||(this.taxAmount=r[5].trim(),r.length<7||(this.balance1=r[6].trim(),r.length<8||(this.balance2=r[7].trim(),r.length<9||(this.serviceFee=r[8].trim())))))))))},rt=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.account=r[0].trim(),r.length<2||(this.entryMode=r[1].trim(),r.length<3||(this.expDate=r[2].trim(),r.length<7||(this.cardType=r[6].trim(),r.length<8||(this.cardHolder=r[7].trim())))))},nt=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.transactionNumber=r[0].trim(),r.length<2||(this.referenceNumber=r[1].trim(),r.length<3||(this.timeStamp=r[2].trim(),r.length<4||(this.invoiceNumber=r[3].trim()))))},ot=function t(e){h()(this,t);var r=e.split(v);r.length<1||(this.approvalCode=r[0].trim(),r.length<2||(this.message=r[1].trim(),r.length<3||(this.zipCode=r[2].trim(),r.length<4||(this.address1=r[3].trim(),r.length<5||(this.approvalCode=r[4].trim())))))};function it(t,e){return"000000"!==e.responseCode?{xResult:function(t){switch(t.responseCode){case"000000":return"A";case"000100":case"100011":return"D";default:return"E"}}(e),xStatus:function(t){switch(t.responseCode){case"000000":return"Approved";case"000100":case"100011":return"Declined";default:return"Error"}}(e),xError:(r=e,n=r.responseCode,o=r.hostInformation,i=r.responseMessage,"000000"===n?"":(null==o?void 0:o.hostResponseCode)&&"0"!==(null==o?void 0:o.hostResponseCode)&&(null==o?void 0:o.hostResponseMessage)||i)}:{xResult:"A",xStatus:"Approved",xAuthCode:e.hostInformation.authCode,xCommand:t.xCommand,xAuthAmount:(e.amountInformation.approveAmount||0)/100,xRefNum:e.hostInformation.hostReferenceNumber,xBatch:e.hostInformation.batchNumber,xAvsResult:e.avsInformation.message,xAvsResultCode:e.avsInformation.approvalCode,xMaskedCardNumber:e.accountInformation.account,xName:e.accountInformation.cardHolder,xRemainingBalance:(e.amountInformation.balance1||0)/100,xRemainingBalanceEBTCB:t.xCommand.startsWith("ebt")?(e.amountInformation.balance1||0)/100:"",xRemainingBalanceEBTFS:t.xCommand.startsWith("ebt")?(e.amountInformation.balance2||0)/100:"",xConvenienceFee:(e.amountInformation.serviceFee||0)/100,xCashbackAmount:(e.amountInformation.cashbackAmount||0)/100,xTip:(e.amountInformation.tipAmount||0)/100,xExp:e.accountInformation.expDate,xInvoice:e.traceInformation.invoiceNumber,xCardType:function(t){switch(t=Number.parseInt(t)){case 1:return S;case 2:return L;case 3:return A;case 4:return k;case 5:return T;case 7:return R;default:return C}}(e.accountInformation.cardType)};var r,n,o,i}var at=function(){function t(e){h()(this,t),this.ipDeviceCommunicator=e}var e;return f()(t,[{key:"process",value:(e=a()(o.a.mark((function t(e){var r,n,i;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this.validate(e),r=$(e),t.next=5,this.ipDeviceCommunicator.getData(btoa(r));case 5:return n=t.sent,i=new X(n),t.abrupt("return",it(e,i));case 10:return t.prev=10,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 13:case"end":return t.stop()}}),t,this,[[0,10]])}))),function(t){return e.apply(this,arguments)})},{key:"validate",value:function(t){t.xInvoice=t.xInvoice||"",t.xStreet=t.xStreet||"",t.xZip=t.xZip||"",t.xTip=t.xTip||"",t.xTax=t.xTax||"",t.xExp=t.xExp||"",t.xAllowDuplicate=!!t.xAllowDuplicate,t.xBillFirstName=t.xBillFirstName||"",t.xBillLastName=t.xBillLastName||"",t.xCity=t.xCity||"",t.xEmail=t.xEmail||"",t.xRefnum=t.xRefnum||0}}]),t}(),st=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};h()(this,t),this.signatureReader=e.signatureReader,this.cardReader=e.cardReader}var e,r;return f()(t,[{key:"getSignature",value:(r=a()(o.a.mark((function t(){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signatureReader.getSignature();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"process",value:(e=a()(o.a.mark((function t(e){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.cardReader.process(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]),t}(),ct="",ut=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(h()(this,t),e.deviceIpAddress)ct=e.deviceIpAddress;else if(!e.deviceSerialNumber)throw"Device serial number required";this.serialNumber=e.deviceSerialNumber}return f()(t,[{key:"getIP",value:function(){return ct}}]),t}(),ht=function t(e,r,n){var i=this;h()(this,t),c()(this,"getData",function(){var t=a()(o.a.mark((function t(e){var r,n,a;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(i.protocol,"//").concat(i.ip,":").concat(i.port,"?").concat(e));case 3:if((r=t.sent).ok){t.next=6;break}throw r;case 6:return n=r.body.getReader(),t.next=9,y(n,new Uint8Array);case 9:return a=(a=t.sent)?new TextDecoder("utf-8").decode(a):"",t.abrupt("return",a);case 14:throw t.prev=14,t.t0=t.catch(0),console.error(t.t0),t.t0;case 18:case"end":return t.stop()}}),t,null,[[0,14]])})));return function(e){return t.apply(this,arguments)}}()),this.ip=e,this.port=r,this.protocol=n};function lt(t){return ft.apply(this,arguments)}function ft(){return(ft=a()(o.a.mark((function t(e){var r,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,r=new ut(e.settings),n=new st({cardReader:new at(new ht(r.getIP(),e.settings.deviceIpPort,e.settings.deviceIpProtocol||location.protocol))}),gt(e.settings.deviceIpAddress,n),t.next=6,n.process(e);case 6:return t.abrupt("return",t.sent);case 9:return t.prev=9,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 12:return t.prev=12,vt[e.settings.deviceIpAddress]=void 0,t.finish(12);case 15:case"end":return t.stop()}}),t,null,[[0,9,12,15]])})))).apply(this,arguments)}function pt(t){return dt.apply(this,arguments)}function dt(){return(dt=a()(o.a.mark((function t(e){var r,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,r=new ut(e),n=new st({signatureReader:new O(new ht(r.getIP(),e.deviceIpPort,e.deviceIpProtocol||location.protocol))}),gt(e.deviceIpAddress,n),t.next=6,n.getSignature();case 6:return t.abrupt("return",t.sent);case 9:return t.prev=9,t.t0=t.catch(0),t.abrupt("return",{xResult:"E",xStatus:"Error",xError:t.t0.toString()});case 12:return t.prev=12,vt[e.deviceIpAddress]=void 0,t.finish(12);case 15:case"end":return t.stop()}}),t,null,[[0,9,12,15]])})))).apply(this,arguments)}function mt(t){try{var e=new ut(t);(new st).cancel(new ht(e.getIP(),t.deviceIpPort,"http"))}catch(t){throw console.error(t),t}}var vt={};function gt(t,e){if(vt[t])throw"Transaction in progress";vt[t]=e}}]));