/*! For license information please see cart-page-container.js.LICENSE.txt */
(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){e=function(){return r};var r={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),c=new O(n||[]);return i(a,"_invoke",{value:L(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var f={};function d(){}function y(){}function v(){}var m={};l(m,c,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(k([])));w&&w!==n&&o.call(w,c)&&(m=w);var b=v.prototype=d.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(e,r){function n(i,a,c,u){var s=p(e[i],e,a);if("throw"!==s.type){var l=s.arg,h=l.value;return h&&"object"==t(h)&&o.call(h,"__await")?r.resolve(h.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(h).then((function(t){l.value=t,c(l)}),(function(t){return n("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,o){n(t,e,r,o)}))}return a=a?a.then(o,o):o()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return j()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=P(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function P(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,P(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r
').concat(e.translations.phone,' *
\n \n \n\n ').concat(e.translations.address,"\n\n ").concat("on_own"!==e.orderShippingMethod?'*':"",'\n
\n \n\n').concat(e.translations.note,'
\n \n\n').concat(e.translations.paymentType,' *
\n \n \n "),t.next=4,Swal.fire({imageUrl:"/logo.png",imageWidth:"13em",imageAlt:"Logo",confirmButtonText:e.translations.confirm,focusConfirm:!1,inputAutoFocus:!1,html:r,didRender:function(){$("#order-client-phone").inputmask("+(\\9\\93)-69-99-99-99")},preConfirm:function(){var t,r,n,o,i,a,c,u=null===(t=document.getElementById("order-client-name"))||void 0===t?void 0:t.value,s=null===(r=document.getElementById("order-client-phone"))||void 0===r?void 0:r.value,l=null===(n=document.getElementById("order-client-address"))||void 0===n?void 0:n.value,h=null===(o=document.getElementById("order-client-note"))||void 0===o?void 0:o.value,p=null===(i=document.getElementById("order-client-payment-method"))||void 0===i?void 0:i.value,f=e.orderShippingMethod,d=null!==(a=null===(c=document.getElementById("order-client-time"))||void 0===c?void 0:c.value)&&void 0!==a?a:"",y=e.orderShippingRegion,v=e.orderShippingProvince,m=e.orderShippingBranch;return""!=u&&""!=s&&""!=p&&""!=f||Swal.showValidationMessage("Maglumatlary giriziň"),"on_own"!==e.orderShippingMethod&&""==l&&Swal.showValidationMessage("Maglumatlary giriziň"),{name:u,phone:s,address:l,notes:h,payment_type:p,shipping_method:f,time:d,region:y,province:v,post_branch_id:m}},allowOutsideClick:function(){return!Swal.isLoading()}});case 4:n=t.sent,(o=n.value)&&(a=document.querySelector("meta[name=csrf-token]").getAttribute("value"),u=c(c({},o),{},{_token:a}),$.ajax({method:"POST",url:e.routes.orders.checkout,data:u,success:function(t){"online"!=u.payment_type?(Swal.fire("Siziň sargydyňyzyň kabul edildi!","Sargydy tassyklamak üçin siziň bilen operator habarlaşar.","success"),Event.fire("cartsUpdated")):window.location.href=t.data.data.url},error:function(t){}}));case 7:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){s(i,n,o,a,c,"next",t)}function c(t){s(i,n,o,a,c,"throw",t)}a(void 0)}))})()}},watch:{orderShippingRegion:function(){var t=this;this.shippingTotal=this.shippingPrice(),this.totalPayment=number_format(parseFloat(this.productsPayment)+this.shippingPrice()),this.regionsProvinces=this.provinces.filter((function(e){return e.region==t.orderShippingRegion})),this.orderShippingProvince=this.regionsProvinces[0]},orderShippingProvince:function(){var t=this;this.regionsBranches=this.branches.filter((function(e){return e.province_id===t.orderShippingProvince})),this.orderShippingBranch=this.regionsBranches[0]},orderShippingMethod:function(){if(this.shippingTotal=this.shippingPrice(),this.totalPayment=number_format(parseFloat(this.productsPayment)+this.shippingPrice()),"ag"!==this.orderShippingRegion)switch(this.orderShippingMethod){case"express":this.regionDeliveryMessage="Sargyt 2-5 gün aralygynda gowşurlar";break;case"on_own":this.regionDeliveryMessage="3-7 gün aralygynda sargydyňyzy saýlan şahamçaňyza baryp alyp bilersiňiz";break;default:this.regionDeliveryMessage="Sargyt 3-7 gün aralygynda gowşurlar"}}},mounted:function(){var t=this;window.Lara.auth.status&&this.syncCarts(),this.getProvinces(),this.getBranches(),Event.listen("cartsUpdated",(function(e){t.syncCarts()})),Event.listen("cartsUpdatedFromSidebar",(function(e){t.syncCarts()}))}}).mount("#cart-container")})();