"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[3],{172:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepareErrorMessage=t.currentlyLoggedInCustomer=t.logoutMutation=t.loginMutation=void 0,t.loginMutation=function(){return"\n mutation login(\n $email: String!,\n $password: String!\n ) {\n login(\n email: $email,\n password: $password\n ) {\n result\n customer {\n ...CustomerFragment\n }\n }\n }\n \n fragment CustomerFragment on Customer {\n entityId\n email\n storeCredit {\n value\n }\n firstName\n lastName\n phone\n company\n }\n"},t.logoutMutation=function(){return"\n mutation logout {\n logout {\n result\n }\n }\n "},t.currentlyLoggedInCustomer=function(){return"\n query customer {\n customer {\n entityId\n storeCredit {\n value\n }\n firstName\n lastName\n phone\n company\n }\n }\n "},t.prepareErrorMessage=function(e,t){var n,r;const o=null===(r=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.errors[0])||void 0===r?void 0:r.message;return void 0!==o?o:`Sorry, error has occurred while trying to ${t}`}},20:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function u(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}s((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.renameMetaobjectKebabCaseKeysToCamelCase=t.getNumberFromString=t.transformObjectKeysToCamelCase=t.replaceNullishWithDefaultValue=t.getTokensCookie=t.getCurrentCustomer=t.saveToLocalStorage=t.readFromLocalStorage=t.getBreadcrumbs=t.prepareBreadcrumbsForCollections=t.prepareBreadcrumbs=t.camelToKebabCase=t.titleToKebabCase=t.titleToCamelCase=t.snakeToCamelCase=t.kebabToTitleCase=t.isDefined=void 0;const o=n(172);function a(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ")}function i(e){try{return e.replace(/_([a-z\d])/g,((e,t)=>t.toUpperCase()))}catch(t){return e}}function u(e){return Object.entries(e).reduce(((e,[t,n])=>{const r=i(t);return Object.assign(Object.assign({},e),{[r]:n})}),{})}t.isDefined=function(e){return Boolean(e)},t.kebabToTitleCase=a,t.snakeToCamelCase=i,t.titleToCamelCase=function(e){try{return e.replace(/\s([a-z\d])/gi,((e,t)=>t.toUpperCase()))}catch(t){return e}},t.titleToKebabCase=function(e){return"string"==typeof e?e.trim().replace(/\s+/g,"-").toLowerCase():""},t.camelToKebabCase=function(e){return e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`)).replace("--","-")},t.prepareBreadcrumbs=(e,t=undefined)=>{const n=e.pathname.split("/").slice(1).filter((e=>""!==e)),r=function(e){const t={name:"Home",url:"/",isDefault:!1},n=void 0!==e,r={name:(null==e?void 0:e.name)||"",url:(null==e?void 0:e.url)||"",isDefault:!1};return n?[t,r]:[t]}(t&&t.parentCategory||void 0);if(t&&t.name&&t.name.length>0){const e={name:t.name,url:t.url||"",isDefault:!0};return[...r,e]}return n.reduce(((e,t,r)=>{const o=a(t),i=`/${t}`;if(r+1===n.length){const t={name:o,url:i,isDefault:!0};return e.concat(t)}const u={name:o,url:i,isDefault:!1};return e.concat(u)}),r)},t.prepareBreadcrumbsForCollections=e=>{const t={name:"Home",url:"/",isDefault:!1};if(!e)return[t];const n={name:e.name,url:e.url,isDefault:!0};if(!e.parent)return[t,n];const r=(e=>{const t=[],n=e=>{e&&(t.unshift({name:e.name,url:e.url,isDefault:!1}),e.parent&&n(e.parent))};return n(e),t})(e.parent);return[t,...r,n]},t.getBreadcrumbs=function(e){const t=e.pathname.split("/");if(!(t.length>1))return[];t.shift();let n="";const r=t.map(((e,r)=>{const o=t.length-1===r,i=a(e),u=n+`/${e}`;return n=u,{name:i,url:u,isDefault:o}}));return r.splice(0,0,{name:"Home",url:"/",isDefault:!1}),r},t.readFromLocalStorage=function(e){return"undefined"!=typeof window&&localStorage.getItem(e)||""},t.saveToLocalStorage=function(e,t){"undefined"!=typeof window&&localStorage.setItem(e,t)},t.getCurrentCustomer=function(){return r(this,void 0,void 0,(function*(){try{const e=(0,o.currentlyLoggedInCustomer)(),t=yield fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e})});return yield t.json()}catch(e){return e&&console.error(e),{data:{customer:null}}}}))},t.getTokensCookie=function(e,t){const n=e.indexOf(t);if(-1===n)return"";const r=e.slice(n),o=r.indexOf(";");return r.slice(0,o)},t.replaceNullishWithDefaultValue=function(e,t){return Object.keys(t).reduce(((n,r)=>{const o=r,a=t[o],i=e[r];return null!=i?Object.assign(n,{[o]:i}):Object.assign(n,{[o]:a})}),{})},t.transformObjectKeysToCamelCase=u;const s={shouldServeFirstNumber:!1,shouldServeLastNumber:!0};t.getNumberFromString=function(e,{shouldServeFirstNumber:t,shouldServeLastNumber:n}=s){const r=e.match(/\d+/g);if(null===r)return null;const o=r;if(t||n){const e=t?o[0]:o.pop();if(e){const t=+e;return isNaN(t)?null:t}}return null},t.renameMetaobjectKebabCaseKeysToCamelCase=function(e,t="Metaobject"){try{return Object.entries(e).reduce(((e,[t,n])=>{const r=u(n);return Object.assign(e,{[t]:r})}),{})}catch(e){throw new Error(`Error has been caught while preparing keys for ${t} metaobject`)}}},197:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.formatDuration=void 0;const n=[{unit:"hr",value:3600},{unit:"min",value:60},{unit:"sec",value:1}];t.formatDuration=function(e){if(e<=0)return"now";const t=[];let r=e;for(const{unit:e,value:o}of n){const e=Math.floor(r/o);r-=e*o,t.push(e<10?`0${e}`:e)}return 1===t.length?t[0].toString():`${t.join(":")}`}},2:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.transformLabelByMultipleOptions=t.calculateExpirationTimeFromStringifiedTimePattern=t.getExpirationTime=t.parseCookies=t.getParamsFromURL=t.pushRoute=t.buildQueryString=t.combineVariantInventory=t.sortEntries=t.prepareFormattedPrice=t.formatCurrency=t.sx=t.cx=void 0,n(20);const r=n(197);function o(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e)}function a(e){return/\.\d\d$/.test(e)?e.slice(0,-3):e}t.cx=(...e)=>e.flat().filter((e=>null!=e&&"boolean"!=typeof e)).join(" "),t.sx=e=>("number"==typeof e?`${e}px`:e)||"unset",t.formatCurrency=o,t.prepareFormattedPrice=a,t.sortEntries=function(e){return[...e].sort(((e,t)=>e.sortOrder-t.sortOrder))},t.combineVariantInventory=function(e){return e.reduce(((e,t)=>e+t.node.inventory.aggregated.availableToSell),0)},t.buildQueryString=e=>{const t=new URLSearchParams;for(const n in e){const r=e[n];Array.isArray(r)?r.forEach((e=>t.append(n,e))):t.set(n,null!=r?r:"")}return t.toString()},t.pushRoute=e=>{if("string"==typeof e)window.location.assign(e);else{const{pathname:n,query:r}=e,o=r?(0,t.buildQueryString)(r):"",a=`${n}${o?"?"+o:""}`;window.history.pushState({},"",a)}},t.getParamsFromURL=()=>{const e=new URL(window.location.href);return{pageParam:Number(e.searchParams.get("page")),sortParam:e.searchParams.get("sort"),searchQueryParam:e.searchParams.get("search_query")}},t.parseCookies=function(e){const t={};if(""===e.trim())return t;const n=e.split(";");for(let e=0,r=n.length;e=r?r:u;return Date.now()+o}t.getExpirationTime=s,t.calculateExpirationTimeFromStringifiedTimePattern=function(e){if(!e.match(/^([0-2]{1}[0-9]{1})-([0-5]{1}[0-9]{1})-([0-5]{1}[0-9]{1})$/))return 0;const[t="0",n="0",r="0"]=e.split("-"),o=[t,n,r].map((e=>parseInt(e)));for(const e of o)if(isNaN(e))return 0;if(!o.some((e=>e>0)))return 0;const[a=0,i=0,u=0]=o;return s(a,i,u)};const c="__TIME__",l="__SAVINGS__",m="__TOTAL_SAVINGS__";t.transformLabelByMultipleOptions=(e,t)=>{if("string"!=typeof e)return e;let n=e;const{isTimerDefined:i,timeLeft:u,price:s,displayPrice:f,retailPrice:p}=t,d="number"==typeof u&&u>=0;if(n.includes(c)){if(!i||!d)return"";n=n.replace(c,(0,r.formatDuration)(u))}const g=n.includes(l),b=n.includes(m),y="number"==typeof s&&s>0,h="number"==typeof f&&f>0,C="number"==typeof p&&p>0;if(g&&f!==s&&h&&y){const e=f-s;if(e>0){const t=a(o(e));n=n.replace(l,t)}}if(b&&y&&h){let e=f-s;if(C&&(e=p-s),e>0){const t=a(o(e));n=n.replace(m,t)}}return n.replace(c,"").replace(l,"").replace(m,"")}}}]);