import{M as e,S as t,L as i,a as n,A as s,D as a,b as o,P as r,c as l,_ as c,d,e as h,I as u,B as p,f as m,g as _,h as g,i as f,j as v,k as b,l as w,s as y,m as k,n as C,H as S,F as M,o as x,p as T,q as A,r as I,u as E,t as L,v as O,w as q,x as P,y as V,z,C as j,E as $,G as U,J as N,K as W,N as D,O as F,Q as B,R as H,T as R,U as K,V as G,W as Q,X as Y,Y as J,Z as X,$ as Z,a0 as ee,a1 as te,a2 as ie,a3 as ne,a4 as se,a5 as ae,a6 as oe,a7 as re,a8 as le,a9 as ce,aa as de,ab as he,ac as ue,ad as pe,ae as me,af as _e,ag as ge,ah as fe,ai as ve,aj as be,ak as we,al as ye,am as ke,an as Ce,ao as Se,ap as Me,aq as xe,ar as Te,as as Ae,at as Ie,au as Ee,av as Le,aw as Oe,ax as qe,ay as Pe,az as Ve,aA as ze,aB as je,aC as $e,aD as Ue,aE as Ne,aF as We,aG as De,aH as Fe,aI as Be,aJ as He,aK as Re,aL as Ke,aM as Ge,aN as Qe,aO as Ye,aP as Je,aQ as Xe,aR as Ze,aS as et,aT as tt,aU as it,aV as nt,aW as st,aX as at,aY as ot,aZ as rt,a_ as lt,a$ as ct,b0 as dt,b1 as ht,b2 as ut,b3 as pt,b4 as mt,b5 as _t,b6 as gt,b7 as ft,b8 as vt,b9 as bt,ba as wt}from"./chunk.common_DFm6c-Mk.esm.js";class yt extends e{constructor({elementName:e,analyticsTraceId:i}){super({elementName:e,analyticsTraceId:i,flow:t})}trackFollowButtonPageImpression(e){this.trackPageImpression({page:e?i.ComponentLoadedFollowing:i.ComponentLoadedNotFollowing})}trackFollowButtonInViewport(){this.trackPageImpression({page:i.FollowButtonShownInViewport})}trackFollowingGetAppButtonPageImpression(){this.trackPageImpression({page:i.FollowingGetShopAppCta})}trackFollowButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:n.FollowOnShopClicked})}trackFollowingGetAppButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:n.FollowingGetShopAppClick})}}class kt extends e{constructor({elementName:e,analyticsTraceId:t,analyticsContext:i=a.Default,flowVersion:n="unspecified",checkoutVersion:o,checkoutToken:r,shopId:l,shopPermanentDomain:c}){super({elementName:e,analyticsTraceId:t,flow:s[i],flowVersion:n,checkoutVersion:o,checkoutToken:r,shopId:l,shopPermanentDomain:c}),this._emailEnteredUserActionTracked=!1,this._passwordManagerAutofillDetected=!1}trackLoginDefaultButtonClicked(){this.trackShopPayLoginWithShopSdkUserAction({userAction:n.SignInWithShopClicked})}trackEmailEnteredAction(){this._emailEnteredUserActionTracked||(this._emailEnteredUserActionTracked=!0,this.trackShopPayLoginWithShopSdkUserAction({userAction:n.EmailEntered}))}trackPasswordManagerAutofillDetected(){this._passwordManagerAutofillDetected||(this._passwordManagerAutofillDetected=!0,this.trackShopPayLoginWithShopSdkUserAction({userAction:n.PasswordManagerAutofillDetected}))}}class Ct extends kt{constructor({elementName:e,flowVersion:t,analyticsTraceId:i}){super({elementName:e,analyticsTraceId:i,analyticsContext:a.ClassicCustomerAccounts,flowVersion:t})}trackClassicCustomerAccountsLoginPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccountLogin})}trackClassicCustomerAccountsCreateAccountPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccountCreateAccount})}trackClassicCustomerAccountsAccountPageImpression(){this.trackPageImpression({page:i.ClassicCustomerAccount})}trackClassicCustomerAccountsContinueWithShopPageImpression(){this.trackPageImpression({page:i.ContinueWithShop})}trackClassicCustomerAccountsCreateAccountAction(){this.trackShopPayLoginWithShopSdkUserAction({userAction:n.CreateAccountLinkClicked})}}const St=window.location.origin,Mt=()=>St,xt=({version:e,apiKey:t,analyticsTraceId:i,analyticsContext:n,isCompactLayout:s,isFullView:a,flow:l,flowVersion:c,signUpEnabled:d,oauthParams:h,avoidPayAltDomain:u,avoidSdkSession:p,hideCopy:m,modalCustomized:_,popupWindowParams:g,consentChallenge:f,checkoutRedirectUrl:v,checkoutVersion:b,checkoutToken:w,transactionParams:y,shopId:k,requireVerification:C,uxMode:S,error:M})=>"1"===e||"redirect"===S?function(e){return Boolean(void 0!==e&&"clientId"in e&&(null==e?void 0:e.clientId))}(h)?(({oauthParams:e,analyticsTraceId:t,analyticsContext:i,isCompactLayout:n,isFullView:s,flow:a,flowVersion:l,signUpEnabled:c,avoidPayAltDomain:d,hideCopy:h,modalCustomized:u,apiKey:p,popupWindowParams:m,consentChallenge:_,checkoutVersion:g,checkoutToken:f,transactionParams:v,shopId:b,requireVerification:w,uxMode:y,error:k})=>{const{clientId:C,redirectType:S}=e,M=e.scope||"openid email profile",x=e.responseType||"id_token",T=e.responseMode||"web_message",A=e.redirectUri||window.location.origin,{popUpName:I,popUpFeatures:E}=m||{},L="redirect"!==y&&h,O=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({target_origin:window.location.origin,response_mode:T,response_type:x,scope:M,version:"1",client_id:C},S&&{redirect_type:S}),{redirect_uri:A,locale:"es"}),t&&{analytics_trace_id:t}),i&&{analytics_context:i}),o("compact_layout",n)),p&&{apiKey:p}),a&&{flow:a}),l&&{flow_version:l}),e.codeChallenge&&{code_challenge:e.codeChallenge}),e.codeChallengeMethod&&{code_challenge_method:e.codeChallengeMethod}),e.state&&{state:e.state}),g&&{checkout_version:g}),f&&{checkout_token:f}),v&&{transaction_params:v}),b&&{shop_id:b}),k&&{error:k}),o("full_view",s)),o("sign_up_enabled",c)),o("hide_copy",L)),o("customize-modal",u)),o("consent_challenge",_)),o("require_verification",w)),o("preact",!1)),"pop_up"===S?{pop_up_name:I,pop_up_features:E}:{}));return`${r}${d?"/pay/sdk-authorize":"/pay/sdk-session"}?${O}`})({popupWindowParams:g,oauthParams:h,analyticsTraceId:i,analyticsContext:n,isCompactLayout:s,isFullView:a,flow:l,flowVersion:c,signUpEnabled:d,avoidPayAltDomain:u,hideCopy:m,modalCustomized:_,apiKey:t,consentChallenge:f,checkoutVersion:b,checkoutToken:w,transactionParams:y,shopId:k,requireVerification:C,uxMode:S,error:M}):"":(({analyticsTraceId:e,analyticsContext:t,isCompactLayout:i,isFullView:n,flow:s,flowVersion:a,signUpEnabled:r,avoidSdkSession:l,hideCopy:c,modalCustomized:d,apiKey:h,consentChallenge:u,checkoutRedirectUrl:p,checkoutVersion:m,checkoutToken:_,transactionParams:g,shopId:f,requireVerification:v,oauthParams:b,error:w})=>{const y=new URLSearchParams(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({target_origin:window.location.origin,api_key:null!=h?h:"123",locale:"es"},e&&{analytics_trace_id:e}),t&&{analytics_context:t}),o("compact_layout",i)),s&&{flow:s}),a&&{flow_version:a}),p&&{checkout_redirect_url:p}),m&&{checkout_version:m}),_&&{checkout_token:_}),g&&{transaction_params:g}),f&&{shop_id:f}),w&&{error:w}),o("full_view",n)),o("sign_up_enabled",r)),o("avoid_sdk_session",l)),o("hide_copy",c)),o("customize-modal",d)),o("consent_challenge",u)),o("require_verification",v)),o("preact",!1)),(null==b?void 0:b.responseType)&&{response_type:b.responseType}),(null==b?void 0:b.redirectType)&&{redirect_type:b.redirectType}));return`${St}/services/login_with_shop/authorize?${y}`})({analyticsTraceId:i,analyticsContext:n,isCompactLayout:s,isFullView:a,flow:l,flowVersion:c,signUpEnabled:d,avoidSdkSession:p,hideCopy:m,modalCustomized:_,apiKey:t,consentChallenge:f,checkoutRedirectUrl:v,checkoutVersion:b,checkoutToken:w,transactionParams:y,shopId:k,requireVerification:C,oauthParams:h,error:M});var Tt,At,It,Et;class Lt extends HTMLElement{constructor(){super(),Tt.add(this),At.set(this,null),It.set(this,null),customElements.get("shop-logo")||customElements.define("shop-logo",l)}connectedCallback(){return c(this,void 0,void 0,(function*(){if(yield d(this,Tt,"m",Et).call(this),this.shadowRoot)return;const e=document.createElement("template");if(e.innerHTML=`\n \n \n `,h(this,At,this.attachShadow({mode:"open"}),"f"),d(this,At,"f").appendChild(e.content.cloneNode(!0)),d(this,It,"f")){const e=d(this,It,"f").translate("login_with_shop.login",{shop:Ot("white")});d(this,At,"f").querySelector('slot[name="login-text"]').innerHTML=e}}))}setFocused(){var e,t;null===(t=null===(e=d(this,At,"f"))||void 0===e?void 0:e.querySelector("button"))||void 0===t||t.focus()}}function Ot(e){return``}At=new WeakMap,It=new WeakMap,Tt=new WeakSet,Et=function(){return c(this,void 0,void 0,(function*(){try{const e="es",t={follow_on_shop:{follow:"Seguir en {shop}",following:"La sigues en {shop}",auth_modal:{title:"Seguir en Shop",description:"Mantente al día: no te pierdas ninguna venta, reposición o actualización de pedido."},following_modal:{title:"Visitar {store} en Shop",subtitle:"Todo lo que necesitas para comprar, hacer seguimientos y efectuar pagos desde un único lugar.",qr_header:"Escanear para visitar {store} en la aplicación Shop",qr_alt_text:"Código QR de la aplicación Shop",continue:"Continuar"},completed:{title:"Sigues a {store}",subtitle:"Te enviamos un correo electrónico con un enlace para descargar la aplicación Shop."},personalization_consent:{title:"Para hacer seguimiento en Shop, sincroniza tu actividad de compra"}},login_with_shop:{login:"Iniciar sesión con {shop}",auth_modal:{login_title:"Iniciar sesión con Shop",login_description:"La forma más fácil y segura de iniciar sesión en {store} (no requiere contraseña).",signup_title:"Crear una cuenta",signup_description:"Introduce tu número de teléfono para crear una cuenta de Shop.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código enviado a {phoneNumber}.",login_email_title:"Confirma que eres tú",login_email_description:"Ingresa el código enviado a tu correo electrónico, {email}.",login_title_with_store:"Iniciar sesión en {store} con Shop",login_webauthn_title:"Confirma que eres tú",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada.",login_webauthn_footer:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},customer_accounts:{remember_me:"Guardar mi información de forma segura con Shop para iniciar sesión rápidamente en cualquier sitio",sign_up_page:{auth_modal:{login_title:"Continuar con Shop",login_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.",login_sms_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a {phoneNumber}.",login_email_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a tu correo electrónico, {email}.",login_webauthn_title:"Continuar con Shop",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada."}}},verified_email_auth:{auth_modal:{login_title:"Inicia sesión o regístrate",signup_title:"Continuar con Shop",signup_description:"Crea una cuenta de Shop para iniciar sesión en {clientName}, sin necesidad de contraseña."}},legal:{terms_of_service:"Términos del Servicio",privacy_policy:"política de privacidad",terms:"términos",client:"Consulta la {termsOfService} y los {privacyPolicy} de {clientName}.",shop:"Al continuar, aceptas los {termsOfService} y la {privacyPolicy} de Shop.",authorized_scopes:{email_name:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},payment_request:{auth_modal:{login_title:"Pagar con Shop Pay",login_description:"Usa tu información guardada para formalizar el pago de manera segura en {store}.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código que se envió al {phoneNumber} para usar tu información guardada de forma segura.",login_email_title:"Confirma que eres tú",login_email_description:"Introduce el código que se envió a tu correo electrónico {email} para usar tu información guardada de forma segura."}},checkout_modal:{auth_modal:{login_sms_description:"Ingresa el código que se envió al {phoneNumber} para usar de forma segura tu información guardada.",login_email_description:"Ingresa el código que se envió a tu correo electrónico ({email}) para usar de forma segura tu información guardada."}}};h(this,It,new u({[e]:t}),"f")}catch(e){e instanceof Error&&p.notify(e)}return null}))},customElements.get("login-with-shop-button")||customElements.define("login-with-shop-button",Lt);function qt(e){if(!f.isSupported)throw new Error("Sanitization of custom modal text is not supported in this browser.");return f.sanitize(e,{ALLOWED_TAGS:[]})}const Pt={step:v.Start,configurable:!1,headerVisible:!1,headerDividerVisible:!1,headerTemplate:"",descriptionTemplate:"",userNameKnown:!1,sessionDetected:!1,templateVariables:{clientName:"the store",store:"the store"}};function Vt(e,t){switch(e.type){case b.Init:return e.payload.personalizeConsentChallenge?Object.assign(Object.assign({},t),{step:v.PersonalizeConsent,headerVisible:!0,headerDividerVisible:!1,userNameKnown:e.payload.userNameKnown||!1,templateVariables:Object.assign(Object.assign(Object.assign({},t.templateVariables),e.payload),{store:e.payload.clientName}),headerTemplate:"login_with_shop.auth_modal.login_title_with_store",descriptionTemplate:"",sessionDetected:e.payload.userFound}):Object.assign(Object.assign({},t),{configurable:!0,headerVisible:!0,headerDividerVisible:e.payload.userFound,step:e.payload.userFound?v.OneClick:v.Start,userNameKnown:e.payload.userNameKnown||!1,templateVariables:Object.assign(Object.assign(Object.assign({},t.templateVariables),e.payload),{store:e.payload.clientName}),headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description",sessionDetected:e.payload.userFound});case b.PopUpOpened:return Object.assign(Object.assign({},t),{step:v.PopUpOpened});case b.Restart:return Object.assign(Object.assign({},t),{configurable:!0,headerDividerVisible:!1,step:v.Start,userNameKnown:!1,headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description",sessionDetected:!1,templateVariables:Object.assign(Object.assign({},t.templateVariables),{email:"",phoneNumber:"",userFound:!1,userNameKnown:!1})});case b.UserMatched:return e.payload.personalizeConsentChallenge?Object.assign(Object.assign({},t),{step:v.PersonalizeConsent,userNameKnown:e.payload.hasName||!1,headerVisible:!0,headerDividerVisible:!1,headerTemplate:"login_with_shop.auth_modal.login_title_with_store",descriptionTemplate:"",sessionDetected:e.payload.userCookieExists}):e.payload.userCookieExists?Object.assign(Object.assign({},t),{configurable:!0,headerDividerVisible:!0,step:v.OneClick,userNameKnown:e.payload.hasName||!1,sessionDetected:!0}):Object.assign(Object.assign({},t),{userNameKnown:e.payload.hasName||!1,sessionDetected:!1});case b.UserNotMatched:return Object.assign(Object.assign({},t),{step:v.SignUp,headerDividerVisible:!0,userNameKnown:!1,configurable:!1,headerTemplate:"login_with_shop.auth_modal.signup_title",descriptionTemplate:"login_with_shop.auth_modal.signup_description",sessionDetected:!1});case b.VerificationStepChanged:{const{step:i,phone:n="",email:s=""}=e.payload;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),{step:zt(i),configurable:!1,headerDividerVisible:!0,templateVariables:Object.assign(Object.assign({},t.templateVariables),{phoneNumber:n.replaceAll(" "," "),email:s}),legalTextVariant:"authorize"}),"email"===i&&{headerTemplate:"login_with_shop.auth_modal.login_email_title",descriptionTemplate:"login_with_shop.auth_modal.login_email_description"}),"sms"===i&&{headerTemplate:"login_with_shop.auth_modal.login_sms_title",descriptionTemplate:"login_with_shop.auth_modal.login_sms_description"}),"one_click"===i&&{headerTemplate:"login_with_shop.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_description"}),"webauthn"===i&&{headerTemplate:"login_with_shop.auth_modal.login_webauthn_title",descriptionTemplate:"login_with_shop.auth_modal.login_webauthn_description",legalTextVariant:"generic",legalTextTemplate:"login_with_shop.auth_modal.login_webauthn_footer",headerDividerVisible:!1})}}return t}function zt(e){switch(e){case"one_click":return v.OneClick;case"email":return v.EmailVerification;case"webauthn":return v.WebAuthnVerification;default:return v.PhoneVerification}}class jt{get _sheetModal(){return this._sheetModalManager.sheetModal}constructor(e,t){this._isCompact=!1,this._isHeaderless=!1,this._analyticsContext=a.Default,this._flowVersion="unspecified",this._authenticationLevel=w.Phone,this._state=Pt,this._rootElement=e,this._sheetModalManager=y().build(),({onOpen:this._onOpen,onClose:this._onClose}=t)}setCompact(e){this._isCompact=e}setHeaderless(e){this._isHeaderless=e}init(){var e,t,i,n;const s=this.getModalAttributes();k(C(s),"shop-login-default-landing",this._sheetModalManager.shadowRoot),this._modalHeader=this._sheetModalManager.shadowRoot.querySelector(`.${S}`),this._footerElement=this._sheetModalManager.shadowRoot.querySelector(`.${M}`),this._footerContent=this._sheetModalManager.shadowRoot.querySelector(`.${x}`),this._iframe=this._sheetModalManager.shadowRoot.querySelector(`.${T}`),this._sheetModal.addEventListener("modalcloserequest",(()=>c(this,void 0,void 0,(function*(){yield this.closeAuthorizeModal({modalStateChangeReason:"user_dismissed"})})))),this._isCompact&&(this._sheetModal.setAttribute(A,""),this._sheetModal.setMonorailTracker(this._monorailTracker),this._iframe.classList.add(I),null===(t=null===(e=this._modalHeader)||void 0===e?void 0:e.parentNode)||void 0===t||t.removeChild(this._modalHeader),null===(n=null===(i=this._footerElement)||void 0===i?void 0:i.parentNode)||void 0===n||n.removeChild(this._footerElement)),E(this._iframe,"allow","publickey-credentials-get *")}setModalAnalyticsTraceId(e){this._sheetModal.setAttribute(L,e)}showModal(e){return c(this,void 0,void 0,(function*(){(yield this._sheetModal.open(e))&&this._onOpen(),this.refreshHeaderIframeHeight()}))}openAuthorizeModal(e){return c(this,void 0,void 0,(function*(){var t;yield this.showModal(e),yield null===(t=this._monorailTracker)||void 0===t?void 0:t.trackPageImpression({page:i.AuthorizeModal})}))}closeAuthorizeModal(){return c(this,arguments,void 0,(function*({modalStateChangeReason:e}={}){var t;if(this._sheetModal){(yield this._sheetModal.close({reason:e}))&&this._onClose()}null===(t=this._continueButton)||void 0===t||t.setFocused()}))}destroy(){this._sheetModalManager.destroy()}setContinueButtonVisible(e){var t,n,s;if(!e)return null===(t=this._continueButton)||void 0===t||t.remove(),void(this._continueButton=void 0);this._continueButton||(this._continueButton=document.createElement("login-with-shop-button"),null===(n=this._continueButton)||void 0===n||n.addEventListener("click",(()=>{var e;null===(e=this._monorailTracker)||void 0===e||e.trackLoginDefaultButtonClicked(),"redirect"===this._uxMode&&this._authorizeUrl?window.location.href=this._authorizeUrl:this.openAuthorizeModal("user_button_clicked")})),null===(s=this._monorailTracker)||void 0===s||s.trackPageImpression({page:i.SignInWithShopButton}),this._rootElement.appendChild(this._continueButton))}setMonorailTracker(e){var t,i;this._monorailTracker=e,null===(i=(t=this._sheetModal).setMonorailTracker)||void 0===i||i.call(t,e)}setAnalyticsContext(e){this._analyticsContext=e}setFlowVersion(e){this._flowVersion=e}getUxMode(){return this._uxMode}setUxMode(e){e&&(this._uxMode=e)}setAuthorizeUrl(e){this._authorizeUrl=e}setAuthenticationLevel(e){this._authenticationLevel=e}onContentLoaded(){this._sheetModal.onContentLoaded()}setFlow(e){this._flow=e,this._sheetModalManager.setNametagSuffix(e)}getIframe(){return this._iframe}setAnchorSelector(e){this._sheetModal.setAttribute(O,e)}setBrand(e){e&&this._sheetModal.setAttribute("modal-brand",e)}resizeIframe(e,t){this._iframe&&(this._iframe.style.height=`${e}px`,this._iframe.style.width=`${q(t,this._iframe)}px`)}render(){const{configurable:e,headerVisible:t,headerDividerVisible:i}=this._state;this.setHeaderVisible(t),this.setHeaderDividerVisible(i),e&&this._modalLogoSrc&&this.updateHeaderLogo(this._modalLogoSrc),this.renderHeaderTemplate(),this.renderHeaderDescriptionTemplate(),this.renderFooterContent(),this.refreshHeaderIframeHeight()}dispatch(e){switch(this._analyticsContext){case a.CheckoutExtension:case a.Default:this._state=this._authenticationLevel===w.Phone?Vt(e,this._state):function(e,t){const i=Vt(e,t);switch(i.step){case v.Start:return Object.assign(Object.assign({},i),{headerTemplate:"verified_email_auth.auth_modal.login_title",descriptionTemplate:""});case v.SignUp:return Object.assign(Object.assign({},i),{headerTemplate:"verified_email_auth.auth_modal.signup_title",descriptionTemplate:"verified_email_auth.auth_modal.signup_description"});case v.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"login_with_shop.auth_modal.login_sms_title",descriptionTemplate:"login_with_shop.auth_modal.login_sms_description"});case v.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"login_with_shop.auth_modal.login_email_title",descriptionTemplate:"login_with_shop.auth_modal.login_email_description"})}return i}(e,this._state);break;case a.ClassicCustomerAccounts:this._state="sign_up"===this._flowVersion?function(e,t){const i=Vt(e,t);switch(i.step){case v.Start:case v.OneClick:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_description"});case v.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_sms_description"});case v.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"customer_accounts.sign_up_page.auth_modal.login_email_description"});case v.WebAuthnVerification:return Object.assign(Object.assign({},i),{headerTemplate:"customer_accounts.sign_up_page.auth_modal.login_title",descriptionTemplate:"login_with_shop.auth_modal.login_webauthn_description"})}return i}(e,this._state):Vt(e,this._state);break;case a.CheckoutModal:this._state=function(e,t){const i=Vt(e,t);switch(i.step){case v.PhoneVerification:return Object.assign(Object.assign({},i),{descriptionTemplate:"checkout_modal.auth_modal.login_sms_description"});case v.EmailVerification:return Object.assign(Object.assign({},i),{descriptionTemplate:"checkout_modal.auth_modal.login_email_description"})}return i}(e,this._state);break;case a.PaymentRequest:this._state=function(e,t){const i=Vt(e,t);switch(i.step){case v.PopUpOpened:case v.OneClick:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_title",descriptionTemplate:"payment_request.auth_modal.login_description"});case v.PhoneVerification:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_sms_title",descriptionTemplate:"payment_request.auth_modal.login_sms_description"});case v.EmailVerification:return Object.assign(Object.assign({},i),{headerTemplate:"payment_request.auth_modal.login_email_title",descriptionTemplate:"payment_request.auth_modal.login_email_description"})}return i}(e,this._state);break;default:this._state=Pt}this._isCompact||this.render()}updateHeaderLogo(e){var t,i;if(!this._headerLogo){this._headerLogo=document.createElement("img");const e=null===(t=this._headerContentsContainer)||void 0===t?void 0:t.firstChild;e&&(null===(i=this._headerContentsContainer)||void 0===i||i.insertBefore(this._headerLogo,e))}this._headerLogo.src=e,this._headerLogo.style.maxHeight="64px",this._headerLogo.style.width="auto"}renderHeaderTemplate(){var e;const{configurable:t,headerTemplate:i,templateVariables:n}=this._state;let s="";if(t&&this._modalTitle)try{s=this._modalTitle.replace(/\${storeName}/gi,n.clientName)}catch(e){if(e instanceof Error&&e.message.includes("replaceAll is not a function"))return void p.notify(new Error("modalTitle is not a string. Expected string, received "+typeof this._modalTitle));throw e}else i&&(s=(null===(e=this._i18n)||void 0===e?void 0:e.translate(i,n))||"");"string"==typeof s&&(this._headerTitle.textContent=s)}renderHeaderDescriptionTemplate(){var e,t;const{configurable:i,descriptionTemplate:n,templateVariables:s}=this._state;let a="";i&&this._modalDescription?a=null===(e=this._modalDescription)||void 0===e?void 0:e.replace(/\${storeName}/gi,s.clientName):n&&(a=(null===(t=this._i18n)||void 0===t?void 0:t.translate(n,s))||""),"string"==typeof a&&(this._headerDescription.textContent=a)}renderFooterContent(){if(!this._i18n)return;const{step:e,templateVariables:t,sessionDetected:i}=this._state,{clientName:n,privacyPolicyUrl:s,termsOfServiceUrl:o}=t;let r="";switch(e){case v.PersonalizeConsent:case v.EmailVerification:case v.PhoneVerification:case v.WebAuthnVerification:case v.OneClick:{if(e===v.PersonalizeConsent&&!i)break;if(this._analyticsContext===a.PaymentRequest)break;const l=this._i18n.translate("legal.authorized_scopes.email_name",t);if(!s||!o){r=l;break}r=`${l} ${this._i18n.translate("legal.client",{clientName:n,privacyPolicy:`${this._i18n.translate("legal.privacy_policy")}`,termsOfService:`${this._i18n.translate("legal.terms")}`})}`;break}case v.SignUp:{const e=`${this._i18n.translate("legal.terms_of_service")}`,t=`${this._i18n.translate("legal.privacy_policy")}`;r=this._i18n.translate("legal.shop",{clientName:n,termsOfService:e,privacyPolicy:t});break}}this._footerContent.innerHTML=r,this.setFooterVisible(Boolean(r))}setHeaderVisible(e){var t;if(this._modalHeader.classList.toggle(P,!e),!this._headerIframe){this._headerIframe=this._sheetModalManager.shadowRoot.querySelector(`.${S}-container`);const e=null===(t=this._headerIframe.contentDocument)||void 0===t?void 0:t.querySelector("body");e.innerHTML=V,this._headerContentsContainer=document.createElement("div"),this._headerContentsContainer.classList.add(z),this._headerTitle=document.createElement("h2"),this._headerTitle.classList.add(j),this._headerDescription=document.createElement("div"),this._headerDescription.classList.add($),this._headerContentsContainer.appendChild(this._headerTitle),this._headerContentsContainer.appendChild(this._headerDescription),"pop_up"===this._flow&&(this._headerContentsContainer.style.display="flex",this._headerContentsContainer.style.flexDirection="column"),e.appendChild(this._headerContentsContainer),window.ResizeObserver?(this._headerResizeObserver=new ResizeObserver((()=>{this.refreshHeaderIframeHeight()})),this._headerResizeObserver.observe(this._headerContentsContainer)):this.refreshHeaderIframeHeight()}}refreshHeaderIframeHeight(){var e,t,i,n;const s=null===(t=null===(e=this._headerIframe)||void 0===e?void 0:e.contentDocument)||void 0===t?void 0:t.querySelector("body"),a=`${null===(i=this._headerContentsContainer)||void 0===i?void 0:i.getBoundingClientRect().height}px`;null==s||s.setAttribute("height",a),null===(n=this._headerIframe)||void 0===n||n.setAttribute("height",a)}setHeaderDividerVisible(e){this._modalHeader.classList.toggle(U,e)}setFooterVisible(e){this._footerElement.classList.toggle(P,!e)}setCloseButtonVisible(e){this._sheetModal.setCloseButtonVisibility(e)}setCustomizedModalContent({modalTitle:e,modalDescription:t,modalLogo:i}){e&&(this._modalTitle=qt(e)),t&&(this._modalDescription=qt(t)),i&&(this._modalLogoSrc=qt(i))}getCustomizedModalContent(){return{modalTitle:this._modalTitle,modalDescription:this._modalDescription,modalLogo:this._modalLogoSrc}}setTranslations(e){this._i18n=e}isModalCustomized(){return Boolean(this._modalTitle||this._modalDescription||this._modalLogoSrc)}getModalAttributes(){var e,t;const i=null!==(t=null===(e=this._sheetModal)||void 0===e?void 0:e.getAttributeNames())&&void 0!==t?t:[];return N(this._isCompact,A,i),N(this._isHeaderless,W,i),i.map((e=>{var t;const i=null===(t=this._sheetModal)||void 0===t?void 0:t.getAttribute(e);return i?`${e}="${i}"`:e})).join(" ")}}const $t=[a.Default,a.CheckoutExtension,a.CheckoutModal,a.ClassicCustomerAccounts,a.PaymentRequest];var Ut,Nt,Wt,Dt,Ft,Bt,Ht,Rt,Kt,Gt,Qt,Yt,Jt,Xt,Zt,ei,ti,ii,ni,si;const ai=[D.CaptchaChallenge];class oi extends B{static get observedAttributes(){return[O,H,R,K,G,Q,Y,J,X,Z,ee,L,te,ie,ne,se,ae,oe,re,le,ce,de,he,m,_,g,ue,pe,me,_e,ge,fe,ve,be,we,ye,ke,Ce,Se,Me,xe]}constructor(){super(),Ut.add(this),Nt.set(this,Te()),Wt.set(this,""),Dt.set(this,"2"),Ft.set(this,window.location.origin),Bt.set(this,new kt({elementName:"shop-login-default",analyticsTraceId:d(this,Nt,"f")})),Ht.set(this,void 0),Rt.set(this,void 0),Kt.set(this,void 0),Gt.set(this,void 0),Qt.set(this,void 0),Yt.set(this,null),this._disableSignUp=!1,this._autoOpen=!1,this._autoOpened=!1,this._analyticsContext=a.Default,this._avoidPayAltDomain=!1,this._avoidSdkSession=!1,this._flow=Ae.Default,this._flowVersion="unspecified",this._error="",this._hideButton=!1,this._anchorSelector="",this._isCompactLayout=!1,this._hidePayCopy=!1,this._email="",this._authorizeModalOpened=!1,this._keepModalOpen=!1,this._requireVerification=!1,this._shouldListenToResizeMessage=!0,Jt.set(this,(()=>{this._updateSrc(!0)})),Xt.set(this,(()=>{var e;this.dispatchCustomEvent("modalclosed"),null===(e=this._iframeMessenger)||void 0===e||e.postMessage({type:"sheetmodalclosed"}),Ie()})),Zt.set(this,(()=>{var e;this.dispatchCustomEvent("modalopened"),null===(e=this._iframeMessenger)||void 0===e||e.postMessage({type:"sheetmodalopened"})})),ei.set(this,(e=>{var t,i;const n=Ee(this._analyticsContext);var s;return this._hidePayCopy=!n&&(s=this._analyticsContext,$t.includes(s)),!(!e&&this._isCompactLayout===n)&&(this._isCompactLayout=n,null===(t=this._view)||void 0===t||t.setCompact(this._isCompactLayout),null===(i=this._view)||void 0===i||i.init(),!0)})),this._rootElement=this.attachShadow({mode:"open"}),this._analyticsContext=this.getAttribute(ee)||a.Default,this._view=new jt(this._rootElement,{onOpen:d(this,Zt,"f"),onClose:d(this,Xt,"f")}),d(this,ei,"f").call(this,!0),this._debouncedUpdateUserInfo=Le((({email:e,firstName:t,lastName:i})=>{var n;(null===(n=this._passwordManagerDetection)||void 0===n?void 0:n.isFilledWithPasswordManager())&&d(this,Bt,"f").trackPasswordManagerAutofillDetected(),this._updateUserInfo({email:e,firstName:t,lastName:i}),We(e)&&d(this,Bt,"f").trackEmailEnteredAction()}),Je),this._payLoadedResolve=()=>{},this._payLoaded=new Promise((e=>{this._payLoadedResolve=e}))}attributeChangedCallback(e,t,i){var n,s,o,r,l,c,u,p,f,v;const b=Boolean(null!==i);switch(e){case R:h(this,Dt,i,"f"),this._updateSrc();break;case H:h(this,Wt,i||"","f"),this._updateSrc();break;case te:this._responseType=i||"",this._updateSrc();break;case ie:this._responseMode=i||"",this._updateSrc();break;case ne:this._codeChallenge=i||"",this._updateSrc();break;case se:this._codeChallengeMethod=i||"",this._updateSrc();break;case ae:this._state=i||"",this._updateSrc();break;case oe:this._scope=i||"",this._updateSrc();break;case K:h(this,Ft,i||window.location.origin,"f"),Oe(d(this,Ft,"f"));break;case G:this._hideButton=b,null===(n=this._view)||void 0===n||n.setContinueButtonVisible(b),this._updateSrc();break;case re:this._avoidPayAltDomain=b,this._updateSrc();break;case le:this._avoidSdkSession=b,this._updateSrc();break;case ce:this._flow=i||Ae.Default,null===(s=this._view)||void 0===s||s.setFlow(this._flow),this._updateSrc();break;case de:this._flowVersion=i||"unspecified",null===(o=this._view)||void 0===o||o.setFlowVersion(this._flowVersion),this._updateMonorailTracker(),this._updateSrc();break;case Q:this._disableSignUp=b,this._updateSrc();break;case Y:this._autoOpen=b;break;case J:h(this,Ht,"pop_up"===i||"iframe"===i?i:"top_frame","f"),this._updateSrc();break;case X:h(this,Rt,i||void 0,"f"),this._updateSrc();break;case Z:h(this,Kt,i||void 0,"f"),null===(r=this._view)||void 0===r||r.setUxMode(d(this,Kt,"f")),this._updateSrc();break;case ee:this._analyticsContext=i||a.Default,null===(l=this._view)||void 0===l||l.setAnalyticsContext(this._analyticsContext),d(this,ei,"f").call(this),this._updateMonorailTracker(),this._updateSrc();break;case L:h(this,Nt,i||Te(),"f"),this._updateMonorailTracker(),this._updateSrc();break;case he:this._initEmail(i||"");break;case O:this._anchorSelector=i||"",null===(c=this._view)||void 0===c||c.setAnchorSelector(i||"");break;case m:null===(u=this._view)||void 0===u||u.setCustomizedModalContent({modalTitle:i||void 0}),this._updateSrc();break;case _:null===(p=this._view)||void 0===p||p.setCustomizedModalContent({modalDescription:i||void 0}),this._updateSrc();break;case g:null===(f=this._view)||void 0===f||f.setCustomizedModalContent({modalLogo:i||void 0}),this._updateSrc();break;case ue:this._apiKey=i||void 0,this._updateSrc();break;case pe:h(this,Gt,i||void 0,"f"),this._updateSrc();break;case me:h(this,Qt,i||void 0,"f"),this._updateSrc();break;case _e:null===(v=this._view)||void 0===v||v.setBrand(i||void 0);break;case ge:this._consentChallenge=b,this._updateSrc();break;case fe:this._checkoutRedirectUrl=i||void 0,this._updateSrc();break;case ve:this._checkoutVersion=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case be:this._checkoutToken=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case we:this._transactionParams=i||void 0,this._updateSrc();break;case ye:this._shopId=i||void 0,this._updateSrc(),this._updateMonorailTracker();break;case ke:this._shopPermanentDomain=i||void 0,this._updateMonorailTracker();break;case Ce:this._firstName=i||void 0;break;case Se:this._lastName=i||void 0;break;case Me:this._requireVerification=b,this._updateSrc();break;case xe:this._source=i||"unspecified"}}connectedCallback(){return c(this,void 0,void 0,(function*(){this.subscribeToHub(qe.UserStatusIdentity,d(this,Jt,"f")),this._keepModalOpen=this.getBooleanAttribute(Pe),this._hideButton=this.getBooleanAttribute(G),this._apiKey=this.getAttribute(ue)||void 0,this._source=this.getAttribute(xe)||"unspecified";try{!function({modalTitle:e,modalDescription:t,modalLogo:i},n){if(Boolean(e||t||i)&&!n)throw new Error("An API key must be provided if the modal content is customized");if(e&&e.length>150)throw new Error(`${m} cannot exceed 150 characters.`);if(t&&t.length>300)throw new Error(`${_} cannot exceed 300 characters.`);if(i)try{new URL(i)}catch(e){throw new Error(`${g} must be a valid URL`)}}(this._view.getCustomizedModalContent(),this._apiKey),yield d(this,Ut,"m",ti).call(this),yield this._initElements(),Oe(d(this,Ft,"f")),d(this,Bt,"f").trackFeatureInitialization({apiKey:this._apiKey,source:this._source})}catch(e){e instanceof Error&&(Ve(`Invalid config. ${e.message}`),this._handleError("invalid_config",D.ApiUnavailable))}}))}_initElements(){return c(this,void 0,void 0,(function*(){var e,t;if(!this._view)return;this._view.setModalAnalyticsTraceId(d(this,Nt,"f")),this._view.setMonorailTracker(d(this,Bt,"f")),this._view.setAnchorSelector(this._anchorSelector),this._view.setContinueButtonVisible(!this._hideButton),this._iframe=this._view.getIframe(),this._updateSrc();const i=(null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0;this._iframeListener=new ze(new je(this._iframe),[r,$e,d(this,Ft,"f")],d(this,Ut,"m",si).bind(this),i),this._iframeMessenger=new Ue(this._iframe);const{userFound:n}=yield this._iframeListener.waitForMessage("loaded");this._payLoadedResolve({userFound:n}),this.dispatchCustomEvent("iframeloaded"),d(this,Bt,"f").trackShopPayModalStateChange({currentState:Ne.Loaded,reason:"event_loaded"}),d(this,Ut,"m",ni).call(this),n&&this._autoOpen&&!this._autoOpened&&(null===(t=this._updateEmailAbortController)||void 0===t||t.abort(),this._autoOpened=!0,yield this._view.openAuthorizeModal("event_loaded_with_auto_open"))}))}_initEmail(e){this._email=e,We(this._email)?this._debouncedUpdateUserInfo({email:this._email,firstName:this._firstName,lastName:this._lastName}):this._debouncedUpdateUserInfo({email:""})}disconnectedCallback(){var e,t;this.unsubscribeAllFromHub(),null===(e=this._iframeListener)||void 0===e||e.destroy(),null===(t=this._view)||void 0===t||t.destroy(),this.stopListeningToInput()}setShouldListenToResizeMessage(e){this._shouldListenToResizeMessage=e}requestShow(e){return c(this,void 0,void 0,(function*(){var t;yield this._payLoaded,this._authorizeModalOpened?p.notify(new Error("requestShow called when the modal is not closed")):(e&&this._updateUserInfo({email:e,firstName:this._firstName,lastName:this._lastName}),yield this._payLoaded,yield null===(t=this._view)||void 0===t?void 0:t.openAuthorizeModal("user_button_clicked"))}))}setPasswordManagerDetection(e){this._passwordManagerDetection=e}listenToInput(e){this.stopListeningToInput();const t=Le((e=>{We(e)?(this._updateUserInfo({email:e}),d(this,Bt,"f").trackEmailEnteredAction()):this._updateUserInfo({email:""})}),Je);t(e.value),this._inputListener=new De(e,t)}getIframe(){var e;return null===(e=this._view)||void 0===e?void 0:e.getIframe()}ensureIframeIsLoaded(){return this._payLoaded.then((()=>{}))}stopListeningToInput(){var e;null===(e=this._inputListener)||void 0===e||e.destroy()}_updateUserInfo(e){return c(this,arguments,void 0,(function*({email:e,firstName:t="",lastName:i=""}){var n,s;if(!this._authorizeModalOpened){this._updateEmailAbortController&&!(null===(n=this._updateEmailAbortController)||void 0===n?void 0:n.signal.aborted)&&this._updateEmailAbortController.abort(),this._updateEmailAbortController=new AbortController;try{const{userFound:n}=yield this._payLoaded;if(n&&this._autoOpen&&!this._autoOpened)return;this._iframeMessenger.postMessage({type:"namesubmitted",firstName:t,lastName:i}),this._iframeMessenger.postMessage({type:"emailsubmitted",email:e,hideChange:e.length>0});const a=this._iframeListener.waitForMessage("shop_user_matched",this._updateEmailAbortController.signal),o=new Promise(((e,t)=>{const i=()=>c(this,void 0,void 0,(function*(){try{const{code:t}=yield this._iframeListener.waitForMessage("error",this._updateEmailAbortController.signal);t===D.CaptchaChallenge?e(void 0):i()}catch(e){t(e)}}));i()}));yield Promise.race([a,o]),yield null===(s=this._view)||void 0===s?void 0:s.openAuthorizeModal("event_shop_user_matched"),this._updateEmailAbortController.abort()}catch(e){if(e instanceof Fe)return;e instanceof Error&&p.notify(new Error(`Error updating user info: ${e.name} - ${e.message}`))}}}))}_updateSrc(e){var t,i,n;const s=null===(t=this._view)||void 0===t?void 0:t.getIframe();if(!s&&"redirect"!==(null===(i=this._view)||void 0===i?void 0:i.getUxMode()))return;const a=this._buildAuthorizeUrl();null===(n=this._view)||void 0===n||n.setAuthorizeUrl(a),s&&a&&(this._updateListeners(s),this._iframeSrcTimeout&&clearTimeout(this._iframeSrcTimeout),this._iframeSrcTimeout=setTimeout((()=>{d(this,Ut,"m",ii).call(this),Be(s,a,e),p.leaveBreadcrumb("Iframe url updated",{authorizeUrl:a},"state")}),0))}_buildAuthorizeUrl(){var e;const t={clientId:d(this,Wt,"f"),responseType:this._responseType,responseMode:this._responseMode,redirectType:d(this,Ht,"f"),redirectUri:d(this,Rt,"f"),codeChallenge:this._codeChallenge,codeChallengeMethod:this._codeChallengeMethod,state:this._state,scope:this._scope},i=null===(e=this._view)||void 0===e?void 0:e.isModalCustomized();return xt(Object.assign(Object.assign({version:d(this,Dt,"f"),analyticsTraceId:d(this,Nt,"f"),analyticsContext:this._analyticsContext,isCompactLayout:this._isCompactLayout,flow:this._flow,flowVersion:this._flowVersion,signUpEnabled:!this._disableSignUp,oauthParams:t,avoidPayAltDomain:this._avoidPayAltDomain,avoidSdkSession:this._avoidSdkSession,hideCopy:this._hidePayCopy},i&&{modalCustomized:i}),{apiKey:this._apiKey,popupWindowParams:{popUpName:d(this,Gt,"f"),popUpFeatures:d(this,Qt,"f")},consentChallenge:this._consentChallenge,checkoutRedirectUrl:this._checkoutRedirectUrl,checkoutVersion:this._checkoutVersion,checkoutToken:this._checkoutToken,transactionParams:this._transactionParams,shopId:this._shopId,requireVerification:this._requireVerification,uxMode:d(this,Kt,"f"),error:this._error}))}_updateListeners(e){this._iframeListener&&(this._iframeListener.eventSource=new je(e)),this._iframeMessenger&&(this._iframeMessenger.eventDestination=e)}_updateMonorailTracker(){var e;h(this,Bt,new kt({elementName:"shop-login-default",analyticsTraceId:d(this,Nt,"f"),analyticsContext:this._analyticsContext,flowVersion:this._flowVersion,shopId:He(this._shopId),shopPermanentDomain:this._shopPermanentDomain,checkoutVersion:this._checkoutVersion,checkoutToken:this._checkoutToken}),"f"),null===(e=this._view)||void 0===e||e.setMonorailTracker(d(this,Bt,"f"))}_handleCompleted(e,t,i,n,s,a,o,r){return c(this,void 0,void 0,(function*(){var l,c;e&&s&&(yield Re(d(this,Ft,"f"),p.notify),this.publishToHub(qe.UserSessionCreate,{email:o||t,initial:o||(null==t?void 0:t[0])||"",avatar:r})),this._keepModalOpen||(yield null===(l=this._view)||void 0===l?void 0:l.closeAuthorizeModal({modalStateChangeReason:"event_completed"})),null===(c=this._iframeListener)||void 0===c||c.destroy(),this.stopListeningToInput(),this.dispatchCustomEvent("completed",{loggedIn:e,email:t,customerAccessToken:i,customerAccessTokenExpiresAt:n,shopPayInstallmentsOnboarded:a}),this._maybeRedirect()}))}_handleCustomFlowSideEffect(e){return c(this,void 0,void 0,(function*(){if(e.flow===Ae.Prequal)this.dispatchCustomEvent("prequal_flow_side_effect",{shopPayInstallmentsOnboarded:e.shopPayInstallmentsOnboarded})}))}_maybeRedirect(){if("pop_up"!==d(this,Ht,"f")&&d(this,Rt,"f"))try{let e=d(this,Rt,"f");if(d(this,Nt,"f")){const t={analytics_trace_id:d(this,Nt,"f")},i=new URLSearchParams(t);e=e.concat(`?${i.toString()}`)}else p.notify(new Error("Missing analytics trace ID when redirecting to account page"));window.location.assign(e)}catch(e){e instanceof Error&&p.notify(e)}}_handleError(e,t){this.dispatchCustomEvent("error",{message:e,code:t}),t===D.RetriableServerError&&(this._error=t,this._updateSrc(!0)),ai.includes(t)?Ke(Ge.HandleSilentError,1,{component:"shop-login-default",errorCode:t}):p.notify(new Error(`Authorize Error: ${e} (${t}).`)),d(this,Ut,"m",ni).call(this)}_onPopUpOpened(e){var t;e.didOpen&&(null===(t=this._view)||void 0===t||t.dispatch({type:b.PopUpOpened,payload:e})),this.dispatchCustomEvent("popuploading",e)}_onLoaded(e){var t,i,n;null===(t=this._view)||void 0===t||t.setAuthenticationLevel((null==e?void 0:e.authenticationLevelRequired)||w.Phone),null===(i=this._view)||void 0===i||i.dispatch({type:b.Init,payload:e}),null===(n=this._view)||void 0===n||n.onContentLoaded()}_onUserMatched({hasName:e=!1,userCookieExists:t=!1,personalizeConsentChallenge:i=!1}){var n;null===(n=this._view)||void 0===n||n.dispatch({type:b.UserMatched,payload:{hasName:e,userCookieExists:t,personalizeConsentChallenge:i}}),Qe(),this.dispatchCustomEvent("shopusermatched")}_onUserNotMatched({apiError:e}){var t;null===(t=this._view)||void 0===t||t.dispatch({type:b.UserNotMatched}),this.dispatchCustomEvent("shopusernotmatched",{apiError:e})}_onEmailChangeRequested(){var e;null===(e=this._view)||void 0===e||e.dispatch({type:b.Restart}),this.dispatchCustomEvent("restarted")}_onVerificationStepChanged(e){var t;null===(t=this._view)||void 0===t||t.dispatch({type:b.VerificationStepChanged,payload:e})}}function ri(){F("shop-login-default",oi)}var li,ci;Nt=new WeakMap,Wt=new WeakMap,Dt=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Rt=new WeakMap,Kt=new WeakMap,Gt=new WeakMap,Qt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,ei=new WeakMap,Ut=new WeakSet,ti=function(){return c(this,void 0,void 0,(function*(){var e;try{const t="es",i={follow_on_shop:{follow:"Seguir en {shop}",following:"La sigues en {shop}",auth_modal:{title:"Seguir en Shop",description:"Mantente al día: no te pierdas ninguna venta, reposición o actualización de pedido."},following_modal:{title:"Visitar {store} en Shop",subtitle:"Todo lo que necesitas para comprar, hacer seguimientos y efectuar pagos desde un único lugar.",qr_header:"Escanear para visitar {store} en la aplicación Shop",qr_alt_text:"Código QR de la aplicación Shop",continue:"Continuar"},completed:{title:"Sigues a {store}",subtitle:"Te enviamos un correo electrónico con un enlace para descargar la aplicación Shop."},personalization_consent:{title:"Para hacer seguimiento en Shop, sincroniza tu actividad de compra"}},login_with_shop:{login:"Iniciar sesión con {shop}",auth_modal:{login_title:"Iniciar sesión con Shop",login_description:"La forma más fácil y segura de iniciar sesión en {store} (no requiere contraseña).",signup_title:"Crear una cuenta",signup_description:"Introduce tu número de teléfono para crear una cuenta de Shop.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código enviado a {phoneNumber}.",login_email_title:"Confirma que eres tú",login_email_description:"Ingresa el código enviado a tu correo electrónico, {email}.",login_title_with_store:"Iniciar sesión en {store} con Shop",login_webauthn_title:"Confirma que eres tú",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada.",login_webauthn_footer:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},customer_accounts:{remember_me:"Guardar mi información de forma segura con Shop para iniciar sesión rápidamente en cualquier sitio",sign_up_page:{auth_modal:{login_title:"Continuar con Shop",login_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.",login_sms_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a {phoneNumber}.",login_email_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a tu correo electrónico, {email}.",login_webauthn_title:"Continuar con Shop",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada."}}},verified_email_auth:{auth_modal:{login_title:"Inicia sesión o regístrate",signup_title:"Continuar con Shop",signup_description:"Crea una cuenta de Shop para iniciar sesión en {clientName}, sin necesidad de contraseña."}},legal:{terms_of_service:"Términos del Servicio",privacy_policy:"política de privacidad",terms:"términos",client:"Consulta la {termsOfService} y los {privacyPolicy} de {clientName}.",shop:"Al continuar, aceptas los {termsOfService} y la {privacyPolicy} de Shop.",authorized_scopes:{email_name:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},payment_request:{auth_modal:{login_title:"Pagar con Shop Pay",login_description:"Usa tu información guardada para formalizar el pago de manera segura en {store}.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código que se envió al {phoneNumber} para usar tu información guardada de forma segura.",login_email_title:"Confirma que eres tú",login_email_description:"Introduce el código que se envió a tu correo electrónico {email} para usar tu información guardada de forma segura."}},checkout_modal:{auth_modal:{login_sms_description:"Ingresa el código que se envió al {phoneNumber} para usar de forma segura tu información guardada.",login_email_description:"Ingresa el código que se envió a tu correo electrónico ({email}) para usar de forma segura tu información guardada."}}};h(this,Yt,new u({[t]:i}),"f"),null===(e=this._view)||void 0===e||e.setTranslations(d(this,Yt,"f"))}catch(e){e instanceof Error&&p.notify(e)}return null}))},ii=function(){d(this,Ut,"m",ni).call(this),this._iframeLoadTimeout=setTimeout((()=>{const e=Xe.temporarilyUnavailable;this.dispatchCustomEvent("error",{message:e.message,code:e.code}),d(this,Ut,"m",ni).call(this)}),Ye)},ni=function(){this._iframeLoadTimeout&&(clearTimeout(this._iframeLoadTimeout),this._iframeLoadTimeout=void 0)},si=function(e){var t,i;switch(e.type){case"loaded":this._onLoaded(e);break;case"resize_iframe":if(!this._shouldListenToResizeMessage)return;null===(t=this._view)||void 0===t||t.resizeIframe(e.height,q(e.width,this._view.getIframe()));break;case"completed":this._handleCompleted(e.loggedIn,e.email,e.customerAccessToken,e.customerAccessTokenExpiresAt,e.shouldFinalizeLogin,e.shopPayInstallmentsOnboarded,e.givenNameFirstInitial,e.avatar);break;case"error":this._handleError(e.message,e.code);break;case"close_requested":null===(i=this._view)||void 0===i||i.closeAuthorizeModal({modalStateChangeReason:"event_close_requested"});break;case"shop_user_matched":this._onUserMatched(e);break;case"pop_up_opened":this._onPopUpOpened(e);break;case"shop_user_not_matched":this._onUserNotMatched(e);break;case"email_change_requested":this._onEmailChangeRequested();break;case"verification_step_changed":this._onVerificationStepChanged(e);break;case"custom_flow_side_effect":this._handleCustomFlowSideEffect(e)}};const di={[Ae.Follow]:"shop-follow-button",[Ae.Default]:"shop-login-default",[Ae.Prequal]:"shop-login-default",[Ae.PopUp]:"shop-login-default",[Ae.Custom]:"shop-login-default"},hi={[G]:!1,[Q]:!1,[Y]:!1,[ee]:"",[re]:!1,[le]:!1,[de]:"unspecified",[he]:"",[tt]:!1,[Pe]:!1,[ge]:!1,[Me]:!1,[xe]:"unspcified"};class ui extends Ze{constructor(){super(...arguments),li.set(this,void 0),ci.set(this,void 0)}static get observedAttributes(){return[H,R,de,K,G,Q,Y,et,J,X,ee,X,Z,te,ie,ne,se,ae,oe,he,O,tt,m,_,g,ue,pe,me,_e,ge,L,fe,ve,be,we,ye,ke,Ce,Se,Me,re,le,Pe,xe]}get clientId(){return this._getAttributeValueWithDefault(H)}set clientId(e){this.updateAttribute(H,e)}set redirectUri(e){this.updateAttribute(X,e)}get version(){return this._getAttributeValueWithDefault(R)}set version(e){this.updateAttribute(R,e)}get email(){return this._getAttributeValueWithDefault(he)}set email(e){this.updateAttribute(he,e)}set firstName(e){this.updateAttribute(Ce,e)}set lastName(e){this.updateAttribute(Se,e)}set popUpName(e){this.updateAttribute(pe,e)}set popUpFeatures(e){this.updateAttribute(me,e)}connectedCallback(){var e;h(this,li,it(this.getAttribute(nt),Ae,Ae.Default),"f"),h(this,ci,this._createActionButton({actionType:d(this,li,"f"),attributes:this._getAttributeValues()}),"f"),this.shadowRoot||this.attachShadow({mode:"open"}),d(this,ci,"f")&&(this.shadowRoot.innerHTML="",null===(e=this.shadowRoot)||void 0===e||e.appendChild(d(this,ci,"f")))}disconnectedCallback(){}attributeChangedCallback(e,t,i){var n,s;const a=i||this._getAttributeValueWithDefault(e);"boolean"==typeof a?this.updateAttribute(e,a?"":void 0):this.updateAttribute(e,a||void 0),null===i?null===(n=d(this,ci,"f"))||void 0===n||n.removeAttribute(e):null===(s=d(this,ci,"f"))||void 0===s||s.setAttribute(e,i)}requestShow(e){d(this,ci,"f")&&"requestShow"in d(this,ci,"f")&&d(this,ci,"f").requestShow(e)}listenToInput(e){d(this,ci,"f")&&"listenToInput"in d(this,ci,"f")&&d(this,ci,"f").listenToInput(e)}stopListeningToInput(){d(this,ci,"f")&&"stopListeningToInput"in d(this,ci,"f")&&d(this,ci,"f").stopListeningToInput()}setPasswordManagerDetection(e){d(this,ci,"f")&&"setPasswordManagerDetection"in d(this,ci,"f")&&d(this,ci,"f").setPasswordManagerDetection(e)}dispatchCustomEvent(e,t){super.dispatchCustomEvent(e,t)}_createActionButton({actionType:e,attributes:t}){const i=di[e];if(!i)return;const n=document.createElement(i);return n?(Object.entries(t).forEach((([e,t])=>{t&&n.setAttribute(e,String(t))})),n):void 0}_getAttributeValues(){return ui.observedAttributes.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this._getAttributeValueWithDefault(t)})),Object.assign(Object.assign({},hi),{[ce]:this._getAttributeValueWithDefault(nt)}))}_getAttributeValueWithDefault(e){switch(e){case nt:case ce:return it(this.getAttribute(nt),Ae,Ae.Default);case G:case Q:case Y:case re:case le:case tt:case Pe:case ge:case Me:case et:return this.getBooleanAttribute(e);case ee:case he:return this.getAttribute(e)||"";case de:return this.getAttribute(e)||"unspecified";case L:return this.getAttribute(e)||Te();default:return this.getAttribute(e)||void 0}}}function pi(){F("shop-login-button",ui)}li=new WeakMap,ci=new WeakMap;class mi extends HTMLElement{constructor(){super();const e=document.createElement("template"),t=this.getAttribute("size"),i=this.getAttribute("background-color")||"#FFF";e.innerHTML=function(e=36,t){const[i,n,s]=st(t),a=`rgb(${i}, ${n}, ${s})`,o=1.15,r=e,l=Math.round(r/o);return`\n \n \n \n \n `}(t?Number.parseInt(t,10):void 0,i),this.attachShadow({mode:"open"}).appendChild(e.content.cloneNode(!0))}}var _i,gi,fi,vi,bi,wi,yi,ki,Ci,Si,Mi,xi,Ti,Ai,Ii;const Ei="shop-modal-content";class Li extends HTMLElement{constructor(){super(),_i.add(this),gi.set(this,void 0),fi.set(this,void 0),vi.set(this,void 0),bi.set(this,void 0),wi.set(this,void 0),yi.set(this,void 0),ki.set(this,void 0),Ci.set(this,void 0),Si.set(this,void 0),Mi.set(this,void 0),xi.set(this,{});const e=document.createElement("template");e.innerHTML=`\n \n \n \n `,h(this,gi,this.attachShadow({mode:"open"}),"f"),d(this,gi,"f").appendChild(e.content.cloneNode(!0)),h(this,fi,d(this,gi,"f").querySelector(`.${Ei}`),"f"),h(this,vi,d(this,gi,"f").querySelector(`.${Ei}-title`),"f"),h(this,bi,d(this,gi,"f").querySelector(`.${Ei}-description`),"f"),h(this,wi,d(this,gi,"f").querySelector(`.${Ei}-content`),"f"),h(this,yi,d(this,gi,"f").querySelector(`.${Ei}-processing`),"f"),h(this,ki,d(this,gi,"f").querySelector(`.${Ei}-processing-user`),"f"),h(this,Si,d(this,gi,"f").querySelector(`.${Ei}-children`),"f"),h(this,Mi,d(this,gi,"f").querySelector(`.${Ei}-disclaimer`),"f")}hideDivider(){d(this,fi,"f").classList.add("hide-divider")}showDivider(){d(this,fi,"f").classList.remove("hide-divider")}update(e){h(this,xi,Object.assign(Object.assign({},d(this,xi,"f")),e),"f"),d(this,_i,"m",Ti).call(this),d(this,_i,"m",Ai).call(this),d(this,_i,"m",Ii).call(this)}}function Oi(e,t=!1){const i=document.createElement("shop-modal-content");return t&&i.hideDivider(),i.update(e),i}gi=new WeakMap,fi=new WeakMap,vi=new WeakMap,bi=new WeakMap,wi=new WeakMap,yi=new WeakMap,ki=new WeakMap,Ci=new WeakMap,Si=new WeakMap,Mi=new WeakMap,xi=new WeakMap,_i=new WeakSet,Ti=function(){const{title:e,description:t,authorizeState:i}=d(this,xi,"f"),n=e||t;d(this,fi,"f").classList.toggle("hidden",!n),d(this,vi,"f").classList.toggle("hidden",!e),d(this,bi,"f").classList.toggle("hidden",!t),d(this,vi,"f").textContent=e||"",d(this,bi,"f").textContent=t||"",i&&(d(this,fi,"f").classList.toggle("hide-divider",i===ot.Start),d(this,fi,"f").classList.toggle(`${Ei}--small`,i===ot.Start))},Ai=function(){var e;const{authorizeState:t,status:i,email:n}=d(this,xi,"f"),s=Boolean(t||i),a=Boolean(i&&n),o=Boolean(s&&!a);if(d(this,wi,"f").classList.toggle("hidden",!s),d(this,yi,"f").classList.toggle("hidden",!a),d(this,Si,"f").classList.toggle("hidden",!o),!d(this,Ci,"f")&&a){const i=t===ot.OneClick?rt.Branded:rt.Regular;h(this,Ci,lt(i),"f"),d(this,yi,"f").appendChild(d(this,Ci,"f")),null===(e=d(this,Ci,"f"))||void 0===e||e.setStatus({status:"loading",message:""})}d(this,ki,"f").textContent=n||""},Ii=function(){const{disclaimer:e}=d(this,xi,"f"),t=Boolean(e);d(this,Mi,"f").classList.toggle("hidden",!t),d(this,Mi,"f").innerHTML=e||""},customElements.get("shop-modal-content")||customElements.define("shop-modal-content",Li);const qi="following";class Pi extends HTMLElement{constructor(){super(),this._rootElement=null,this._button=null,this._wrapper=null,this._heartIcon=null,this._followSpan=null,this._followingSpan=null,this._i18n=null,this._followTextWidth=0,this._followingTextWidth=0,customElements.get("shop-logo")||customElements.define("shop-logo",l)}connectedCallback(){return c(this,void 0,void 0,(function*(){yield this._initTranslations(),this._initElements()}))}setFollowing({following:e=!0,skipAnimation:t=!1}){var i,n,s,a,o;null===(i=this._button)||void 0===i||i.classList.toggle("button--animating",!t),null===(n=this._button)||void 0===n||n.classList.toggle("button--following",e),null!==this._followSpan&&null!==this._followingSpan&&(this._followSpan.ariaHidden=e?"true":"false",this._followingSpan.ariaHidden=e?"false":"true"),this.style.setProperty("--button-width",`${e?this._followingTextWidth:this._followTextWidth}px`),window.matchMedia("(prefers-reduced-motion: reduce)").matches||t?null===(s=this._heartIcon)||void 0===s||s.setFilled(e):null===(o=null===(a=this._button)||void 0===a?void 0:a.querySelector(".follow-text"))||void 0===o||o.addEventListener("transitionend",(()=>{var t;null===(t=this._heartIcon)||void 0===t||t.setFilled(e)}))}setFocused(){var e;null===(e=this._button)||void 0===e||e.focus()}_initTranslations(){return c(this,void 0,void 0,(function*(){try{const e="es",t={follow_on_shop:{follow:"Seguir en {shop}",following:"La sigues en {shop}",auth_modal:{title:"Seguir en Shop",description:"Mantente al día: no te pierdas ninguna venta, reposición o actualización de pedido."},following_modal:{title:"Visitar {store} en Shop",subtitle:"Todo lo que necesitas para comprar, hacer seguimientos y efectuar pagos desde un único lugar.",qr_header:"Escanear para visitar {store} en la aplicación Shop",qr_alt_text:"Código QR de la aplicación Shop",continue:"Continuar"},completed:{title:"Sigues a {store}",subtitle:"Te enviamos un correo electrónico con un enlace para descargar la aplicación Shop."},personalization_consent:{title:"Para hacer seguimiento en Shop, sincroniza tu actividad de compra"}},login_with_shop:{login:"Iniciar sesión con {shop}",auth_modal:{login_title:"Iniciar sesión con Shop",login_description:"La forma más fácil y segura de iniciar sesión en {store} (no requiere contraseña).",signup_title:"Crear una cuenta",signup_description:"Introduce tu número de teléfono para crear una cuenta de Shop.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código enviado a {phoneNumber}.",login_email_title:"Confirma que eres tú",login_email_description:"Ingresa el código enviado a tu correo electrónico, {email}.",login_title_with_store:"Iniciar sesión en {store} con Shop",login_webauthn_title:"Confirma que eres tú",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada.",login_webauthn_footer:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},customer_accounts:{remember_me:"Guardar mi información de forma segura con Shop para iniciar sesión rápidamente en cualquier sitio",sign_up_page:{auth_modal:{login_title:"Continuar con Shop",login_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.",login_sms_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a {phoneNumber}.",login_email_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a tu correo electrónico, {email}.",login_webauthn_title:"Continuar con Shop",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada."}}},verified_email_auth:{auth_modal:{login_title:"Inicia sesión o regístrate",signup_title:"Continuar con Shop",signup_description:"Crea una cuenta de Shop para iniciar sesión en {clientName}, sin necesidad de contraseña."}},legal:{terms_of_service:"Términos del Servicio",privacy_policy:"política de privacidad",terms:"términos",client:"Consulta la {termsOfService} y los {privacyPolicy} de {clientName}.",shop:"Al continuar, aceptas los {termsOfService} y la {privacyPolicy} de Shop.",authorized_scopes:{email_name:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},payment_request:{auth_modal:{login_title:"Pagar con Shop Pay",login_description:"Usa tu información guardada para formalizar el pago de manera segura en {store}.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código que se envió al {phoneNumber} para usar tu información guardada de forma segura.",login_email_title:"Confirma que eres tú",login_email_description:"Introduce el código que se envió a tu correo electrónico {email} para usar tu información guardada de forma segura."}},checkout_modal:{auth_modal:{login_sms_description:"Ingresa el código que se envió al {phoneNumber} para usar de forma segura tu información guardada.",login_email_description:"Ingresa el código que se envió a tu correo electrónico ({email}) para usar de forma segura tu información guardada."}}};this._i18n=new u({[e]:t})}catch(e){e instanceof Error&&p.notify(e)}return null}))}_initElements(){var e,t,i,n;const s=document.createElement("template");if(s.innerHTML=`\n \n \n `,this._rootElement=this.attachShadow({mode:"open"}),this._rootElement.appendChild(s.content.cloneNode(!0)),this._i18n){const e=this._i18n.translate("follow_on_shop.follow",{shop:Vi("white")}),t=this._i18n.translate("follow_on_shop.following",{shop:Vi("black")});this._rootElement.querySelector('slot[name="follow-text"]').innerHTML=e,this._rootElement.querySelector('slot[name="following-text"]').innerHTML=t}this._button=this._rootElement.querySelector(".button"),this._wrapper=this._button.querySelector(".follow-icon-wrapper"),this._followSpan=null===(e=this._rootElement)||void 0===e?void 0:e.querySelector("span.follow-text"),this._followingSpan=null===(t=this._rootElement)||void 0===t?void 0:t.querySelector("span.following-text"),this._heartIcon=ct(),this._wrapper.prepend(this._heartIcon),this._followTextWidth=(null===(i=this._rootElement.querySelector(".follow-text"))||void 0===i?void 0:i.scrollWidth)||0,this._followingTextWidth=(null===(n=this._rootElement.querySelector(".following-text"))||void 0===n?void 0:n.scrollWidth)||0,this.style.setProperty("--reserved-width",`${Math.max(this._followTextWidth,this._followingTextWidth)}px`),this.setFollowing({following:this.hasAttribute(qi),skipAnimation:!0}),this._setButtonStyle()}_setButtonStyle(){var e,t;const i=dt(this),n=ht(i,"#ffffff")>ht(i,"#000000"),s=ht(i,"#5433EB")<=3.06;if(null===(e=this._button)||void 0===e||e.classList.toggle("button--dark",n),null===(t=this._button)||void 0===t||t.classList.toggle("button--bordered",s),n&&this._i18n){const e=this._i18n.translate("follow_on_shop.following",{shop:Vi("white")});this._rootElement.querySelector('slot[name="following-text"]').innerHTML=e}}}function Vi(e){return``}var zi,ji,$i,Ui,Ni,Wi,Di,Fi,Bi,Hi;customElements.get("follow-on-shop-button")||customElements.define("follow-on-shop-button",Pi);const Ri="store-logo";class Ki extends HTMLElement{constructor(){super(),zi.add(this),ji.set(this,void 0),$i.set(this,void 0),Ui.set(this,void 0),Ni.set(this,void 0),Wi.set(this,void 0),Di.set(this,void 0),Fi.set(this,""),Bi.set(this,"");const e=document.createElement("template");e.innerHTML=`\n \n
\n
\n \n \n
\n
\n
\n `,h(this,ji,this.attachShadow({mode:"open"}),"f"),d(this,ji,"f").appendChild(e.content.cloneNode(!0)),h(this,$i,d(this,ji,"f").querySelector(`.${Ri}`),"f"),h(this,Ui,d(this,ji,"f").querySelector(`.${Ri}-logo-wrapper`),"f"),h(this,Ni,d(this,Ui,"f").querySelector("img"),"f"),h(this,Wi,d(this,Ui,"f").querySelector("span"),"f"),h(this,Di,ct(),"f"),d(this,ji,"f").querySelector(`.${Ri}-icon-wrapper`).append(d(this,Di,"f"))}update({name:e,logoSrc:t}){h(this,Fi,e||d(this,Fi,"f"),"f"),h(this,Bi,t||d(this,Bi,"f"),"f"),d(this,zi,"m",Hi).call(this)}connectedCallback(){d(this,Ni,"f").addEventListener("error",(()=>{h(this,Bi,"","f"),d(this,zi,"m",Hi).call(this)}))}setFavorited(){return d(this,$i,"f").classList.add(`${Ri}--favorited`),window.matchMedia("(prefers-reduced-motion: reduce)").matches?(d(this,Di,"f").setFilled(),Promise.resolve()):new Promise((e=>{d(this,Di,"f").addEventListener("animationstart",(()=>{d(this,Di,"f").setFilled()})),d(this,Di,"f").addEventListener("animationend",(()=>{setTimeout(e,1e3)}))}))}}var Gi,Qi,Yi,Ji,Xi,Zi,en,tn,nn,sn,an,on,rn,ln,cn,dn,hn,un,pn,mn,_n,gn,fn,vn,bn,wn,yn,kn,Cn,Sn,Mn,xn,Tn,An,In,En,Ln,On,qn,Pn,Vn,zn,jn,$n,Un,Nn,Wn,Dn,Fn,Bn,Hn;ji=new WeakMap,$i=new WeakMap,Ui=new WeakMap,Ni=new WeakMap,Wi=new WeakMap,Di=new WeakMap,Fi=new WeakMap,Bi=new WeakMap,zi=new WeakSet,Hi=function(){const e=d(this,Fi,"f"),t=d(this,Ni,"f").src;d(this,Wi,"f").textContent=e.charAt(0),d(this,Wi,"f").ariaLabel=e,d(this,Bi,"f")&&d(this,Bi,"f")!==t?(d(this,Ni,"f").src=d(this,Bi,"f"),d(this,Ni,"f").alt=e,d(this,Ui,"f").classList.remove(`${Ri}-logo-wrapper--text`),d(this,Ui,"f").classList.add(`${Ri}-logo-wrapper--image`)):d(this,Bi,"f")||(d(this,Ui,"f").classList.remove(`${Ri}-logo-wrapper--image`),d(this,Ui,"f").classList.add(`${Ri}-logo-wrapper--text`))},customElements.get(Ri)||customElements.define(Ri,Ki),function(e){e.Closed="closed",e.Mounting="mounting",e.Open="open"}(Hn||(Hn={}));class Rn extends B{static get observedAttributes(){return[H,R,K,tt]}constructor(){super(),Gi.add(this),Qi.set(this,void 0),Yi.set(this,Te()),Ji.set(this,""),Xi.set(this,"2"),Zi.set(this,window.location.origin),en.set(this,!1),tn.set(this,new yt({elementName:"shop-follow-button",analyticsTraceId:d(this,Yi,"f")})),nn.set(this,void 0),sn.set(this,void 0),an.set(this,!1),on.set(this,null),rn.set(this,void 0),ln.set(this,void 0),cn.set(this,void 0),dn.set(this,void 0),hn.set(this,void 0),un.set(this,void 0),pn.set(this,void 0),mn.set(this,void 0),_n.set(this,void 0),gn.set(this,Hn.Closed),fn.set(this,void 0),vn.set(this,void 0),bn.set(this,void 0),wn.set(this,new ut("following",!1)),yn.set(this,null),kn.set(this,""),Cn.set(this,(()=>{d(this,Gi,"m",qn).call(this,!0)})),h(this,Qi,this.attachShadow({mode:"open"}),"f"),h(this,an,d(this,wn,"f").value,"f")}attributeChangedCallback(e,t,i){switch(e){case R:h(this,Xi,i,"f"),d(this,Gi,"m",qn).call(this);break;case H:h(this,Ji,i,"f"),d(this,Gi,"m",qn).call(this);break;case K:h(this,Zi,i,"f"),Oe(d(this,Zi,"f"));break;case tt:h(this,en,"true"===i,"f"),d(this,Gi,"m",qn).call(this)}}connectedCallback(){return c(this,void 0,void 0,(function*(){this.subscribeToHub(qe.UserStatusIdentity,d(this,Cn,"f")),yield d(this,Gi,"m",Sn).call(this),d(this,Gi,"m",Mn).call(this),d(this,Gi,"m",xn).call(this)}))}disconnectedCallback(){var e,t,i,n;this.unsubscribeAllFromHub(),null===(e=d(this,ln,"f"))||void 0===e||e.destroy(),null===(t=d(this,nn,"f"))||void 0===t||t.disconnect(),null===(i=d(this,hn,"f"))||void 0===i||i.destroy(),null===(n=d(this,un,"f"))||void 0===n||n.destroy()}}Qi=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,sn=new WeakMap,an=new WeakMap,on=new WeakMap,rn=new WeakMap,ln=new WeakMap,cn=new WeakMap,dn=new WeakMap,hn=new WeakMap,un=new WeakMap,pn=new WeakMap,mn=new WeakMap,_n=new WeakMap,gn=new WeakMap,fn=new WeakMap,vn=new WeakMap,bn=new WeakMap,wn=new WeakMap,yn=new WeakMap,kn=new WeakMap,Cn=new WeakMap,Gi=new WeakSet,Sn=function(){return c(this,void 0,void 0,(function*(){try{const e="es",t={follow_on_shop:{follow:"Seguir en {shop}",following:"La sigues en {shop}",auth_modal:{title:"Seguir en Shop",description:"Mantente al día: no te pierdas ninguna venta, reposición o actualización de pedido."},following_modal:{title:"Visitar {store} en Shop",subtitle:"Todo lo que necesitas para comprar, hacer seguimientos y efectuar pagos desde un único lugar.",qr_header:"Escanear para visitar {store} en la aplicación Shop",qr_alt_text:"Código QR de la aplicación Shop",continue:"Continuar"},completed:{title:"Sigues a {store}",subtitle:"Te enviamos un correo electrónico con un enlace para descargar la aplicación Shop."},personalization_consent:{title:"Para hacer seguimiento en Shop, sincroniza tu actividad de compra"}},login_with_shop:{login:"Iniciar sesión con {shop}",auth_modal:{login_title:"Iniciar sesión con Shop",login_description:"La forma más fácil y segura de iniciar sesión en {store} (no requiere contraseña).",signup_title:"Crear una cuenta",signup_description:"Introduce tu número de teléfono para crear una cuenta de Shop.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código enviado a {phoneNumber}.",login_email_title:"Confirma que eres tú",login_email_description:"Ingresa el código enviado a tu correo electrónico, {email}.",login_title_with_store:"Iniciar sesión en {store} con Shop",login_webauthn_title:"Confirma que eres tú",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada.",login_webauthn_footer:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},customer_accounts:{remember_me:"Guardar mi información de forma segura con Shop para iniciar sesión rápidamente en cualquier sitio",sign_up_page:{auth_modal:{login_title:"Continuar con Shop",login_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.",login_sms_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a {phoneNumber}.",login_email_description:"Usa tu cuenta de Shop para iniciar sesión en cualquier lugar, sin necesidad de contraseña.\r\n\r\nConfirma que eres tú. Introduce el código enviado a tu correo electrónico, {email}.",login_webauthn_title:"Continuar con Shop",login_webauthn_description:"Inicia sesión con una clave de acceso para usar de forma segura la información guardada."}}},verified_email_auth:{auth_modal:{login_title:"Inicia sesión o regístrate",signup_title:"Continuar con Shop",signup_description:"Crea una cuenta de Shop para iniciar sesión en {clientName}, sin necesidad de contraseña."}},legal:{terms_of_service:"Términos del Servicio",privacy_policy:"política de privacidad",terms:"términos",client:"Consulta la {termsOfService} y los {privacyPolicy} de {clientName}.",shop:"Al continuar, aceptas los {termsOfService} y la {privacyPolicy} de Shop.",authorized_scopes:{email_name:"Al continuar, tu nombre y dirección de correo electrónico se compartirán con {store}."}},payment_request:{auth_modal:{login_title:"Pagar con Shop Pay",login_description:"Usa tu información guardada para formalizar el pago de manera segura en {store}.",login_sms_title:"Confirma que eres tú",login_sms_description:"Introduce el código que se envió al {phoneNumber} para usar tu información guardada de forma segura.",login_email_title:"Confirma que eres tú",login_email_description:"Introduce el código que se envió a tu correo electrónico {email} para usar tu información guardada de forma segura."}},checkout_modal:{auth_modal:{login_sms_description:"Ingresa el código que se envió al {phoneNumber} para usar de forma segura tu información guardada.",login_email_description:"Ingresa el código que se envió a tu correo electrónico ({email}) para usar de forma segura tu información guardada."}}};h(this,yn,new u({[e]:t}),"f")}catch(e){e instanceof Error&&p.notify(e)}return null}))},Mn=function(){h(this,sn,function(e){const t=document.createElement("follow-on-shop-button");return e&&t.setAttribute(qi,""),t}(d(this,an,"f")),"f"),d(this,Qi,"f").innerHTML=pt,d(this,Qi,"f").appendChild(d(this,sn,"f"))},xn=function(){var e;d(this,Gi,"m",zn).call(this,d(this,an,"f")),d(this,Gi,"m",jn).call(this),Oe(d(this,Zi,"f")),null===(e=d(this,sn,"f"))||void 0===e||e.addEventListener("click",(()=>{var e;if(d(this,en,"f"))return h(this,an,!d(this,an,"f"),"f"),void(null===(e=d(this,sn,"f"))||void 0===e||e.setFollowing({following:d(this,an,"f")}));d(this,an,"f")?(d(this,tn,"f").trackFollowingGetAppButtonPageImpression(),mt()?d(this,Gi,"m",An).call(this):d(this,Gi,"m",On).call(this)):(d(this,tn,"f").trackFollowButtonClicked(),d(this,Gi,"m",Tn).call(this))}))},Tn=function(){d(this,pn,"f")?d(this,Gi,"m",Dn).call(this):(h(this,mn,d(this,Gi,"m",In).call(this),"f"),h(this,_n,Oi({}),"f"),d(this,_n,"f").append(d(this,Gi,"m",En).call(this)),h(this,hn,y().withInnerHTML(pt).build(),"f"),d(this,hn,"f").setNametagSuffix("follow"),h(this,pn,d(this,hn,"f").sheetModal,"f"),d(this,pn,"f").setAttribute(L,d(this,Yi,"f")),d(this,pn,"f").appendChild(d(this,mn,"f")),d(this,pn,"f").appendChild(d(this,_n,"f")),d(this,pn,"f").addEventListener("modalcloserequest",d(this,Gi,"m",Fn).bind(this)),d(this,pn,"f").setMonorailTracker(d(this,tn,"f")),h(this,gn,Hn.Mounting,"f"))},An=function(){return c(this,void 0,void 0,(function*(){var e,t,i;if(!d(this,fn,"f")){h(this,un,y().withInnerHTML(pt).build(),"f"),d(this,un,"f").setNametagSuffix("followed"),h(this,fn,d(this,un,"f").sheetModal,"f"),d(this,fn,"f").setMonorailTracker(d(this,tn,"f")),d(this,fn,"f").setAttribute("disable-popup","true");const n=yield d(this,Gi,"m",$n).call(this),s=null!==(e=null==n?void 0:n.name)&&void 0!==e?e:"the store",a=null===(t=d(this,yn,"f"))||void 0===t?void 0:t.translate("follow_on_shop.following_modal.title",{store:s}),o=null===(i=d(this,yn,"f"))||void 0===i?void 0:i.translate("follow_on_shop.following_modal.subtitle");h(this,vn,Oi({title:a,description:o},!0),"f"),d(this,fn,"f").appendChild(d(this,vn,"f")),d(this,fn,"f").appendChild(yield d(this,Gi,"m",Ln).call(this)),d(this,fn,"f").addEventListener("modalcloserequest",(()=>c(this,void 0,void 0,(function*(){var e;d(this,fn,"f")&&(yield d(this,fn,"f").close({reason:"user_dismissed"})),null===(e=d(this,sn,"f"))||void 0===e||e.setFocused()})))),a&&d(this,fn,"f").setAttribute("title",a)}d(this,fn,"f").open("user_button_clicked"),d(this,tn,"f").trackFollowingGetAppButtonPageImpression()}))},In=function(){const e=document.createElement(Ri);return d(this,Gi,"m",$n).call(this).then((t=>{e.update({name:(null==t?void 0:t.name)||"",logoSrc:(null==t?void 0:t.id)?`${_t}/shops/${t.id}/logo?width=58`:""})})).catch((()=>{})),e},En=function(){var e;h(this,rn,document.createElement("iframe"),"f"),d(this,rn,"f").tabIndex=0,d(this,Gi,"m",qn).call(this);const t=(null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView)||void 0;return h(this,ln,new ze(new je(d(this,rn,"f")),[r,$e,d(this,Zi,"f")],d(this,Gi,"m",Bn).bind(this),t),"f"),h(this,cn,new Ue(d(this,rn,"f")),"f"),E(d(this,rn,"f"),"allow","publickey-credentials-get *"),d(this,rn,"f")},Ln=function(){return c(this,void 0,void 0,(function*(){var e,t;const i=document.createElement("div"),n=yield d(this,Gi,"m",$n).call(this),s=null==n?void 0:n.id,a=null!==(t=null===(e=d(this,yn,"f"))||void 0===e?void 0:e.translate("follow_on_shop.following_modal.continue",{defaultValue:"Continue"}))&&void 0!==t?t:"",o=s?`https://shop.app/sid/${s}`:"#";return i.innerHTML=gt(o,a),i.addEventListener("click",(()=>c(this,void 0,void 0,(function*(){var e;d(this,tn,"f").trackFollowingGetAppButtonClicked(),null===(e=d(this,fn,"f"))||void 0===e||e.close({reason:"user_dismissed"})})))),i}))},On=function(){return c(this,void 0,void 0,(function*(){var e,t,i,n,s,a,o;if(!d(this,bn,"f")){h(this,bn,document.createElement("div"),"f"),d(this,bn,"f").classList.add("fos-tooltip","fos-tooltip-hidden");const r=yield d(this,Gi,"m",$n).call(this),l=null!==(e=null==r?void 0:r.name)&&void 0!==e?e:"the store",c=null!==(i=null===(t=d(this,yn,"f"))||void 0===t?void 0:t.translate("follow_on_shop.following_modal.qr_header",{store:l}))&&void 0!==i?i:"",u=null!==(s=null===(n=d(this,yn,"f"))||void 0===n?void 0:n.translate("follow_on_shop.following_modal.qr_alt_text"))&&void 0!==s?s:"",p=null==r?void 0:r.id,m=p?`${_t}/qr/sid/${p}`:"#";d(this,bn,"f").innerHTML=ft(c,m,u),null===(a=d(this,bn,"f").querySelector(".fos-tooltip-overlay"))||void 0===a||a.addEventListener("click",(()=>{var e;null===(e=d(this,bn,"f"))||void 0===e||e.classList.toggle("fos-tooltip-hidden",!0)})),null===(o=d(this,bn,"f"))||void 0===o||o.addEventListener("click",(()=>{var e;null===(e=d(this,bn,"f"))||void 0===e||e.classList.toggle("fos-tooltip-hidden",!0)})),d(this,Qi,"f").appendChild(d(this,bn,"f"))}d(this,bn,"f").classList.toggle("fos-tooltip-hidden",!1)}))},qn=function(e){if(d(this,rn,"f")){const t={clientId:d(this,Ji,"f"),responseType:"code"},i=xt({version:d(this,Xi,"f"),analyticsTraceId:d(this,Yi,"f"),flow:Ae.Follow,error:d(this,kn,"f"),oauthParams:t});d(this,Gi,"m",Pn).call(this),E(d(this,rn,"f"),"src",i,e),p.leaveBreadcrumb("Iframe url updated",{authorizeUrl:i},"state")}},Pn=function(){d(this,Gi,"m",Vn).call(this),h(this,dn,setTimeout((()=>{const e=Xe.temporarilyUnavailable;this.dispatchCustomEvent("error",{message:e.message,code:e.code}),d(this,Gi,"m",Vn).call(this)}),Ye),"f")},Vn=function(){d(this,dn,"f")&&(clearTimeout(d(this,dn,"f")),h(this,dn,void 0,"f"))},zn=function(e){d(this,tn,"f").trackFollowButtonPageImpression(e)},jn=function(){h(this,nn,new IntersectionObserver((e=>{var t;for(const{isIntersecting:i}of e)i&&(null===(t=d(this,nn,"f"))||void 0===t||t.disconnect(),d(this,tn,"f").trackFollowButtonInViewport())})),"f"),d(this,nn,"f").observe(d(this,sn,"f"))},$n=function(){return c(this,void 0,void 0,(function*(){return d(this,on,"f")||h(this,on,yield vt(d(this,Zi,"f")),"f"),d(this,on,"f")}))},Un=function(e){return c(this,arguments,void 0,(function*({loggedIn:e,shouldFinalizeLogin:t,email:i,givenNameFirstInitial:n,avatar:s}){var a,o,r,l;d(this,wn,"f").set(!0),e&&t&&(Re(d(this,Zi,"f"),(e=>{p.notify(new Error(e))})),this.publishToHub(qe.UserSessionCreate,{email:n||i,initial:n||(null==i?void 0:i[0])||"",avatar:s})),this.dispatchCustomEvent("completed",{loggedIn:e,email:i}),yield null===(a=d(this,mn,"f"))||void 0===a?void 0:a.setFavorited(),yield null===(o=d(this,pn,"f"))||void 0===o?void 0:o.close({reason:"event_completed"}),null===(r=d(this,ln,"f"))||void 0===r||r.destroy(),null===(l=d(this,sn,"f"))||void 0===l||l.setFollowing({following:!0}),h(this,an,!0,"f"),d(this,Gi,"m",zn).call(this,!0)}))},Nn=function(e,t,i){var n;d(this,Gi,"m",Vn).call(this),e===D.RetriableServerError&&(null===(n=d(this,_n,"f"))||void 0===n||n.update({status:void 0}),h(this,kn,e,"f"),d(this,Gi,"m",qn).call(this,!0)),this.dispatchCustomEvent("error",{code:e,message:t,email:i})},Wn=function(e){return c(this,arguments,void 0,(function*({clientName:e,logoSrc:t}){(e||t)&&d(this,mn,"f").update({name:e,logoSrc:t}),d(this,tn,"f").trackShopPayModalStateChange({currentState:Ne.Loaded,reason:"event_loaded"}),d(this,gn,"f")===Hn.Mounting&&(d(this,Gi,"m",Dn).call(this),h(this,gn,Hn.Open,"f"),d(this,Gi,"m",Vn).call(this))}))},Dn=function(){return c(this,void 0,void 0,(function*(){var e;(yield d(this,pn,"f").open("user_button_clicked"))&&(null===(e=d(this,cn,"f"))||void 0===e||e.postMessage({type:"sheetmodalopened"}))}))},Fn=function(){return c(this,void 0,void 0,(function*(){var e,t;if(d(this,pn,"f")){(yield d(this,pn,"f").close({reason:"user_dismissed"}))&&(null===(e=d(this,cn,"f"))||void 0===e||e.postMessage({type:"sheetmodalclosed"}),Ie())}null===(t=d(this,sn,"f"))||void 0===t||t.setFocused()}))},Bn=function(e){var t,i,n,s;switch(e.type){case"loaded":d(this,Gi,"m",Wn).call(this,e);break;case"resize_iframe":d(this,rn,"f").style.height=`${e.height}px`,d(this,rn,"f").style.width=`${q(e.width,d(this,rn,"f"))}px`;break;case"completed":d(this,Gi,"m",Un).call(this,e);break;case"error":d(this,Gi,"m",Nn).call(this,e.code,e.message,e.email);break;case"content":null===(t=d(this,pn,"f"))||void 0===t||t.setAttribute("title",e.title),null===(i=d(this,_n,"f"))||void 0===i||i.update(e),null===(n=d(this,mn,"f"))||void 0===n||n.classList.toggle("hidden",e.authorizeState===ot.Captcha);break;case"processing_status_updated":null===(s=d(this,_n,"f"))||void 0===s||s.update(e);break;case"close_requested":d(this,Gi,"m",Fn).call(this)}},bt()&&(wt({bundle:"loginButton",bundleLocale:"es"}),pi(),F("shop-follow-button",Rn),ri(),F("shop-swirl",mi));export{Ct as C,ui as S,ri as a,xt as b,pi as d,Mt as g}; //# sourceMappingURL=client.login-button_BpPwkrhu.es.esm.js.map