"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[29],{688:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.loadStylux=void 0;const s=t(21);n.loadStylux=function(e){const n=Object.assign({src:"https://sdk.stylux.io/js-sdk.js",id:"styluxScript",anonymous:!1},e);(0,s.loadScript)(n)}},209:function(e,n,t){var s=this&&this.__awaiter||function(e,n,t,s){return new(t||(t=Promise))((function(a,i){function o(e){try{r(s.next(e))}catch(e){i(e)}}function l(e){try{r(s.throw(e))}catch(e){i(e)}}function r(e){var n;e.done?a(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(o,l)}r((s=s.apply(e,n||[])).next())}))};Object.defineProperty(n,"__esModule",{value:!0}),n.useStyluxFeature=void 0;const a=t(3),i=t(688);n.useStyluxFeature=({addToCartWithPayload:e,payload:n,styluxAddToCartAnimation:t=!0,styluxPersonalizationPrice:o})=>{const[l,r]=(0,a.useState)(""),[d,c]=(0,a.useState)(!1),[u,p]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!0),y=()=>p(!1),[f,b]=(0,a.useState)(3),w=d||!!l.length,[g,m]=(0,a.useState)(null);function S(){var e,t,a,i;return s(this,void 0,void 0,(function*(){if(window.Stylux)try{const s=yield window.Stylux.api.getProduct(n.variant.id),{offers:o=[]}=s;if(1===o.length){m(o[0]);const n=Number(null===(i=null===(a=null===(t=null===(e=o[0])||void 0===e?void 0:e.options)||void 0===t?void 0:t[0])||void 0===a?void 0:a.simpleText)||void 0===i?void 0:i.maxLength);Number.isNaN(n)||n==f||b(n)}}catch(e){return void console.warn("ERROR GETING STYLUX PRODUCT ====> ",e)}}))}function T(){return s(this,void 0,void 0,(function*(){try{function e(){return s(this,void 0,void 0,(function*(){if(!window.Stylux)throw new Error("Stylux is not defined");console.warn("STYLUX SETUP START"),yield window.Stylux.setup({apiKey:"STLX_7e571906d0d98eafeba362aec8e4b8d3225ba3b17c875d44a58859d0155f",merchantId:"fc220d21-1347-4fd8-a741-587bc5842827",preload:!1}),console.warn("STYLUX SETUP END")}))}return yield e(),yield S(),!0}catch(n){return!1}}))}return(0,a.useEffect)((()=>{let e=0;if("undefined"==typeof window)return;const n=setInterval((()=>s(void 0,void 0,void 0,(function*(){window.Stylux?(clearInterval(n),T(),console.warn("stylux loaded")):(e>50&&clearInterval(n),e++,console.warn("loading stylux"),(0,i.loadStylux)())}))),500)}),[]),(0,a.useEffect)((()=>{S()}),[n.variant.id]),{text:l,isActive:w,handleBlur:()=>{c(!1)},handleChange:e=>{j(!0),/[\uD800-\uDFFF\u2600-\u26FF\u2700-\u27BF\uD83C][\uDC00-\uDFFF\uDFC0-\uDFFF]/.test(e.currentTarget.value)&&j(!1),r(e.currentTarget.value)},handleFocus:()=>{c(!0)},MAX_TEXT_LENGTH:f,show:u,handleOpen:()=>p(!0),handleClose:y,addToCart:a=>s(void 0,void 0,void 0,(function*(){if(h)return;x(!0);const i=yield function(e){var n,t;return s(this,void 0,void 0,(function*(){try{if(!e&&(yield T(),!e))throw new Error("offer is not defined");const s=null===(t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[0])||void 0===t?void 0:t.id,a=yield window.Stylux.api.createBundle([{personalizationOptionId:s,simpleText:{personalizationText:l}}],e),{id:i}=a;return i||null}catch(e){return console.log("error creating stylux bundle",e),null}}))}(g);i?(e(Object.assign(Object.assign({},n),{properties:Object.assign(Object.assign({},n.properties),{_STYLUX_BUNDLE:i,_styluxPersonalizationText:l,_styluxPersonalizationPrice:o})}),t?a:void 0,t?n.quantity:void 0),y(),x(!1)):x(!1)})),isAddingToCart:h,isValid:v}}},79:function(e,n,t){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.StyluxFeature=void 0;const a=t(0),i=t(1),o=t(2),l=t(25),r=t(4),d=s(t(99)),c=t(209),u=t(41),{wrapper:p,wrapperImage:h,wrapperText:x,wrapperContent:v,wrapperHeader:j,wrapperIcons:y,wrapperIcon:f,wrapperButtons:b,wrapperInput:w,wrapperInputActive:g,wrapperInputError:m,wrapperButton:S,wrapperClose:T,modalCloseWhite:O,button:C}=d.default;n.StyluxFeature=function({onClose:e,image:n,onOpen:t,onSubmit:s,displayPrice:d,styluxPersonalizationPrice:N,labels:{beUnique:F,chooseCharacters:P,customizeYourSleeve:_,greatGift:I,makeItMine:E,makeItYours:A,nevermind:k},addToCartWithPayload:D,payload:L,styluxAddToCartAnimation:z}){const{handleBlur:U,handleChange:X,handleFocus:B,isActive:M,text:G,MAX_TEXT_LENGTH:Y,handleClose:R,handleOpen:W,show:H,addToCart:$,isAddingToCart:q,isValid:V}=(0,c.useStyluxFeature)({addToCartWithPayload:D,payload:L,styluxAddToCartAnimation:z,styluxPersonalizationPrice:N}),K=`personalize - ${d}`;return(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)("button",Object.assign({className:C,onClick:()=>{t&&t(),W()}},{children:K})),(0,a.jsx)(l.Modal,Object.assign({show:H,onClose:()=>{e&&e(),R()},className:O},{children:(0,a.jsxs)("div",Object.assign({className:p},{children:[(0,a.jsxs)("div",Object.assign({className:h},{children:[(0,a.jsx)("img",{src:n.src,alt:n.alt}),(0,a.jsx)("span",Object.assign({className:x},{children:G}))]})),(0,a.jsxs)("div",Object.assign({className:v},{children:[(0,a.jsxs)("div",Object.assign({className:j},{children:[(0,a.jsx)("h2",{children:A}),(0,a.jsx)("h5",{children:_})]})),(0,a.jsxs)("div",Object.assign({className:y},{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",Object.assign({className:f},{children:(0,a.jsx)(r.Icons.StarIcon,{})})),(0,a.jsx)("p",Object.assign({class:"no-translate"},{children:F}))]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",Object.assign({className:f},{children:(0,a.jsx)(r.Icons.GiftIcon,{})})),(0,a.jsx)("p",Object.assign({class:"no-translate"},{children:I}))]})]})),(0,a.jsxs)("div",Object.assign({className:b},{children:[(0,a.jsxs)("div",Object.assign({className:(0,o.cx)(w,M&&g)},{children:[(0,a.jsx)("input",{type:"text",onChange:X,value:G,maxLength:3,name:"textInput",placeholder:"",onFocus:B,onBlur:U}),(0,a.jsx)("label",Object.assign({class:"no-translate"},{children:P})),(0,a.jsx)("span",{children:`${G.length}/${Y}`})]})),!V&&(0,a.jsx)("p",Object.assign({className:m},{children:"Text should not contain emojis"})),(0,a.jsx)("button",Object.assign({disabled:!V||q,className:S,onClick:e=>{s&&s(),$(e)}},{children:q?(0,a.jsx)(u.Spinner,{}):E})),(0,a.jsx)("button",Object.assign({onClick:()=>{e&&e(),R()},className:T},{children:k}))]}))]}))]}))}))]})}}}]);