UNPKG

@apicart/vue-components

Version:

Apicart Vue.Js components for simple e-commerce platform development

7 lines (6 loc) 249 kB
/** * @apicart/vue-components v1.0.0-alpha7 * (c) 2018-2020 Apicart Company * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("https"),require("http")):"function"==typeof define&&define.amd?define(["https","http"],e):(t=t||self).Apicart=e(t.httpsProcessor,t.httpProcessor)}(this,(function(t,e){"use strict";!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}('@font-face {\n font-family: \'apicart-icons\';\n src: url(\'data:font/woff;base64,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\') format(\'woff\');\n font-weight: normal;\n font-style: normal;\n font-display: block;\n}\n\n[class^="apicart-icon-"], [class*=" apicart-icon-"] {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: \'apicart-icons\' !important;\n speak: none;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.apicart-icon-image:before {\n content: "\\e902";\n}\n.apicart-icon-x:before {\n content: "\\e907";\n}\n.apicart-icon-minus:before {\n content: "\\e900";\n}\n.apicart-icon-plus:before {\n content: "\\e901";\n}\n.apicart-icon-arrow-left-circle:before {\n content: "\\e903";\n}\n.apicart-icon-arrow-right-circle:before {\n content: "\\e904";\n}\n.apicart-icon-shopping-bag:before {\n content: "\\e905";\n}\n');var n=new(function(){function n(){}return n.prototype.get=function(t,e){return void 0===e&&(e={}),e.method="get",e.url=t,this.sendRequest(e)},n.prototype.post=function(t,e){return void 0===e&&(e={}),e.method="post",e.url=t,this.sendRequest(e)},n.prototype.request=function(t){return this.sendRequest(t)},n.prototype.createResponseObject=function(t){var e,n,r={},i={};return"xhr"===t.type?(c.forEach(t.request.getAllResponseHeaders().trim().split(/[\r\n]+/),(function(t){var e=t.split(": ");r[e.shift()]=e.join(": ")})),i=t.responseData,e=t.request.status,n=t.request.statusText):"nodeHttp"===t.type&&(i=t.responseData,r=t.response?t.response.headers:null,e=t.response?t.response.statusCode:null,n=t.response?t.response.statusMessage:null),{config:t.requestConfig,data:s.isJson(i)?s.parse(i):i,headers:r,request:t.request,status:e,statusText:n}},n.prototype.sendRequest=function(t){if(h.isEmpty(t.url))throw"@apicart/js-utils: No url provided for ajax request";var e=p.merge({adapter:null,data:{},eventListeners:Object,headers:{},method:"get",timeout:5e3,url:"",withCredentials:!1,isGet:function(){return"get"===this.method},isPost:function(){return"post"===this.method}},t);e.url=new URL(e.url),e.isGet()?c.forEach(e.data,(function(t,n){e.url.searchParams.append(n,encodeURIComponent(t))})):"string"!=typeof e.data&&(e.data=s.stringify(e.data)),h.isEmpty(e.data)&&(e.data=null);var n=e.adapter||null,r=null;if("function"===n)r=n.call(this,e);else if("undefined"!=typeof XMLHttpRequest)r=this.xhrAdapter(e);else{if("undefined"==typeof process||"[object process]"!==Object.prototype.toString.call(process))throw"@apicart/js-utils: Request cannot be processed because no Adapter was configuredor is not a callable function.";r=this.httpAdapter(e)}return r},n.prototype.xhrAdapter=function(t){var e=this,n=function(t,n){return e.createResponseObject({type:"xhr",request:t,responseData:t.responseText,requestConfig:n})};return new Promise((function(e,r){var i=new XMLHttpRequest;c.forEach(t.eventListeners,(function(t,e){i.addEventListener(t,(function(t){return e.call(i,t)}))})),i.addEventListener("load",(function(){e(n(i,t))})),i.addEventListener("error",(function(){r(n(i,t))})),i.open(t.method,t.url.toString()),i.withCredentials=t.withCredentials,t.timeout>0&&(i.timeout=t.timeout,i.addEventListener("timeout",(function(){r(n(i,t))}))),h.isEmpty(t.headers)||c.forEach(t.headers,(function(t,e){i.setRequestHeader(e,t)})),i.send(t.data)}))},n.prototype.httpAdapter=function(n){var r=this,i={hostname:n.url.hostname,port:null,path:n.url.pathname,method:n.method,headers:n.headers,timeout:n.timeout};n.isPost()&&(i.headers["Content-Type"]="application/json",i.headers["Content-Length"]=n.data?n.data.length:0);var o=null,a=n.url.protocol;if("http:"===a)i.port=80,o=e;else{if("https:"!==a)throw'@apicart/js-utils: No processor was found for URL protocol "'+a+'"';i.port=443,o=t}var s=function(t,e,i){return r.createResponseObject({type:"nodeHttp",request:t,response:e,responseData:i,requestConfig:n})};return new Promise((function(t){var e=o.request(i,(function(n){var r="";n.on("data",(function(t){r+=t})),n.on("end",(function(){t(s(e,n,r))}))}));e.on("error",(function(n){t(s(e,null,n))})),e.on("timeout",(function(){e.abort()})),n.isPost()&&e.write(n.data),e.end()}))},n}()),r=new(function(){function t(){}return t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return void 0!==console.error&&console.error.apply(console,t),this},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return void 0!==console.log&&console.log.apply(console,t),this},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return void 0!==console.warn&&console.warn.apply(console,t),this},t}()),i=new(function(){function t(){}return t.prototype.addClass=function(t,e){return"string"==typeof e&&(e=e.split(" ")),c.forEach(e,(function(e){t.classList.contains(e)||(t.className+=" "+e)})),t.className=t.className.trim(),this},t.prototype.findParent=function(t,e){for(var n=null;t=t.parentElement;)if(this.matches(t,e)){n=t;break}return n},t.prototype.matches=function(t,e){var n=Element.prototype;return n.matches?t.matches(e):!!n.msMatchesSelector&&t.msMatchesSelector(e)},t.prototype.on=function(t,e,n){var r=this;return"string"==typeof t&&(t=t.split(" ")),"string"==typeof e&&(e=e.split(",")),c.forEach(e,(function(e){c.forEach(t,(function(t){!function(t,e){document.addEventListener(e,(function(e){var i=e.target;if(i!==this&&(r.matches(i,t)||(i=r.findParent(i,t)),i&&i!==this)){e.preventDefault();var o={currentTarget:i,originalEvent:e};c.forEach(["altKey","bubbles","button","buttons","cancelable","char","charCode","clientX","clientY","ctrlKey","data","detail","eventPhase","key","keyCode","metaKey","offsetX","offsetY","originalTarget","pageX","pageY","preventDefault","relatedTarget","screenX","screenY","shiftKey","stopImmediatePropagation","stopPropagation","target","toElement","type","view","which"],(function(t){p.keyExists(e,t)&&(e[t]instanceof Function?o[t]=function(){return e[t]()}:Object.defineProperty(o,t,{get:function(){return e[t]}}))})),n.call(i,o)}}))}(e,t)}))})),this},t.prototype.removeClass=function(t,e){return t.className=t.className.replace(new RegExp(e.trim().replace(" ","|"),"g"),"").trim().replace(/\s+/," "),this},t.prototype.toggleClass=function(t,e){var n=e.split(" "),r="",i="";return c.forEach(n,(function(e){t.classList.contains(e)?r+=" "+e:i+=" "+e})),this.removeClass(t,r),this.addClass(t,i),this},t.prototype.trigger=function(t,e){return t instanceof Element&&(t=[t]),c.forEach(t,(function(t){t.dispatchEvent(new Event(e,{bubbles:!0,cancelable:!0}))})),this},t}()),o=new(function(){function t(){this.eventsRegister={}}return t.prototype.addListener=function(t,e,n,r){var i=this;return void 0===r&&(r=!1),"string"==typeof e&&(e=e.split(" ")),c.forEach(e,(function(e){e in i.eventsRegister||(i.eventsRegister[e]={}),i.eventsRegister[e][t]={callback:n,singleAction:r}})),this},t.prototype.dispatchEvent=function(t,e){var n=this;return void 0===e&&(e=[]),Array.isArray(e)||(e=[e]),"string"==typeof t&&(t=t.split(" ")),c.forEach(t,(function(t){t in n.eventsRegister&&c.forEach(n.eventsRegister[t],(function(r,i){r.singleAction&&n.removeListener(i,t),r.callback.apply(null,e)}))})),this},t.prototype.removeListener=function(t,e){var n=this;return"string"==typeof e&&(e=e.split(" ")),c.forEach(e,(function(e){delete n.eventsRegister[e][t]})),this},t}()),a=new(function(){function t(){this.STORAGE_KEY="utils_flash_messages"}return t.prototype.addMessage=function(t,e){void 0===e&&(e=null),e=e||"info";var n=this.getMessages();return e in n||(n[e]=[]),n[e].push(t),u.setItem(this.STORAGE_KEY,n),this},t.prototype.getMessages=function(){return u.getItem(this.STORAGE_KEY)},t.prototype.hasMessages=function(t){void 0===t&&(t=null);var e=this.getMessages(),n=t?p.find(e,t):e;return h.isEmpty(n)},t.prototype.processMessages=function(t,e){void 0===e&&(e=null);var n=this.getMessages();return e&&p.keyExists(n,e)?c.forEach(n[e],(function(n){t(n,e)})):h.isEmpty(n)&&c.forEach(n,(function(e,n){h.isEmpty(e)||c.forEach(e,(function(e){t(e,n)}))})),localStorage.setItem(this.STORAGE_KEY,s.stringify({})),this},t}()),s=new(function(){function t(){}return t.prototype.isJson=function(t){if("string"!=typeof t)return!1;try{JSON.parse(t)}catch(t){return!1}return!0},t.prototype.parse=function(t){return this.isJson(t)?JSON.parse(t):{}},t.prototype.stringify=function(t){return"object"==typeof t?JSON.stringify(t):""},t}()),u=new(function(){function t(){this._localStorageManager={_data:{},getItem:function(t){return void 0===this._data[t]?null:this._data[t]},setItem:function(t,e){this._data[t]=e},removeItem:function(t){delete this._data[t]},clear:function(){this._data={}},key:function(t){return void 0===Object.keys(this._data)[t]?null:Object.keys(this._data)[t]}},"undefined"!=typeof localStorage&&(this._localStorageManager=localStorage)}return t.prototype.clear=function(){return this._localStorageManager.clear(),this},t.prototype.getItem=function(t){var e=this._localStorageManager.getItem(t),n=null;return e&&null!==(n=s.parse(e)).expiration&&n.expiration<this.getActualTimestamp()&&(n=null,this.removeItem(t)),null===n?n:n.value},t.prototype.setItem=function(t,e,n){void 0===n&&(n=null);var i={expiration:n?this.getActualTimestamp()+n:null,value:e};try{this._localStorageManager.setItem(t,s.stringify(i))}catch(t){r.error(t)}return this},t.prototype.updateItem=function(t,e,n){void 0===n&&(n=null);var r=this.getItem(t)||{};return p.merge(r,e),this.setItem(t,r,n),this},t.prototype.removeItem=function(t){return this._localStorageManager.removeItem(t),this},t.prototype.hasItem=function(t){return null!==this.getItem(t)},t.prototype.getActualTimestamp=function(){return(new Date).getTime()},t}()),c=new(function(){function t(){}return t.prototype.forEach=function(t,e){var n,r,i,o,a,s={iterableLength:0,counter:0,isEven:function(){return this.counter%2==0},isOdd:function(){return 1===Math.abs(this.counter%2)},isFirst:function(){return 1===this.counter},isLast:function(){return this.counter===this.iterableLength}};if(null!==t&&!["undefined","number"].includes(typeof t)){if(Array.isArray(t)){if(!(r=Object.keys(t).length))return;for(s.iterableLength=r,n=0;n<r&&(s.counter++,!1!==e.apply(s,[t[n],n]));n++);}else{if(o=(i=Object.keys(t)).length,!i.length)return;for(s.iterableLength=o,n=0;n<o&&(s.counter++,a=i[n],!1!==e.apply(s,[t[a],a]));n++);}return this}},t}()),l=new(function(){function t(){}return t.prototype.randomNumber=function(t,e){return Math.random()*(e-t)+t},t.prototype.randomInt=function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t}()),p=new(function(){function t(){}return t.prototype.assign=function(t,e,n){var r;"string"==typeof e&&(e=e.split("."));for(var i=e.length-1,o=0;o<i;++o)(r=e[o])in t||(t[r]={}),t=t[r];t[e[i]]=n},t.prototype.copy=function(t){var e=this,n={};return c.forEach(t,(function(t,r){n[r]=e.isObject(t)?e.copy(t):t})),n},t.prototype.delete=function(t,e){"string"==typeof e&&(e=e.split(".")),e.length&&c.forEach(e,(function(e){if(this.isLast()||"object"!=typeof t[e])return!1;t=t[e]})),delete t[e.pop()]},t.prototype.find=function(t,e){if(!e||!t||"object"!=typeof t)return null;"string"==typeof e&&(e=e.split("."));var n=!1;return e.length&&c.forEach(e,(function(e){if(null===t||"object"!=typeof t||!(e in t))return n=!0,!1;t=t[e]})),n?null:t},t.prototype.keyExists=function(t,e){if(!e||!t||"object"!=typeof t)return!1;"string"==typeof e&&(e=e.split("."));var n=!0;return e.length?c.forEach(e,(function(e){if(null===t||"object"!=typeof t||!(e in t))return n=!1,!1;t=t[e]})):n=!1,n},t.prototype.isObject=function(t){return null!=t&&!Array.isArray(t)&&"object"==typeof t},t.prototype.merge=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r={};return c.forEach(e,(function(e){c.forEach(e,(function(e,n){r[n]=n in r&&t.isObject(e)?t.merge(r[n],e):e}))})),r},t.prototype.values=function(t){var e=[];return c.forEach(t,(function(t){e.push(t)})),e},t}()),f=new(function(){function t(){}return t.prototype.firstToUpper=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},t.prototype.generateHash=function(t,e){void 0===e&&(e="abcdefghijklmnopqrstuvwxyz0123456789");for(var n="";t--;)n+=e.charAt(Math.floor(Math.random()*e.length));return n},t.prototype.sprintf=function(t,e){return c.forEach(e,(function(e,n){["number","string"].includes(typeof e)&&(t=t.replace(new RegExp("%"+n+"%","g"),e))})),t},t.prototype.stripHtml=function(t){var e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""},t.prototype.truncate=function(t,e,n,r){return void 0===n&&(n=" "),void 0===r&&(r="..."),t.length<=e?t:t.substr(0,t.lastIndexOf(n,e-3))+r},t}()),h=new(function(){function t(){}return t.prototype.isEmpty=function(t){var e=typeof t;return"undefined"===e||null===t||"number"!==e&&("string"===e?0===t.length:"object"===e||Array.isArray(t)?Object.keys(t).length<1:void 0)},t}()),d={Ajax:n,Console:r,Dom:i,EventDispatcher:o,FlashMessages:a,Json:s,LocalStorage:u,Loops:c,Numbers:l,Objects:p,Strings:f,Validators:h},m=new(function(){function t(){this.ENV_DEV="dev",this.ENV_PROD="prod",this._parameters={env:this.ENV_PROD},"undefined"!=typeof ApicartConfig&&(this._parameters=d.Objects.merge(this._parameters,ApicartConfig))}return t.prototype.configure=function(t){this._parameters=d.Objects.merge(this._parameters,t),d.EventDispatcher.dispatchEvent("apicart:configure")},t.prototype.setEnvironment=function(t){if(![this.ENV_PROD,this.ENV_DEV].includes(t))throw new Error('Unknown environment "'+t+'".');this._parameters.env=t,d.EventDispatcher.dispatchEvent("apicart:environment:changed")},t.prototype.isDevEnv=function(){return this._parameters.env===this.ENV_DEV},t.prototype.isProdEnv=function(){return this._parameters.env===this.ENV_PROD},t.prototype.getEnvironment=function(){return this._parameters.env},t.prototype.getParameter=function(t){return d.Objects.find(this._parameters,t)},t}()),g=new(function(){function t(){var t=this;this.STORAGE_KEY="apicart-1.0.0-alpha7",this._cacheKey=null,this._storage={},this.init(),d.EventDispatcher.addListener("apicart-storage","apicart:configure",(function(){t.init()}))}return t.prototype.init=function(){this._cacheKey=m.getParameter("storage.cacheKey");var t=d.LocalStorage.getItem(this.STORAGE_KEY);!t||this._cacheKey&&this._cacheKey!==t._cacheKey?this.clearStorage():this._storage[this.STORAGE_KEY]=t},t.prototype.clearStorage=function(){this._storage={},this._storage[this.STORAGE_KEY]={_cacheKey:m.getParameter("storage.cacheKey")||null},this.saveStorage()},t.prototype.saveStorage=function(){d.LocalStorage.setItem(this.STORAGE_KEY,this.getStorage())},t.prototype.find=function(t){return d.Objects.find(this.getStorage(),t)},t.prototype.getStorage=function(){return this._storage[this.STORAGE_KEY]},t.prototype.getItem=function(t){var e=d.LocalStorage.getItem(this.STORAGE_KEY);return d.Objects.find(e,t)},t.prototype.setItem=function(t,e){d.Objects.assign(this.getStorage(),t,e),this.saveStorage()},t.prototype.updateItem=function(t,e){var n=this.getItem(t);n?(d.Objects.merge(n,e),this.setItem(t,n)):this.setItem(t,e)},t.prototype.hasItem=function(t){return null!==this.getItem(t)},t.prototype.removeItem=function(t){d.Objects.delete(this._storage[this.STORAGE_KEY],t),this.saveStorage()},t}()),v=new(function(){function t(){}return t.prototype.call=function(t,e,n,r,i){return d.Ajax.post(t,{data:d.Json.stringify({query:e,variables:n}),headers:{"Content-Type":"application/json"},withCredentials:i,timeout:r}).then((function(t){if(401===t.status)throw"401 Unauthorized - check provided Payments API token";if(404===t.status)throw"404 Not Found - data source was not found";if(429===t.status)throw"429 Too Many Requests - read rate limit docs section";if(200!==t.status)throw t.status+" - please contact Apicart support";return t})).catch((function(t){d.Console.error(t)}))},t.prototype.isSuccessResult=function(t,e,n){if(void 0===t&&(t=null),void 0===n&&(n=!0),null===t)throw"An error occurred, please try again in a few minutes.";if(d.Validators.isEmpty(t))throw"Response is empty.";var r=t.data;if(!d.Objects.keyExists(r,"data."+e+".result"))throw"Response doesn't contains valid result.";if(n&&"SUCCESS"!==r.data[e].result)throw d.Strings.sprintf('Response returned result "%0%" with message "%1%".',[r.data[e].result,r.data[e].message||""]);return!0},t}()),y=new(function(){function t(){this.ApiCommunicator=v,this.Configurator=m,this.Storage=g,this.Utils=d}return t.prototype.setDevEnv=function(){return this.Configurator.setEnvironment(this.Configurator.ENV_DEV),this},t.prototype.setProdEnv=function(){return this.Configurator.setEnvironment(this.Configurator.ENV_PROD),this},t.prototype.configure=function(t){return this.Configurator.configure(t),this},t.prototype.isDevEnv=function(){return this.Configurator.isDevEnv()},t.prototype.isProdEnv=function(){return this.Configurator.isProdEnv()},t.prototype.getConfigParameter=function(t){return this.Configurator.getParameter(t)},t}());function _(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function A(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var b=function(){function t(t,e,n,r){this._code=t,this._enabled=e,this._id=n,this._name=r}return t.prototype.getCode=function(){return this._code},t.prototype.setCode=function(t){this._code=t},t.prototype.isEnabled=function(){return this._enabled},t.prototype.setEnabled=function(t){this._enabled=t},t.prototype.getId=function(){return this._id},t.prototype.setId=function(t){this._id=t},t.prototype.getName=function(){return this._name},t.prototype.setName=function(t){this._name=t},t.deserialize=function(e){return new t(e.code,e.enabled,e.id,e.name)},t}(),E=function(){function t(t,e,n,r){void 0===r&&(r=[]),this._gateways=[],this._filteredTotal=t,this._hasMore=e,this._total=n,this._gateways=r}return t.prototype.getFilteredTotal=function(){return this._filteredTotal},t.prototype.setFilteredTotal=function(t){this._filteredTotal=t},t.prototype.getGateways=function(){return this._gateways},t.prototype.hasMore=function(){return this._hasMore},t.prototype.addGateway=function(t){this._gateways.push(t)},t.prototype.getTotal=function(){return this._total},t.prototype.setTotal=function(t){this._total=t},t.deserialize=function(e){var n=new t(e.filteredTotal,e.hasMore,e.total);return y.Utils.Loops.forEach(e.gateways,(function(t){n.addGateway(b.deserialize(t))})),n},t}(),w=function(){function t(t,e,n){if(void 0===n&&(n={}),this._parameters={},!y.Utils.Objects.keyExists(n,"url"))throw'Parameter "dataSource.url" is missing.';this._token=t,this._environment=e,this._parameters=n}return t.prototype.gatewaysPage=function(t,e,n){return void 0===e&&(e=10),void 0===n&&(n=null),_(this,void 0,void 0,(function(){var r,i;return A(this,(function(o){switch(o.label){case 0:return"\n\t\t\tquery gatewaysPage($input: GatewaysPageQueryInput!) {\n\t\t\t\tgatewaysPage(input: $input) {\n\t\t\t\t\tfilteredTotal\n\t\t\t\t\ttotal\n\t\t\t\t\tgateways {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tcode\n\t\t\t\t\t\tenabled\n\t\t\t\t\t}\n\t\t\t\t\thasMore\n\t\t\t\t}\n\t\t\t}",[4,this.call("\n\t\t\tquery gatewaysPage($input: GatewaysPageQueryInput!) {\n\t\t\t\tgatewaysPage(input: $input) {\n\t\t\t\t\tfilteredTotal\n\t\t\t\t\ttotal\n\t\t\t\t\tgateways {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tcode\n\t\t\t\t\t\tenabled\n\t\t\t\t\t}\n\t\t\t\t\thasMore\n\t\t\t\t}\n\t\t\t}",{input:{page:t,size:e,filter:n}})];case 1:return r=o.sent(),[2,(i=this.getResponseData(r,"gatewaysPage"))?E.deserialize(i):null]}}))}))},t.prototype.findGateway=function(t){return _(this,void 0,void 0,(function(){var e,n;return A(this,(function(r){switch(r.label){case 0:return"\n\t\t\tquery findGateway($input: FindGatewayQueryInput!) {\n\t\t\t\tfindGateway(input: $input) {\n\t\t\t\t\tgateway {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tcode\n\t\t\t\t\t\tenabled\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",[4,this.call("\n\t\t\tquery findGateway($input: FindGatewayQueryInput!) {\n\t\t\t\tfindGateway(input: $input) {\n\t\t\t\t\tgateway {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tname\n\t\t\t\t\t\tcode\n\t\t\t\t\t\tenabled\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",{input:{gateway:t}})];case 1:return e=r.sent(),[2,(n=this.getResponseData(e,"findGateway.gateway"))?b.deserialize(n):null]}}))}))},t.prototype.gatewayAction=function(t,e,n){return void 0===n&&(n={}),_(this,void 0,void 0,(function(){var r;return A(this,(function(i){switch(i.label){case 0:return"\n\t\t\tmutation gatewayAction($input: GatewayActionMutationInput!) {\n\t\t\t\tgatewayAction(input: $input) {\n\t\t\t\t\tresult {\n\t\t\t\t\t\tstatus\n\t\t\t\t\t\tdescription\n\t\t\t\t\t\tdata\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",[4,this.call("\n\t\t\tmutation gatewayAction($input: GatewayActionMutationInput!) {\n\t\t\t\tgatewayAction(input: $input) {\n\t\t\t\t\tresult {\n\t\t\t\t\t\tstatus\n\t\t\t\t\t\tdescription\n\t\t\t\t\t\tdata\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",{input:{environment:this._environment,gateway:t,action:e,parameters:n}})];case 1:return r=i.sent(),[2,this.getResponseData(r,"gatewayAction.result")]}}))}))},t.prototype.pay=function(t,e,n,r){return _(this,void 0,void 0,(function(){var i;return A(this,(function(o){switch(o.label){case 0:return"\n\t\t\tmutation pay($input: PayMutationInput!) {\n\t\t\t\tpay(input: $input) {\n\t\t\t\t\tresult {\n\t\t\t\t\t\tstatus\n\t\t\t\t\t\tdescription\n\t\t\t\t\t\tdata\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",[4,this.call("\n\t\t\tmutation pay($input: PayMutationInput!) {\n\t\t\t\tpay(input: $input) {\n\t\t\t\t\tresult {\n\t\t\t\t\t\tstatus\n\t\t\t\t\t\tdescription\n\t\t\t\t\t\tdata\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",{input:{environment:this._environment,gateway:t,payment:e,orderId:n,parameters:r}})];case 1:return i=o.sent(),[2,this.getResponseData(i,"pay.result")]}}))}))},t.prototype.call=function(t,e){return e.input.token=this._token,y.ApiCommunicator.call(this._parameters.url,t,e,this._parameters.connectTimeout,this._parameters.withCredentials)},t.prototype.getResponseData=function(t,e){return y.Utils.Objects.find(t,"data.data."+e)},t}(),C=function(){function t(t,e){this._paymentGateway=null,this._dataSource=t,this._name=e}return t.prototype.getEntity=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return null!==this._paymentGateway?[3,2]:[4,this._dataSource.findGateway(this._name)];case 1:if(null===(t=e.sent()))throw'Entity with name "'+this._name+'" not found.';this._paymentGateway=t,e.label=2;case 2:return[2,this._paymentGateway]}}))}))},t.prototype.getCode=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getCode():null]}}))}))},t.prototype.isEnabled=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.isEnabled():null]}}))}))},t.prototype.getId=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getId():null]}}))}))},t.prototype.getName=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getName():null]}}))}))},t}(),P=function(){function t(t,e,n,r){void 0===n&&(n=10),void 0===r&&(r=null),this._size=10,this._filter=null,this._paymentGatewaysPage=null,this._dataSource=t,this._page=e,this._size=n,this._filter=r}return t.prototype.getEntity=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return null!==this._paymentGatewaysPage?[3,2]:[4,this._dataSource.gatewaysPage(this._page,this._size,this._filter)];case 1:t=e.sent(),this._paymentGatewaysPage=t,e.label=2;case 2:return[2,this._paymentGatewaysPage]}}))}))},t.prototype.getFilteredTotal=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getFilteredTotal():null]}}))}))},t.prototype.getGateways=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getGateways():null]}}))}))},t.prototype.hasMore=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.hasMore():null]}}))}))},t.prototype.getTotal=function(){return _(this,void 0,void 0,(function(){var t;return A(this,(function(e){switch(e.label){case 0:return[4,this.getEntity()];case 1:return[2,(t=e.sent())?t.getTotal():null]}}))}))},t}(),S=function(){function t(t){this._dataSource=null,this._config={token:"",environment:"sandbox",dataSource:{class:w,parameters:{connectionTimeout:5e3,url:"https://payment-api.apicart."+(y.Configurator.isDevEnv()?"dev":"net"),withCredentials:!1}}},this._config=this.parseConfig(t)}return t.prototype.pay=function(t,e,n,r){return _(this,void 0,void 0,(function(){return A(this,(function(i){return[2,this.getDataSource().pay(t,e,n,r)]}))}))},t.prototype.findGateway=function(t){return _(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return[4,(e=new C(this.getDataSource(),t)).getEntity()];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getGatewaysPage=function(t,e,n){return void 0===e&&(e=10),void 0===n&&(n=null),_(this,void 0,void 0,(function(){var r;return A(this,(function(i){switch(i.label){case 0:return[4,(r=new P(this.getDataSource(),t,e,n)).getEntity()];case 1:return i.sent(),[2,r]}}))}))},t.prototype.gatewayAction=function(t,e,n){return void 0===n&&(n={}),this.getDataSource().gatewayAction(t,e,n)},t.prototype.getToken=function(){return this._config.token},t.prototype.getDataSource=function(){if(null===this._dataSource){var t=this._config.dataSource.class;this._dataSource=new t(this._config.token,this._config.environment,this._config.dataSource.parameters)}return this._dataSource},t.prototype.parseConfig=function(t){var e=y.Utils.Objects.merge(this._config,t);if(!y.Utils.Objects.keyExists(e,"token")||y.Utils.Validators.isEmpty(e.token))throw"Missing token";if(!y.Utils.Objects.keyExists(e,"dataSource")||!y.Utils.Objects.keyExists(e,"dataSource.class")||y.Utils.Validators.isEmpty(e.dataSource.class)||y.Utils.Validators.isEmpty(e.dataSource.class))throw'Parameter "dataSource" is not valid.';if(!/^[0-9a-zA-Z_!?]{64}$/i.test(e.token))throw'Parameter "token" must contains 64 characters.';return e},t}(),I=function(){function t(t){this._code=t}return t.prototype.getCode=function(){return this._code},t.prototype.setCode=function(t){this._code=t},t.CODE_ACTIVE="active",t.CODE_MERGED="merged",t.CODE_FINISHED="finished",t}(),k=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),M=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),$=function(){function t(t,e,n,r,i,o){var a=this;void 0===o&&(o=[]),this._parameters=[],this._externalId=t,this._name=e,this._price=n,this._taxRate=r,this._dataUrl=i,y.Utils.Loops.forEach(o,(function(t){a.addParameter(t)}))}return t.prototype.getExternalId=function(){return this._externalId},t.prototype.getName=function(){return this._name},t.prototype.getPrice=function(){return this._price},t.prototype.getTaxRate=function(){return this._taxRate},t.prototype.getDataUrl=function(){return this._dataUrl},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){if(n.getKey()===t.getKey())return n.setValue(t.getValue()),void(e=!0)})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){n.getKey()===t&&delete e._parameters[r]}))},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){e.getKey()===t&&(n=e.getValue())})),n},t.prototype.serialize=function(){var t={externalId:this.getExternalId(),dataUrl:this.getDataUrl(),name:this.getName(),parameters:[],taxRate:this.getTaxRate(),price:this.getPrice()};return y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.prototype.serializeForGraphQL=function(){var t=this.serialize();return delete t.price,t},t.deserialize=function(e){y.Utils.Loops.forEach(["externalId","name","taxRate","dataUrl"],(function(t){if(!y.Utils.Objects.keyExists(e,t))throw'Item: Missing required parameter: "'+t+'".'}));var n=new t(e.externalId,e.name,e.price,e.taxRate,e.dataUrl);return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new M(t.key,t.value||null))})),n},t}(),D=function(){function t(t,e,n,r){var i=this;void 0===r&&(r=[]),this._parameters=[],this._quantity=t,this._totalPrice=e,this._item=n,y.Utils.Loops.forEach(r,(function(t){i.addParameter(t)}))}return t.prototype.getQuantity=function(){return this._quantity},t.prototype.increaseQuantity=function(t){void 0===t&&(t=1),this._quantity+=t},t.prototype.decreaseQuantity=function(t){if(void 0===t&&(t=1),this.getQuantity()-t<=0)throw"Product quantity cannot be decreased to zero.";this._quantity-=t},t.prototype.getTotalPrice=function(){return this._totalPrice},t.prototype.getItem=function(){return this._item},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){if(n.getKey()===t.getKey())return n.setValue(t.getValue()),void(e=!0)})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){n.getKey()===t&&delete e._parameters[r]}))},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){e.getKey()===t&&(n=e.getValue())})),n},t.prototype.getExternalId=function(){return this.getItem().getExternalId()},t.prototype.serialize=function(){var t={dataUrl:this.getItem().getDataUrl(),quantity:this.getQuantity(),parameters:[],totalPrice:this.getTotalPrice(),item:this.getItem().serialize()};return y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.prototype.serializeForGraphQL=function(){return this.serialize()},t.deserialize=function(e){y.Utils.Loops.forEach(["quantity","totalPrice","item"],(function(t){if(!y.Utils.Objects.keyExists(e,t))throw'CartItem: Missing required parameter: "'+t+'".'}));var n=new t(e.quantity,e.totalPrice,$.deserialize(e.item));return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new k(t.key,t.value||null))})),n},t}(),T=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),x=function(){function t(t){this._code=t}return t.prototype.getCode=function(){return this._code},t.prototype.setCode=function(t){this._code=t},t.CODE_ACTIVE="active",t.CODE_DISABLE="disable",t}(),O=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),U=function(){function t(t,e,n,r,i){var o=this;void 0===i&&(i=[]),this._parameters=[],this._createdAt=t,this._updatedAt=e,this._hash=n,this.setCustomerState(r),y.Utils.Loops.forEach(i,(function(t){o.addParameter(t)}))}return t.prototype.getCreatedAt=function(){return this._createdAt},t.prototype.getUpdatedAt=function(){return this._updatedAt},t.prototype.getHash=function(){return this._hash},t.prototype.getCustomerState=function(){return this._customerState},t.prototype.setCustomerState=function(t){this._customerState=t},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){n.getKey()===t.getKey()&&(n.setValue(t.getValue()),e=!0)})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){if(n.getKey()===t)return delete e._parameters[r],!1}))},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){if(e.getKey()===t)return n=e.getValue(),!1})),n},t.prototype.getExternalId=function(){var t=this.getParameterValue("externalId");return["string","number"].includes(typeof t)||null===t||(t=null),t},t.prototype.serialize=function(){var t={createdAt:this.getCreatedAt(),updatedAt:this.getUpdatedAt(),hash:this.getHash(),state:{code:this.getCustomerState().getCode()},parameters:[]};return y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.prototype.serializeForGraphQL=function(){var t=this.serialize();return{hash:t.hash,state:t.state.code,parameters:t.parameters}},t.deserialize=function(e){y.Utils.Loops.forEach(["createdAt","updatedAt","hash","state"],(function(t){if(!y.Utils.Objects.keyExists(e,t))throw'Customer: Missing required parameter: "'+t+'".'}));var n=new t(new Date(e.createdAt),new Date(e.updatedAt),e.hash,new x(e.state.code));return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new O(t.key,t.value||null))})),n},t}(),L=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),R=function(){function t(t,e,n,r,i,o,a,s,u,c){var l=this;void 0===u&&(u=null),void 0===c&&(c=[]),this._uid=null,this._enabled=!1,this._parameters=[],this._id=t,this._uid=u,this._name=e,this._description=n,this._image=r,this._type=i,this._price=o,this._sort=a,this._enabled=s,y.Utils.Loops.forEach(c,(function(t){l.addParameter(t)}))}return t.prototype.getId=function(){return this._id},t.prototype.getUid=function(){return this._uid},t.prototype.getName=function(){return this._name},t.prototype.getDescription=function(){return this._description},t.prototype.getImage=function(){return this._image},t.prototype.getType=function(){return this._type},t.prototype.getPrice=function(){return this._price},t.prototype.getSort=function(){return this._sort},t.prototype.isEnabled=function(){return this._enabled},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){if(n.getKey()===t.getKey())return n.setValue(t.getValue()),e=!0,!1})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){if(n.getKey()===t)return delete e._parameters[r],!1}))},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){if(e.getKey()===t)return n=e.getValue(),!1})),n},t.prototype.serialize=function(){var t={id:this.getId(),uid:this.getUid(),name:this.getName(),description:this.getDescription(),image:this.getImage(),type:this.getType(),price:this.getPrice(),sort:this.getSort(),enabled:this.isEnabled(),parameters:[]};return y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.deserialize=function(e){y.Utils.Loops.forEach(["id","name","image","type","price","sort","enabled"],(function(t){if(!(t in e))throw'PaymentMethod: Missing required parameter: "'+t+'".'}));var n=new t(e.id,e.name,e.description,e.image,e.type,e.price,e.sort,e.enabled,e.uid);return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new L(t.key,t.value||null))})),n},t.TYPE_APICART_PAYMENT_ADYEN="apicart-payment-adyen",t.TYPE_APICART_PAYMENT_BRAINTREE="apicart-payment-braintree",t.TYPE_APICART_PAYMENT_PAY_U="apicart-payment-pay_u",t.TYPE_APICART_PAYMENT_STRIPE="apicart-payment-stripe",t.TYPE_BANK_TRANSFER="bank-transfer",t.TYPE_CASH="cash",t.TYPE_CASH_ON_DELIVERY="cash-on-delivery",t.TYPE_CUSTOM="custom",t}(),F=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),N=function(){function t(t,e,n,r,i,o,a,s,u){var c=this;void 0===s&&(s=null),void 0===u&&(u=[]),this._uid=null,this._enabled=!1,this._parameters=[],this._id=t,this._uid=s,this._name=e,this._description=n,this._image=r,this._price=i,this._sort=o,this._enabled=a,y.Utils.Loops.forEach(u,(function(t){c.addParameter(t)}))}return t.prototype.getId=function(){return this._id},t.prototype.getUid=function(){return this._uid},t.prototype.getName=function(){return this._name},t.prototype.getDescription=function(){return this._description},t.prototype.getImage=function(){return this._image},t.prototype.getPrice=function(){return this._price},t.prototype.getSort=function(){return this._sort},t.prototype.isEnabled=function(){return this._enabled},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){if(n.getKey()===t.getKey())return n.setValue(t.getValue()),e=!0,!1})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){if(n.getKey()===t)return delete e._parameters[r],!1}))},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){if(e.getKey()===t)return n=e.getValue(),!1})),n},t.prototype.serialize=function(){var t={id:this.getId(),uid:this.getUid(),name:this.getName(),description:this.getDescription(),image:this.getImage(),price:this.getPrice(),sort:this.getSort(),enabled:this.isEnabled(),parameters:[]};return y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.deserialize=function(e){y.Utils.Loops.forEach(["id","name","image","price","sort","enabled"],(function(t){if(!(t in e))throw'ShippingMethod: Missing required parameter: "'+t+'".'}));var n=new t(e.id,e.name,e.description,e.image,e.price,e.sort,e.enabled,e.uid);return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new F(t.key,t.value||null))})),n},t}(),j=function(){function t(t,e,n,r,i,o,a,s,u,c){var l=this;void 0===a&&(a=null),void 0===s&&(s=null),void 0===u&&(u=[]),void 0===c&&(c=[]),this._items=[],this._parameters=[],this._shippingMethod=null,this._paymentMethod=null,this._createdAt=t,this._updatedAt=e,this._hash=n,this._totalPrice=r,this._paymentMethod=a,this._shippingMethod=s,this.setCartState(i),this.setCustomer(o),y.Utils.Loops.forEach(u,(function(t){l.addItem(t)})),y.Utils.Loops.forEach(c,(function(t){l.addParameter(t)}))}return t.prototype.getCreatedAt=function(){return this._createdAt},t.prototype.getUpdatedAt=function(){return this._updatedAt},t.prototype.getHash=function(){return this._hash},t.prototype.getTotalPrice=function(){return this._totalPrice},t.prototype.getCartState=function(){return this._cartState},t.prototype.setCartState=function(t){this._cartState=t},t.prototype.getCustomer=function(){return this._customer},t.prototype.setCustomer=function(t){this._customer=t},t.prototype.getItems=function(){return this._items},t.prototype.getTotalItemsQuantity=function(){var t=0;return y.Utils.Loops.forEach(this.getItems(),(function(e){t+=e.getQuantity()})),t},t.prototype.addItem=function(t){this._items.push(t)},t.prototype.removeItemByExternalId=function(t){var e=this;y.Utils.Loops.forEach(this.getItems(),(function(n,r){if(n.getExternalId()===t)return delete e._items[r],!1}))},t.prototype.removeItemByDataUrl=function(t){var e=this;y.Utils.Loops.forEach(this.getItems(),(function(n,r){if(n.getItem().getDataUrl()===t)return delete e._items[r],!1}))},t.prototype.findItemByExternalId=function(t){var e=null;return y.Utils.Loops.forEach(this.getItems(),(function(n){if(n.getItem().getExternalId()===t)return e=n,!1})),e},t.prototype.findItemByDataUrl=function(t){var e=null;return y.Utils.Loops.forEach(this.getItems(),(function(n){if(n.getItem().getDataUrl()===t)return e=n,!1})),e},t.prototype.getParameters=function(){return this._parameters},t.prototype.addParameter=function(t){var e=!1;y.Utils.Loops.forEach(this.getParameters(),(function(n){if(n.getKey()===t.getKey())return n.setValue(t.getValue()),e=!0,!1})),e||this._parameters.push(t)},t.prototype.removeParameter=function(t){var e=this;y.Utils.Loops.forEach(this.getParameters(),(function(n,r){if(n.getKey()===t)return delete e._parameters[r],!1}))},t.prototype.getPaymentMethod=function(){return this._paymentMethod},t.prototype.getShippingMethod=function(){return this._shippingMethod},t.prototype.getParameterValue=function(t,e){void 0===e&&(e=null);var n=e;return y.Utils.Loops.forEach(this.getParameters(),(function(e){if(e.getKey()===t)return n=e.getValue(),!1})),n},t.prototype.getExternalId=function(){var t=this.getParameterValue("externalId");return["string","number"].includes(typeof t)||null===t||(t=null),t},t.prototype.serialize=function(){var t={createdAt:this.getCreatedAt(),updatedAt:this.getUpdatedAt(),hash:this.getHash(),totalPrice:this.getTotalPrice(),state:{code:this.getCartState().getCode()},customer:this.getCustomer().serialize(),items:[],parameters:[],paymentMethod:null,shippingMethod:null},e=this.getPaymentMethod(),n=this.getShippingMethod();return e&&(t.paymentMethod=e.serialize()),n&&(t.shippingMethod=n.serialize()),y.Utils.Loops.forEach(this.getItems(),(function(e){t.items.push(e.serialize())})),y.Utils.Loops.forEach(this.getParameters(),(function(e){t.parameters.push({key:e.getKey(),value:e.getValue()})})),t},t.prototype.serializeForGraphQL=function(){var t=this.serialize();return{hash:t.hash,state:t.state.code,customerHash:t.customer.hash,items:t.items,parameters:t.parameters}},t.deserialize=function(e){y.Utils.Loops.forEach(["createdAt","updatedAt","hash","totalPrice","state.code","customer.hash","customer.state"],(function(t){if(!y.Utils.Objects.keyExists(e,t))throw'Cart: Missing required parameter: "'+t+'".'}));var n=new t(new Date(e.createdAt),new Date(e.updatedAt),e.hash,e.totalPrice,new I(e.state.code),U.deserialize(e.customer),e.paymentMethod?R.deserialize(e.paymentMethod):null,e.shippingMethod?N.deserialize(e.shippingMethod):null);return"parameters"in e&&Array.isArray(e.parameters)&&y.Utils.Loops.forEach(e.parameters,(function(t){"key"in t&&n.addParameter(new T(t.key,t.value||null))})),"items"in e&&Array.isArray(e.items)&&y.Utils.Loops.forEach(e.items,(function(t){n.addItem(D.deserialize(t))})),n},t}(),B=function(){function t(t){this._code=t}return t.prototype.getCode=function(){return this._code},t.prototype.setCode=function(t){this._code=t},t.CODE_NEW="new",t.CODE_WAITING_FOR_PAYMENT="waitingForPayment",t.CODE_PAID="paid",t.CODE_DISTRIBUTED="distributed",t.CODE_CANCELED="canceled",t}(),V=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this._value=t},t}(),z=function(){function t(t,e){this._key=t,this._value=e}return t.prototype.getKey=function(){return this._key},t.prototype.getValue=function(){return this._value},t.prototype.setValue=function(t){this.