"use strict";(self.webpackChunk_redotech_redo_shopify_extension=self.webpackChunk_redotech_redo_shopify_extension||[]).push([[841],{1838:(e,t,o)=>{o.d(t,{Z:()=>d});var n=o(50972),r=o(41425),l=o(60414),i=o(9616),a=o(89244),s=o(84352);const d=n.forwardRef((function(e,t){const{children:o,container:d,disablePortal:u=!1}=e,[c,m]=n.useState(null),f=(0,l.A)(n.isValidElement(o)?o.ref:null,t);return(0,i.A)((()=>{u||m(function(e){return"function"==typeof e?e():e}(d)||document.body)}),[d,u]),(0,i.A)((()=>{if(c&&!u)return(0,a.A)(t,c),()=>{(0,a.A)(t,null)}}),[t,c,u]),u?n.isValidElement(o)?n.cloneElement(o,{ref:f}):(0,s.jsx)(n.Fragment,{children:o}):(0,s.jsx)(n.Fragment,{children:c?r.createPortal(o,c):c})}))},73387:(e,t,o)=>{function n(e){const{disableDefaultClasses:t}=r.useContext(l);return o=>t?"":e(o)}o.d(t,{W:()=>n});var r=o(50972);o(84352);const l=r.createContext({disableDefaultClasses:!1})},44997:(e,t,o)=>{function n(e,t,o){return void 0===e||(0,l.g)(e)?t:(0,r.A)({},t,{ownerState:(0,r.A)({},t.ownerState,o)})}o.d(t,{X:()=>n});var r=o(1063),l=o(99604)},74631:(e,t,o)=>{function n(e,t=[]){if(void 0===e)return{};const o={};return Object.keys(e).filter((o=>o.match(/^on[A-Z]/)&&"function"==typeof e[o]&&!t.includes(o))).forEach((t=>{o[t]=e[t]})),o}o.d(t,{h:()=>n})},99604:(e,t,o)=>{function n(e){return"string"==typeof e}o.d(t,{g:()=>n})},69107:(e,t,o)=>{function n(e){const{getSlotProps:t,additionalProps:o,externalSlotProps:n,externalForwardedProps:s,className:d}=e;if(!t){const e=(0,l.A)(null==s?void 0:s.className,null==n?void 0:n.className,d,null==o?void 0:o.className),t=(0,r.A)({},null==o?void 0:o.style,null==s?void 0:s.style,null==n?void 0:n.style),i=(0,r.A)({},o,s,n);return e.length>0&&(i.className=e),Object.keys(t).length>0&&(i.style=t),{props:i,internalRef:void 0}}const u=(0,i.h)((0,r.A)({},s,n)),c=(0,a.p)(n),m=(0,a.p)(s),f=t(u),p=(0,l.A)(null==f?void 0:f.className,null==o?void 0:o.className,d,null==s?void 0:s.className,null==n?void 0:n.className),h=(0,r.A)({},null==f?void 0:f.style,null==o?void 0:o.style,null==s?void 0:s.style,null==n?void 0:n.style),g=(0,r.A)({},f,o,m,c);return p.length>0&&(g.className=p),Object.keys(h).length>0&&(g.style=h),{props:g,internalRef:f.ref}}o.d(t,{p:()=>n});var r=o(1063),l=o(94184),i=o(74631),a=o(95795)},95795:(e,t,o)=>{function n(e){if(void 0===e)return{};const t={};return Object.keys(e).filter((t=>!(t.match(/^on[A-Z]/)&&"function"==typeof e[t]))).forEach((o=>{t[o]=e[o]})),t}o.d(t,{p:()=>n})},86166:(e,t,o)=>{function n(e,t,o){return"function"==typeof e?e(t,o):e}o.d(t,{Y:()=>n})},39046:(e,t,o)=>{function n(e){var t;const{elementType:o,externalSlotProps:n,ownerState:c,skipResolvingSlotProps:m=!1}=e,f=(0,l.A)(e,u),p=m?{}:(0,d.Y)(n,c),{props:h,internalRef:g}=(0,s.p)((0,r.A)({},f,{externalSlotProps:p})),b=(0,i.A)(g,null==p?void 0:p.ref,null==(t=e.additionalProps)?void 0:t.ref);return(0,a.X)(o,(0,r.A)({},h,{ref:b}),c)}o.d(t,{Q:()=>n});var r=o(1063),l=o(62302),i=o(60414),a=o(44997),s=o(69107),d=o(86166);const u=["elementType","externalSlotProps","ownerState","skipResolvingSlotProps"]},28611:(e,t,o)=>{o.d(t,{W:()=>i});var n=o(82502),r=o(41050),l=o(72220);const i={name:"getSignupForm",input:n.Ikc({shopifyCustomerId:n.YjP().nullable(),redoCustomerId:n.YjP().nullish(),customerHash:n.YjP(),formId:n.YjP().nullable(),isOnMobile:n.zMY(),site:n.k5n(r.lG).optional(),utmParams:n.YjP(),forceId:n.YjP().optional(),exitIntentOnly:n.zMY().optional()}),output:n.Ikc({form:l.Ke.nullable(),formId:n.YjP().nullable(),treatmentId:n.YjP().nullable(),skipPhoneSteps:n.zMY(),merchantPhoneNumber:n.YjP().optional(),reason:n.YjP().optional()})}},26208:(e,t,o)=>{o.d(t,{B:()=>s});var n=o(2077),r=o(82502),l=o(82689),i=o(80662);const a=r.Ikc({email:r.YjP().optional(),phone:r.YjP().optional(),birthday:r.p6U().optional(),customFields:r.YOg(r.Ikc({declarationId:r.YjP(),dataType:r.k5n(i.WR),value:i.gR})).optional()}),s={name:"submitSignupFormStep",input:r.Ikc({formId:r.YjP(),stepIndex:r.aig(),formData:a,customerId:r.YjP().nullable().optional(),entryPoint:r.k5n(l.fh),anonymousId:r.YjP().optional(),treatmentId:n.Tu().nullish()}),output:r.Ikc({success:r.zMY(),error:r.YjP().optional(),discountCode:r.YjP().optional()})}},24953:(e,t,o)=>{function n(e){(0,A.R)("Initializing Marketing embedded form"),new MutationObserver((t=>{for(const o of t)for(const t of o.addedNodes)t instanceof HTMLElement&&r({parentElement:t,autocheck:e})})).observe(document.body,{childList:!0,subtree:!0}),r({parentElement:document.body,autocheck:e})}function r({autocheck:e,parentElement:t}){const o=t.querySelectorAll('div[id^="redo-marketing-embedded-form-"]:not([data-initialized="true"])'),n=Array.from(o).filter((e=>/^[a-zA-Z0-9]{5}$/.test(e.id.split("-").pop()??"")));if(0!==n.length){(0,A.R)(`Found ${n.length} Marketing embedded form containers`);for(const t of n)l({autocheck:e,formDiv:t})}}function l({autocheck:e,formDiv:t}){t.style.display="unset",t.dataset.initialized="true",(0,j.H)(t).render((0,a.jsx)(d.GH,{container:t,styleManager:x.A,children:(0,a.jsx)(F.N,{extensionShopifyClient:void 0,storeUrl:globalThis.redoStorefront?.storeUrl??globalThis.Shopify?.shop??globalThis.Shopify?.Checkout?.apiHost,children:(0,a.jsx)(Y.F,{baseUrl:globalThis.redoStorefront?.env?.REDO_SHOPIFY_SERVER_URL??"https://shopify-server.getredo.com",storeUrl:globalThis.redoStorefront?.storeUrl??globalThis.Shopify?.shop??globalThis.Shopify?.Checkout?.apiHost,widgetId:globalThis.redoWidgetId,children:(0,a.jsx)(i,{autocheck:e,formDivId:t.id})})})}))}function i({autocheck:e,formDivId:t}){const o=(0,k.useContext)(Y.Q),[n,r]=(0,k.useState)(0),[l,i]=(0,k.useState)((()=>{const e=localStorage.getItem(C);return e?(0,g.LK)(e):{}})),d=(0,k.useMemo)((()=>globalThis.ShopifyAnalytics?.meta?.page?.customerId?.toString()??null),[]),S=(0,s.Y5)((async()=>{if(!o)return[];if(globalThis.redoStorefront?.marketing?.embeddedForms){const e=v.safeParse(globalThis.redoStorefront.marketing.embeddedForms);if(e.success)return e.data}const e=await o(I,{});return globalThis.redoStorefront={...globalThis.redoStorefront,marketing:{...globalThis.redoStorefront?.marketing,embeddedForms:e}},e.filter((e=>e.publishedAt))}),[]),{form:P,formId:j,merchantPhoneNumber:F}=function(e,t,o,n){const[r,l]=(0,k.useState)(null),[i,a]=(0,k.useState)(null),[s,d]=(0,k.useState)(void 0);if(e.value&&t&&!r){const r=e.value.find((e=>e.form?.behavior.embeddedCode.includes(n)));if(r){(0,A.R)("Form found",r);const e=localStorage.getItem(b.mJ);e&&t(f.K,{anonymousId:e,shopifyCustomerId:o,formId:r.id,type:"view",treatmentId:null}).catch((e=>{console.error("Error logging form view:",e)})),l(r.form),a(r.id),d(r.merchantPhoneNumber)}}return{form:r,formId:i,merchantPhoneNumber:s}}(S,o,d,t),x=(0,k.useMemo)((()=>{if(o)return{getSignupForm:async(e,t)=>o(c.W,e,t),getCustomFieldOptions:async e=>o(y.m,e),logSignupFormAnalytics:async e=>o(f.K,e),submitSignupFormStep:async e=>o(m.B,e)}}),[o]),{logAnalytics:N}=(0,g.qh)({client:x,formId:j,treatmentId:null,shopifyCustomerId:d,localData:l,setLocalData:i}),R=(0,k.useCallback)((async(e,t)=>{await(0,g.dA)({i:e,formData:t,form:P,formId:j,client:x,localData:l,logAnalytics:N,setCurrentStep:r,entryPoint:u.fh.SIGNUP_FORM,skipPhoneSteps:!0,treatmentId:null})}),[x,l,P,j,N]);return S.pending||S.error?null:P?o?(0,a.jsx)(p.n,{getCustomFieldOptions:e=>o(y.m,{customFieldId:e}),children:(0,a.jsx)(h.H,{brandKit:e.brandKit,currentStep:n,form:P,merchantPhoneNumber:F,onSubmitStep:R})}):(0,a.jsx)(h.H,{brandKit:e.brandKit,currentStep:n,form:P,merchantPhoneNumber:F,onSubmitStep:R}):null}o.d(t,{initialize:()=>n});var a=o(84352),s=o(17995),d=o(29190),u=o(82689),c=o(28611),m=o(26208),f=o(22880),p=o(48379),h=o(897),g=o(38236),b=o(41468),y=o(65858),S=o(72220),P=o(82502);const v=P.YOg(P.Ikc({id:P.YjP(),form:S.Ke,publishedAt:P.p6U().nullable(),merchantPhoneNumber:P.YjP().optional()})),I={name:"getEmbeddedForms",input:P.Ikc({}),output:v};var k=o(50972),j=o(6858),Y=o(78927),A=o(19515),F=o(17900),x=o(18237);const C="redo.marketing-signup-form"},65858:(e,t,o)=>{o.d(t,{m:()=>r});var n=o(82502);const r={name:"getCustomFieldOptions",input:n.Ikc({customFieldId:n.YjP()}),output:n.Ikc({name:n.YjP(),options:n.YOg(n.Ikc({id:n.YjP(),name:n.YjP()}))})}}}]); //# sourceMappingURL=841-5b83cc9e.js.map