var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opens = _____WB$wombat$assign$function_____("opens"); import{x as F,a as e,eB as ce,dE as H,eC as Z,am as C,A as j,q as v,eD as X,aj as te,eE as K,cl as de,eF as me,T as ue,cn as G,co as oe,aI as pe,aJ as Y,dZ as ae,af as z,y as M,a5 as V,cp as he,eG as _e,eH as fe,eI as be,cP as ge,eJ as ve,eK as ye,eL as Pe,bN as Ie,a6 as re,eM as Ee,en as Se,eN as Oe,b7 as W,a4 as Ce,a2 as Me,d as Fe,eO as Re,a1 as B,b0 as ee,aN as Ne,eP as ke,aG as Ae,s as Le,eQ as Te,bw as xe}from"./app.Dqw-tRcr.js";import{u as Be}from"./ShopPayOptInDisclaimer.CPHj_-jF.js";function Ve({defaultEmail:n}){const{record:r}=H(),{autoOptIn:t,isOptedIn:i}=Z(),[s,c]=C(n),o=j(void 0),a=v(()=>{s!==o.current&&(o.current=s,r({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{action:"update_email_input",email:s,source:"order_created",trigger:t&&i?"auto":"manual"}}))},[t,i,s,r]);return{value:s,handleInput:p=>{c(p)},handleBlur:()=>{a()}}}function ze({value:n,onInput:r,onBlur:t}){const i=F(),{value:s,handleInput:c,handleBlur:o}=Ve({defaultEmail:n});return e(ce,{id:"email",name:"email",label:i("shop_pay_remember_me.email_label","Email"),value:s,onInput:a=>{c(a),r?.(a)},onBlur:()=>{o(),t?.()},required:!1})}function we(){const n=X(void 0),r=X(void 0),t=F(),i=te(),[,s]=K(),c=de(),o=i.shippingAddress.fields.firstName.value,a=me("shipping"),d=!ue(()=>a??c,[a,c]).isRequired("firstName")&&!G(o),y=v(g=>{if(!G(g))return t("field_errors.address_first_name_blank","Enter a first name")},[t]),_=v(g=>{if(!d)return;if(!G(g))return r.value=Y.InvalidOptInName,t("field_errors.address_first_name_blank","Enter a first name");const R=n.peek()||"";s({optInFirstName:R})},[d,n,s,t,r]),b=oe(n,r,y);return pe(n,r,_,Y.InvalidOptInName),d?e(z,{children:e(ae,{name:"shopFirstName",label:t("contact.first_name_label","First name"),required:!0,...b})}):null}function De({countryCode:n,validationError:r,value:t,onBlur:i=()=>{},onInput:s=()=>{}}){const c=F(),{record:o}=H(),a=j(""),p=v(d=>{o({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{action:"update_phone_input",phoneNumber:a.current,source:"order_created",trigger:d}})},[o]);return M(()=>{a.current!==t&&(a.current=t,p("auto"))},[p,t]),e(he,{error:r?e(V,{children:c("general.errors.buyer_identity.phone_number_does_not_match_expected_pattern","The specified phone number does not match the expected pattern.")}):void 0,countryCode:n,label:c("shop_pay_remember_me.mobile_phone_number","Mobile phone number"),value:t,icon:"mobile",prefillCountryCode:!!n,onInputValueChange:d=>{s?.(d,n),a.current=d},onBlur:()=>{p("manual"),i?.()},onSelectedCountryChange:(d,y)=>{s?.(y,d),a.current=y}})}const T="RememberMeCheckbox";function ne(){const{record:n}=H(),r=te(),{value:t}=_e(),{autoOptIn:i,isOptedIn:s}=Z(),{storeOptOutPreference:c}=fe(),[o,a]=K(),p=o||i&&o===void 0,d=r.phone.value,y=r.email.value,_=!d,{shopPayOptInPhone:b}=t||{},g=be(),[u,R]=C(g),f=ge(),[S,N]=C([]),x=S.includes(T)||!!o,w=!_,{validate:O,error:D}=ve(u,x,w),P=ye(),I=Pe(u),k=j(I),[h,Q]=C(o&&o.vaultPhone||b||I||""),[A,U]=C(o&&o?.vaultEmail||y||""),L=v((m,l)=>{n({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{action:m,phoneNumber:l.phone,email:l.email,source:"order_created",trigger:i&&s?"auto":"manual"}})},[n,i,s]),J=v(m=>{O(m,u)||f("violationError",{error:{message:"The specified phone number does not match the expected pattern",code:"remember_me_phone_error",field:"phone",origin:"client",type:"inline-validation"},timestamp:new Date})},[u,O,f]),q=v((m,l)=>{R(l),Q(m);const E=P(m,l);a({optInPhone:E??m,optInEmail:""})},[a,P]),se=v(m=>{U(m);const l=P(d,u);a({optInPhone:l??d,optInEmail:m})},[P,d,a,u]),ie=v(m=>{N(m);const l=m.includes(T),E=o&&o.vaultPhone||b||I||h,$=o&&o.vaultEmail||A;Q(E),U($);const le=P(E,u);a(l?{optInPhone:le??E,optInEmail:_?"":$}:!1),c(!l),l&&E&&O(E,u),L(l?"click_remember_me_box":"unclick_remember_me_box",{phone:E,email:$})},[u,A,P,O,h,L,a,b,I,o,_,c]);return M(()=>{if(!S.includes(T)||!i)return;const m=!h||h==="",l=I||b||void 0;m&&l&&l!==k.current?(q(l,u),J(l),k.current=l):m||(k.current=l)},[S,h,u,I,b,o,q,i,L,J]),M(()=>{N(p?[T]:[])},[p]),M(()=>{x&&h&&O(h,u)},[]),M(()=>{if(n({schemaId:"shopify_pay_user_optin_ui_impression/1.0",payload:{elementType:"remember_me_box",source:"order_created"}}),i&&s){const m=_?"":A;L("click_remember_me_box",{phone:h,email:A}),a({optInPhone:h,optInEmail:m})}},[i,n,L]),e(Se,{name:"RememberMe",value:S,variant:"group",onChange:ie,children:e(Ie,{id:T,details:e(z,{children:[e(we,{}),_?e(De,{countryCode:u,validationError:D,value:h,onInput:q,onBlur:()=>J(h)}):e(ze,{value:A,onInput:se}),s?null:e(re,{children:e(Ee,{field:_?"phone":"email",link:null})})]}),children:e(Je,{})})})}function Je(){const n=F(),r=Oe(),{autoOptIn:t}=Z();return t?e(V,{children:n("shop_pay_remember_me.label_shop_account","Save my information for a faster checkout with a Shop account")}):r?e(V,{children:n("shop_pay_remember_me.payment_information_only_label","Save my payment information for a faster checkout")}):e(V,{children:n("shop_pay_remember_me.label","Save my information for a faster checkout")})}const qe={title:"Shop",style:{fill:"var(--x-default-color-icon)",width:44,height:17}};function $e(){const r=F()("shop_pay_remember_me.secure_label","Secure and encrypted");return e(W,{columns:["fill","auto"],children:[e(W,{columns:["auto","fill"],spacing:"small400",blockAlignment:"center",children:[e(Ce,{size:"small-200",type:"lock"}),e(Me,{color:"subdued",type:"small",children:r})]}),e(Fe,{children:e(Re,{...qe})})]})}function Ke({variant:n}){const r=F(),t=Be(),[i,s]=K();if(M(()=>{!t&&i&&s(!1)},[t,s,i]),!t)return null;if(n==="minimal")return e(re,{children:[e(B,{spacing:"small100"}),e(ne,{})]});const c=e(ke,{sectionId:"rememberMe",children:e(ne,{})});return n==="compact"?e(Ne,{accessibilityLabel:r("shop_pay_remember_me.title","Remember me"),children:e(z,{children:[e(ee,{level:2,children:r("shop_pay_remember_me.title","Remember me")}),c]})}):e(z,{spacing:"none",children:[e(B,{spacing:"large300"}),e(ee,{level:2,children:r("shop_pay_remember_me.title","Remember me")}),e(B,{}),c,e(B,{spacing:"small100"}),e($e,{})]})}function Qe({localizationExtension:n,index:r}){const t=Ae(),{negotiate:i}=Le(),[s,c]=C(),[o,a]=C(),p=oe(n.fields.value,t),d=n.fields.title.value,{localizedFieldErrors:y}=Te(),_=`$.cart.localizedField.${n.peek().key}`,b=`$.localizationExtension[${r}]`,g=y.find(({target:f})=>f===_),u=f=>{const S=f.violations?.find(w=>{const{code:O,localizedMessage:D,nonLocalizedMessage:P,target:I}=w,k=D??P;if(O==="LOCALIZATION_EXTENSION_FIELD_ERROR"&&I===b)return k});if(!S)return;const{localizedMessage:N,nonLocalizedMessage:x}=S;return N??x};M(()=>{if(g){t.value=g.message;return}if(o){t.value=o;return}t.value=void 0},[t,g,o,s]);const R=()=>{p.onBlur(),c(void 0),a(void 0),i({fieldsToResolve:["localizationExtensions"],include:[],onComplete:f=>{a(u(f)),c("blur")}})};return xe(f=>{a(u(f)),c("submit")}),e(ae,{...p,label:d,name:d,onBlur:R,value:p.value??void 0})}export{Qe as L,Ke as R}; }