From 3144e7daf4ad171661551463b9decf21d3f6d087 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Mon, 3 Feb 2025 13:23:04 +0200 Subject: [PATCH 1/9] 569-fixed auth modal focus --- blocks/header/renderAuthCombine.js | 53 +++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/blocks/header/renderAuthCombine.js b/blocks/header/renderAuthCombine.js index 18797b1e2..a63e01c3d 100644 --- a/blocks/header/renderAuthCombine.js +++ b/blocks/header/renderAuthCombine.js @@ -11,6 +11,57 @@ import { Button } from '@dropins/tools/components.js'; import { getCookie } from '../../scripts/configs.js'; import { CUSTOMER_ACCOUNT_PATH, CUSTOMER_FORGOTPASSWORD_PATH, CUSTOMER_LOGIN_PATH } from '../../scripts/constants.js'; +function cycleFocus(element) { + document.addEventListener('keydown', (event) => { + const authCombineModal = document.querySelector('#auth-combine-modal'); + + if (event.key === 'Escape') { + event.preventDefault(); + authCombineModal.click(); + + element?.focus(); + + return; + } + + if (!authCombineModal) return; + + const focusableElements = authCombineModal.querySelectorAll( + 'input[name="email"], input, button, textarea, select, a[href], [tabindex]:not([tabindex="-1"])' + ); + + if (focusableElements.length === 0) return; + + const firstElement = focusableElements[0]; + const lastElement = focusableElements[focusableElements.length - 1]; + + if (!authCombineModal.dataset.focusInitialized) { + authCombineModal.dataset.focusInitialized = 'true'; + setTimeout(() => firstElement.focus(), 10); + } + + if (event.key === 'Tab') { + if (document.activeElement === lastElement) { + event.preventDefault(); + firstElement.focus(); + } else if (document.activeElement === authCombineModal) { + event.preventDefault(); + firstElement.focus(); + } + } + }); + + const authCombineModal = document.querySelector('#auth-combine-modal'); + if (authCombineModal) { + setTimeout(() => { + const firstElement = authCombineModal.querySelector( + 'form, input, button, textarea, select, a[href], [tabindex]:not([tabindex="-1"])', + ); + if (firstElement) firstElement.focus(); + }, 10); + } +} + const signInFormConfig = { renderSignUpLink: true, routeForgotPassword: () => CUSTOMER_FORGOTPASSWORD_PATH, @@ -223,7 +274,7 @@ const renderAuthCombine = (navSections, toggleMenu) => { } }); - toggleMenu?.(); + cycleFocus(accountLi); }); }; From e467b77e205f8f26d97f806b6837ce6dce5a5c19 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Mon, 3 Feb 2025 14:41:10 +0200 Subject: [PATCH 2/9] eds-569 fixed after CR --- blocks/header/renderAuthCombine.js | 125 ++++++++++++++--------------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/blocks/header/renderAuthCombine.js b/blocks/header/renderAuthCombine.js index a63e01c3d..c25ea3a58 100644 --- a/blocks/header/renderAuthCombine.js +++ b/blocks/header/renderAuthCombine.js @@ -9,58 +9,11 @@ import * as authApi from '@dropins/storefront-auth/api.js'; import { events } from '@dropins/tools/event-bus.js'; import { Button } from '@dropins/tools/components.js'; import { getCookie } from '../../scripts/configs.js'; -import { CUSTOMER_ACCOUNT_PATH, CUSTOMER_FORGOTPASSWORD_PATH, CUSTOMER_LOGIN_PATH } from '../../scripts/constants.js'; - -function cycleFocus(element) { - document.addEventListener('keydown', (event) => { - const authCombineModal = document.querySelector('#auth-combine-modal'); - - if (event.key === 'Escape') { - event.preventDefault(); - authCombineModal.click(); - - element?.focus(); - - return; - } - - if (!authCombineModal) return; - - const focusableElements = authCombineModal.querySelectorAll( - 'input[name="email"], input, button, textarea, select, a[href], [tabindex]:not([tabindex="-1"])' - ); - - if (focusableElements.length === 0) return; - - const firstElement = focusableElements[0]; - const lastElement = focusableElements[focusableElements.length - 1]; - - if (!authCombineModal.dataset.focusInitialized) { - authCombineModal.dataset.focusInitialized = 'true'; - setTimeout(() => firstElement.focus(), 10); - } - - if (event.key === 'Tab') { - if (document.activeElement === lastElement) { - event.preventDefault(); - firstElement.focus(); - } else if (document.activeElement === authCombineModal) { - event.preventDefault(); - firstElement.focus(); - } - } - }); - - const authCombineModal = document.querySelector('#auth-combine-modal'); - if (authCombineModal) { - setTimeout(() => { - const firstElement = authCombineModal.querySelector( - 'form, input, button, textarea, select, a[href], [tabindex]:not([tabindex="-1"])', - ); - if (firstElement) firstElement.focus(); - }, 10); - } -} +import { + CUSTOMER_ACCOUNT_PATH, + CUSTOMER_FORGOTPASSWORD_PATH, + CUSTOMER_LOGIN_PATH, +} from '../../scripts/constants.js'; const signInFormConfig = { renderSignUpLink: true, @@ -168,7 +121,7 @@ const resetPasswordFormConfig = { routeSignIn: () => CUSTOMER_LOGIN_PATH, }; -const onHeaderLinkClick = () => { +const onHeaderLinkClick = (element) => { const viewportMeta = document.querySelector('meta[name="viewport"]'); const originalViewportContent = viewportMeta.getAttribute('content'); @@ -186,13 +139,44 @@ const onHeaderLinkClick = () => { signInModal.setAttribute('id', 'auth-combine-modal'); signInModal.classList.add('auth-combine-modal-overlay'); - const closeModalWindow = (event) => { - if ((event.key === 'Escape' || event.key === 'Esc') && event.target.nodeName === 'BODY') { - signInModal.remove(); + const cycleFocus = (event) => { + if (!signInModal) return; + + const key = event.key.toLowerCase(); + + if (key === 'escape') { + event.preventDefault(); + signInModal.click(); + element?.focus(); + return; + } + + const focusableElements = signInModal.querySelectorAll( + 'input[name="email"], input, button, textarea, select, a[href], [tabindex]:not([tabindex="-1"])', + ); + + if (focusableElements.length === 0) return; + + const firstElement = focusableElements[0]; + const lastElement = focusableElements[focusableElements.length - 1]; + + if (!signInModal.dataset.focusInitialized) { + signInModal.dataset.focusInitialized = 'true'; + requestAnimationFrame(() => firstElement.focus(), 10); + } + + if (key === 'tab') { + if (document.activeElement === lastElement) { + event.preventDefault(); + firstElement.focus(); + } else if (document.activeElement === signInModal) { + event.preventDefault(); + firstElement.focus(); + } } }; - window.addEventListener('keydown', closeModalWindow); + window.addEventListener('keydown', cycleFocus); signInModal.onclick = () => { signInModal.remove(); @@ -221,8 +205,11 @@ const renderAuthCombine = (navSections, toggleMenu) => { const navListEl = navSections.querySelector('.default-content-wrapper > ul'); - const listItems = navListEl.querySelectorAll('.default-content-wrapper > ul > li'); - const accountLi = Array.from(listItems).find((li) => li.textContent.includes('Account')); + const listItems = navListEl.querySelectorAll( + '.default-content-wrapper > ul > li', + ); + const accountLi = Array.from(listItems).find((li) => + li.textContent.includes('Account')); const accountLiItems = accountLi.querySelectorAll('ul > li'); const authCombineLink = accountLiItems[accountLiItems.length - 1]; @@ -231,7 +218,7 @@ const renderAuthCombine = (navSections, toggleMenu) => { authCombineLink.innerHTML = `${text}`; authCombineLink.addEventListener('click', (event) => { event.preventDefault(); - onHeaderLinkClick(); + onHeaderLinkClick(accountLi); function getPopupElements() { const headerBlock = document.querySelector('.header.block'); @@ -248,11 +235,18 @@ const renderAuthCombine = (navSections, toggleMenu) => { } events.on('authenticated', (isAuthenticated) => { - const authCombineNavElement = document.querySelector('.authCombineNavElement'); + const authCombineNavElement = document.querySelector( + '.authCombineNavElement', + ); if (isAuthenticated) { const { headerLoginButton, popupElement, popupMenuContainer } = getPopupElements(); - if (!authCombineNavElement || !headerLoginButton || !popupElement || !popupMenuContainer) { + if ( + !authCombineNavElement + || !headerLoginButton + || !popupElement + || !popupMenuContainer + ) { return; } @@ -261,7 +255,9 @@ const renderAuthCombine = (navSections, toggleMenu) => { popupElement.style.minWidth = '250px'; if (headerLoginButton) { const spanElementText = headerLoginButton.querySelector('span'); - spanElementText.textContent = `Hi, ${getCookie('auth_dropin_firstname')}`; + spanElementText.textContent = `Hi, ${getCookie( + 'auth_dropin_firstname', + )}`; } popupMenuContainer.insertAdjacentHTML( 'afterend', @@ -273,8 +269,7 @@ const renderAuthCombine = (navSections, toggleMenu) => { ); } }); - - cycleFocus(accountLi); + toggleMenu?.(); }); }; From 921097f4bf059751b54efa7be82afa99fd1d4b42 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Tue, 4 Feb 2025 20:04:43 +0200 Subject: [PATCH 3/9] eds-569 added window.removeEventListener --- blocks/header/renderAuthCombine.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blocks/header/renderAuthCombine.js b/blocks/header/renderAuthCombine.js index c25ea3a58..d26988aa7 100644 --- a/blocks/header/renderAuthCombine.js +++ b/blocks/header/renderAuthCombine.js @@ -148,6 +148,7 @@ const onHeaderLinkClick = (element) => { event.preventDefault(); signInModal.click(); element?.focus(); + window.removeEventListener('keydown', cycleFocus); return; } @@ -182,6 +183,7 @@ const onHeaderLinkClick = (element) => { signInModal.remove(); document.body.style.overflow = 'auto'; viewportMeta.setAttribute('content', originalViewportContent); + window.removeEventListener('keydown', cycleFocus); }; const signInForm = document.createElement('div'); From dfbd8d984df9c3971e92bce489d615cb36362e24 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 12:18:38 +0100 Subject: [PATCH 4/9] Update auth, order and account to 1.0.3 --- package-lock.json | 24 +++---- package.json | 6 +- .../chunks/CustomerInformationCard.js | 2 +- .../containers/CustomerInformation.js | 2 +- .../storefront-account/i18n/en_US.json.d.ts | 32 ++++++++- .../lib/getAddressButtonAriaLabel.d.ts | 2 + .../lib/validationFields.d.ts | 4 +- .../__dropins__/storefront-account/render.js | 2 +- .../storefront-auth/chunks/SignUpForm.js | 2 +- .../storefront-auth/containers/SignUp.js | 2 +- .../storefront-auth/i18n/en_US.json.d.ts | 5 +- scripts/__dropins__/storefront-auth/render.js | 4 +- .../storefront-auth/types/signUp.types.d.ts | 8 ++- scripts/__dropins__/storefront-order/api.js | 27 ++----- .../storefront-order/api/fragments.d.ts | 4 +- ...l.d.ts => GuestOrderFragment.graphql.d.ts} | 2 +- .../graphql/OrderItemsFragment.graphql.d.ts | 2 + .../storefront-order/chunks/initialize.js | 70 ++++--------------- .../chunks/requestGuestOrderCancel.js | 33 +++------ .../__dropins__/storefront-order/fragments.js | 59 +++++++++------- 20 files changed, 129 insertions(+), 163 deletions(-) create mode 100644 scripts/__dropins__/storefront-account/lib/getAddressButtonAriaLabel.d.ts rename scripts/__dropins__/storefront-order/api/graphql/{GurestOrderFragment.graphql.d.ts => GuestOrderFragment.graphql.d.ts} (92%) diff --git a/package-lock.json b/package-lock.json index 02095980a..5617ea93a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,11 +12,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "~1.0.2", - "@dropins/storefront-auth": "~1.0.2", + "@dropins/storefront-account": "~1.0.3", + "@dropins/storefront-auth": "~1.0.3", "@dropins/storefront-cart": "~1.0.2", "@dropins/storefront-checkout": "~1.0.0", - "@dropins/storefront-order": "~1.0.2", + "@dropins/storefront-order": "~1.0.3", "@dropins/storefront-pdp": "~1.0.0", "@dropins/tools": "^0.40.0" }, @@ -1798,14 +1798,14 @@ } }, "node_modules/@dropins/storefront-account": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-1.0.2.tgz", - "integrity": "sha512-NiDvGzDPOtlUo5pXZuxvR+vjiajZCcqEFpG+lL1AYVgCj75CyQqWJoDwhpbiojhQL8wZErufT3Byg8P5H87jzg==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-1.0.3.tgz", + "integrity": "sha512-MTYujgjk7GLSU4+SRf27uvkbGXFSYWS+6ZtRZpM/JpjRDGkTjXXewxtV/e95BKbDhPf3v7ZzTG5eEugmpLohGA==" }, "node_modules/@dropins/storefront-auth": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@dropins/storefront-auth/-/storefront-auth-1.0.2.tgz", - "integrity": "sha512-yit76KU3nR97UdmBvP9o3/Z4HtDF7BzKgm/4Gf7Hkm+eFmofnss1Co0YCb/uOTHWuSsBrKNfK0Dd6V57ies0qg==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@dropins/storefront-auth/-/storefront-auth-1.0.3.tgz", + "integrity": "sha512-cKPh0OwDr8A3XpvYfeKpdwImAutnqr2M7iTFJrJvgrBUVkFsYWpV9biWg4nctj8etbI03f+2mrPYyZul1bQjEA==" }, "node_modules/@dropins/storefront-cart": { "version": "1.0.2", @@ -1818,9 +1818,9 @@ "integrity": "sha512-tNCmgVEWEW2OzyNll69jTUTsT3wNG8yJ4HRZ/MrBJF+5/B/o3O+dfYTs4RUpIohXC8sGPkAjXCn5k6BQyo7QUA==" }, "node_modules/@dropins/storefront-order": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.2.tgz", - "integrity": "sha512-IXX+cMDucyHHhIm9jPOf6iXP7oEzkDjPOWbul11e8vnOCkxkl60J3Y01GuXMW+6Fdt6CTxI+sNDfPLhPF2mEkQ==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.3.tgz", + "integrity": "sha512-DAWhQ4h3cDPx8ZlUbqz2D2f3g/t3TRqOZOH6koBhJRQleWKF6+hEE9mIaWdkzuJAapw+jqT3DHhcT9sCHi+Gbg==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0", diff --git a/package.json b/package.json index 1db222e0d..cada03a2e 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,11 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "~1.0.2", - "@dropins/storefront-auth": "~1.0.2", + "@dropins/storefront-account": "~1.0.3", + "@dropins/storefront-auth": "~1.0.3", "@dropins/storefront-cart": "~1.0.2", "@dropins/storefront-checkout": "~1.0.0", - "@dropins/storefront-order": "~1.0.2", + "@dropins/storefront-order": "~1.0.3", "@dropins/storefront-pdp": "~1.0.0", "@dropins/tools": "^0.40.0" } diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js index b54dad365..58f7d993d 100644 --- a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -1,3 +1,3 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{jsx as n,Fragment as Q,jsxs as W}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Y,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Ge,Input as Je,InputDate as Xe,Checkbox as Re,TextArea as De,Card as he,Skeleton as we,SkeletonRow as X,Button as de,Tag as pe,Icon as He,Modal as Ke,ProgressSpinner as Ye,IllustratedMessage as Qe,Header as et,InLineAlert as tt}from"@dropins/tools/components.js";import{useRef as rt,useState as _,useEffect as ee,useCallback as z,useMemo as st}from"@dropins/tools/preact-hooks.js";import{n as Ve,o as Be,u as Ce,c as ze,e as at,m as nt,j as dt,h as ot,i as lt,d as ct}from"./removeCustomerAddress.js";import{useText as ae}from"@dropins/tools/i18n.js";import*as D from"@dropins/tools/preact-compat.js";import{memo as _e,forwardRef as it,useImperativeHandle as ut,useMemo as Me,useCallback as Te}from"@dropins/tools/preact-compat.js";import{Fragment as $e}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:a,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:f,billingCheckBoxValue:g,shippingCheckBoxValue:C,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:N,onSubmit:t,onCloseBtnClick:p,onSuccess:m,onError:T,onChange:$})=>n("div",{className:Y(["account-address-form"]),children:n(Xt,{hideActionFormButtons:e,formName:s,showFormLoader:a,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:f,shippingCheckBoxValue:C,billingCheckBoxValue:g,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:N,onSubmit:t,onCloseBtnClick:p,onSuccess:m,onError:T,onChange:$,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),pt=e=>e.reduce((s,a)=>({...s,[a.name]:a.value}),{}),ft=e=>/^\d+$/.test(e),mt=e=>/^[a-zA-Z0-9\s]+$/.test(e),ht=e=>/^[a-zA-Z0-9]+$/.test(e),At=e=>/^[a-zA-Z]+$/.test(e),Lt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),gt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),bt=(e,s,a)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=a},Ze=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],yt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),Ct=(e,s,a)=>{const r=e.length;return r>=s&&r<=a},ye=(e,s,a,r)=>{var S,R;const{requiredFieldError:d,lengthTextError:o,numericError:c,alphaNumWithSpacesError:l,alphaNumericError:i,alphaError:u,emailError:f,dateError:g,urlError:C,dateLengthError:O}=a,L=s==null?void 0:s.customUpperCode,N={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&(!e||e==="false"))return{[L]:d};if(!(s!=null&&s.required)&&!e||!((S=s==null?void 0:s.validateRules)!=null&&S.length))return N;const t=pt(s==null?void 0:s.validateRules),p=t.MIN_TEXT_LENGTH??1,m=t.MAX_TEXT_LENGTH??255,T=t.DATE_RANGE_MIN,$=t.DATE_RANGE_MAX;if(!Ct(e,+p,+m)&&!(T||$))return{[L]:o.replace("{min}",p).replace("{max}",m)};if(!bt(e,+T,+$)&&(T||$))return{[L]:O.replace("{min}",Ze(T)).replace("{max}",Ze($))};const k={numeric:{validate:ft,error:c},"alphanum-with-spaces":{validate:mt,error:l},alphanumeric:{validate:ht,error:i},alpha:{validate:At,error:u},email:{validate:Lt,error:f},date:{validate:gt,error:g},url:{validate:yt,error:C}}[t.INPUT_VALIDATION];return k&&!k.validate(e)&&!((R=r[L])!=null&&R.length)?{[L]:k.error}:N},ke=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},Mt=["true","false","yes","on","off"],vt={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},Et=e=>{const s={},a={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const c=o[1],l=parseInt(o[2],10);a[c]||(a[c]=[]),a[c].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?a[r]=[{index:1,value:d}]:s[r]=d}for(const r in a)if(Object.prototype.hasOwnProperty.call(a,r)){const d=a[r];d.sort((o,c)=>o.index-c.index),s[r]=d.map(o=>o.value)}return s},_t=e=>{const s={},a=[];for(const r in e){const d=Mt.includes(e[r])?ke(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(vt,r)?s[r]=d:a.push({code:Be(r),value:d}))}return{...s,customAttributes:a}},ne=(e,s=!1)=>{const a=Ve(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=_t(Et(a));if(!s)return r;const[d,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...o&&{regionId:+o}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ie=(e,s)=>Object.keys(e).length?Object.keys(e).every(r=>r in s&&s[r]!==""):!1,qe=e=>typeof e=="function",Nt=e=>e.reduce((s,{customUpperCode:a,required:r,defaultValue:d})=>(r&&a&&(s.initialData[a]=d||"",s.errorList[a]=""),s),{initialData:{},errorList:{}}),xe=e=>Object.keys(e).length>0,Tt=({fieldsConfig:e,onSubmit:s,onChange:a,setInputChange:r,formName:d,isWaitingForResponse:o})=>{const c=ae({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=rt(null),[i,u]=_({}),[f,g]=_({}),[C,O]=_({}),[L,N]=_(!0),[t,p]=_(!1),[m,T]=_(!1),[$,Z]=_(!0),[k,S]=_(!1);ee(()=>{const h=()=>{if(l.current){const y=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,M=l.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(y-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const R=z((h=!1)=>{let v=!0;const y={...f};let M=null;for(const[x,A]of Object.entries(i)){const I=e==null?void 0:e.find(F=>F.customUpperCode.includes(x)),B=ye(A.toString(),I,c,y);B[x]&&(Object.assign(y,B),v=!1),M||(M=Object.keys(y).find(F=>y[F])||null)}if(h||g(y),M&&l.current&&!h){const x=l.current.elements.namedItem(M);x==null||x.focus()}return v},[f,e,i,c]),b=z((h,v,y,M)=>{const x={...me(l),[v]:h,...v.includes("countryCode")?{region:""}:{}},A={data:ne(x,!0),isDataValid:Ie(y,x)};S(A.isDataValid),R(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(A)),a==null||a(A,{},M)},[R,d,a]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=Nt(e);u(y=>({...h,...y})),g(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(m)return;const h=me(l),v=sessionStorage.getItem(`${d}_addressData`);if(xe(i)&&xe(C)){let y={};const M=Ie(C,i);v?y=JSON.parse(v).data:y=ne(h,!0)??{},a==null||a({data:y,isDataValid:M},{},null),S(M),T(!0)}},[i,C]),ee(()=>{var x;if(!$)return;const h=me(l),v=!!(h!=null&&h.countryCode),y=!!((x=h==null?void 0:h.region)!=null&&x.length);h&&v&&!y&&qe(a)&&!o&&b(h==null?void 0:h.region,"region",C,null)},[$,L,e,l,a,b,C,t,o]);const U=z((h,v)=>{const{name:y,value:M,type:x,checked:A}=h==null?void 0:h.target,I=x==="checkbox"?A:M;u(H=>{const te={...H,[y]:I};return y==="countryCode"&&(te.region="",N(!0),p(!1)),te}),r==null||r({[y]:I}),T(!0);const B=e==null?void 0:e.find(H=>H.customUpperCode.includes(y));let F=v?{...v}:{...f};if(B){const H=ye(I.toString(),B,c,F);H&&Object.assign(F,H),g(F)}b(I,y,C,h)},[r,e,f,c,b,C,L]),P=z(h=>{const{name:v}=h==null?void 0:h.target,y=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(y!=null&&y.options.length)&&Z(!1),Z(v==="countryCode")},[]),V=z((h,v)=>{const{name:y,value:M,type:x,checked:A}=h==null?void 0:h.target,I=x==="checkbox"?A:M,B=e==null?void 0:e.find(F=>F.customUpperCode===y);if(B){const F=v?{...v}:{...f},H=ye(I.toString(),B,c,F);H&&Object.assign(F,H),g(F)}},[f,e,c]),K=z(h=>{h.preventDefault();const v=R();s==null||s(h,v)},[R,s]);return{isDataValid:k,formData:i,errors:f,formRef:l,handleInputChange:U,onFocus:P,handleBlur:V,handleSubmit:K,handleValidationSubmit:R}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const $t=_e(({loading:e,values:s,fields:a=[],errors:r,className:d="",onChange:o,onBlur:c,onFocus:l,slots:i})=>{const u=`${d}__field`,f=(t,p)=>{if(!(i!=null&&i[`AddressFormInput_${t.code}`]))return;const m={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:c,handleOnFocus:l,errorMessage:p,errors:r,config:t};return n(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:i[`AddressFormInput_${t.code}`],context:m},t.id)},g=(t,p,m)=>{var $;const T=(($=t.options.find(Z=>Z.isDefault))==null?void 0:$.value)??p??t.defaultValue;return n(Q,{children:f(t,m)??n(le,{error:m,className:Y([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:n(Ge,{"aria-label":t.label,"aria-required":t.required?"true":"false",id:t.code,required:t==null?void 0:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,options:t.options,onBlur:c,onFocus:l,handleSelect:o,defaultValue:T,value:T})},t.id)})},C=(t,p,m)=>n(Q,{children:f(t,m)??n(le,{error:m,className:Y([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:n(Je,{"aria-label":t.label,"aria-required":t.required?"true":"false",id:t.code,type:"text",name:t.customUpperCode,value:p??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onFocus:l,onChange:o})},t.id)}),O=(t,p,m)=>n(Q,{children:f(t,m)??n(le,{error:m,className:Y([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:n(Xe,{"aria-label":t.label,"aria-required":t.required?"true":"false",id:t.code,type:"text",name:t.customUpperCode,value:p||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,p,m)=>n(Q,{children:f(t,m)??n(le,{error:m,className:Y([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:(t==null?void 0:t.isHidden)??e,children:n(Re,{"aria-label":t.label,"aria-required":t.required?"true":"false","aria-hidden":t.isHidden,tabindex:t!=null&&t.isHidden?-1:0,id:t.code,name:t.customUpperCode,checked:p||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:o})},t.id)}),N=(t,p,m)=>n(Q,{children:f(t,m)??n(le,{error:m,className:Y([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:n(De,{"aria-label":t.label,"aria-required":t.required?"true":"false",id:t.code,type:"text",name:t.customUpperCode,value:p??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:o})},t.id)});return a.length?n(Q,{children:a.map(t=>{const p=r==null?void 0:r[t.customUpperCode],m=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?g(t,m,p):C(t,m,p);case se.MULTILINE:return C(t,m,p);case se.SELECT:return g(t,m,p);case se.DATE:return O(t,m,p);case se.BOOLEAN:return L(t,m,p);case se.TEXTAREA:return N(t,m,p);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const a=W(we,{"data-testid":e||"skeletonLoader",children:[n(X,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),n(X,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),n(X,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?a:n(he,{variant:"secondary",className:Y(["account-account-loaders","account-account-loaders--card-loader"]),children:a})},Zt=()=>W(we,{"data-testid":"addressFormLoader",children:[n(X,{variant:"heading",size:"medium"}),n(X,{variant:"empty",size:"medium"}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large",fullWidth:!0}),n(X,{size:"large",fullWidth:!0,lines:3}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large"}),n(X,{size:"large",fullWidth:!0})]}),It=_e(it(({isWaitingForResponse:e,setInputChange:s,showFormLoader:a,slots:r,name:d,loading:o,children:c,className:l="defaultForm",fieldsConfig:i,onSubmit:u,onChange:f,forwardFormRef:g,regionOptions:C,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:N})=>{const t=ae({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:p,formData:m,errors:T,formRef:$,handleInputChange:Z,handleBlur:k,handleSubmit:S,handleValidationSubmit:R,onFocus:b}=Tt({fieldsConfig:i,onSubmit:u,onChange:f,setInputChange:s,regionOptions:C,formName:d,isWaitingForResponse:e});return ut(g,()=>{const U=me($);return{handleValidationSubmit:R,formData:ne(U,!0),isDataValid:p}}),a||!(i!=null&&i.length)?n(Zt,{}):W("form",{className:Y(["account-form",l]),onSubmit:S,name:d,ref:$,children:[n($t,{className:l,loading:o,fields:i,onChange:Z,onBlur:k,errors:T,values:m,onFocus:b,slots:r}),r!=null&&r.AddressFormInputs?n(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?n("div",{className:"account-address-form--saveAddressBook",children:n(Re,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:N,onChange:U=>{Z(U),L==null||L(U)}})}):null,c]})})),ve=({slots:e,selectable:s,selectShipping:a,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:c,addressData:l,loading:i,setAddressId:u,handleRenderModal:f,handleRenderForm:g})=>{const C=o?"minifiedView":"fullSizeView",O=ae({actionRemove:`Account.${C}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${C}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${C}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${C}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${C}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),N=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),p=Me(()=>{const b={shippingLabel:N,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?a&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!a?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:b:b},[L,t,N,r,a,s]),m=Te(()=>{u==null||u(l==null?void 0:l.id),f==null||f()},[f,l==null?void 0:l.id,u]),T=Te(()=>{u==null||u(l==null?void 0:l.id),g==null||g()},[g,l==null?void 0:l.id,u]),$=Me(()=>{if(!c)return[];const{region:b,...U}=l,P={...U,...b};return c.filter(({name:V})=>P[V]).map(V=>({name:V.name,orderNumber:V.orderNumber,value:P[V.name],label:V.label}))},[l,c]),{shippingLabel:Z,billingLabel:k,hideShipping:S,hideBilling:R}=p;return n(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:i?n(Ue,{}):W(Q,{children:[W("div",{className:"account-address-card__action",children:[f?n(de,{type:"button",variant:"tertiary",onClick:m,"data-testid":"removeButton",children:O.actionRemove}):null,g?n(de,{type:"button",variant:"tertiary",onClick:T,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),n("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?n(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:$}}):n(Q,{children:$.map((b,U)=>{const P=b.label?`${b.label}: ${b==null?void 0:b.value}`:b==null?void 0:b.value;return n("p",{"data-testid":`${b.name}_${U}`,children:P},U)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?W("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?n(pe,{label:N}):null,l!=null&&l.defaultBilling?n(pe,{label:L}):null]}):null,s?W("div",{className:"account-address-card__labels",children:[!S&&(l!=null&&l.defaultShipping)?n(pe,{label:Z}):null,!R&&(l!=null&&l.defaultBilling)?n(pe,{label:k}):null]}):null]})})},xt=e=>D.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},D.createElement("g",{id:"Large"},D.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),D.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},D.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),D.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),Ft=e=>D.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},D.createElement("g",{id:"Large"},D.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),D.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},D.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Ot=e=>D.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},D.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"currentColor"})),St=e=>D.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},D.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"currentColor"})),Fe=({selectable:e,className:s,addNewAddress:a,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",c=ae({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",i=e?{}:{AriaRole:"button",type:"button"},u=r&&!a?c.viewAllAddressesButton:c.addNewAddressButton,f=e?c.differentAddressButton:u;return W(l,{...i,className:Y(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[n("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:f}),n(He,{source:r&&!a?Ft:xt,size:"32"})]})},Rt=({minifiedView:e,keysSortOrder:s,addressData:a,open:r,submitLoading:d,onRemoveAddress:o,closeModal:c})=>{const l=e?"minifiedView":"fullSizeView",i=ae({title:`Account.${l}.Addresses.removeAddressModal.title`,description:`Account.${l}.Addresses.removeAddressModal.description`,actionCancel:`Account.${l}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${l}.Addresses.removeAddressModal.actionConfirm`});return r?n("div",{className:"account-address-modal",children:W(Ke,{className:"account-address-modal--overlay",title:n("h3",{children:i.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:c,children:[d?n("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:n(Ye,{stroke:"4",size:"large"})}):null,n("p",{children:i.description}),n(ve,{minifiedView:e,addressData:a,keysSortOrder:s}),W("div",{className:"account-address-modal__buttons",children:[n(de,{type:"button",onClick:c,variant:"secondary",disabled:d,children:i.actionCancel}),n(de,{disabled:d,onClick:o,children:i.actionConfirm})]})]})}):null},wt=({typeList:e,isEmpty:s,minifiedView:a,className:r})=>{const d=a?"minifiedView":"fullSizeView",o=ae({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),c=Me(()=>{switch(e){case"address":return{icon:Ot,text:n("p",{children:o.addressesMessage})};case"orders":return{icon:St,text:n("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!c.text?null:n(Qe,{className:Y(["account-empty-list",a?"account-empty-list--minified":"",r]),message:c.text,icon:n(He,{source:c.icon}),"data-testid":"emptyList"})},Ht=async(e,s)=>{if(s.length===1){const c=s[0],i=Object.values(c.region).every(f=>!!f)?{}:{region:{...c.region,regionId:0}};return!!await Ce({addressId:Number(c==null?void 0:c.id),defaultShipping:!1,defaultBilling:!1,...i})}const a=s.filter(c=>c.id!==e&&(c.defaultBilling||c.defaultShipping)||c.id!==e),r=s[s.length-1],d=a[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},Vt=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],n1=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],Pe=(e,s,a)=>{if(s&&a||!s&&!a)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):a?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},Ee=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ee),Bt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:a,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:c})=>{const[l,i]=_(""),[u,f]=_(!1),[g,C]=_(!1),[O,L]=_(!1),[N,t]=_(!1),[p,m]=_(!1),[T,$]=_(""),[Z,k]=_([]),[S,R]=_([]),b=z(async()=>{L(!0),Promise.all([ze("shortRequest"),at()]).then(A=>{const[I,B]=A;if(I){const F=I.map(({name:H,orderNumber:te,label:re})=>({name:nt(H),orderNumber:te,label:Vt.includes(H)?null:re}));R(F)}if(B)if(d){const F=B.filter(H=>!!H.defaultShipping||!!H.defaultBilling);k(F)}else k(B)}).finally(()=>{L(!1)})},[d]);ee(()=>{b()},[b]),ee(()=>{var A;if(Z.length)if(a===0)m(!0),i("0");else{const I=Z.find(F=>+F.id===a)||Pe(Z,e,s)[0],B={data:ne(I),isDataValid:!Ee(I)};i(a.toString()||((A=I==null?void 0:I.id)==null?void 0:A.toString())),r==null||r(B)}},[Z,a,r,s,e]);const U=z(A=>{$(A),m(!1)},[]),P=z((A,I)=>{const B=(A==null?void 0:A.target).value,F=(A==null?void 0:A.target).nextSibling;i(B);const H={data:ne(I),isDataValid:!Ee(ne(I))};r==null||r(H),m(B==="0"),F&&(F.focus(),window.scrollBy(0,100))},[r]),V=z(()=>{C(!0)},[]),K=z(()=>{$(""),C(!1),f(!1)},[]),h=z(()=>{f(!0)},[]),v=z(async()=>{t(!0),await Ht(T,Z),dt(+T).then(()=>{b(),K()}).finally(()=>{t(!1)})},[Z,T,K,b]),y=z(()=>{m(!1)},[]),M=z(()=>{qe(o)&&d&&!p?window.location.href=o():(m(!0),$(""))},[p,o,d]),x=z(async()=>{await b(),await(c==null?void 0:c())},[b,c]);return{keysSortOrder:S,submitLoading:N,isModalRendered:u,isFormRendered:g,loading:O,addNewAddress:p,addressesList:Z,addressId:T,handleRenderForm:V,handleRenderModal:h,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:U,closeNewAddressForm:y,redirectToAddressesRoute:M,handleOnSuccess:x,handleSelectAddressOption:P,selectedAddressOption:l}},d1=_e(({minifiedViewKey:e,hideActionFormButtons:s=!1,inputName:a,slots:r,title:d="",addressFormTitle:o="",defaultSelectAddressId:c="",showFormLoader:l=!1,onAddressData:i,forwardFormRef:u,className:f,showSaveCheckBox:g=!1,saveCheckBoxValue:C=!1,selectShipping:O=!1,selectBilling:L=!1,selectable:N=!1,withHeader:t=!0,minifiedView:p=!1,withActionsInMinifiedView:m=!1,withActionsInFullSizeView:T=!0,inputsDefaultValueSet:$,showShippingCheckBox:Z=!0,showBillingCheckBox:k=!0,shippingCheckBoxValue:S=!0,billingCheckBoxValue:R=!0,routeAddressesPage:b,onSuccess:U,onError:P})=>{const V=ae({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,ariaLabelAddressPicker:`Account.${e}.Addresses.ariaLabelAddressPicker`}),{keysSortOrder:K,submitLoading:h,isModalRendered:v,isFormRendered:y,loading:M,addNewAddress:x,addressesList:A,addressId:I,handleRenderForm:B,handleRenderModal:F,removeAddress:H,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ce,handleSelectAddressOption:ie,selectedAddressOption:ue}=Bt({defaultSelectAddressId:c,minifiedView:p,routeAddressesPage:b,onSuccess:U,onAddressData:i,selectShipping:O,selectBilling:L}),E=d||V.containerTitle;let j=null;if(N){const w=Pe(A,O,L)||[];let G;x?G=n("div",{className:Y(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",x]]),children:n(fe,{slots:r,hideActionFormButtons:s,formName:a,showFormLoader:l,isOpen:x,forwardFormRef:u,showSaveCheckBox:g,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:R,addressesFormTitle:o||V.differentAddressFormTitle,inputsDefaultValueSet:$,showShippingCheckBox:Z,showBillingCheckBox:k,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:i})}):w.length?G=n(Fe,{selectable:N,minifiedView:p,addNewAddress:x,routeAddressesPage:ce}):G=null;const J=`generalLabel_${E.replace(/\s+/g,"")}`;j=W("div",{className:"account-addresses-wrapper--select-view",children:[n("span",{id:J,style:"display: none;",children:E}),w.map((q,ge)=>{const be=`${a}_${q.id}`,Ne=`${be}_label`;return W($e,{children:[n("input",{"data-testid":`radio-${ge+1}`,type:"radio",name:a,id:be,value:q.id,checked:ue===(q==null?void 0:q.id.toString()),onChange:We=>ie(We,q),"aria-labelledby":`${J} ${Ne}`}),n("label",{id:Ne,htmlFor:be,className:"account-addresses-wrapper__label",children:n(ve,{slots:r,selectable:N,selectShipping:O,selectBilling:L,minifiedView:p,addressData:q,keysSortOrder:K,loading:M})})]},q.id)}),n("input",{"aria-label":`${E} ${V.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:a,id:`${a}_addressActions`,value:"0",checked:ue==="0",onChange:q=>ie(q,{}),tabindex:G?0:-1}),n("label",{htmlFor:`${a}_addressActions`,className:"account-addresses-wrapper__label",children:G})]})}else j=W(Q,{children:[A.map(w=>n($e,{children:I===w.id&&y?n(he,{variant:"secondary",style:{marginBottom:20},children:n(fe,{slots:r,isOpen:I===w.id&&y,addressFormId:I,inputsDefaultValueSet:w,addressesFormTitle:V.editAddressFormTitle,showShippingCheckBox:Z,showBillingCheckBox:k,shippingCheckBoxValue:S,billingCheckBoxValue:R,onCloseBtnClick:te,onSuccess:re,onError:P})}):n(ve,{slots:r,minifiedView:p,addressData:w,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:p&&m||!p&&T?F:void 0,handleRenderForm:p&&m||!p&&T?B:void 0},w.id)},w.id)),n("div",{className:"account-addresses__footer",children:x?n(he,{variant:"secondary",children:n(fe,{slots:r,isOpen:x,addressesFormTitle:V.newAddressFormTitle,inputsDefaultValueSet:$,showShippingCheckBox:!!(A!=null&&A.length),showBillingCheckBox:!!(A!=null&&A.length),shippingCheckBoxValue:S,billingCheckBoxValue:R,onCloseBtnClick:oe,onSuccess:re,onError:P})}):n(Fe,{minifiedView:p,addNewAddress:x,routeAddressesPage:ce})})]});return W("div",{children:[t?n(et,{title:E,divider:!p,className:p?"account-addresses-header":""}):null,W("div",{className:Y(["account-addresses-wrapper",f]),"data-testid":"addressesIdWrapper",children:[n(Rt,{minifiedView:p,addressData:A==null?void 0:A.find(w=>w.id===I),keysSortOrder:K,submitLoading:h,open:v,closeModal:te,onRemoveAddress:H}),M?n(Ue,{testId:"addressSkeletonLoader",withCard:!1}):N?n(fe,{slots:r,hideActionFormButtons:s,formName:a,isOpen:!(A!=null&&A.length),forwardFormRef:u,showSaveCheckBox:g,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:R,inputsDefaultValueSet:$,showShippingCheckBox:Z,showBillingCheckBox:k,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:i}):n(wt,{isEmpty:!(A!=null&&A.length),typeList:"address",minifiedView:p}),j]})]})}),je={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},zt={...je,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},kt={...je,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},qt=(e,s)=>s==null?void 0:s.map(a=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(a));if(Object.hasOwn(r,a.customUpperCode)){const o=r[a.customUpperCode];a.customUpperCode==="region"&&typeof o=="object"?d.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:d.defaultValue=o}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},Ut=({fields:e,addressId:s,countryOptions:a,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:c})=>e.filter(i=>!(s&&(i.customUpperCode==="defaultShipping"||i.customUpperCode==="defaultBilling")&&i.defaultValue)).map(i=>i.customUpperCode==="countryCode"?{...i,options:a,disabled:r}:i.customUpperCode==="postcode"?{...i,required:c}:i.customUpperCode==="region"?{...i,options:d,required:o,disabled:r}:i),Pt=(e,s="address")=>{const a=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","prefix","suffix","fax"],r={},d=[];return Object.keys(e).forEach(o=>{a.includes(o)?r[o]=e[o]:d.push({attribute_code:Be(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Se=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],a=["on","off","true","false"],r=[],d={};for(const L in e){const N=e[L];a.includes(N)&&(d[L]=ke(N)),s.includes(L)&&r.push(N)}const{street:o,streetMultiline_2:c,streetMultiline_1:l,region:i,...u}=e,[f,g]=i?i.split(","):[void 0,void 0],C=g&&f?{regionId:+g,regionCode:f}:{region:f};return Pt({...u,...d,region:{...C},street:r})},jt=(e,s)=>{const a={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const o=s.find(c=>(c==null?void 0:c.id)===d.regionId);o?a[r]={...d,text:o.text}:a[r]=d}else Array.isArray(d)?(a[r]=d[0]||"",d.slice(1).forEach((o,c)=>{a[`${r}Multiline_${c+2}`]=o})):a[r]=d}return a},Wt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Gt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:a,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:c,showBillingCheckBox:l,inputsDefaultValueSet:i,onCloseBtnClick:u,onSuccess:f,onError:g,formName:C})=>{const[O,L]=_({text:"",type:"success"}),[N,t]=_(e??!1),[p,m]=_(r||""),[T,$]=_([]),[Z,k]=_([]),[S,R]=_([]),[b,U]=_([]),[P,V]=_([]),[K,h]=_(!1),[v,y]=_(!1),[M,x]=_(()=>{var j,w;const E=sessionStorage.getItem(`${C}_addressData`);return E?{countryCode:(w=(j=JSON.parse(E))==null?void 0:j.data)==null?void 0:w.countryCode}:i}),[A,I]=_(!1),[B,F]=_(!1),[H,te]=_(()=>{var w,G;const E=sessionStorage.getItem(`${C}_addressData`);return E?(G=(w=JSON.parse(E))==null?void 0:w.data)==null?void 0:G.saveAddressBook:a}),re=z(E=>{te(E.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{ze(p?"customer_address_edit":"customer_register_address").then(E=>{$(E)})},[p]),ee(()=>{I(!0),ot().then(({availableCountries:E,countriesWithRequiredRegion:j,optionalZipCountries:w})=>{k(E),U(j),V(w),I(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){I(!0),F(!0);const E=M==null?void 0:M.countryCode;lt(E).then(j=>{R(j);const w=b.find(J=>J===E),G=P.find(J=>J===E);h(!!w),y(!G),I(!1),F(!1)})}},[M==null?void 0:M.countryCode,b,P]);const Le=z(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=z(async(E,j)=>{if(!j)return null;t(!0);const w=Oe(E.target),G=Se(w);await Ce(G).then(()=>{var J;f==null||f(),u==null||u(),(J=E==null?void 0:E.target)==null||J.reset()}).catch(J=>{L(q=>({...q,text:J.message,type:"error"})),g==null||g(J)}).finally(()=>{m(""),t(!1)})},[u,g,f]),ce=z(async(E,j)=>{if(!j)return;t(!0);const{saveAddressBook:w,...G}=Oe(E.target),J=Se(G);await ct(J).then(()=>{var q;f==null||f(),u==null||u(),(q=E==null?void 0:E.target)==null||q.reset()}).catch(q=>{L(ge=>({...ge,text:q.message,type:"error"})),g==null||g(q)}).finally(()=>{m(""),t(!1)})},[u,g,f]),ie=st(()=>{if(!T.length)return[];const E={...zt,defaultValue:o,isHidden:s&&!H?!0:!c},j={...kt,defaultValue:d,isHidden:s&&!H?!0:!l},w=[...T,E,j],G=sessionStorage.getItem(`${C}_addressData`),J=G?jt(JSON.parse(G).data,S):{},q=qt(Wt(J,i),w);return Ut({fields:q,addressId:p,countryOptions:Z,disableField:A,regionOptions:S,isRequiredRegion:K,isRequiredPostCode:v})},[T,o,s,H,c,d,l,C,S,i,p,Z,A,K,v]),ue=z(E=>{x(j=>({...j,...E}))},[]);return{isWaitingForResponse:B,regionOptions:S,saveCheckBoxAddress:H,inLineAlert:O,addressId:p,submitLoading:N,normalizeFieldsConfig:ie,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ce,handleOnCloseForm:Le,handleInputChange:ue}},Jt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(s[o.code]=o.value)});const{customAttributes:a,...r}=e;return{...r,...Ve(s,"camelCase",{})}},Xt=({hideActionFormButtons:e,formName:s="",showFormLoader:a=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:f,showShippingCheckBox:g=!0,showBillingCheckBox:C=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:N,onSubmit:t,onCloseBtnClick:p,onSuccess:m,onError:T,onChange:$})=>{const Z=ae({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:k,inLineAlert:S,addressId:R,submitLoading:b,normalizeFieldsConfig:U,handleUpdateAddress:P,handleCreateAddress:V,handleOnCloseForm:K,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:y,regionOptions:M}=Gt({showFormLoader:a,addressFormId:u,inputsDefaultValueSet:Jt(f),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:g,showBillingCheckBox:C,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:m,onError:T,onCloseBtnClick:p,formName:s});return N?W("div",{className:Y(["account-address-form-wrapper",i]),children:[l?n("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,S.text?n(tt,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:S.type,variant:"secondary",heading:S.text,icon:S.icon}):null,W(It,{regionOptions:M,forwardFormRef:o,slots:c,className:"account-address-form",name:s||"addressesForm",fieldsConfig:U,onSubmit:t||(R?P:V),setInputChange:y,loading:b,showFormLoader:a,showSaveCheckBox:r,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:$,isWaitingForResponse:k,children:[R?n("input",{type:"hidden",name:"addressId",value:R,"data-testid":"hidden_test_id"}):null,e?null:n("div",{className:Y(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:c!=null&&c.AddressFormActions?n(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:c.AddressFormActions,context:{handleUpdateAddress:P,handleCreateAddress:V,addressId:R}}):n(Q,{children:r?null:W(Q,{children:[n(de,{type:"button",onClick:K,variant:"secondary",disabled:b,children:Z.secondaryButton}),n(de,{disabled:b,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,wt as E,It as F,Ft as S,d1 as a,qe as c,n1 as d,Oe as g,Pt as n}; +import{jsx as a,Fragment as D,jsxs as G}from"@dropins/tools/preact-jsx-runtime.js";import{classes as Q,Slot as me}from"@dropins/tools/lib.js";import{Field as le,Picker as Je,Input as Xe,InputDate as Ke,Checkbox as Re,TextArea as Ye,Card as he,Skeleton as we,SkeletonRow as K,Button as de,Tag as pe,Icon as He,Modal as Qe,ProgressSpinner as De,IllustratedMessage as et,Header as tt,InLineAlert as rt}from"@dropins/tools/components.js";import{useRef as st,useState as $,useEffect as ee,useCallback as k,useMemo as nt}from"@dropins/tools/preact-hooks.js";import{n as Ve,o as ze,u as ye,c as ke,e as at,m as dt,j as ot,h as lt,i as it,d as ct}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as Y from"@dropins/tools/preact-compat.js";import{memo as _e,forwardRef as ut,useImperativeHandle as pt,useId as ft,useMemo as ve,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as Te}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:t,saveCheckBoxValue:d,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,billingCheckBoxValue:g,shippingCheckBoxValue:y,showBillingCheckBox:M,showShippingCheckBox:L,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>a("div",{className:Q(["account-address-form"]),children:a(Yt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,shippingCheckBoxValue:y,billingCheckBoxValue:g,showShippingCheckBox:L,showBillingCheckBox:M,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S,forwardFormRef:l,showSaveCheckBox:t,saveCheckBoxValue:d})}),At=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ht=e=>/^\d+$/.test(e),mt=e=>/^[a-zA-Z0-9\s]+$/.test(e),Lt=e=>/^[a-zA-Z0-9]+$/.test(e),gt=e=>/^[a-zA-Z]+$/.test(e),bt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),Ct=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),yt=(e,s,n)=>{const t=new Date(e).getTime()/1e3;return!(isNaN(t)||t<0||s!==void 0&&tn)},Ze=e=>!e||isNaN(Number(e))?"":new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],vt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),Mt=(e,s,n)=>{const t=e.length;return t>=s&&t<=n},Ce=(e,s,n,t)=>{var O,B;const{requiredFieldError:d,lengthTextError:l,numericError:i,alphaNumWithSpacesError:o,alphaNumericError:c,alphaError:p,emailError:f,dateError:g,urlError:y,dateLengthError:M}=n,L=s==null?void 0:s.customUpperCode,N={[L]:""};if(t[L]&&delete t[L],s!=null&&s.required&&(!e||e==="false"))return{[L]:d};if(!(s!=null&&s.required)&&!e||!((O=s==null?void 0:s.validateRules)!=null&&O.length))return N;const r=At(s==null?void 0:s.validateRules),u=r.MIN_TEXT_LENGTH??1,A=r.MAX_TEXT_LENGTH??255,T=r.DATE_RANGE_MIN,S=r.DATE_RANGE_MAX;if(!Mt(e,+u,+A)&&!(T||S))return{[L]:l.replace("{min}",u).replace("{max}",A)};if(!yt(e,+T,+S)&&(T||S))return{[L]:M.replace("{min}",Ze(T)).replace("{max}",Ze(S))};const q={numeric:{validate:ht,error:i},"alphanum-with-spaces":{validate:mt,error:o},alphanumeric:{validate:Lt,error:c},alpha:{validate:gt,error:p},email:{validate:bt,error:f},date:{validate:Ct,error:g},url:{validate:vt,error:y}}[r.INPUT_VALIDATION];return q&&!q.validate(e)&&!((B=t[L])!=null&&B.length)?{[L]:q.error}:N},qe=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},Et=["true","false","yes","on","off"],_t={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},$t=e=>{const s={},n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t],l=t.match(/^(.*)Multiline_(\d+)$/);if(l){const i=l[1],o=parseInt(l[2],10);n[i]||(n[i]=[]),n[i].push({index:o,value:d})}else Object.keys(e).filter(o=>o.startsWith(`${t}Multiline_`)).length>0?n[t]=[{index:1,value:d}]:s[t]=d}for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const d=n[t];d.sort((l,i)=>l.index-i.index),s[t]=d.map(l=>l.value)}return s},Nt=e=>{const s={},n=[];for(const t in e){const d=Et.includes(e[t])?qe(e[t]):e[t];Object.prototype.hasOwnProperty.call(e,t)&&(Object.prototype.hasOwnProperty.call(_t,t)?s[t]=d:n.push({code:ze(t),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Ve(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),t=Nt($t(n));if(!s)return t;const[d,l]=t.region?t.region.split(","):[];return{...t,region:{regionCode:d,...l&&{regionId:+l}}}},Ae=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((t,d)=>(d.name&&(t[d.name]=d.type==="checkbox"?d.checked:d.value),t),{})},Ie=(e,s)=>Object.keys(e).length?Object.keys(e).every(t=>t in s&&s[t]!==""):!1,Ue=e=>typeof e=="function",Tt=e=>e.reduce((s,{customUpperCode:n,required:t,defaultValue:d})=>(t&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),Se=e=>Object.keys(e).length>0,Zt=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:t,formName:d,isWaitingForResponse:l})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),o=st(null),[c,p]=$({}),[f,g]=$({}),[y,M]=$({}),[L,N]=$(!0),[r,u]=$(!1),[A,T]=$(!1),[S,_]=$(!0),[q,O]=$(!1);ee(()=>{const h=()=>{if(o.current){const b=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,C=o.current.querySelector(".account-address-form--saveAddressBook");C&&(C.style.gridRow=String(b-1))}};return h(),window.addEventListener("resize",h),()=>{window.removeEventListener("resize",h)}},[e==null?void 0:e.length]);const B=k((h=!1)=>{let v=!0;const b={...f};let C=null;for(const[x,m]of Object.entries(c)){const I=e==null?void 0:e.find(F=>F.customUpperCode.includes(x)),z=Ce(m.toString(),I,i,b);z[x]&&(Object.assign(b,z),v=!1),C||(C=Object.keys(b).find(F=>b[F])||null)}if(h||g(b),C&&o.current&&!h){const x=o.current.elements.namedItem(C);x==null||x.focus()}return v},[f,e,c,i]),w=k((h,v,b,C)=>{const x={...Ae(o),[v]:h,...v.includes("countryCode")?{region:""}:{}},m={data:ae(x,!0),isDataValid:Ie(b,x)};O(m.isDataValid),B(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(m)),n==null||n(m,{},C)},[B,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:h,errorList:v}=Tt(e);p(b=>({...h,...b})),g(v),M(v)}},[JSON.stringify(e)]),ee(()=>{if(A)return;const h=Ae(o),v=sessionStorage.getItem(`${d}_addressData`);if(Se(c)&&Se(y)){let b={};const C=Ie(y,c);v?b=JSON.parse(v).data:b=ae(h,!0)??{},n==null||n({data:b,isDataValid:C},{},null),O(C),T(!0)}},[c,y]),ee(()=>{var x;if(!S)return;const h=Ae(o),v=!!(h!=null&&h.countryCode),b=!!((x=h==null?void 0:h.region)!=null&&x.length);h&&v&&!b&&Ue(n)&&!l&&w(h==null?void 0:h.region,"region",y,null)},[S,L,e,o,n,w,y,r,l]);const Z=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C;p(H=>{const te={...H,[b]:I};return b==="countryCode"&&(te.region="",N(!0),u(!1)),te}),t==null||t({[b]:I}),T(!0);const z=e==null?void 0:e.find(H=>H.customUpperCode.includes(b));let F=v?{...v}:{...f};if(z){const H=Ce(I.toString(),z,i,F);H&&Object.assign(F,H),g(F)}w(I,b,y,h)},[t,e,f,i,w,y,L]),P=k(h=>{const{name:v}=h==null?void 0:h.target,b=e==null?void 0:e.find(C=>C.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&_(!1),_(v==="countryCode")},[]),j=k((h,v)=>{const{name:b,value:C,type:x,checked:m}=h==null?void 0:h.target,I=x==="checkbox"?m:C,z=e==null?void 0:e.find(F=>F.customUpperCode===b);if(z){const F=v?{...v}:{...f},H=Ce(I.toString(),z,i,F);H&&Object.assign(F,H),g(F)}},[f,e,i]),V=k(h=>{h.preventDefault();const v=B();s==null||s(h,v)},[B,s]);return{isDataValid:q,formData:c,errors:f,formRef:o,handleInputChange:Z,onFocus:P,handleBlur:j,handleSubmit:V,handleValidationSubmit:B}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const It=_e(({loading:e,values:s,fields:n=[],errors:t,className:d="",onChange:l,onBlur:i,onFocus:o,slots:c})=>{const p=`${d}__field`,f=(r,u)=>{if(!(c!=null&&c[`AddressFormInput_${r.code}`]))return;const A={inputName:r.customUpperCode,handleOnChange:l,handleOnBlur:i,handleOnFocus:o,errorMessage:u,errors:t,config:r};return a(me,{"data-testid":`addressFormInput_${r.code}`,name:`AddressFormInput_${r.code}`,slot:c[`AddressFormInput_${r.code}`],context:A},r.id)},g=(r,u,A)=>{var S;const T=((S=r.options.find(_=>_.isDefault))==null?void 0:S.value)??u??r.defaultValue;return a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Je,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,required:r==null?void 0:r.required,name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,options:r.options,onBlur:i,onFocus:o,handleSelect:l,defaultValue:T,value:T})},r.id)})},y=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Xe,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onFocus:o,onChange:l})},r.id)}),M=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e||r.disabled,children:a(Ke,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l,disabled:e||r.disabled})},r.id)}),L=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:(r==null?void 0:r.isHidden)??e,children:a(Re,{"aria-label":r.label,"aria-required":r.required?"true":"false","aria-hidden":r.isHidden,tabindex:r!=null&&r.isHidden?-1:0,id:r.code,name:r.customUpperCode,checked:u||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)}),N=(r,u,A)=>a(D,{children:f(r,A)??a(le,{error:A,className:Q([p,`${p}--${r.id}`,[`${p}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${d}--${r.id}`,disabled:e,children:a(Ye,{"aria-label":r.label,"aria-required":r.required?"true":"false",id:r.code,type:"text",name:r.customUpperCode,value:u??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:i,onChange:l})},r.id)});return n.length?a(D,{children:n.map(r=>{const u=t==null?void 0:t[r.customUpperCode],A=s==null?void 0:s[r.customUpperCode];switch(r.fieldType){case se.TEXT:return r.options.length?g(r,A,u):y(r,A,u);case se.MULTILINE:return y(r,A,u);case se.SELECT:return g(r,A,u);case se.DATE:return M(r,A,u);case se.BOOLEAN:return L(r,A,u);case se.TEXTAREA:return N(r,A,u);default:return null}})}):null}),Pe=({testId:e,withCard:s=!0})=>{const n=G(we,{"data-testid":e||"skeletonLoader",children:[a(K,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(K,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:Q(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},St=()=>G(we,{"data-testid":"addressFormLoader",children:[a(K,{variant:"heading",size:"medium"}),a(K,{variant:"empty",size:"medium"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0}),a(K,{size:"large",fullWidth:!0,lines:3}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large"}),a(K,{size:"large",fullWidth:!0})]}),xt=_e(ut(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:t,name:d,loading:l,children:i,className:o="defaultForm",fieldsConfig:c,onSubmit:p,onChange:f,forwardFormRef:g,regionOptions:y,showSaveCheckBox:M,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:N})=>{const r=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:u,formData:A,errors:T,formRef:S,handleInputChange:_,handleBlur:q,handleSubmit:O,handleValidationSubmit:B,onFocus:w}=Zt({fieldsConfig:c,onSubmit:p,onChange:f,setInputChange:s,regionOptions:y,formName:d,isWaitingForResponse:e});return pt(g,()=>{const Z=Ae(S);return{handleValidationSubmit:B,formData:ae(Z,!0),isDataValid:u}}),n||!(c!=null&&c.length)?a(St,{}):G("form",{className:Q(["account-form",o]),onSubmit:O,name:d,ref:S,children:[a(It,{className:o,loading:l,fields:c,onChange:_,onBlur:q,errors:T,values:A,onFocus:w,slots:t}),t!=null&&t.AddressFormInputs?a(me,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:t.AddressFormInputs,context:{formActions:{handleChange:_}}}):null,M?a("div",{className:"account-address-form--saveAddressBook",children:a(Re,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:r.saveAddressBook,checked:N,onChange:Z=>{_(Z),L==null||L(Z)}})}):null,i]})})),xe=(e,s,n={},t="editButton")=>{const d=t==="removeButton",l={shippingAndBilling:{edit:n.editAddressAriaLabelShippingAndBilling,remove:n.removeAddressAriaLabelShippingAndBilling},shipping:{edit:n.editAddressAriaLabelShipping,remove:n.removeAddressAriaLabelShipping},billing:{edit:n.editAddressAriaLabelBilling,remove:n.removeAddressAriaLabelBilling},default:{edit:n.editAddressAriaLabelDefault,remove:n.removeAddressAriaLabelDefault}};let i="default";return e&&s?i="shippingAndBilling":e?i="shipping":s&&(i="billing"),d?l[i].remove:l[i].edit},Me=({slots:e,selectable:s,selectShipping:n,selectBilling:t,variant:d="secondary",minifiedView:l,keysSortOrder:i,addressData:o,loading:c,setAddressId:p,handleRenderModal:f,handleRenderForm:g})=>{const y=ft(),M=l?"minifiedView":"fullSizeView",L=ne({actionRemove:`Account.${M}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${M}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${M}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${M}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${M}.Addresses.addressCard.defaultLabelText`,editAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.default`,editAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shipping`,editAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.billing`,editAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.editButton.shippingAndBilling`,removeAddressAriaLabelDefault:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.default`,removeAddressAriaLabelShipping:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shipping`,removeAddressAriaLabelBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.billing`,removeAddressAriaLabelShippingAndBilling:`Account.${M}.Addresses.addressCard.ariaLabel.removeButton.shippingAndBilling`}),N=L.cardLabelBilling.toLocaleUpperCase(),r=L.cardLabelShipping.toLocaleUpperCase(),u=L.defaultLabelText.toLocaleUpperCase(),A=ve(()=>{const Z={shippingLabel:r,billingLabel:N,hideShipping:!1,hideBilling:!1};return s?n&&!t?{shippingLabel:u,billingLabel:u,hideShipping:!1,hideBilling:!0}:t&&!n?{shippingLabel:u,billingLabel:u,hideShipping:!0,hideBilling:!1}:Z:Z},[N,u,r,t,n,s]),T=Ne(()=>{p==null||p(o==null?void 0:o.id),f==null||f()},[f,o==null?void 0:o.id,p]),S=Ne(()=>{p==null||p(o==null?void 0:o.id),g==null||g()},[g,o==null?void 0:o.id,p]),_=ve(()=>{if(!i)return[];const{region:Z,...P}=o,j={...P,...Z};return i.filter(({name:V})=>j[V]).map(V=>({name:V.name,orderNumber:V.orderNumber,value:j[V.name],label:V.label}))},[o,i]),{shippingLabel:q,billingLabel:O,hideShipping:B,hideBilling:w}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Pe,{}):G(D,{children:[G("div",{className:"account-address-card__action",children:[f?a(de,{type:"button",variant:"tertiary",onClick:T,"data-testid":"removeButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,L,"removeButton"),"aria-describedby":y,children:L.actionRemove}):null,g?a(de,{type:"button",variant:"tertiary",onClick:S,className:"account-address-card__action--editbutton","data-testid":"editButton","aria-label":xe(o==null?void 0:o.defaultShipping,o==null?void 0:o.defaultBilling,L,"editButton"),"aria-describedby":y,children:L.actionEdit}):null]}),a("div",{className:"account-address-card__description",id:y,children:e!=null&&e.AddressCard?a(me,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:_}}):a(D,{children:_.map((Z,P)=>{const j=Z.label?`${Z.label}: ${Z==null?void 0:Z.value}`:Z==null?void 0:Z.value;return a("p",{"data-testid":`${Z.name}_${P}`,children:j},P)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?G("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:r}):null,o!=null&&o.defaultBilling?a(pe,{label:N}):null]}):null,s?G("div",{className:"account-address-card__labels",children:[!B&&(o!=null&&o.defaultShipping)?a(pe,{label:q}):null,!w&&(o!=null&&o.defaultBilling)?a(pe,{label:O}):null]}):null]})})},Ft=e=>Y.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},Y.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),Y.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),Ot=e=>Y.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},Y.createElement("g",{id:"Large"},Y.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),Y.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},Y.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Bt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"currentColor"})),Rt=e=>Y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Y.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"currentColor"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:t,routeAddressesPage:d})=>{const l=t?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},p=t&&!n?i.viewAllAddressesButton:i.addNewAddressButton,f=e?i.differentAddressButton:p;return G(o,{...c,className:Q(["account-actions-address",["account-actions-address--viewall",t],["account-actions-address--address",!t],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:f}),a(He,{source:t&&!n?Ot:Ft,size:"32"})]})},wt=({minifiedView:e,keysSortOrder:s,addressData:n,open:t,submitLoading:d,onRemoveAddress:l,closeModal:i})=>{const o=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return t?a("div",{className:"account-address-modal",children:G(Qe,{className:"account-address-modal--overlay",title:a("h3",{children:c.title}),size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(De,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),G("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:l,children:c.actionConfirm})]})]})}):null},Ht=({typeList:e,isEmpty:s,minifiedView:n,className:t})=>{const d=n?"minifiedView":"fullSizeView",l=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=ve(()=>{switch(e){case"address":return{icon:Bt,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:Rt,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!i.text?null:a(et,{className:Q(["account-empty-list",n?"account-empty-list--minified":"",t]),message:i.text,icon:a(He,{source:i.icon}),"data-testid":"emptyList"})},Vt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(f=>!!f)?{}:{region:{...i.region,regionId:0}};return!!await ye({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),t=s[s.length-1],d=n[0]||((t==null?void 0:t.id)!==e?t:null);return!d||!d.id?!1:!!await ye({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},zt=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],or=["email","firstname","lastname","middlename","gender","dob","prefix","suffix","fax"],je=(e,s,n)=>{if(s&&n||!s&&!n)return e;const t=e.slice();return s?t.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?t.sort((d,l)=>Number(l.defaultBilling)-Number(d.defaultBilling)):e},Ee=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(Ee),kt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:t,minifiedView:d,routeAddressesPage:l,onSuccess:i})=>{const[o,c]=$(""),[p,f]=$(!1),[g,y]=$(!1),[M,L]=$(!1),[N,r]=$(!1),[u,A]=$(!1),[T,S]=$(""),[_,q]=$([]),[O,B]=$([]),w=k(async()=>{L(!0),Promise.all([ke("shortRequest"),at()]).then(m=>{const[I,z]=m;if(I){const F=I.map(({name:H,orderNumber:te,label:re})=>({name:dt(H),orderNumber:te,label:zt.includes(H)?null:re}));B(F)}if(z)if(d){const F=z.filter(H=>!!H.defaultShipping||!!H.defaultBilling);q(F)}else q(z)}).finally(()=>{L(!1)})},[d]);ee(()=>{w()},[w]),ee(()=>{var m;if(_.length)if(n===0)A(!0),c("0");else{const I=_.find(F=>+F.id===n)||je(_,e,s)[0],z={data:ae(I),isDataValid:!Ee(I)};c(n.toString()||((m=I==null?void 0:I.id)==null?void 0:m.toString())),t==null||t(z)}},[_,n,t,s,e]);const Z=k(m=>{S(m),A(!1)},[]),P=k((m,I)=>{const z=(m==null?void 0:m.target).value,F=(m==null?void 0:m.target).nextSibling;c(z);const H={data:ae(I),isDataValid:!Ee(ae(I))};t==null||t(H),A(z==="0"),F&&(F.focus(),window.scrollBy(0,100))},[t]),j=k(()=>{y(!0)},[]),V=k(()=>{S(""),y(!1),f(!1)},[]),h=k(()=>{f(!0)},[]),v=k(async()=>{r(!0),await Vt(T,_),ot(+T).then(()=>{w(),V()}).finally(()=>{r(!1)})},[_,T,V,w]),b=k(()=>{A(!1)},[]),C=k(()=>{Ue(l)&&d&&!u?window.location.href=l():(A(!0),S(""))},[u,l,d]),x=k(async()=>{await w(),await(i==null?void 0:i())},[w,i]);return{keysSortOrder:O,submitLoading:N,isModalRendered:p,isFormRendered:g,loading:M,addNewAddress:u,addressesList:_,addressId:T,handleRenderForm:j,handleRenderModal:h,removeAddress:v,onCloseBtnClick:V,setEditingAddressId:Z,closeNewAddressForm:b,redirectToAddressesRoute:C,handleOnSuccess:x,handleSelectAddressOption:P,selectedAddressOption:o}},lr=_e(({minifiedViewKey:e,hideActionFormButtons:s=!1,inputName:n,slots:t,title:d="",addressFormTitle:l="",defaultSelectAddressId:i="",showFormLoader:o=!1,onAddressData:c,forwardFormRef:p,className:f,showSaveCheckBox:g=!1,saveCheckBoxValue:y=!1,selectShipping:M=!1,selectBilling:L=!1,selectable:N=!1,withHeader:r=!0,minifiedView:u=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:T=!0,inputsDefaultValueSet:S,showShippingCheckBox:_=!0,showBillingCheckBox:q=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:B=!0,routeAddressesPage:w,onSuccess:Z,onError:P})=>{const j=ne({containerTitle:`Account.${e}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${e}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${e}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${e}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${e}.Addresses.newAddressFormTitle`,ariaLabelAddressPicker:`Account.${e}.Addresses.ariaLabelAddressPicker`}),{keysSortOrder:V,submitLoading:h,isModalRendered:v,isFormRendered:b,loading:C,addNewAddress:x,addressesList:m,addressId:I,handleRenderForm:z,handleRenderModal:F,removeAddress:H,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=kt({defaultSelectAddressId:i,minifiedView:u,routeAddressesPage:w,onSuccess:Z,onAddressData:c,selectShipping:M,selectBilling:L}),E=d||j.containerTitle;let W=null;if(N){const R=je(m,M,L)||[];let J;x?J=a("div",{className:Q(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",x]]),children:a(fe,{slots:t,hideActionFormButtons:s,formName:n,showFormLoader:o,isOpen:x,forwardFormRef:p,showSaveCheckBox:g,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,addressesFormTitle:l||j.differentAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c})}):R.length?J=a(Fe,{selectable:N,minifiedView:u,addNewAddress:x,routeAddressesPage:ie}):J=null;const X=`generalLabel_${E.replace(/\s+/g,"")}`;W=G("div",{className:"account-addresses-wrapper--select-view",children:[a("span",{id:X,style:"display: none;",children:E}),R.map((U,ge)=>{const be=`${n}_${U.id}`,$e=`${be}_label`;return G(Te,{children:[a("input",{"data-testid":`radio-${ge+1}`,type:"radio",name:n,id:be,value:U.id,checked:ue===(U==null?void 0:U.id.toString()),onChange:Ge=>ce(Ge,U),"aria-labelledby":`${X} ${$e}`}),a("label",{id:$e,htmlFor:be,className:"account-addresses-wrapper__label",children:a(Me,{slots:t,selectable:N,selectShipping:M,selectBilling:L,minifiedView:u,addressData:U,keysSortOrder:V,loading:C})})]},U.id)}),a("input",{"aria-label":`${E} ${j.ariaLabelAddressPicker}`,"data-testid":"radio-0",type:"radio",name:n,id:`${n}_addressActions`,value:"0",checked:ue==="0",onChange:U=>ce(U,{}),tabindex:J?0:-1}),a("label",{htmlFor:`${n}_addressActions`,className:"account-addresses-wrapper__label",children:J})]})}else W=G(D,{children:[m.map(R=>a(Te,{children:I===R.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:t,isOpen:I===R.id&&b,addressFormId:I,inputsDefaultValueSet:R,addressesFormTitle:j.editAddressFormTitle,showShippingCheckBox:_,showBillingCheckBox:q,shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:te,onSuccess:re,onError:P})}):a(Me,{slots:t,minifiedView:u,addressData:R,keysSortOrder:V,loading:C,setAddressId:Le,handleRenderModal:u&&A||!u&&T?F:void 0,handleRenderForm:u&&A||!u&&T?z:void 0},R.id)},R.id)),a("div",{className:"account-addresses__footer",children:x?a(he,{variant:"secondary",children:a(fe,{slots:t,isOpen:x,addressesFormTitle:j.newAddressFormTitle,inputsDefaultValueSet:S,showShippingCheckBox:!!(m!=null&&m.length),showBillingCheckBox:!!(m!=null&&m.length),shippingCheckBoxValue:O,billingCheckBoxValue:B,onCloseBtnClick:oe,onSuccess:re,onError:P})}):a(Fe,{minifiedView:u,addNewAddress:x,routeAddressesPage:ie})})]});return G("div",{children:[r?a(tt,{title:E,divider:!u,className:u?"account-addresses-header":""}):null,G("div",{className:Q(["account-addresses-wrapper",f]),"data-testid":"addressesIdWrapper",children:[a(wt,{minifiedView:u,addressData:m==null?void 0:m.find(R=>R.id===I),keysSortOrder:V,submitLoading:h,open:v,closeModal:te,onRemoveAddress:H}),C?a(Pe,{testId:"addressSkeletonLoader",withCard:!1}):N?a(fe,{slots:t,hideActionFormButtons:s,formName:n,isOpen:!(m!=null&&m.length),forwardFormRef:p,showSaveCheckBox:g,saveCheckBoxValue:y,shippingCheckBoxValue:O,billingCheckBoxValue:B,inputsDefaultValueSet:S,showShippingCheckBox:_,showBillingCheckBox:q,onCloseBtnClick:oe,onSuccess:re,onError:P,onChange:c}):a(Ht,{isEmpty:!(m!=null&&m.length),typeList:"address",minifiedView:u}),W]})]})}),We={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},qt={...We,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ut={...We,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Pt=(e,s)=>s==null?void 0:s.map(n=>{const t={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(t,n.customUpperCode)){const l=t[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(t=>{s.has(t.name)||s.set(t.name,"false"),t.checked&&s.set(t.name,"true")}),s&&typeof s.entries=="function"){const t=s.entries();if(t&&typeof t[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(t)))||{}}return{}},jt=({fields:e,addressId:s,countryOptions:n,disableField:t,regionOptions:d,isRequiredRegion:l,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:t}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:l,disabled:t}:c),Wt=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","prefix","suffix","fax"],t={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?t[l]=e[l]:d.push({attribute_code:ze(l),value:e[l]})}),d.length>0&&(t.custom_attributesV2=d),t},Be=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],t=[],d={};for(const L in e){const N=e[L];n.includes(N)&&(d[L]=qe(N)),s.includes(L)&&t.push(N)}const{street:l,streetMultiline_2:i,streetMultiline_1:o,region:c,...p}=e,[f,g]=c?c.split(","):[void 0,void 0],y=g&&f?{regionId:+g,regionCode:f}:{region:f};return Wt({...p,...d,region:{...y},street:t})},Gt=(e,s)=>{const n={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const d=e[t];if(t==="region"&&d.regionId){const l=s.find(i=>(i==null?void 0:i.id)===d.regionId);l?n[t]={...d,text:l.text}:n[t]=d}else Array.isArray(d)?(n[t]=d[0]||"",d.slice(1).forEach((l,i)=>{n[`${t}Multiline_${i+2}`]=l})):n[t]=d}return n},Jt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Xt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:t,billingCheckBoxValue:d,shippingCheckBoxValue:l,showShippingCheckBox:i,showBillingCheckBox:o,inputsDefaultValueSet:c,onCloseBtnClick:p,onSuccess:f,onError:g,formName:y})=>{const[M,L]=$({text:"",type:"success"}),[N,r]=$(e??!1),[u,A]=$(t||""),[T,S]=$([]),[_,q]=$([]),[O,B]=$([]),[w,Z]=$([]),[P,j]=$([]),[V,h]=$(!1),[v,b]=$(!1),[C,x]=$(()=>{var W,R;const E=sessionStorage.getItem(`${y}_addressData`);return E?{countryCode:(R=(W=JSON.parse(E))==null?void 0:W.data)==null?void 0:R.countryCode}:c}),[m,I]=$(!1),[z,F]=$(!1),[H,te]=$(()=>{var R,J;const E=sessionStorage.getItem(`${y}_addressData`);return E?(J=(R=JSON.parse(E))==null?void 0:R.data)==null?void 0:J.saveAddressBook:n}),re=k(E=>{te(E.target.checked)},[]);ee(()=>{typeof e>"u"||r(e)},[e]),ee(()=>{ke(u?"customer_address_edit":"customer_register_address").then(E=>{S(E)})},[u]),ee(()=>{I(!0),lt().then(({availableCountries:E,countriesWithRequiredRegion:W,optionalZipCountries:R})=>{q(E),Z(W),j(R),I(!1)})},[]),ee(()=>{if(C!=null&&C.countryCode){I(!0),F(!0);const E=C==null?void 0:C.countryCode;it(E).then(W=>{B(W);const R=w.find(X=>X===E),J=P.find(X=>X===E);h(!!R),b(!J),I(!1),F(!1)})}},[C==null?void 0:C.countryCode,w,P]);const Le=k(()=>{L({text:"",type:"success"}),p==null||p()},[p]),oe=k(async(E,W)=>{if(!W)return null;r(!0);const R=Oe(E.target),J=Be(R);await ye(J).then(()=>{var X;f==null||f(),p==null||p(),(X=E==null?void 0:E.target)==null||X.reset()}).catch(X=>{L(U=>({...U,text:X.message,type:"error"})),g==null||g(X)}).finally(()=>{A(""),r(!1)})},[p,g,f]),ie=k(async(E,W)=>{if(!W)return;r(!0);const{saveAddressBook:R,...J}=Oe(E.target),X=Be(J);await ct(X).then(()=>{var U;f==null||f(),p==null||p(),(U=E==null?void 0:E.target)==null||U.reset()}).catch(U=>{L(ge=>({...ge,text:U.message,type:"error"})),g==null||g(U)}).finally(()=>{A(""),r(!1)})},[p,g,f]),ce=nt(()=>{if(!T.length)return[];const E={...qt,defaultValue:l,isHidden:s&&!H?!0:!i},W={...Ut,defaultValue:d,isHidden:s&&!H?!0:!o},R=[...T,E,W],J=sessionStorage.getItem(`${y}_addressData`),X=J?Gt(JSON.parse(J).data,O):{},U=Pt(Jt(X,c),R);return jt({fields:U,addressId:u,countryOptions:_,disableField:m,regionOptions:O,isRequiredRegion:V,isRequiredPostCode:v})},[T,l,s,H,i,d,o,y,O,c,u,_,m,V,v]),ue=k(E=>{x(W=>({...W,...E}))},[]);return{isWaitingForResponse:z,regionOptions:O,saveCheckBoxAddress:H,inLineAlert:M,addressId:u,submitLoading:N,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},Kt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(l=>{l.code&&Object.hasOwn(l,"value")&&(s[l.code]=l.value)});const{customAttributes:n,...t}=e;return{...t,...Ve(s,"camelCase",{})}},Yt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:t=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:p,inputsDefaultValueSet:f,showShippingCheckBox:g=!0,showBillingCheckBox:y=!0,shippingCheckBoxValue:M=!0,billingCheckBoxValue:L=!0,isOpen:N,onSubmit:r,onCloseBtnClick:u,onSuccess:A,onError:T,onChange:S})=>{const _=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:q,inLineAlert:O,addressId:B,submitLoading:w,normalizeFieldsConfig:Z,handleUpdateAddress:P,handleCreateAddress:j,handleOnCloseForm:V,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:C}=Xt({showFormLoader:n,addressFormId:p,inputsDefaultValueSet:Kt(f),shippingCheckBoxValue:M,billingCheckBoxValue:L,showShippingCheckBox:g,showBillingCheckBox:y,saveCheckBoxValue:d,showSaveCheckBox:t,onSuccess:A,onError:T,onCloseBtnClick:u,formName:s});return N?G("div",{className:Q(["account-address-form-wrapper",c]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,O.text?a(rt,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,G(xt,{regionOptions:C,forwardFormRef:l,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:Z,onSubmit:r||(B?P:j),setInputChange:b,loading:w,showFormLoader:n,showSaveCheckBox:t,handleSaveCheckBoxAddress:h,saveCheckBoxAddress:v,onChange:S,isWaitingForResponse:q,children:[B?a("input",{type:"hidden",name:"addressId",value:B,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:Q(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",t]]),children:i!=null&&i.AddressFormActions?a(me,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:P,handleCreateAddress:j,addressId:B}}):a(D,{children:t?null:G(D,{children:[a(de,{type:"button",onClick:V,variant:"secondary",disabled:w,children:_.secondaryButton}),a(de,{disabled:w,children:_.primaryButton})]})})})]})]}):null};export{fe as A,Pe as C,Ht as E,xt as F,Ot as S,lr as a,Ue as c,or as d,Oe as g,Wt as n}; diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js index 03ed904d0..21f893706 100644 --- a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js @@ -1,3 +1,3 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{jsxs as L,jsx as d,Fragment as he}from"@dropins/tools/preact-jsx-runtime.js";import{classes as ne,Slot as ge}from"@dropins/tools/lib.js";import{F as we,d as Ce,g as Pe,n as ee,C as pe}from"../chunks/CustomerInformationCard.js";import*as V from"@dropins/tools/preact-compat.js";import{Card as X,Header as Q,InLineAlert as oe,InputPassword as R,Button as B}from"@dropins/tools/components.js";import{useState as m,useEffect as U,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ee}from"../chunks/getStoreConfig.js";import{u as be,g as Ve,b as re,a as ye}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ie}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const _e=e=>V.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("g",{clipPath:"url(#clip0_841_1324)"},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),V.createElement("defs",null,V.createElement("clipPath",{id:"clip0_841_1324"},V.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ve=e=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Le=e=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Fe=e=>({firstName:e.firstName,lastName:e.lastName,emailAddress:(e==null?void 0:e.email)||"",accountId:(e==null?void 0:e.email)||""}),Ne=()=>{const[e,r]=m(null);return U(()=>{const n=sessionStorage.getItem("accountStoreConfig"),t=n?JSON.parse(n):null;if(t){const{minLength:o,requiredCharacterClasses:s}=t;r({minLength:o,requiredCharacterClasses:s})}else Ee().then(o=>{if(o){const{minLength:s,requiredCharacterClasses:P}=o;sessionStorage.setItem("accountStoreConfig",JSON.stringify(o)),r({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},Ae=({currentPassword:e,newPassword:r,confirmPassword:n,translations:t})=>{let o={...K};const s=!e.length&&!r.length&&!n.length,P=e.length&&r!==n;return s?(o={...o,currentPassword:t.requiredFieldError,newPassword:t.requiredFieldError,confirmPassword:t.requiredFieldError},{isValid:!1,errors:o}):e.length?r.length?n.length?P?(o={...o,currentPassword:"",newPassword:"",confirmPassword:t.passwordMismatch},{isValid:!1,errors:o}):{isValid:!0,errors:o}:(o={...o,confirmPassword:t.requiredFieldError},{isValid:!1,errors:o}):(o={...o,newPassword:t.requiredFieldError},{isValid:!1,errors:o}):(o={...o,currentPassword:t.requiredFieldError},{isValid:!1,errors:o})},ae=(e,r)=>{if(r<=1)return!0;const n=/[0-9]/.test(e)?1:0,t=/[a-z]/.test(e)?1:0,o=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return n+t+o+s>=r},K={currentPassword:"",newPassword:"",confirmPassword:""},Se=({passwordConfigs:e,handleSetInLineAlert:r,handleHideChangePassword:n})=>{const t=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[o,s]=m(!1),[P,u]=m(!1),[c,p]=m(""),[h,l]=m(""),[F,y]=m(""),[I,E]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{n(()=>{r({}),E(K)})},[n,r]),A=C(f=>{p(f),E(b=>({...b,currentPassword:f?"":t.requiredFieldError}))},[t]),w=C(f=>{l(f),E(b=>({...b,newPassword:f?"":t.requiredFieldError}))},[t]),H=C(f=>{y(f),E(b=>({...b,confirmPassword:f?"":t.requiredFieldError}))},[t]),N=C(f=>{const{name:b,value:$}=f==null?void 0:f.target;E(_=>({..._,[b]:$?"":t.requiredFieldError}))},[t]),O=C(()=>{const{isValid:f,errors:b}=Ae({currentPassword:c,newPassword:h,confirmPassword:F,translations:t});return E(b),f},[c,h,F,t]),Z=C(f=>{f.preventDefault(),u(!0);const b=(e==null?void 0:e.requiredCharacterClasses)??0,$=(e==null?void 0:e.minLength)??1;if(!O()){s(!0),u(!1);return}if(!ae(h,b)||$>(h==null?void 0:h.length)){s(!0),u(!1);return}be({currentPassword:c,newPassword:h}).then(_=>{if(!(_!=null&&_.length)){u(!1);return}p(""),l(""),y(""),E(K),s(!1),r({type:"success",text:t.passwordUpdateMessage})}).catch(_=>{_.message==="Invalid login or password."&&r({type:"error",text:t.incorrectCurrentPassword}),_.message==="The account is locked."&&r({type:"error",text:_.message})}),u(!1)},[e,O,h,c,r,t]);return{hideChangePassword:i,handleOnBlurPassword:N,handleConfirmPasswordChange:H,handleNewPasswordChange:w,handleCurrentPasswordChange:A,mutationChangePassword:Z,currentPassword:c,newPassword:h,confirmPassword:F,passwordErrors:I,submitLoading:P,isClickSubmit:o}},Te=({passwordConfigs:e,isClickSubmit:r,password:n})=>{const t=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[o,s]=m("pending");U(()=>{if(!e)return;const u=ae(n,e.requiredCharacterClasses);r&&n.length>0?s(u?"success":"error"):r&&n.length===0?s("pending"):s(u?"success":"pending")},[r,e,n]);const P=G(()=>{var c;if(!e)return;const u={status:"pending",icon:"pending",message:(c=t.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return n.length&&n.length>=e.minLength?{...u,icon:"success",status:"success"}:n.length&&n.lengthe==="error"||(r==null?void 0:r.status)==="error"||n&&t.trim().length===0?o.newPassword:void 0,qe=({handleHideChangePassword:e,handleSetInLineAlert:r,inLineAlertProps:n})=>{const{passwordConfigs:t}=Ne(),{hideChangePassword:o,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:u,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:l,confirmPassword:F,passwordErrors:y,submitLoading:I,isClickSubmit:E}=Se({passwordConfigs:t,handleSetInLineAlert:r,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:A}=Te({password:l,isClickSubmit:E,passwordConfigs:t}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return L(X,{className:"account-change-password",variant:"secondary",children:[d(Q,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),n.text?d(oe,{className:"account-change-password__notification",type:n.type,variant:"secondary",heading:n.text,icon:n.icon,"data-testid":"changePasswordInLineAlert"}):null,L("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:t==null?void 0:t.minLength,validateLengthConfig:A,uniqueSymbolsStatus:i,requiredCharacterClasses:t==null?void 0:t.requiredCharacterClasses,errorMessage:Me(i,A,E,l,y),defaultValue:l,onValue:u,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:F,onValue:P,onBlur:s})]}),L("div",{className:"account-change-password__actions",children:[d(B,{type:"button",disabled:I,onClick:o,variant:"secondary",children:w.buttonSecondary}),d(B,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},ke=({inLineAlertProps:e,errorPasswordEmpty:r,passwordValue:n,showPasswordOnEmailChange:t,submitLoading:o,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:u,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return L(X,{variant:"secondary",className:"account-edit-customer-information",children:[d(Q,{title:l.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(oe,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,L(we,{loading:o,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:u,setInputChange:c,children:[t?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:l.placeholder,floatingLabel:l.floatingLabel,errorMessage:r?l.requiredFieldError:void 0,defaultValue:n,onValue:p,onBlur:h})}):null,L("div",{className:"account-edit-customer-information__actions",children:[d(B,{disabled:o,type:"button",variant:"secondary",onClick:()=>P(),children:l.buttonSecondary}),d(B,{disabled:o,type:"submit",variant:"primary",children:l.buttonPrimary})]})]})]})},xe=({createdAt:e,slots:r,orderedCustomerData:n,showEditForm:t,showChangePassword:o,handleShowChangePassword:s,handleShowEditForm:P})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(X,{variant:"secondary",className:ne(["account-customer-information-card",["account-customer-information-card-short",o||t]]),children:L("div",{className:"account-customer-information-card__wrapper",children:[L("div",{className:"account-customer-information-card__actions",children:[d(B,{type:"button",variant:"tertiary",onClick:s,children:u.buttonSecondary}),d(B,{type:"button",variant:"tertiary",onClick:P,children:u.buttonPrimary})]}),d("div",{className:"account-customer-information-card__content",children:r!=null&&r.CustomerData?d(ge,{name:"CustomerData",slot:r==null?void 0:r.CustomerData,context:{customerData:n}}):L(he,{children:[n==null?void 0:n.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),L("p",{children:[u.accountCreation,": ",e]})]})})]})})},Oe=e=>{if(!(e!=null&&e.dateOfBirth))return e;const{dateOfBirth:r,...n}=e;return{...n,dob:r}},Ue="accountContext";var k=(e=>(e.EDIT_ACCOUNT_EVENT="edit-account",e))(k||{});const Be={EDIT_ACCOUNT_EVENT:"edit-account"};function se(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function He(e,r){const n=se();n.push({[e]:null}),n.push({[e]:r})}function Ze(e,r){se().push(t=>{const o=t.getState?t.getState():{};t.push({event:e,eventInfo:{...o,...r}})})}function $e(e){const r=Fe(e);He(Ue,r),Ze(Be.EDIT_ACCOUNT_EVENT)}const te=(e,r)=>{const n=sessionStorage.getItem("accountStoreConfig"),o={...n?JSON.parse(n):{},...r};switch(e){case"edit-account":$e(o);break;default:return null}},ze=({handleSetInLineAlert:e})=>{const r=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[n,t]=m(!0),[o,s]=m(!1),[P,u]=m(!1),[c,p]=m(!1),[h,l]=m(!1),[F,y]=m(!1),[I,E]=m([]),[i,A]=m(null),[w,H]=m([]),[N,O]=m({}),[Z,f]=m(""),[b,$]=m(""),_=C(a=>{const{value:g}=a==null?void 0:a.target;g.length&&l(!1),g.length||l(!0)},[]),S=C(a=>{f(a)},[]),ie=C(a=>{O(a)},[]),ce=C(()=>{u(!0),p(!1),e(),S("")},[e,S]),de=C(a=>{a==null||a(),u(!1)},[]),ue=C(()=>{p(!0),u(!1),e(),S("")},[e,S]),le=C(a=>{a==null||a(),p(!1)},[]),T=C((a,g)=>{a==="success"?e({type:"success",text:g??r.accountSuccess}):a==="error"?e({type:"error",text:g??r.accountError}):e(),s(!1)},[e,r]),j=C(()=>{Ve().then(a=>{var v;const g=(v=a==null?void 0:a.createdAt)==null?void 0:v.split(" ")[0],W=Oe({...a,gender:a.gender===1?r.genderMale:r.genderFemale});A(W),$(g)})},[r.genderFemale,r.genderMale]);U(()=>{j()},[]),U(()=>{Ie("customer_account_edit").then(a=>{H(a);const g=a.map(({name:W,customUpperCode:v,orderNumber:M,label:D})=>({name:v,orderNumber:M,label:Ce.includes(W)?null:D}));E(g)})},[]),U(()=>{N.email&&N.email!==(i==null?void 0:i.email)?y(!0):N.email&&N.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,N]);const z=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);U(()=>{z!=null&&z.length&&t(!1)},[z]);const me=G(()=>w==null?void 0:w.map(a=>({...a,defaultValue:a!=null&&a.customUpperCode&&i?i[a.customUpperCode]??"":""})).map(a=>a.customUpperCode==="gender"?{...a,defaultValue:a.defaultValue==="Male"?1:2}:a),[w,i]),fe=C(async(a,g)=>{const W=Pe(a.target),{email:v,password:M,...D}=W,Y=v!==(i==null?void 0:i.email)&&M.length===0;if(!g){Y&&l(!0);return}if(l(!1),s(!0),v===(i==null?void 0:i.email)){S(""),re(ee(D,"account")).then(q=>{q&&(j(),T("success"),te(k==null?void 0:k.EDIT_ACCOUNT_EVENT,{...i}))}).catch(q=>{T("error",q.message)});return}if(Y){l(!0),s(!1);return}v!=null&&v.length&&(M!=null&&M.length)&&ye({email:v,password:M}).then(q=>{q&&re(ee(D,"account")).then(J=>{J&&(j(),T("success"),te(k==null?void 0:k.EDIT_ACCOUNT_EVENT,{...i}))}).catch(J=>{T("error",J.message)})}).catch(q=>{T("error",q.message)})},[i,S,j,T]);return{createdAt:b,errorPasswordEmpty:h,passwordValue:Z,showPasswordOnEmailChange:F,orderedCustomerData:z,loading:n,normalizeFieldsConfig:me,submitLoading:o,showEditForm:c,showChangePassword:P,handleShowChangePassword:ce,handleHideChangePassword:de,handleShowEditForm:ue,handleHideEditForm:le,handleUpdateCustomerInformation:fe,handleInputChange:ie,handleSetPassword:S,handleOnBlurPassword:_,renderAlertMessage:T}},We={success:d(ve,{}),warning:d(_e,{}),error:d(Le,{})},je=()=>{const[e,r]=m({}),n=C(t=>{if(!(t!=null&&t.type)){r({});return}const o=We[t.type];r({...t,icon:o})},[]);return{inLineAlertProps:e,handleSetInLineAlert:n}},ar=({className:e,withHeader:r=!0,slots:n})=>{const t=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:o,handleSetInLineAlert:s}=je(),{createdAt:P,errorPasswordEmpty:u,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:l,normalizeFieldsConfig:F,submitLoading:y,showEditForm:I,showChangePassword:E,handleShowChangePassword:i,handleHideChangePassword:A,handleShowEditForm:w,handleHideEditForm:H,handleUpdateCustomerInformation:N,handleInputChange:O,handleSetPassword:Z,handleOnBlurPassword:f}=ze({handleSetInLineAlert:s});return l?d("div",{"data-testid":"customerInformationLoader",children:d(pe,{withCard:!0})}):L("div",{className:ne(["account-customer-information",e]),children:[r?d(Q,{title:t.containerTitle,divider:!1,className:"customer-information__title"}):null,d(xe,{createdAt:P,slots:n,orderedCustomerData:h,showEditForm:I,showChangePassword:E,handleShowChangePassword:i,handleShowEditForm:w}),E?d(qe,{inLineAlertProps:o,handleSetInLineAlert:s,handleHideChangePassword:A}):null,I?d(ke,{inLineAlertProps:o,submitLoading:y,formFieldsList:F,errorPasswordEmpty:u,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:Z,handleOnBlurPassword:f,handleUpdateCustomerInformation:N,handleHideEditForm:H,handleInputChange:O}):null]})};export{ar as CustomerInformation,ar as default}; +import{jsxs as L,jsx as d,Fragment as he}from"@dropins/tools/preact-jsx-runtime.js";import{classes as ne,Slot as ge}from"@dropins/tools/lib.js";import{F as we,d as Ce,g as Pe,n as ee,C as pe}from"../chunks/CustomerInformationCard.js";import*as V from"@dropins/tools/preact-compat.js";import{Card as X,Header as Q,InLineAlert as oe,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ee}from"../chunks/getStoreConfig.js";import{u as be,g as Ve,b as re,a as ye}from"../chunks/updateCustomer.js";import{useText as O}from"@dropins/tools/i18n.js";import{c as Ie}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const _e=e=>V.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("g",{clipPath:"url(#clip0_841_1324)"},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),V.createElement("defs",null,V.createElement("clipPath",{id:"clip0_841_1324"},V.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ve=e=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Le=e=>V.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),V.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Fe=e=>({firstName:e.firstName,lastName:e.lastName,emailAddress:(e==null?void 0:e.email)||"",accountId:(e==null?void 0:e.email)||""}),Ne=()=>{const[e,r]=m(null);return B(()=>{const n=sessionStorage.getItem("accountStoreConfig"),t=n?JSON.parse(n):null;if(t){const{minLength:o,requiredCharacterClasses:s}=t;r({minLength:o,requiredCharacterClasses:s})}else Ee().then(o=>{if(o){const{minLength:s,requiredCharacterClasses:P}=o;sessionStorage.setItem("accountStoreConfig",JSON.stringify(o)),r({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},Ae=({currentPassword:e,newPassword:r,confirmPassword:n,translations:t})=>{let o={...K};const s=!e.length&&!r.length&&!n.length,P=e.length&&r!==n;return s?(o={...o,currentPassword:t.requiredFieldError,newPassword:t.requiredFieldError,confirmPassword:t.requiredFieldError},{isValid:!1,errors:o}):e.length?r.length?n.length?P?(o={...o,currentPassword:"",newPassword:"",confirmPassword:t.passwordMismatch},{isValid:!1,errors:o}):{isValid:!0,errors:o}:(o={...o,confirmPassword:t.requiredFieldError},{isValid:!1,errors:o}):(o={...o,newPassword:t.requiredFieldError},{isValid:!1,errors:o}):(o={...o,currentPassword:t.requiredFieldError},{isValid:!1,errors:o})},ae=(e,r)=>{if(r<=1)return!0;const n=/[0-9]/.test(e)?1:0,t=/[a-z]/.test(e)?1:0,o=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return n+t+o+s>=r},K={currentPassword:"",newPassword:"",confirmPassword:""},Se=({passwordConfigs:e,handleSetInLineAlert:r,handleHideChangePassword:n})=>{const t=O({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[o,s]=m(!1),[P,u]=m(!1),[c,p]=m(""),[h,l]=m(""),[F,y]=m(""),[I,E]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{n(()=>{r({}),E(K)})},[n,r]),A=C(f=>{p(f),E(b=>({...b,currentPassword:f?"":t.requiredFieldError}))},[t]),w=C(f=>{l(f),E(b=>({...b,newPassword:f?"":t.requiredFieldError}))},[t]),Z=C(f=>{y(f),E(b=>({...b,confirmPassword:f?"":t.requiredFieldError}))},[t]),N=C(f=>{const{name:b,value:z}=f==null?void 0:f.target;E(_=>({..._,[b]:z?"":t.requiredFieldError}))},[t]),U=C(()=>{const{isValid:f,errors:b}=Ae({currentPassword:c,newPassword:h,confirmPassword:F,translations:t});return E(b),f},[c,h,F,t]),$=C(f=>{f.preventDefault(),u(!0);const b=(e==null?void 0:e.requiredCharacterClasses)??0,z=(e==null?void 0:e.minLength)??1;if(!U()){s(!0),u(!1);return}if(!ae(h,b)||z>(h==null?void 0:h.length)){s(!0),u(!1);return}be({currentPassword:c,newPassword:h}).then(_=>{if(!(_!=null&&_.length)){u(!1);return}p(""),l(""),y(""),E(K),s(!1),r({type:"success",text:t.passwordUpdateMessage})}).catch(_=>{_.message==="Invalid login or password."&&r({type:"error",text:t.incorrectCurrentPassword}),_.message==="The account is locked."&&r({type:"error",text:_.message})}),u(!1)},[e,U,h,c,r,t]);return{hideChangePassword:i,handleOnBlurPassword:N,handleConfirmPasswordChange:Z,handleNewPasswordChange:w,handleCurrentPasswordChange:A,mutationChangePassword:$,currentPassword:c,newPassword:h,confirmPassword:F,passwordErrors:I,submitLoading:P,isClickSubmit:o}},Te=({passwordConfigs:e,isClickSubmit:r,password:n})=>{const t=O({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[o,s]=m("pending");B(()=>{if(!e)return;const u=ae(n,e.requiredCharacterClasses);r&&n.length>0?s(u?"success":"error"):r&&n.length===0?s("pending"):s(u?"success":"pending")},[r,e,n]);const P=G(()=>{var c;if(!e)return;const u={status:"pending",icon:"pending",message:(c=t.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return n.length&&n.length>=e.minLength?{...u,icon:"success",status:"success"}:n.length&&n.lengthe==="error"||(r==null?void 0:r.status)==="error"||n&&t.trim().length===0?o.newPassword:void 0,qe=({handleHideChangePassword:e,handleSetInLineAlert:r,inLineAlertProps:n})=>{const{passwordConfigs:t}=Ne(),{hideChangePassword:o,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:u,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:l,confirmPassword:F,passwordErrors:y,submitLoading:I,isClickSubmit:E}=Se({passwordConfigs:t,handleSetInLineAlert:r,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:A}=Te({password:l,isClickSubmit:E,passwordConfigs:t}),w=O({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return L(X,{className:"account-change-password",variant:"secondary",children:[d(Q,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),n.text?d(oe,{className:"account-change-password__notification",type:n.type,variant:"secondary",heading:n.text,icon:n.icon,"data-testid":"changePasswordInLineAlert"}):null,L("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:t==null?void 0:t.minLength,validateLengthConfig:A,uniqueSymbolsStatus:i,requiredCharacterClasses:t==null?void 0:t.requiredCharacterClasses,errorMessage:Me(i,A,E,l,y),defaultValue:l,onValue:u,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:F,onValue:P,onBlur:s})]}),L("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:o,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},ke=({inLineAlertProps:e,errorPasswordEmpty:r,passwordValue:n,showPasswordOnEmailChange:t,submitLoading:o,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:u,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const l=O({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return L(X,{variant:"secondary",className:"account-edit-customer-information",children:[d(Q,{title:l.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(oe,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,L(we,{loading:o,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:u,setInputChange:c,children:[t?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:l.placeholder,floatingLabel:l.floatingLabel,errorMessage:r?l.requiredFieldError:void 0,defaultValue:n,onValue:p,onBlur:h})}):null,L("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:o,type:"button",variant:"secondary",onClick:()=>P(),children:l.buttonSecondary}),d(H,{disabled:o,type:"submit",variant:"primary",children:l.buttonPrimary})]})]})]})},xe=({createdAt:e,slots:r,orderedCustomerData:n,showEditForm:t,showChangePassword:o,handleShowChangePassword:s,handleShowEditForm:P})=>{const u=O({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(X,{variant:"secondary",className:ne(["account-customer-information-card",["account-customer-information-card-short",o||t]]),children:L("div",{className:"account-customer-information-card__wrapper",children:[L("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:u.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:u.buttonPrimary})]}),d("div",{className:"account-customer-information-card__content",children:r!=null&&r.CustomerData?d(ge,{name:"CustomerData",slot:r==null?void 0:r.CustomerData,context:{customerData:n}}):L(he,{children:[n==null?void 0:n.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),L("p",{children:[u.accountCreation,": ",e]})]})})]})})},Oe=e=>{if(!(e!=null&&e.dateOfBirth))return e;const{dateOfBirth:r,...n}=e;return{...n,dob:r}},Ue="accountContext";var x=(e=>(e.EDIT_ACCOUNT_EVENT="edit-account",e))(x||{});const Be={EDIT_ACCOUNT_EVENT:"edit-account"};function se(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function He(e,r){const n=se();n.push({[e]:null}),n.push({[e]:r})}function Ze(e,r){se().push(t=>{const o=t.getState?t.getState():{};t.push({event:e,eventInfo:{...o,...r}})})}function $e(e){const r=Fe(e);He(Ue,r),Ze(Be.EDIT_ACCOUNT_EVENT)}const te=(e,r)=>{const n=sessionStorage.getItem("accountStoreConfig"),o={...n?JSON.parse(n):{},...r};switch(e){case"edit-account":$e(o);break;default:return null}},ze=({handleSetInLineAlert:e})=>{const r=O({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[n,t]=m(!0),[o,s]=m(!1),[P,u]=m(!1),[c,p]=m(!1),[h,l]=m(!1),[F,y]=m(!1),[I,E]=m([]),[i,A]=m(null),[w,Z]=m([]),[N,U]=m({}),[$,f]=m(""),[b,z]=m(""),_=C(a=>{const{value:g}=a==null?void 0:a.target;g.length&&l(!1),g.length||l(!0)},[]),S=C(a=>{f(a)},[]),ie=C(a=>{U(a)},[]),ce=C(()=>{u(!0),p(!1),e(),S("")},[e,S]),de=C(a=>{a==null||a(),u(!1)},[]),ue=C(()=>{p(!0),u(!1),e(),S("")},[e,S]),le=C(a=>{a==null||a(),p(!1)},[]),T=C((a,g)=>{a==="success"?e({type:"success",text:g??r.accountSuccess}):a==="error"?e({type:"error",text:g??r.accountError}):e(),s(!1)},[e,r]),j=C(()=>{Ve().then(a=>{var v;const g=(v=a==null?void 0:a.createdAt)==null?void 0:v.split(" ")[0],M=Oe({...a,gender:a.gender===1?r.genderMale:r.genderFemale});A(M),z(g)})},[r.genderFemale,r.genderMale]);B(()=>{j()},[]),B(()=>{Ie("customer_account_edit").then(a=>{Z(a);const g=a.map(({name:M,customUpperCode:v,orderNumber:q,label:D})=>({name:v,orderNumber:q,label:Ce.includes(M)?null:D}));E(g)})},[]),B(()=>{N.email&&N.email!==(i==null?void 0:i.email)?y(!0):N.email&&N.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,N]);const W=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{W!=null&&W.length&&t(!1)},[W]);const me=G(()=>w==null?void 0:w.map(a=>({...a,defaultValue:a!=null&&a.customUpperCode&&i?i[a.customUpperCode]??"":""})).map(a=>a.customUpperCode==="gender"?{...a,defaultValue:a.defaultValue==="Male"?1:2}:a),[w,i]),fe=C(async(a,g)=>{const M=Pe(a.target),{email:v,password:q,...D}=M,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&l(!0);return}if(l(!1),s(!0),v===(i==null?void 0:i.email)){S(""),re(ee(D,"account")).then(k=>{k&&(j(),T("success"),te(x==null?void 0:x.EDIT_ACCOUNT_EVENT,{...M}))}).catch(k=>{T("error",k.message)});return}if(Y){l(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&ye({email:v,password:q}).then(k=>{k&&re(ee(D,"account")).then(J=>{J&&(j(),T("success"),te(x==null?void 0:x.EDIT_ACCOUNT_EVENT,{...M}))}).catch(J=>{T("error",J.message)})}).catch(k=>{T("error",k.message)})},[i,S,j,T]);return{createdAt:b,errorPasswordEmpty:h,passwordValue:$,showPasswordOnEmailChange:F,orderedCustomerData:W,loading:n,normalizeFieldsConfig:me,submitLoading:o,showEditForm:c,showChangePassword:P,handleShowChangePassword:ce,handleHideChangePassword:de,handleShowEditForm:ue,handleHideEditForm:le,handleUpdateCustomerInformation:fe,handleInputChange:ie,handleSetPassword:S,handleOnBlurPassword:_,renderAlertMessage:T}},We={success:d(ve,{}),warning:d(_e,{}),error:d(Le,{})},je=()=>{const[e,r]=m({}),n=C(t=>{if(!(t!=null&&t.type)){r({});return}const o=We[t.type];r({...t,icon:o})},[]);return{inLineAlertProps:e,handleSetInLineAlert:n}},ar=({className:e,withHeader:r=!0,slots:n})=>{const t=O({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:o,handleSetInLineAlert:s}=je(),{createdAt:P,errorPasswordEmpty:u,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:l,normalizeFieldsConfig:F,submitLoading:y,showEditForm:I,showChangePassword:E,handleShowChangePassword:i,handleHideChangePassword:A,handleShowEditForm:w,handleHideEditForm:Z,handleUpdateCustomerInformation:N,handleInputChange:U,handleSetPassword:$,handleOnBlurPassword:f}=ze({handleSetInLineAlert:s});return l?d("div",{"data-testid":"customerInformationLoader",children:d(pe,{withCard:!0})}):L("div",{className:ne(["account-customer-information",e]),children:[r?d(Q,{title:t.containerTitle,divider:!1,className:"customer-information__title"}):null,d(xe,{createdAt:P,slots:n,orderedCustomerData:h,showEditForm:I,showChangePassword:E,handleShowChangePassword:i,handleShowEditForm:w}),E?d(qe,{inLineAlertProps:o,handleSetInLineAlert:s,handleHideChangePassword:A}):null,I?d(ke,{inLineAlertProps:o,submitLoading:y,formFieldsList:F,errorPasswordEmpty:u,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:$,handleOnBlurPassword:f,handleUpdateCustomerInformation:N,handleHideEditForm:Z,handleInputChange:U}):null]})};export{ar as CustomerInformation,ar as default}; diff --git a/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts index f7294923a..d4f5b4f85 100644 --- a/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-account/i18n/en_US.json.d.ts @@ -60,7 +60,21 @@ declare const _default: { "actionEdit": "Edit", "cardLabelShipping": "Shipping", "cardLabelBilling": "Billing", - "defaultLabelText": "DEFAULT" + "defaultLabelText": "DEFAULT", + "ariaLabel": { + "editButton": { + "default": "Edit address", + "shipping": "Edit default shipping address", + "billing": "Edit default billing address", + "shippingAndBilling": "Edit address set as default for both shipping and billing" + }, + "removeButton": { + "default": "Remove address", + "shipping": "Remove default shipping address", + "billing": "Remove default billing address", + "shippingAndBilling": "Remove address set as default for both shipping and billing" + } + } }, "removeAddressModal": { "title": "Remove address", @@ -110,7 +124,21 @@ declare const _default: { "actionEdit": "Edit", "cardLabelShipping": "Shipping", "cardLabelBilling": "Billing", - "defaultLabelText": "DEFAULT" + "defaultLabelText": "DEFAULT", + "ariaLabel": { + "editButton": { + "default": "Edit address", + "shipping": "Edit default shipping address", + "billing": "Edit default billing address", + "shippingAndBilling": "Edit address set as default for both shipping and billing" + }, + "removeButton": { + "default": "Remove address", + "shipping": "Remove default shipping address", + "billing": "Remove default billing address", + "shippingAndBilling": "Remove address set as default for both shipping and billing" + } + } }, "removeAddressModal": { "title": "Remove address", diff --git a/scripts/__dropins__/storefront-account/lib/getAddressButtonAriaLabel.d.ts b/scripts/__dropins__/storefront-account/lib/getAddressButtonAriaLabel.d.ts new file mode 100644 index 000000000..445d0ae83 --- /dev/null +++ b/scripts/__dropins__/storefront-account/lib/getAddressButtonAriaLabel.d.ts @@ -0,0 +1,2 @@ +export declare const getAddressButtonAriaLabel: (defaultShipping?: boolean, defaultBilling?: boolean, translations?: Record, type?: 'removeButton' | 'editButton') => string; +//# sourceMappingURL=getAddressButtonAriaLabel.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/lib/validationFields.d.ts b/scripts/__dropins__/storefront-account/lib/validationFields.d.ts index 3c0b2eefe..25bd489dc 100644 --- a/scripts/__dropins__/storefront-account/lib/validationFields.d.ts +++ b/scripts/__dropins__/storefront-account/lib/validationFields.d.ts @@ -22,8 +22,8 @@ export declare const validateAlphanumeric: (value: string) => boolean; export declare const validateAlpha: (value: string) => boolean; export declare const validateEmail: (value: string) => boolean; export declare const validateDate: (value: string) => boolean; -export declare const isDateWithinRange: (date: string, minTimestamp: number, maxTimestamp: number) => boolean; -export declare const convertTimestampToDate: (timestamp: string) => string; +export declare const isDateWithinRange: (date: string, minTimestamp?: number, maxTimestamp?: number) => boolean; +export declare const convertTimestampToDate: (timestamp: string | null | undefined) => string; export declare const validateUrl: (url: string) => boolean; export declare const validateLength: (value: string, minLength: number, maxLength: number) => boolean; export declare const validationFields: (value: string, configs: ValidationFieldsConfig, translations: TranslationList, errorsList: ErrorsList) => { diff --git a/scripts/__dropins__/storefront-account/render.js b/scripts/__dropins__/storefront-account/render.js index e87370fe6..3deb63f24 100644 --- a/scripts/__dropins__/storefront-account/render.js +++ b/scripts/__dropins__/storefront-account/render.js @@ -2,4 +2,4 @@ All Rights Reserved. */ (function(e,r){try{if(typeof document<"u"){const a=document.createElement("style"),o=r.styleId;for(const t in r.attributes)a.setAttribute(t,r.attributes[t]);a.setAttribute("data-dropin",o),a.appendChild(document.createTextNode(e));const c=document.querySelector('style[data-dropin="sdk"]');if(c)c.after(a);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(`.account-orders-list-header{margin-bottom:var(--spacing-medium)}.account-orders-list ul{list-style:none;margin:0;padding:0}.account-orders-list__date-select{margin-bottom:var(--spacing-xbig)}.account-orders-list__date-select span{display:inline-block;font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-xsmall)}.account-orders-list__date-select .dropin-picker{max-width:224px} .account-form{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.account-form{display:grid;grid-template-columns:repeat(2,1fr)}.account-form>.dropin-field:nth-child(1),.account-form>.dropin-field:nth-child(2){grid-column:span 1}.account-form>.dropin-field:nth-child(3),.account-form>.dropin-field:nth-child(4),.account-form>.dropin-field:nth-child(5){grid-column:span 2}.account-form>.dropin-field:nth-child(6),.account-form>.dropin-field:nth-child(7){grid-column:span 1}.account-form>.dropin-field:nth-child(8),.account-form>.dropin-field:nth-child(9){grid-column:span 1}.account-form>.dropin-field:nth-child(n+10){grid-column:span 2}}.account-form [class$=-hidden]{position:absolute;opacity:0;height:0;width:0;overflow:hidden;clip:rect(0,0,0,0)}.account-account-loaders--card-loader{margin-bottom:var(--spacing-small)}.account-account-loaders--picker-loader div:first-child{max-width:200px}.account-account-loaders--picker-loader div:nth-child(3){max-width:400px}.account-address-card{margin-bottom:var(--spacing-small)}.account-address-card .dropin-card__content{display:grid;grid-template-columns:1fr auto;gap:var(--spacing-small) 0px;grid-template-areas:"description action" "labels action"}.account-address-card .account-address-card__action{display:flex;justify-content:flex-end;align-items:baseline;cursor:pointer;grid-area:action}.account-address-card .account-address-card__action--editbutton{margin-left:var(--spacing-small)}.account-address-card .account-address-card__action button{padding:0}.account-address-card .account-address-card__action button:hover{text-decoration:underline}.account-address-card .account-address-card__description{grid-area:description;margin:0;padding:0}.account-address-card .account-address-card__labels{display:flex;gap:0 var(--spacing-xsmall);grid-area:labels}.account-address-card .account-address-card__description p{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);line-height:var(--spacing-xbig);color:var(--color-neutral-800);padding:0;margin:0 var(--spacing-xsmall) 0 0}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(2){margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0;color:var(--color-neutral-800);font:var(--type-button-2-font);font-weight:500;cursor:default}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(3),.account-address-card .account-address-card__description p:nth-child(4),.account-address-card .account-address-card__description p:nth-child(6){float:left}.account-actions-address{cursor:pointer;padding:var(--spacing-xsmall) var(--spacing-medium);border-radius:var(--shape-border-radius-2);border:var(--shape-border-width-2) solid var(--color-neutral-400);background-color:var(--color-neutral-50);width:100%;height:88px;display:flex;align-items:center;justify-content:space-between}.account-actions-address--selectable{max-width:100%;width:auto}.account-actions-address__title{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing);-moz-appearance:none;appearance:none;-webkit-appearance:none;color:var(--color-neutral-800)}.account-actions-address svg{stroke:var(--shape-icon-stroke-4);color:var(--color-neutral-800)}@supports (height: 100dvh){.account-address-modal .dropin-modal{height:100dvh}}.account-address-modal--overlay{position:relative;padding:var(--spacing-small) var(--spacing-small) var(--spacing-small) var(--spacing-small);width:100%;margin:auto;max-width:340px}@media (min-width: 768px){.account-address-modal--overlay{position:relative;padding:var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig);width:100%;margin:auto;max-width:721px}.account-address-card .dropin-card__content{padding:var(--spacing-small)}}.dropin-modal__body--medium>.dropin-modal__header-title,.dropin-modal__body--full>.dropin-modal__header-title,.account-address-modal .dropin-modal__content{margin:0;align-items:center}.account-address-modal .dropin-modal__header-title-content h3{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);margin:0;padding:0}.account-address-modal .account-address-modal__spinner{position:absolute;top:0;left:0;background-color:var(--color-neutral-200);opacity:.8;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1}.account-address-modal p{margin:var(--spacing-small) 0}@media (min-width: 768px){.account-address-modal p{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}}.account-address-modal .account-address-modal__buttons{display:flex;align-items:center;justify-content:right;gap:0 var(--spacing-small)}.account-empty-list{margin-bottom:var(--spacing-small)}.account-empty-list.account-empty-list--minified,.account-empty-list .dropin-card{border:none}.account-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.account-empty-list.account-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.account-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.account-empty-list.account-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.account-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.account-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.account-orders-list-action{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}a.account-orders-list-action:focus-visible{display:inline-block}.account-orders-list-action--minifiedView{width:100%;text-align:left;font:var(--type-body-1-default-font)}.account-orders-list-action.account-orders-list-action--minifiedView:hover{text-decoration:none}.account-orders-list-action--minifiedView .account-orders-list-action__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.account-orders-list-action__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-orders-list-action__card-wrapper svg,.account-orders-list-action svg{color:var(--color-neutral-800)}.account-orders-list-action--minifiedView .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.account-orders-list-action--minifiedView p{font:var(--type-body-1-strong-font)}.account-orders-list-card{height:100%;margin-bottom:var(--spacing-small)}.account-orders-list-card .dropin-card__content{padding:var(--spacing-medium);display:grid;grid-template-areas:"content actions" "imageList actions";gap:0;max-height:100%}.account-orders-list-card .account-orders-list-card__content{grid-area:content;margin-bottom:var(--spacing-small)}.account-orders-list-card__content--quantity{font-weight:500;color:var(--color-neutral-800)}.account-orders-list-card__content--track_number,.account-orders-list-card__content--return_number{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.account-orders-list-card .account-orders-list-card__content>div:first-child{font-weight:500}.account-orders-list-card .account-orders-list-card__content p,.account-orders-list-card .account-orders-list-card__content div{padding:0;text-align:left;font:var(--type-body-1-default-font);margin:0 0 var(--spacing-small) 0;color:var(--color-neutral-800)}.account-orders-list-card p.account-orders-list-card__content--product-name{margin:0}.account-orders-list-card .account-orders-list-card__content p:last-child{margin:0}.account-orders-list-card .account-orders-list-card__content div{font:var(--type-button-2-font);margin-bottom:var(--spacing-small)}.account-orders-list-card .account-orders-list-card__actions{grid-area:actions}.account-orders-list-card .account-orders-list-card__images{overflow:auto}.account-orders-list-card .account-orders-list-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.account-orders-list-card .account-orders-list-card__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.account-orders-list-card .account-orders-list-card__images img{object-fit:contain;width:65px;height:65px}.account-orders-list-card .account-orders-list-card__actions{position:relative;align-self:center;margin-left:auto}@media (min-width: 768px){.account-orders-list-card.account-orders-list-card--full .dropin-card__content{max-height:100%}}.account-addresses-header{margin-bottom:var(--spacing-medium)}.account-addresses-wrapper{box-sizing:border-box;position:relative}.account-addresses-wrapper--select-view{position:relative;margin:0;padding:0;border:none}.account-addresses-wrapper--select-view input[type=radio]{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;padding:0;margin:-1px;border:0;overflow:hidden}.account-addresses-wrapper--select-view .account-addresses-wrapper__label{cursor:pointer;display:block;border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card{border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label:nth-child(2){border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:nth-child(2)>.account-address-card{border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child,.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child>.account-actions-address.account-actions-address--address{border-radius:0 0 var(--shape-border-radius-1) var(--shape-border-radius-1)}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-200)}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:focus+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);outline:var(--spacing-xxsmall) solid var(--color-button-focus);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-addresses-form__footer__wrapper{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-50)}.account-addresses-wrapper--select-view .account-address-card{margin:0}.account-addresses-wrapper--select-view .account-addresses-form__footer__wrapper{padding:var(--spacing-medium)}.account-address-form-wrapper{box-sizing:border-box;background-color:var(--color-neutral-50)}.account-address-form-wrapper__notification{margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__buttons{display:flex;align-items:center;justify-content:end;gap:0 var(--spacing-medium);margin-top:var(--spacing-medium)}.account-address-form-wrapper__buttons--empty{gap:0;margin:0;padding:0;display:inline-block}.account-address-form-wrapper__buttons button{min-width:142px}.account-change-password .dropin-card__content{gap:0}.account-change-password__title,.account-change-password .account-change-password__notification,.account-change-password .account-change-password__fields .account-change-password__fields-item{margin-bottom:var(--spacing-medium)}.account-change-password .account-change-password__fields .account-change-password__fields-item:last-child{margin-bottom:0}.account-change-password .account-change-password__actions{display:flex;justify-content:right;align-items:center;gap:0 var(--grid-3-gutters)}.account-change-password .account-change-password__actions button{min-width:144px}.account-edit-customer-information__title{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .dropin-card__content{gap:0}.account-edit-customer-information .account-edit-customer-information__notification{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .account-edit-customer-information-form__field:nth-child(n+3),.account-edit-customer-information .account-edit-customer-information__password{grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions{display:flex;justify-content:end;align-items:center;gap:0 var(--grid-2-gutters);grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions button{min-width:144px}.customer-information__title{margin-bottom:var(--spacing-medium)}.account-customer-information-card-short{margin-bottom:var(--spacing-small)}.account-customer-information-card .dropin-card__content{gap:0}.account-customer-information-card__wrapper{display:grid;grid-template-columns:1fr;align-items:start;gap:var(--grid-1-gutters) 0}.account-customer-information-card .account-customer-information-card__actions{margin-left:auto;display:flex;justify-content:space-between;align-items:center;gap:0 var(--grid-2-gutters)}@media (max-width: 300px){.account-customer-information-card .account-customer-information-card__actions{align-items:self-end;flex-direction:column-reverse}}.account-customer-information-card .account-customer-information-card__actions button{cursor:pointer;margin:0;padding:0}.account-customer-information-card__content p{font:var(--type-body-1-default-font);margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-xbig);padding:0}.account-customer-information-card__content p:nth-child(1),.account-customer-information-card__content p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0}.account-customer-information-card__content p:nth-child(1){float:left}`,{styleId:"account"}); -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as o}from"@dropins/tools/lib.js";import{useState as n,useEffect as i}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const m={minifiedView:{CustomerInformation:{containerTitle:"Account settings",genderMale:"Male",genderFemale:"Female",changePassword:{passwordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical",incorrectCurrentPassword:"The current password you entered is incorrect. Please check and try again.",passwordUpdateMessage:"Your password has been updated"},containerTitle:"Change password",currentPassword:{placeholder:"Password",floatingLabel:"Password"},newPassword:{placeholder:"New Password",floatingLabel:"New Password"},confirmPassword:{placeholder:"Confirm new password",floatingLabel:"Confirm new password"},buttonSecondary:"Cancel",buttonPrimary:"Save"},customerInformationCard:{buttonSecondary:"Change password",buttonPrimary:"Edit",accountCreation:"Account creation date"},editCustomerInformation:{containerTitle:"Edit details",buttonSecondary:"Cancel",buttonPrimary:"Save",accountSuccess:"Your account information has been updated.",accountError:"Your account information has not been updated.",passwordField:{placeholder:"Password",floatingLabel:"Password"}}},Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",viewAllAddressesButton:"View address list",differentAddressButton:"Use a different address",ariaLabelAddressPicker:"form",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Recent orders",viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},fullSizeView:{Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",newAddressFormTitle:"Add address",addNewAddressButton:"Create new",differentAddressButton:"Use a different address",ariaLabelAddressPicker:"form",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Your orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},AddressForm:{formText:{secondaryButton:"Cancel",primaryButton:"Save",defaultShippingLabel:"Set as default shipping address",defaultBillingLabel:"Set as default billing address",saveAddressBook:"Save in address book"}},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",urlError:"Please enter a valid URL, e.g., http://www.adobe.com.",lengthTextError:"Text length must be between {min} and {max} characters."}},u={Account:m},w={default:u},p=({children:a})=>{const[s,t]=n("en_US");return i(()=>{const e=c.on("locale",d=>{t(d)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:s,langDefinitions:w,children:a})},L=new o(r(p,{}));export{L as render}; +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as i}from"@dropins/tools/lib.js";import{useState as o,useEffect as n}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const u={minifiedView:{CustomerInformation:{containerTitle:"Account settings",genderMale:"Male",genderFemale:"Female",changePassword:{passwordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical",incorrectCurrentPassword:"The current password you entered is incorrect. Please check and try again.",passwordUpdateMessage:"Your password has been updated"},containerTitle:"Change password",currentPassword:{placeholder:"Password",floatingLabel:"Password"},newPassword:{placeholder:"New Password",floatingLabel:"New Password"},confirmPassword:{placeholder:"Confirm new password",floatingLabel:"Confirm new password"},buttonSecondary:"Cancel",buttonPrimary:"Save"},customerInformationCard:{buttonSecondary:"Change password",buttonPrimary:"Edit",accountCreation:"Account creation date"},editCustomerInformation:{containerTitle:"Edit details",buttonSecondary:"Cancel",buttonPrimary:"Save",accountSuccess:"Your account information has been updated.",accountError:"Your account information has not been updated.",passwordField:{placeholder:"Password",floatingLabel:"Password"}}},Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",viewAllAddressesButton:"View address list",differentAddressButton:"Use a different address",ariaLabelAddressPicker:"form",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT",ariaLabel:{editButton:{default:"Edit address",shipping:"Edit default shipping address",billing:"Edit default billing address",shippingAndBilling:"Edit address set as default for both shipping and billing"},removeButton:{default:"Remove address",shipping:"Remove default shipping address",billing:"Remove default billing address",shippingAndBilling:"Remove address set as default for both shipping and billing"}}},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Recent orders",viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},fullSizeView:{Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",newAddressFormTitle:"Add address",addNewAddressButton:"Create new",differentAddressButton:"Use a different address",ariaLabelAddressPicker:"form",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT",ariaLabel:{editButton:{default:"Edit address",shipping:"Edit default shipping address",billing:"Edit default billing address",shippingAndBilling:"Edit address set as default for both shipping and billing"},removeButton:{default:"Remove address",shipping:"Remove default shipping address",billing:"Remove default billing address",shippingAndBilling:"Remove address set as default for both shipping and billing"}}},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Your orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},AddressForm:{formText:{secondaryButton:"Cancel",primaryButton:"Save",defaultShippingLabel:"Set as default shipping address",defaultBillingLabel:"Set as default billing address",saveAddressBook:"Save in address book"}},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",urlError:"Please enter a valid URL, e.g., http://www.adobe.com.",lengthTextError:"Text length must be between {min} and {max} characters."}},m={Account:u},p={default:m},f=({children:a})=>{const[s,d]=o("en_US");return n(()=>{const e=c.on("locale",t=>{d(t)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:s,langDefinitions:p,children:a})},A=new i(r(f,{}));export{A as render}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js index a45ec6dde..cbdc87079 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js @@ -1,3 +1,3 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{jsx as u,jsxs as I}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Pe,classes as _e}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Ne,c as ye,a as Ee}from"./createCustomerAddress.js";import{useState as p,useEffect as Le,useCallback as T,useMemo as Ue}from"@dropins/tools/preact-hooks.js";import{s as de,b as Me}from"./simplifyTransformAttributesForm.js";import{v as xe,u as Te,a as Se}from"./usePasswordValidationMessage.js";import{a as ve}from"./getCustomerToken.js";import{p as qe,E as Ce}from"./getStoreConfig.js";import{c as $,g as Ae,u as Be,B as ce}from"./Button2.js";import{c as Ke}from"./transform-attributes-form.js";import{f as le,E as je}from"./focusOnEmptyPasswordField.js";import{Header as Ie,InLineAlert as Ge,InputPassword as fe,Field as te,Checkbox as se}from"@dropins/tools/components.js";import{u as He,F as Ve}from"./Button.js";import{S as We}from"./SkeletonLoader.js";const he=(m,t)=>t!=null&&t.length?m.map(e=>{var d;const s=(d=t.find(({code:o})=>o===e.code))==null?void 0:d.defaultValue;return s?{...e,defaultValue:s}:e}):m,$e=({inputsDefaultValueSet:m,fieldsConfigForApiVersion1:t,apiVersion2:e})=>{const[s,d]=p([]);return Le(()=>{(async()=>{if(e){const i=await Ne("customer_account_create");if(i!=null&&i.length)if(m!=null&&m.length){const F=he(i,m);d(F)}else d(i)}else{const i=de(Me),F=de(t),N=he(i,m);d(t&&t.length?F:N)}})()},[e,t,m]),{fieldsListConfigs:s.map(o=>({...o,...o.code==="email"?{autocomplete:"username"}:{}}))}},Je=(m,t)=>{const e=["dob","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],s=Ke(m,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!t)return{...s,...s!=null&&s.gender?{gender:Number(s==null?void 0:s.gender)}:{}};const d={},o=[];return Object.keys(s).forEach(i=>{e.includes(i)?d[i]=i.includes("gender")?Number(s[i]):s[i]:o.push({attribute_code:i,value:s[i]})}),o.length>0&&(d.custom_attributes=o),d},Oe=({requireRetypePassword:m,addressesData:t,translations:e,isEmailConfirmationRequired:s,apiVersion2:d=!0,passwordConfigs:o,isAutoSignInEnabled:i,routeRedirectOnSignIn:F,routeSignIn:N,onErrorCallback:S,onSuccessCallback:h,setActiveComponent:w,handleSetInLineAlertProps:b,routeRedirectOnEmailConfirmationClose:q})=>{const[J,C]=p(!1),[a,n]=p(""),[g,c]=p(""),[G,y]=p(""),[H,A]=p(!1),[O,B]=p({userName:"",status:!1}),[l,K]=p(""),[Q,V]=p(!1),[X,E]=p(!1),[W,Y]=p(!0),Z=T(r=>{const f=r.target.value;C(!f.length),f.length&&a.length&&f!==a&&c(e.passwordMismatch)},[a,e.passwordMismatch]),k=T(r=>{const f=r.target.value;c(f.length?"":e.requiredFieldError),f.length&&l.length&&f!==l&&c(e.passwordMismatch)},[l,e.passwordMismatch,e.requiredFieldError]),z=T(r=>{n(r),c(r?l===r?"":e.passwordMismatch:e.requiredFieldError)},[e,l]),D=T(({target:r})=>{Y(r.checked)},[]),R=T(()=>{if($(w)){w("signInForm");return}$(N)&&(window.location.href=N())},[w,N]),ee=T(r=>{K(r),C(!r.length),r===a&&c("")},[a]),re=T(()=>{b(),K(""),$(q)?window.location.href=q():(A(!1),w==null||w("signInForm"))},[b,q,w]),U=()=>{V(!0),E(!1)},P=(r,f)=>{const ie=l.length&&a.length,j=l!==a,v=()=>{C(!l.length),a||c(e.requiredFieldError),ie&&j&&c(e.passwordMismatch)},M=()=>{c(a.length?e.passwordMismatch:e.requiredFieldError),le(r,l,a)};return f?m&&(g.length||j)?(U(),M(),!0):(le(r,l,""),v(),!1):(U(),v(),!0)};return{showPasswordErrorMessage:J,confirmPassword:a,confirmPasswordMessage:g,isKeepMeLogged:W,userEmail:G,showEmailConfirmationForm:H,isSuccessful:O,isClickSubmit:Q,signUpPasswordValue:l,isLoading:X,onSubmitSignUp:async(r,f)=>{var ae,ne,ue;if(b(),c(""),E(!0),P(r,f))return;const{confirmPasswordField:ie,...j}=Ae(r.target),{email:v,password:M,is_subscribed:ge}=j,pe=(o==null?void 0:o.requiredCharacterClasses)||0,Fe=(o==null?void 0:o.minLength)||1;if(!xe(M,pe)||Fe>(M==null?void 0:M.length)){U();return}const we=Je({...j,is_subscribed:!!ge||!1},d),L=await ye(we,d);if((ae=L==null?void 0:L.errors)!=null&&ae.length){const{errors:x}=L;b==null||b({type:"error",text:(ne=x[0])==null?void 0:ne.message}),S==null||S(x),y(v)}else{const x=L==null?void 0:L.firstName;if(qe(Ce.CREATE_ACCOUNT_EVENT,{...L}),s||!i){if(h==null||h({userName:x,status:!0}),s){(ue=r.target)==null||ue.reset(),K(""),A(!0),y(v),E(!1);return}if(!i){E(!1),B({userName:x,status:!0});return}}const _=await ve({email:v,password:M,translations:e,handleSetInLineAlertProps:b,onErrorCallback:S});if(_!=null&&_.userName){if(t!=null&&t.length)for(const me of t)try{await Ee(me)}catch(be){console.error(e.failedCreateCustomerAddress,me,be)}$(F)?window.location.href=F():(h==null||h({userName:_==null?void 0:_.userName,status:!0}),B({userName:_==null?void 0:_.userName,status:!0}))}else h==null||h({userName:x,status:!0}),B({userName:x,status:!0})}E(!1)},signInButton:R,handleSetSignUpPasswordValue:ee,onKeepMeLoggedChange:D,handleHideEmailConfirmationForm:re,handleConfirmPasswordChange:z,onBlurPassword:Z,onBlurConfirmPassword:k}},ur=({requireRetypePassword:m=!1,addressesData:t,formSize:e="default",inputsDefaultValueSet:s,fieldsConfigForApiVersion1:d,apiVersion2:o=!0,isAutoSignInEnabled:i=!0,displayTermsOfUseCheckbox:F=!1,displayNewsletterCheckbox:N=!1,hideCloseBtnOnEmailConfirmation:S=!1,routeRedirectOnEmailConfirmationClose:h,routeRedirectOnSignIn:w,routeSignIn:b,onErrorCallback:q,onSuccessCallback:J,setActiveComponent:C,slots:a})=>{const n=He({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",privacyPolicyDefaultText:"Auth.SignUpForm.privacyPolicyDefaultText",subscribedDefaultText:"Auth.SignUpForm.subscribedDefaultText",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:g,isEmailConfirmationRequired:c}=Te(),{fieldsListConfigs:G}=$e({fieldsConfigForApiVersion1:d,apiVersion2:o,inputsDefaultValueSet:s}),{inLineAlertProps:y,handleSetInLineAlertProps:H}=Be(),{showPasswordErrorMessage:A,confirmPassword:O,confirmPasswordMessage:B,isKeepMeLogged:l,userEmail:K,showEmailConfirmationForm:Q,isSuccessful:V,isClickSubmit:X,signUpPasswordValue:E,isLoading:W,onSubmitSignUp:Y,signInButton:Z,handleSetSignUpPasswordValue:k,onKeepMeLoggedChange:z,handleHideEmailConfirmationForm:D,handleConfirmPasswordChange:R,onBlurPassword:ee,onBlurConfirmPassword:re}=Oe({requireRetypePassword:m,addressesData:t,translations:n,isEmailConfirmationRequired:c,apiVersion2:o,passwordConfigs:g,isAutoSignInEnabled:i,routeRedirectOnSignIn:w,routeSignIn:b,onErrorCallback:q,onSuccessCallback:J,setActiveComponent:C,handleSetInLineAlertProps:H,routeRedirectOnEmailConfirmationClose:h}),{isValidUniqueSymbols:U,defaultLengthMessage:P}=Se({password:E,isClickSubmit:X,passwordConfigs:g}),oe=Ue(()=>A?n.requiredFieldError:U==="error"||(P==null?void 0:P.status)==="error"?" ":"",[P==null?void 0:P.status,U,A,n.requiredFieldError]),r=!c&&(t==null?void 0:t.length);return!G.length&&o?u("div",{className:`auth-sign-up-form auth-sign-up-form--${e} skeleton-loader`,"data-testid":"SignUpForm",children:u(We,{activeSkeleton:"signUpForm"})}):V.status&&(a!=null&&a.SuccessNotification)?u(Pe,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:V}}):Q?u(je,{formSize:e,userEmail:K,inLineAlertProps:y,hideCloseBtnOnEmailConfirmation:S,handleSetInLineAlertProps:H,onPrimaryButtonClick:D}):I("div",{className:_e(["auth-sign-up-form",`auth-sign-up-form--${e}`]),"data-testid":"SignUpForm",children:[u(Ie,{title:n.title,divider:!1,className:"auth-sign-up-form__title"}),y.text?u(Ge,{className:"auth-sign-up-form__notification",type:y.type,variant:"secondary",heading:y.text,icon:y.icon}):null,I(Ve,{onSubmit:Y,className:"auth-sign-up-form__form",loading:W,name:"signUp_form",fieldsConfig:G,slots:a,children:[I(fe,{validateLengthConfig:P,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:g==null?void 0:g.minLength,errorMessage:oe,defaultValue:E,uniqueSymbolsStatus:U,requiredCharacterClasses:g==null?void 0:g.requiredCharacterClasses,onValue:k,placeholder:n.placeholder,floatingLabel:n.floatingLabel,onBlur:ee,children:[m?u("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:u(fe,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:n.confirmPasswordPlaceholder,floatingLabel:n.confirmPasswordFloatingLabel,errorMessage:B,defaultValue:O,onValue:R,onBlur:re})}):null,r?u("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:u(te,{children:u(se,{name:"",placeholder:n.keepMeLoggedText,label:n.keepMeLoggedText,checked:l,onChange:z})})}):null]}),N||F?I("div",{className:"auth-sign-up-form__item auth-sign-up-form__checkbox",children:[N?u(te,{children:u(se,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:n.subscribedDefaultText,label:n.subscribedDefaultText})}):null,F?u(te,{children:u(se,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:n.privacyPolicyDefaultText,label:n.privacyPolicyDefaultText})}):null]}):null,I("div",{className:"auth-sign-up-form-buttons",children:[u(ce,{className:"auth-sign-up-form-buttons--signin",type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonSecondary,enableLoader:!1,onClick:Z}),u(ce,{type:"submit",buttonText:n.buttonPrimary,variant:"primary",enableLoader:W})]})]}),u("div",{id:"createCustomerV2"})]})};export{ur as S}; +import{jsx as c,jsxs as $}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as nr,classes as Pr}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as br,c as _r,a as Nr}from"./createCustomerAddress.js";import{useState as p,useEffect as Er,useCallback as U,useMemo as Lr}from"@dropins/tools/preact-hooks.js";import{s as mr,b as yr}from"./simplifyTransformAttributesForm.js";import{v as Mr,u as Ur,a as Cr}from"./usePasswordValidationMessage.js";import{a as Sr}from"./getCustomerToken.js";import{p as xr,E as Tr}from"./getStoreConfig.js";import{c as O,g as qr,u as vr,B as ur}from"./Button2.js";import{c as Br}from"./transform-attributes-form.js";import{f as dr,E as Ar}from"./focusOnEmptyPasswordField.js";import{Header as Kr,InLineAlert as jr,InputPassword as cr,Field as Ir,Checkbox as Gr}from"@dropins/tools/components.js";import{u as Hr,F as Vr}from"./Button.js";import{S as Wr}from"./SkeletonLoader.js";const fr=(n,e)=>e!=null&&e.length?n.map(r=>{var d;const t=(d=e.find(({code:s})=>s===r.code))==null?void 0:d.defaultValue;return t?{...r,defaultValue:t}:r}):n,$r=({inputsDefaultValueSet:n,fieldsConfigForApiVersion1:e,apiVersion2:r})=>{const[t,d]=p([]);return Er(()=>{(async()=>{if(r){const o=await br("customer_account_create");if(o!=null&&o.length)if(n!=null&&n.length){const _=fr(o,n);d(_)}else d(o)}else{const o=mr(yr),_=mr(e),E=fr(o,n);d(e&&e.length?_:E)}})()},[r,e,n]),{fieldsListConfigs:t.map(s=>({...s,...s.code==="email"?{autocomplete:"username"}:{}}))}},Or=(n,e)=>{const r=["dob","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],t=Br(n,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!e)return{...t,...t!=null&&t.gender?{gender:Number(t==null?void 0:t.gender)}:{}};const d={},s=[];return Object.keys(t).forEach(o=>{r.includes(o)?d[o]=o.includes("gender")?Number(t[o]):t[o]:s.push({attribute_code:o,value:t[o]})}),s.length>0&&(d.custom_attributes=s),d},Jr=({requireRetypePassword:n,addressesData:e,translations:r,isEmailConfirmationRequired:t,apiVersion2:d=!0,passwordConfigs:s,isAutoSignInEnabled:o,routeRedirectOnSignIn:_,routeSignIn:E,onErrorCallback:C,onSuccessCallback:g,setActiveComponent:w,handleSetInLineAlertProps:F,routeRedirectOnEmailConfirmationClose:T})=>{const[l,m]=p(!1),[i,I]=p(""),[q,u]=p(""),[G,v]=p(""),[J,H]=p(!1),[Q,B]=p({userName:"",status:!1}),[f,S]=p(""),[X,V]=p(!1),[W,L]=p(!1),[Y,Z]=p(!0),k=U(a=>{const h=a.target.value;m(!h.length),h.length&&i.length&&h!==i&&u(r.passwordMismatch)},[i,r.passwordMismatch]),z=U(a=>{const h=a.target.value;u(h.length?"":r.requiredFieldError),h.length&&f.length&&h!==f&&u(r.passwordMismatch)},[f,r.passwordMismatch,r.requiredFieldError]),R=U(a=>{I(a),u(a?f===a?"":r.passwordMismatch:r.requiredFieldError)},[r,f]),D=U(({target:a})=>{Z(a.checked)},[]),rr=U(()=>{if(O(w)){w("signInForm");return}O(E)&&(window.location.href=E())},[w,E]),A=U(a=>{S(a),m(!a.length),a===i&&u("")},[i]),P=U(()=>{F(),S(""),O(T)?window.location.href=T():(H(!1),w==null||w("signInForm"))},[F,T,w]),K=()=>{V(!0),L(!1)},er=(a,h)=>{const tr=f.length&&i.length,j=f!==i,x=()=>{m(!f.length),i||u(r.requiredFieldError),tr&&j&&u(r.passwordMismatch)},y=()=>{u(i.length?r.passwordMismatch:r.requiredFieldError),dr(a,f,i)};return h?n&&(q.length||j)?(K(),y(),!0):(dr(a,f,""),x(),!1):(K(),x(),!0)};return{showPasswordErrorMessage:l,confirmPassword:i,confirmPasswordMessage:q,isKeepMeLogged:Y,userEmail:G,showEmailConfirmationForm:J,isSuccessful:Q,isClickSubmit:X,signUpPasswordValue:f,isLoading:W,onSubmitSignUp:async(a,h)=>{var sr,or,ir;if(F(),u(""),L(!0),er(a,h))return;const{confirmPasswordField:tr,...j}=qr(a.target),{email:x,password:y,is_subscribed:gr}=j,hr=(s==null?void 0:s.requiredCharacterClasses)||0,pr=(s==null?void 0:s.minLength)||1;if(!Mr(y,hr)||pr>(y==null?void 0:y.length)){K();return}const wr=Or({...j,is_subscribed:!!gr||!1},d),N=await _r(wr,d);if((sr=N==null?void 0:N.errors)!=null&&sr.length){const{errors:M}=N;F==null||F({type:"error",text:(or=M[0])==null?void 0:or.message}),C==null||C(M),v(x)}else{const M=N==null?void 0:N.firstName;if(xr(Tr.CREATE_ACCOUNT_EVENT,{...N}),t||!o){if(g==null||g({userName:M,status:!0}),t){(ir=a.target)==null||ir.reset(),S(""),H(!0),v(x),L(!1);return}if(!o){L(!1),B({userName:M,status:!0});return}}const b=await Sr({email:x,password:y,translations:r,handleSetInLineAlertProps:F,onErrorCallback:C});if(b!=null&&b.userName){if(e!=null&&e.length)for(const ar of e)try{await Nr(ar)}catch(Fr){console.error(r.failedCreateCustomerAddress,ar,Fr)}O(_)?window.location.href=_():(g==null||g({userName:b==null?void 0:b.userName,status:!0}),B({userName:b==null?void 0:b.userName,status:!0}))}else g==null||g({userName:M,status:!0}),B({userName:M,status:!0})}L(!1)},signInButton:rr,handleSetSignUpPasswordValue:A,onKeepMeLoggedChange:D,handleHideEmailConfirmationForm:P,handleConfirmPasswordChange:R,onBlurPassword:k,onBlurConfirmPassword:z}},me=({requireRetypePassword:n=!1,addressesData:e,formSize:r="default",inputsDefaultValueSet:t,fieldsConfigForApiVersion1:d,apiVersion2:s=!0,isAutoSignInEnabled:o=!0,hideCloseBtnOnEmailConfirmation:_=!1,routeRedirectOnEmailConfirmationClose:E,routeRedirectOnSignIn:C,routeSignIn:g,onErrorCallback:w,onSuccessCallback:F,setActiveComponent:T,slots:l})=>{const m=Hr({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:i,isEmailConfirmationRequired:I}=Ur(),{fieldsListConfigs:q}=$r({fieldsConfigForApiVersion1:d,apiVersion2:s,inputsDefaultValueSet:t}),{inLineAlertProps:u,handleSetInLineAlertProps:G}=vr(),{showPasswordErrorMessage:v,confirmPassword:J,confirmPasswordMessage:H,isKeepMeLogged:Q,userEmail:B,showEmailConfirmationForm:f,isSuccessful:S,isClickSubmit:X,signUpPasswordValue:V,isLoading:W,onSubmitSignUp:L,signInButton:Y,handleSetSignUpPasswordValue:Z,onKeepMeLoggedChange:k,handleHideEmailConfirmationForm:z,handleConfirmPasswordChange:R,onBlurPassword:D,onBlurConfirmPassword:rr}=Jr({requireRetypePassword:n,addressesData:e,translations:m,isEmailConfirmationRequired:I,apiVersion2:s,passwordConfigs:i,isAutoSignInEnabled:o,routeRedirectOnSignIn:C,routeSignIn:g,onErrorCallback:w,onSuccessCallback:F,setActiveComponent:T,handleSetInLineAlertProps:G,routeRedirectOnEmailConfirmationClose:E}),{isValidUniqueSymbols:A,defaultLengthMessage:P}=Cr({password:V,isClickSubmit:X,passwordConfigs:i}),K=Lr(()=>v?m.requiredFieldError:A==="error"||(P==null?void 0:P.status)==="error"?" ":"",[P==null?void 0:P.status,A,v,m.requiredFieldError]),er=!I&&(e==null?void 0:e.length);return!q.length&&s?c("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:c(Wr,{activeSkeleton:"signUpForm"})}):S.status&&(l!=null&&l.SuccessNotification)?c(nr,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:l==null?void 0:l.SuccessNotification,context:{isSuccessful:S}}):f?c(Ar,{formSize:r,userEmail:B,inLineAlertProps:u,hideCloseBtnOnEmailConfirmation:_,handleSetInLineAlertProps:G,onPrimaryButtonClick:z}):$("div",{className:Pr(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[c(Kr,{title:m.title,divider:!1,className:"auth-sign-up-form__title"}),u.text?c(jr,{className:"auth-sign-up-form__notification",type:u.type,variant:"secondary",heading:u.text,icon:u.icon}):null,$(Vr,{onSubmit:L,className:"auth-sign-up-form__form",loading:W,name:"signUp_form",fieldsConfig:q,slots:l,children:[$(cr,{validateLengthConfig:P,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:i==null?void 0:i.minLength,errorMessage:K,defaultValue:V,uniqueSymbolsStatus:A,requiredCharacterClasses:i==null?void 0:i.requiredCharacterClasses,onValue:Z,placeholder:m.placeholder,floatingLabel:m.floatingLabel,onBlur:D,children:[n?c("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:c(cr,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:m.confirmPasswordPlaceholder,floatingLabel:m.confirmPasswordFloatingLabel,errorMessage:H,defaultValue:J,onValue:R,onBlur:rr})}):null,er?c("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:c(Ir,{children:c(Gr,{name:"",placeholder:m.keepMeLoggedText,label:m.keepMeLoggedText,checked:Q,onChange:k})})}):null]}),c(nr,{name:"PrivacyPolicyConsent","data-testid":"privacyPolicyConsent",slot:l==null?void 0:l.PrivacyPolicyConsent},"privacyPolicyConsent"),$("div",{className:"auth-sign-up-form-buttons",children:[c(ur,{className:"auth-sign-up-form-buttons--signin",type:"button",variant:"tertiary",style:{padding:0},buttonText:m.buttonSecondary,enableLoader:!1,onClick:Y}),c(ur,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:W})]})]}),c("div",{id:"createCustomerV2"})]})};export{me as S}; diff --git a/scripts/__dropins__/storefront-auth/containers/SignUp.js b/scripts/__dropins__/storefront-auth/containers/SignUp.js index 6ea1727ac..f217d085d 100644 --- a/scripts/__dropins__/storefront-auth/containers/SignUp.js +++ b/scripts/__dropins__/storefront-auth/containers/SignUp.js @@ -1,3 +1,3 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as h}from"../chunks/SignUpForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/initialize.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"../chunks/getCustomerToken.js";import"../chunks/Button2.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/SkeletonLoader.js";const P=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,fieldsConfigForApiVersion1:u,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,onSuccessCallback:g,onErrorCallback:l,routeSignIn:S})=>r("div",{className:"auth-sign-up",children:r(h,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:u,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,routeSignIn:S,slots:i,onErrorCallback:l,onSuccessCallback:g})});export{P as SignUp,P as default}; +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{S as l}from"../chunks/SignUpForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/initialize.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"../chunks/getCustomerToken.js";import"../chunks/Button2.js";import"../chunks/focusOnEmptyPasswordField.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/SkeletonLoader.js";const M=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:n,hideCloseBtnOnEmailConfirmation:e,routeRedirectOnEmailConfirmationClose:u,routeRedirectOnSignIn:c,onSuccessCallback:d,onErrorCallback:f,routeSignIn:g})=>r("div",{className:"auth-sign-up",children:r(l,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:n,hideCloseBtnOnEmailConfirmation:e,routeRedirectOnEmailConfirmationClose:u,routeRedirectOnSignIn:c,routeSignIn:g,slots:i,onErrorCallback:f,onSuccessCallback:d})});export{M as SignUp,M as default}; diff --git a/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts b/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts index 466616129..b20d9f11b 100644 --- a/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts +++ b/scripts/__dropins__/storefront-auth/i18n/en_US.json.d.ts @@ -22,8 +22,6 @@ declare const _default: { "title": "Sign up", "buttonPrimary": "Create account", "buttonSecondary": "Already a member? Sign in", - "privacyPolicyDefaultText": "I’ve read and accept the Terms of Use and Privacy Policy.", - "subscribedDefaultText": "Subscribe to our newsletter and be the first to know about new arrivals, sales and exclusive offers.", "keepMeLoggedText": "Keep me logged in after account creation", "failedCreateCustomerAddress": "Failed to create customer addresses:", "confirmPassword": { @@ -87,6 +85,7 @@ declare const _default: { "floatingLabel": "Password *" } } -}; +} +; export default _default; diff --git a/scripts/__dropins__/storefront-auth/render.js b/scripts/__dropins__/storefront-auth/render.js index a0eec6c6c..341ce5938 100644 --- a/scripts/__dropins__/storefront-auth/render.js +++ b/scripts/__dropins__/storefront-auth/render.js @@ -1,4 +1,4 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -(function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})('.auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)}.auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__checkbox{margin-bottom:12px}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}',{styleId:"Auth"}); -import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as f}from"@dropins/tools/preact-hooks.js";import{UIProvider as h}from"@dropins/tools/components.js";import{events as p}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as g}from"./chunks/initialize.js";const w={PasswordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long"},ResetPasswordForm:{title:"Reset your password",buttonPrimary:"Reset password",buttonSecondary:"Back to sign in",formAriaLabel:"Reset your password form"},SignInForm:{title:"Sign in",buttonPrimary:"Sign in",buttonSecondary:"Sign up",buttonTertiary:"Forgot password?"},SignUpForm:{title:"Sign up",buttonPrimary:"Create account",buttonSecondary:"Already a member? Sign in",privacyPolicyDefaultText:"I’ve read and accept the Terms of Use and Privacy Policy.",subscribedDefaultText:"Subscribe to our newsletter and be the first to know about new arrivals, sales and exclusive offers.",keepMeLoggedText:"Keep me logged in after account creation",failedCreateCustomerAddress:"Failed to create customer addresses:",confirmPassword:{placeholder:"Confirm password",floatingLabel:"Confirm password *",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical."}},UpdatePasswordForm:{title:"Update password",buttonPrimary:"Update password"},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",dateMaxError:"Date must be less than or equal to {max}.",dateMinError:"Date must be greater than or equal to {min}.",urlError:"Please enter a valid URL, e.g., https://www.website.com.",lengthTextError:"Text length must be between {min} and {max} characters."},EmailConfirmationForm:{title:"Verify your email address",subtitle:"We`ve sent an email to",mainText:"Check your inbox and click on the link we just send you to confirm your email address and activate your account.",buttonSecondary:"Resend email",buttonPrimary:"Close",accountConfirmMessage:"Account confirmed",accountConfirmationEmailSuccessMessage:"Congratulations! Your account at {email} email has been successfully confirmed."},Notification:{errorNotification:"Your password update failed due to validation errors. Please check your information and try again.",updatePasswordMessage:"The password has been updated.",updatePasswordActionMessage:"Sign in",successPasswordResetEmailNotification:"If there is an account associated with {email} you will receive an email with a link to reset your password.",resendEmailNotification:{informationText:"This account is not confirmed.",buttonText:"Resend confirmation email"},emailConfirmationMessage:"Please check your email for confirmation link.",technicalErrors:{technicalErrorSendEmail:"A technical error occurred while trying to send the email. Please try again later."}},SuccessNotification:{headingText:"Welcome!",messageText:"We are glad to see you!",primaryButtonText:"Continue shopping",secondaryButtonText:"Logout"},Api:{customerTokenErrorMessage:"Unable to log in. Please try again later or contact support if the issue persists."},InputPassword:{placeholder:"Password",floatingLabel:"Password *"}},b={Auth:w},y={default:b},P=({children:n})=>{var r,t;const[e,i]=u("en_US"),c=(t=(r=g)==null?void 0:r.getConfig())==null?void 0:t.langDefinitions;f(()=>{const a=p.on("locale",o=>{o!==e&&i(o)},{eager:!0});return()=>{a==null||a.off()}},[e]);const l=d(y,c??{});return s(h,{lang:e,langDefinitions:l,children:n})},k=new m(s(P,{}));export{k as render}; +(function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})('.auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)}.auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}',{styleId:"Auth"}); +import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as d,Render as m}from"@dropins/tools/lib.js";import{useState as u,useEffect as h}from"@dropins/tools/preact-hooks.js";import{UIProvider as g}from"@dropins/tools/components.js";import{events as p}from"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{c as f}from"./chunks/initialize.js";const w={PasswordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long"},ResetPasswordForm:{title:"Reset your password",buttonPrimary:"Reset password",buttonSecondary:"Back to sign in",formAriaLabel:"Reset your password form"},SignInForm:{title:"Sign in",buttonPrimary:"Sign in",buttonSecondary:"Sign up",buttonTertiary:"Forgot password?"},SignUpForm:{title:"Sign up",buttonPrimary:"Create account",buttonSecondary:"Already a member? Sign in",keepMeLoggedText:"Keep me logged in after account creation",failedCreateCustomerAddress:"Failed to create customer addresses:",confirmPassword:{placeholder:"Confirm password",floatingLabel:"Confirm password *",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical."}},UpdatePasswordForm:{title:"Update password",buttonPrimary:"Update password"},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",dateMaxError:"Date must be less than or equal to {max}.",dateMinError:"Date must be greater than or equal to {min}.",urlError:"Please enter a valid URL, e.g., https://www.website.com.",lengthTextError:"Text length must be between {min} and {max} characters."},EmailConfirmationForm:{title:"Verify your email address",subtitle:"We`ve sent an email to",mainText:"Check your inbox and click on the link we just send you to confirm your email address and activate your account.",buttonSecondary:"Resend email",buttonPrimary:"Close",accountConfirmMessage:"Account confirmed",accountConfirmationEmailSuccessMessage:"Congratulations! Your account at {email} email has been successfully confirmed."},Notification:{errorNotification:"Your password update failed due to validation errors. Please check your information and try again.",updatePasswordMessage:"The password has been updated.",updatePasswordActionMessage:"Sign in",successPasswordResetEmailNotification:"If there is an account associated with {email} you will receive an email with a link to reset your password.",resendEmailNotification:{informationText:"This account is not confirmed.",buttonText:"Resend confirmation email"},emailConfirmationMessage:"Please check your email for confirmation link.",technicalErrors:{technicalErrorSendEmail:"A technical error occurred while trying to send the email. Please try again later."}},SuccessNotification:{headingText:"Welcome!",messageText:"We are glad to see you!",primaryButtonText:"Continue shopping",secondaryButtonText:"Logout"},Api:{customerTokenErrorMessage:"Unable to log in. Please try again later or contact support if the issue persists."},InputPassword:{placeholder:"Password",floatingLabel:"Password *"}},y={Auth:w},b={default:y},P=({children:n})=>{var r,t;const[e,i]=u("en_US"),c=(t=(r=f)==null?void 0:r.getConfig())==null?void 0:t.langDefinitions;h(()=>{const a=p.on("locale",o=>{o!==e&&i(o)},{eager:!0});return()=>{a==null||a.off()}},[e]);const l=d(b,c??{});return s(g,{lang:e,langDefinitions:l,children:n})},L=new m(s(P,{}));export{L as render}; diff --git a/scripts/__dropins__/storefront-auth/types/signUp.types.d.ts b/scripts/__dropins__/storefront-auth/types/signUp.types.d.ts index 328e8223c..6c55da4f9 100644 --- a/scripts/__dropins__/storefront-auth/types/signUp.types.d.ts +++ b/scripts/__dropins__/storefront-auth/types/signUp.types.d.ts @@ -19,14 +19,13 @@ export interface SignUpProps { inputsDefaultValueSet?: inputsDefaultValueSetProps[]; fieldsConfigForApiVersion1?: any; apiVersion2?: boolean; - displayTermsOfUseCheckbox?: boolean; - displayNewsletterCheckbox?: boolean; isAutoSignInEnabled?: boolean; formSize?: 'default' | 'small'; hideCloseBtnOnEmailConfirmation?: boolean; routeRedirectOnEmailConfirmationClose?: () => string; slots?: { SuccessNotification?: SlotProps; + PrivacyPolicyConsent: SlotProps; }; routeSignIn?: () => string; routeRedirectOnSignIn?: () => string; @@ -38,8 +37,11 @@ export interface SignUpProps { } export interface SignUpFormProps extends SignUpProps { setActiveComponent?: (componentName: activeComponentType) => void; + slot?: { + PrivacyPolicyConsent: SlotProps; + }; } -export interface UseSingUpFormProps extends Omit { +export interface UseSingUpFormProps extends Omit { passwordConfigs?: { minLength: number; requiredCharacterClasses: number; diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index d166efed6..8b21222ac 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{c as j,r as z}from"./chunks/requestGuestOrderCancel.js";import{f as R,h as g}from"./chunks/fetch-graphql.js";import{g as K,r as W,s as Z,a as ee,b as re}from"./chunks/fetch-graphql.js";import{g as oe}from"./chunks/getAttributesForm.js";import{g as ne,a as se,r as ue}from"./chunks/requestGuestReturn.js";import{g as ie,a as le}from"./chunks/getGuestOrder.js";import{g as de}from"./chunks/getCustomerOrdersReturn.js";import{a as A}from"./chunks/initialize.js";import{d as Te,g as me,c as _e,i as Re}from"./chunks/initialize.js";import{g as Ae}from"./chunks/getStoreConfig.js";import{h as D}from"./chunks/network-error.js";import{events as d}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as O,PRICE_DETAILS_FRAGMENT as h,GIFT_CARD_DETAILS_FRAGMENT as f,ORDER_ITEM_DETAILS_FRAGMENT as x,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as C,ORDER_SUMMARY_FRAGMENT as b,ADDRESS_FRAGMENT as M}from"./fragments.js";import{a as Oe,c as he,r as fe}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const m=(r,t)=>r+t.amount.value,G=(r,t)=>({id:r,totalQuantity:t.totalQuantity,possibleOnepageCheckout:!0,items:t.items.map(e=>{var o,a,n,s,u,c,i,l;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:(o=e.product)==null?void 0:o.canonicalUrl,mainImageUrl:((a=e.product)==null?void 0:a.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((u=e.product)==null?void 0:u.sku)??"",topLevelSku:(c=e.product)==null?void 0:c.sku},prices:{price:{value:e.price.value,currency:e.price.currency,regularPrice:((i=e.regularPrice)==null?void 0:i.value)??e.price.value}},configurableOptions:((l=e.selectedOptions)==null?void 0:l.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}}),prices:{subtotalExcludingTax:{value:t.subtotalExclTax.value,currency:t.subtotalExclTax.currency},subtotalIncludingTax:{value:t.subtotalInclTax.value,currency:t.subtotalInclTax.currency}},discountAmount:t.discounts.reduce(m,0)}),I=r=>{var o,a,n;const t=r.coupons[0],e=(o=r.payments)==null?void 0:o[0];return{appliedCouponCode:(t==null?void 0:t.code)??"",email:r.email,grandTotal:r.grandTotal.value,orderId:r.number,orderType:"checkout",otherTax:0,salesTax:r.totalTax.value,shipping:{shippingMethod:((a=r.shipping)==null?void 0:a.code)??"",shippingAmount:((n=r.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:r.subtotalExclTax.value,subtotalIncludingTax:r.subtotalInclTax.value,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:r.grandTotal.value,orderId:r.number}]:[],discountAmount:r.discounts.reduce(m,0),taxAmount:r.totalTax.value}},N=r=>{var e,o;const t=(o=(e=r==null?void 0:r.data)==null?void 0:e.placeOrder)==null?void 0:o.orderV2;return t?A(t):null},E={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},v={PLACE_ORDER:"place-order"};function _(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function T(r,t){const e=_();e.push({[r]:null}),e.push({[r]:t})}function L(r){_().push(e=>{const o=e.getState?e.getState():{};e.push({event:r,eventInfo:{...o}})})}function y(r,t){const e=I(t),o=G(r,t);T(E.ORDER_CONTEXT,{...e}),T(E.SHOPPING_CART_CONTEXT,{...o}),L(v.PLACE_ORDER)}class S extends Error{constructor(t){super(t),this.name="PlaceOrderError"}}const F=r=>{const t=r.map(e=>e.message).join(" ");throw new S(t)},P=` +import{c as z,r as J}from"./chunks/requestGuestOrderCancel.js";import{f as _,h as g}from"./chunks/fetch-graphql.js";import{g as W,r as Z,s as ee,a as re,b as te}from"./chunks/fetch-graphql.js";import{g as oe}from"./chunks/getAttributesForm.js";import{g as se,a as ce,r as ue}from"./chunks/requestGuestReturn.js";import{g as le,a as pe}from"./chunks/getGuestOrder.js";import{g as me}from"./chunks/getCustomerOrdersReturn.js";import{a as h}from"./chunks/initialize.js";import{d as Te,g as Re,c as _e,i as ge}from"./chunks/initialize.js";import{g as Ae}from"./chunks/getStoreConfig.js";import{h as A}from"./chunks/network-error.js";import{events as d}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as O,PRICE_DETAILS_FRAGMENT as D,GIFT_CARD_DETAILS_FRAGMENT as x,ORDER_ITEM_DETAILS_FRAGMENT as f,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as C,ORDER_SUMMARY_FRAGMENT as b,ADDRESS_FRAGMENT as M,ORDER_ITEM_FRAGMENT as v}from"./fragments.js";import{a as De,c as xe,r as fe}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const T=(r,t)=>r+t.amount.value,y=(r,t)=>({id:r,totalQuantity:t.totalQuantity,possibleOnepageCheckout:!0,items:t.items.map(e=>{var a,o,n,s,c,u,i,l;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:(a=e.product)==null?void 0:a.canonicalUrl,mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((c=e.product)==null?void 0:c.sku)??"",topLevelSku:(u=e.product)==null?void 0:u.sku},prices:{price:{value:e.price.value,currency:e.price.currency,regularPrice:((i=e.regularPrice)==null?void 0:i.value)??e.price.value}},configurableOptions:((l=e.selectedOptions)==null?void 0:l.map(p=>({optionLabel:p.label,valueLabel:p.value})))||[]}}),prices:{subtotalExcludingTax:{value:t.subtotalExclTax.value,currency:t.subtotalExclTax.currency},subtotalIncludingTax:{value:t.subtotalInclTax.value,currency:t.subtotalInclTax.currency}},discountAmount:t.discounts.reduce(T,0)}),G=r=>{var a,o,n;const t=r.coupons[0],e=(a=r.payments)==null?void 0:a[0];return{appliedCouponCode:(t==null?void 0:t.code)??"",email:r.email,grandTotal:r.grandTotal.value,orderId:r.number,orderType:"checkout",otherTax:0,salesTax:r.totalTax.value,shipping:{shippingMethod:((o=r.shipping)==null?void 0:o.code)??"",shippingAmount:((n=r.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:r.subtotalExclTax.value,subtotalIncludingTax:r.subtotalInclTax.value,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:r.grandTotal.value,orderId:r.number}]:[],discountAmount:r.discounts.reduce(T,0),taxAmount:r.totalTax.value}},N=r=>{var e,a;const t=(a=(e=r==null?void 0:r.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return t?h(t):null},m={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},L={PLACE_ORDER:"place-order"};function R(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function E(r,t){const e=R();e.push({[r]:null}),e.push({[r]:t})}function S(r){R().push(e=>{const a=e.getState?e.getState():{};e.push({event:r,eventInfo:{...a}})})}function F(r,t){const e=G(t),a=y(r,t);E(m.ORDER_CONTEXT,{...e}),E(m.SHOPPING_CART_CONTEXT,{...a}),S(L.PLACE_ORDER)}class I extends Error{constructor(t){super(t),this.name="PlaceOrderError"}}const P=r=>{const t=r.map(e=>e.message).join(" ");throw new I(t)},k=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -59,23 +59,7 @@ import{c as j,r as z}from"./chunks/requestGuestOrderCancel.js";import{f as R,h a ...ADDRESS_FRAGMENT } items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } total { ...ORDER_SUMMARY_FRAGMENT @@ -84,10 +68,11 @@ import{c as j,r as z}from"./chunks/requestGuestOrderCancel.js";import{f as R,h a } } ${O} - ${h} - ${f} + ${D} ${x} + ${f} ${C} ${b} ${M} -`,X=async r=>{if(!r)throw new Error("No cart ID found");return R(P,{variables:{cartId:r}}).then(t=>{var o,a,n,s,u;(o=t.errors)!=null&&o.length&&g(t.errors),(s=(n=(a=t.data)==null?void 0:a.placeOrder)==null?void 0:n.errors)!=null&&s.length&&F((u=t.data.placeOrder)==null?void 0:u.errors);const e=N(t);return e&&(d.emit("order/placed",e),d.emit("cart/reset",void 0),y(r,e)),e}).catch(D)};export{j as cancelOrder,Te as config,Oe as confirmCancelOrder,he as confirmGuestReturn,R as fetchGraphQl,oe as getAttributesForm,ne as getAttributesList,K as getConfig,ie as getCustomer,de as getCustomerOrdersReturn,le as getGuestOrder,me as getOrderDetailsById,Ae as getStoreConfig,_e as guestOrderByToken,Re as initialize,X as placeOrder,W as removeFetchGraphQlHeader,fe as reorderItems,z as requestGuestOrderCancel,se as requestGuestReturn,ue as requestReturn,Z as setEndpoint,ee as setFetchGraphQlHeader,re as setFetchGraphQlHeaders}; + ${v} +`,V=async r=>{if(!r)throw new Error("No cart ID found");return _(k,{variables:{cartId:r}}).then(t=>{var a,o,n,s,c;(a=t.errors)!=null&&a.length&&g(t.errors),(s=(n=(o=t.data)==null?void 0:o.placeOrder)==null?void 0:n.errors)!=null&&s.length&&P((c=t.data.placeOrder)==null?void 0:c.errors);const e=N(t);return e&&(d.emit("order/placed",e),d.emit("cart/reset",void 0),F(r,e)),e}).catch(A)};export{z as cancelOrder,Te as config,De as confirmCancelOrder,xe as confirmGuestReturn,_ as fetchGraphQl,oe as getAttributesForm,se as getAttributesList,W as getConfig,le as getCustomer,me as getCustomerOrdersReturn,pe as getGuestOrder,Re as getOrderDetailsById,Ae as getStoreConfig,_e as guestOrderByToken,ge as initialize,V as placeOrder,Z as removeFetchGraphQlHeader,fe as reorderItems,J as requestGuestOrderCancel,ce as requestGuestReturn,ue as requestReturn,ee as setEndpoint,re as setFetchGraphQlHeader,te as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/fragments.d.ts b/scripts/__dropins__/storefront-order/api/fragments.d.ts index b6db02a89..6ec94d614 100644 --- a/scripts/__dropins__/storefront-order/api/fragments.d.ts +++ b/scripts/__dropins__/storefront-order/api/fragments.d.ts @@ -15,8 +15,8 @@ *******************************************************************/ export { REQUEST_RETURN_ORDER_FRAGMENT } from './graphql/RequestReturnOrderFragment.graphql'; export { ADDRESS_FRAGMENT } from './graphql/CustomerAddressFragment.graphql'; -export { PRODUCT_DETAILS_FRAGMENT, PRICE_DETAILS_FRAGMENT, GIFT_CARD_DETAILS_FRAGMENT, ORDER_ITEM_DETAILS_FRAGMENT, BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT, } from './graphql/OrderItemsFragment.graphql'; +export { PRODUCT_DETAILS_FRAGMENT, PRICE_DETAILS_FRAGMENT, GIFT_CARD_DETAILS_FRAGMENT, ORDER_ITEM_FRAGMENT, ORDER_ITEM_DETAILS_FRAGMENT, BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT, DOWNLOADABLE_ORDER_ITEMS_FRAGMENT, } from './graphql/OrderItemsFragment.graphql'; export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql'; export { RETURNS_FRAGMENT } from './graphql/ReturnsFragment.graphql'; -export { GUEST_ORDER_FRAGMENT } from './graphql/GurestOrderFragment.graphql'; +export { GUEST_ORDER_FRAGMENT } from './graphql/GuestOrderFragment.graphql'; //# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/GuestOrderFragment.graphql.d.ts similarity index 92% rename from scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts rename to scripts/__dropins__/storefront-order/api/graphql/GuestOrderFragment.graphql.d.ts index 2d36c9f39..549f341bd 100644 --- a/scripts/__dropins__/storefront-order/api/graphql/GurestOrderFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/graphql/GuestOrderFragment.graphql.d.ts @@ -14,4 +14,4 @@ * from Adobe. *******************************************************************/ export declare const GUEST_ORDER_FRAGMENT: string; -//# sourceMappingURL=GurestOrderFragment.graphql.d.ts.map \ No newline at end of file +//# sourceMappingURL=GuestOrderFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts b/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts index 032c0a4cf..12f1c1367 100644 --- a/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-order/api/graphql/OrderItemsFragment.graphql.d.ts @@ -18,4 +18,6 @@ export declare const PRICE_DETAILS_FRAGMENT = "\n fragment PRICE_DETAILS_FRAGME export declare const GIFT_CARD_DETAILS_FRAGMENT = "\n fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem {\n ...PRICE_DETAILS_FRAGMENT\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n"; export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface {\n __typename\n status\n product_sku\n eligible_for_return\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_return_requested\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...PRODUCT_DETAILS_FRAGMENT\n }\n ...PRICE_DETAILS_FRAGMENT\n }\n"; export declare const BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem {\n ...PRICE_DETAILS_FRAGMENT\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n"; +export declare const DOWNLOADABLE_ORDER_ITEMS_FRAGMENT = "\n fragment DOWNLOADABLE_ORDER_ITEMS_FRAGMENT on DownloadableOrderItem {\n product_name\n downloadable_links {\n sort_order\n title\n }\n }\n"; +export declare const ORDER_ITEM_FRAGMENT: string; //# sourceMappingURL=OrderItemsFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js index c1be8eca9..0600a8efb 100644 --- a/scripts/__dropins__/storefront-order/chunks/initialize.js +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -1,6 +1,6 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as L}from"@dropins/tools/event-bus.js";import{h as Y}from"./network-error.js";import{PRODUCT_DETAILS_FRAGMENT as Q,PRICE_DETAILS_FRAGMENT as K,GIFT_CARD_DETAILS_FRAGMENT as j,ORDER_ITEM_DETAILS_FRAGMENT as P,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as D,ORDER_SUMMARY_FRAGMENT as V,ADDRESS_FRAGMENT as X,RETURNS_FRAGMENT as H}from"../fragments.js";import{f as J,h as o}from"./fetch-graphql.js";const r=n=>n||0,I=n=>{var i,u,_,l,c,s,E,y,T;return{__typename:(n==null?void 0:n.__typename)||"",uid:(n==null?void 0:n.uid)||"",onlyXLeftInStock:(n==null?void 0:n.only_x_left_in_stock)??0,stockStatus:(n==null?void 0:n.stock_status)??"",priceRange:{maximumPrice:{regularPrice:{currency:((_=(u=(i=n==null?void 0:n.price_range)==null?void 0:i.maximum_price)==null?void 0:u.regular_price)==null?void 0:_.currency)??"",value:((s=(c=(l=n==null?void 0:n.price_range)==null?void 0:l.maximum_price)==null?void 0:c.regular_price)==null?void 0:s.value)??0}}},canonicalUrl:(n==null?void 0:n.canonical_url)??"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)??"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((E=n==null?void 0:n.image)==null?void 0:E.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((y=n==null?void 0:n.thumbnail)==null?void 0:y.label)||"",url:((T=n==null?void 0:n.thumbnail)==null?void 0:T.url)||""}}},d=n=>{if(!n||!("selected_options"in n))return;const i={};for(const u of n.selected_options)i[u.label]=u.value;return i},nn=n=>{const i=n==null?void 0:n.map(_=>({uid:_.uid,label:_.label,values:_.values.map(l=>l.product_name).join(", ")})),u={};return i==null||i.forEach(_=>{u[_.label]=_.values}),Object.keys(u).length>0?u:null},un=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(i=>i.title).join(", ")}:null,_n=n=>({quantityCanceled:(n==null?void 0:n.quantity_canceled)??0,quantityInvoiced:(n==null?void 0:n.quantity_invoiced)??0,quantityOrdered:(n==null?void 0:n.quantity_ordered)??0,quantityRefunded:(n==null?void 0:n.quantity_refunded)??0,quantityReturned:(n==null?void 0:n.quantity_returned)??0,quantityShipped:(n==null?void 0:n.quantity_shipped)??0,quantityReturnRequested:(n==null?void 0:n.quantity_return_requested)??0}),ln=n=>({firstName:(n==null?void 0:n.firstname)??"",lastName:(n==null?void 0:n.lastname)??"",middleName:(n==null?void 0:n.middlename)??""}),$=n=>{const{firstName:i,lastName:u,middleName:_}=ln(n);return{firstName:i,lastName:u,middleName:_,city:(n==null?void 0:n.city)??"",company:(n==null?void 0:n.company)??"",country:(n==null?void 0:n.country)??"",countryCode:(n==null?void 0:n.country_code)??"",fax:(n==null?void 0:n.fax)??"",postCode:(n==null?void 0:n.postcode)??"",prefix:(n==null?void 0:n.prefix)??"",region:(n==null?void 0:n.region)??"",regionId:(n==null?void 0:n.region_id)??"",street:(n==null?void 0:n.street)??[],suffix:(n==null?void 0:n.suffix)??"",telephone:(n==null?void 0:n.telephone)??"",vatId:(n==null?void 0:n.vat_id)??"",customAttributes:(n==null?void 0:n.custom_attributes)??[]}},cn=n=>{const i={value:0,currency:"USD"};return{grandTotal:(n==null?void 0:n.grand_total)??i,totalGiftcard:(n==null?void 0:n.total_giftcard)??i,subtotalExclTax:(n==null?void 0:n.subtotal_excl_tax)??i,subtotalInclTax:(n==null?void 0:n.subtotal_incl_tax)??i,taxes:(n==null?void 0:n.taxes)??[],totalTax:(n==null?void 0:n.total_tax)??i,totalShipping:(n==null?void 0:n.total_shipping)??i,discounts:(n==null?void 0:n.discounts)??[]}},w=n=>{const i={value:0,currency:"USD"},u=(n==null?void 0:n.prices)??{};return{price:(u==null?void 0:u.price)??i,priceIncludingTax:(u==null?void 0:u.price_including_tax)??i,originalPrice:(u==null?void 0:u.original_price)??i,originalPriceIncludingTax:(u==null?void 0:u.original_price_including_tax)??i,discounts:(u==null?void 0:u.discounts)??[]}},an=(n,i,u)=>{const _=n==null?void 0:n.price,l=n==null?void 0:n.priceIncludingTax,c=n==null?void 0:n.originalPrice,s=u?c==null?void 0:c.value:l==null?void 0:l.value,E={originalPrice:c,baseOriginalPrice:{value:s,currency:c==null?void 0:c.currency},baseDiscountedPrice:{value:l==null?void 0:l.value,currency:l==null?void 0:l.currency},baseExcludingTax:{value:_==null?void 0:_.value,currency:_==null?void 0:_.currency}},y={originalPrice:c,baseOriginalPrice:{value:c==null?void 0:c.value,currency:l==null?void 0:l.currency},baseDiscountedPrice:{value:i==null?void 0:i.value,currency:_==null?void 0:_.currency},baseExcludingTax:{value:_==null?void 0:_.value,currency:_==null?void 0:_.currency}},T={singleItemPrice:{value:u?c.value:l.value,currency:l.currency},baseOriginalPrice:{value:s,currency:l.currency},baseDiscountedPrice:{value:l.value,currency:l.currency}};return{includeAndExcludeTax:E,excludeTax:y,includeTax:T}},tn=n=>{var i,u,_,l,c;return{senderName:((i=n.gift_card)==null?void 0:i.sender_name)||"",senderEmail:((u=n.gift_card)==null?void 0:u.sender_email)||"",recipientEmail:((_=n.gift_card)==null?void 0:_.recipient_email)||"",recipientName:((l=n.gift_card)==null?void 0:l.recipient_name)||"",message:((c=n.gift_card)==null?void 0:c.message)||""}},sn=n=>{var i,u,_,l;return{label:((u=(i=n==null?void 0:n.product)==null?void 0:i.thumbnail)==null?void 0:u.label)||"",url:((l=(_=n==null?void 0:n.product)==null?void 0:_.thumbnail)==null?void 0:l.url)||""}},W=n=>{var G,e,F,q,x,f,N,t,A,h,O,S,v,M,p,k,g,b;const{quantityCanceled:i,quantityInvoiced:u,quantityOrdered:_,quantityRefunded:l,quantityReturned:c,quantityShipped:s,quantityReturnRequested:E}=_n(n),y=w(n),T=((G=n==null?void 0:n.prices)==null?void 0:G.original_price.value)*(n==null?void 0:n.quantity_ordered)>((e=n==null?void 0:n.prices)==null?void 0:e.price.value)*(n==null?void 0:n.quantity_ordered),a=r(n==null?void 0:n.quantity_ordered),R={value:((F=n==null?void 0:n.product_sale_price)==null?void 0:F.value)||0,currency:(q=n==null?void 0:n.product_sale_price)==null?void 0:q.currency};return{selectedOptions:(n==null?void 0:n.selected_options)??[],productSalePrice:n==null?void 0:n.product_sale_price,status:(n==null?void 0:n.status)??"",type:n==null?void 0:n.__typename,eligibleForReturn:(n==null?void 0:n.eligible_for_return)??!1,productSku:(n==null?void 0:n.product_sku)??"",productName:(n==null?void 0:n.product_name)??"",productUrlKey:(n==null?void 0:n.product_url_key)??"",quantityCanceled:i,quantityInvoiced:u,quantityOrdered:_,quantityRefunded:l,quantityReturned:c,quantityShipped:s,quantityReturnRequested:E,id:n==null?void 0:n.id,discounted:T,total:{value:((x=n==null?void 0:n.product_sale_price)==null?void 0:x.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((f=n==null?void 0:n.product_sale_price)==null?void 0:f.currency)||""},totalInclTax:{value:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(t=n==null?void 0:n.product_sale_price)==null?void 0:t.currency},price:R,prices:w(n),itemPrices:y,taxCalculations:an(y,R,T),priceInclTax:{value:((A=n==null?void 0:n.product_sale_price)==null?void 0:A.value)??0,currency:(h=n==null?void 0:n.product_sale_price)==null?void 0:h.currency},totalQuantity:a,regularPrice:{value:(M=(v=(S=(O=n==null?void 0:n.product)==null?void 0:O.price_range)==null?void 0:S.maximum_price)==null?void 0:v.regular_price)==null?void 0:M.value,currency:(b=(g=(k=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:k.maximum_price)==null?void 0:g.regular_price)==null?void 0:b.currency},product:I(n==null?void 0:n.product),thumbnail:sn(n),giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?tn(n):void 0,configurableOptions:d(n),bundleOptions:n.__typename==="BundleOrderItem"?nn(n.bundle_options):null,downloadableLinks:n.__typename==="DownloadableOrderItem"?un(n==null?void 0:n.downloadable_links):null}},U=n=>n==null?void 0:n.filter(i=>i.__typename).map(i=>W(i)),Rn=n=>({token:(n==null?void 0:n.token)??"",email:(n==null?void 0:n.email)??"",status:(n==null?void 0:n.status)??"",number:(n==null?void 0:n.number)??"",id:(n==null?void 0:n.id)??"",carrier:n.carrier??"",coupons:(n==null?void 0:n.applied_coupons)??[],orderDate:(n==null?void 0:n.order_date)??"",isVirtual:(n==null?void 0:n.is_virtual)??!1,availableActions:(n==null?void 0:n.available_actions)??[],orderStatusChangeDate:(n==null?void 0:n.order_status_change_date)??"",shippingMethod:(n==null?void 0:n.shipping_method)??""}),B=(n,i)=>{var t,A,h,O,S,v,M,p,k;const u=Rn(n),_=$(n==null?void 0:n.billing_address),l=$(n==null?void 0:n.shipping_address),c=(t=n.shipments)==null?void 0:t.map(g=>({...g,items:g.items.map(b=>({id:b.id,productName:b.product_name,productSku:b.product_sku,quantityShipped:b.quantity_shipped,orderItem:W(b.order_item)}))})),s=U(n.items),E=((A=En(n==null?void 0:n.returns))==null?void 0:A.ordersReturn)??[],y=i?E.filter(g=>g.returnNumber===i):E,T=U(n.items_eligible_for_return),a=cn(n==null?void 0:n.total),R=(h=n==null?void 0:n.payment_methods)==null?void 0:h[0],G=n==null?void 0:n.shipping_method,e=s==null?void 0:s.reduce((g,b)=>g+(b==null?void 0:b.totalQuantity),0),F={amount:((O=a==null?void 0:a.totalShipping)==null?void 0:O.value)??0,currency:((S=a==null?void 0:a.totalShipping)==null?void 0:S.currency)||"",code:(u==null?void 0:u.shippingMethod)??""},q=[{code:(R==null?void 0:R.type)??"",name:(R==null?void 0:R.name)??""}],x=a==null?void 0:a.subtotalExclTax,f=a==null?void 0:a.subtotalInclTax,N={...u,...a,subtotalExclTax:x,subtotalInclTax:f,billingAddress:_,shippingAddress:l,shipments:c,items:s,returns:y,itemsEligibleForReturn:T,totalQuantity:e,shippingMethod:G,shipping:F,payments:q};return z(N,(k=(p=(M=(v=C==null?void 0:C.getConfig())==null?void 0:v.models)==null?void 0:M.OrderDataModel)==null?void 0:p.transformer)==null?void 0:k.call(p,n))},yn=(n,i,u)=>{var _,l,c,s,E,y,T;if((s=(c=(l=(_=i==null?void 0:i.data)==null?void 0:_.customer)==null?void 0:l.orders)==null?void 0:c.items)!=null&&s.length&&n==="orderData"){const a=(T=(y=(E=i==null?void 0:i.data)==null?void 0:E.customer)==null?void 0:y.orders)==null?void 0:T.items[0];return B(a,u)}return null},En=n=>{var c,s,E,y,T;if(!((c=n==null?void 0:n.items)!=null&&c.length))return null;const i=n==null?void 0:n.items,u=n==null?void 0:n.page_info,l={ordersReturn:[...i].sort((a,R)=>+R.number-+a.number).map(a=>{var f,N;const{order:R,status:G,number:e,created_at:F}=a,q=((N=(f=a==null?void 0:a.shipping)==null?void 0:f.tracking)==null?void 0:N.map(t=>{const{status:A,carrier:h,tracking_number:O}=t;return{status:A,carrier:h,trackingNumber:O}}))??[],x=a.items.map(t=>{var p;const A=t==null?void 0:t.quantity,h=t==null?void 0:t.status,O=t==null?void 0:t.request_quantity,S=t==null?void 0:t.uid,v=t==null?void 0:t.order_item,M=((p=U([v]))==null?void 0:p.reduce((k,g)=>g,{}))??{};return{uid:S,quantity:A,status:h,requestQuantity:O,...M}});return{createdReturnAt:F,returnStatus:G,token:R==null?void 0:R.token,orderNumber:R==null?void 0:R.number,returnNumber:e,items:x,tracking:q}}),...u?{pageInfo:{pageSize:u.page_size,totalPages:u.total_pages,currentPage:u.current_page}}:{}};return z(l,(T=(y=(E=(s=C==null?void 0:C.getConfig())==null?void 0:s.models)==null?void 0:E.CustomerOrdersReturnModel)==null?void 0:y.transformer)==null?void 0:T.call(y,{...i,...u}))},Gn=(n,i)=>{var _,l;if(!((_=n==null?void 0:n.data)!=null&&_.guestOrder))return null;const u=(l=n==null?void 0:n.data)==null?void 0:l.guestOrder;return B(u,i)},Tn=(n,i)=>{var _,l;if(!((_=n==null?void 0:n.data)!=null&&_.guestOrderByToken))return null;const u=(l=n==null?void 0:n.data)==null?void 0:l.guestOrderByToken;return B(u,i)},bn=` +import{merge as z,Initializer as o}from"@dropins/tools/lib.js";import{events as U}from"@dropins/tools/event-bus.js";import{h as Y}from"./network-error.js";import{PRODUCT_DETAILS_FRAGMENT as Q,PRICE_DETAILS_FRAGMENT as K,GIFT_CARD_DETAILS_FRAGMENT as j,ORDER_ITEM_DETAILS_FRAGMENT as V,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as X,ORDER_SUMMARY_FRAGMENT as H,ADDRESS_FRAGMENT as J,RETURNS_FRAGMENT as P,ORDER_ITEM_FRAGMENT as W}from"../fragments.js";import{f as Z,h as r}from"./fetch-graphql.js";const I=n=>n||0,d=n=>{var i,u,_,c,l,t,E,R,g;return{__typename:(n==null?void 0:n.__typename)||"",uid:(n==null?void 0:n.uid)||"",onlyXLeftInStock:(n==null?void 0:n.only_x_left_in_stock)??0,stockStatus:(n==null?void 0:n.stock_status)??"",priceRange:{maximumPrice:{regularPrice:{currency:((_=(u=(i=n==null?void 0:n.price_range)==null?void 0:i.maximum_price)==null?void 0:u.regular_price)==null?void 0:_.currency)??"",value:((t=(l=(c=n==null?void 0:n.price_range)==null?void 0:c.maximum_price)==null?void 0:l.regular_price)==null?void 0:t.value)??0}}},canonicalUrl:(n==null?void 0:n.canonical_url)??"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)??"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((E=n==null?void 0:n.image)==null?void 0:E.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((R=n==null?void 0:n.thumbnail)==null?void 0:R.label)||"",url:((g=n==null?void 0:n.thumbnail)==null?void 0:g.url)||""}}},nn=n=>{if(!n||!("selected_options"in n))return;const i={};for(const u of n.selected_options)i[u.label]=u.value;return i},un=n=>{const i=n==null?void 0:n.map(_=>({uid:_.uid,label:_.label,values:_.values.map(c=>c.product_name).join(", ")})),u={};return i==null||i.forEach(_=>{u[_.label]=_.values}),Object.keys(u).length>0?u:null},_n=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(i=>i.title).join(", ")}:null,cn=n=>({quantityCanceled:(n==null?void 0:n.quantity_canceled)??0,quantityInvoiced:(n==null?void 0:n.quantity_invoiced)??0,quantityOrdered:(n==null?void 0:n.quantity_ordered)??0,quantityRefunded:(n==null?void 0:n.quantity_refunded)??0,quantityReturned:(n==null?void 0:n.quantity_returned)??0,quantityShipped:(n==null?void 0:n.quantity_shipped)??0,quantityReturnRequested:(n==null?void 0:n.quantity_return_requested)??0}),ln=n=>({firstName:(n==null?void 0:n.firstname)??"",lastName:(n==null?void 0:n.lastname)??"",middleName:(n==null?void 0:n.middlename)??""}),L=n=>{const{firstName:i,lastName:u,middleName:_}=ln(n);return{firstName:i,lastName:u,middleName:_,city:(n==null?void 0:n.city)??"",company:(n==null?void 0:n.company)??"",country:(n==null?void 0:n.country)??"",countryCode:(n==null?void 0:n.country_code)??"",fax:(n==null?void 0:n.fax)??"",postCode:(n==null?void 0:n.postcode)??"",prefix:(n==null?void 0:n.prefix)??"",region:(n==null?void 0:n.region)??"",regionId:(n==null?void 0:n.region_id)??"",street:(n==null?void 0:n.street)??[],suffix:(n==null?void 0:n.suffix)??"",telephone:(n==null?void 0:n.telephone)??"",vatId:(n==null?void 0:n.vat_id)??"",customAttributes:(n==null?void 0:n.custom_attributes)??[]}},an=n=>{const i={value:0,currency:"USD"};return{grandTotal:(n==null?void 0:n.grand_total)??i,totalGiftcard:(n==null?void 0:n.total_giftcard)??i,subtotalExclTax:(n==null?void 0:n.subtotal_excl_tax)??i,subtotalInclTax:(n==null?void 0:n.subtotal_incl_tax)??i,taxes:(n==null?void 0:n.taxes)??[],totalTax:(n==null?void 0:n.total_tax)??i,totalShipping:(n==null?void 0:n.total_shipping)??i,discounts:(n==null?void 0:n.discounts)??[]}},w=n=>{const i={value:0,currency:"USD"},u=(n==null?void 0:n.prices)??{};return{price:(u==null?void 0:u.price)??i,priceIncludingTax:(u==null?void 0:u.price_including_tax)??i,originalPrice:(u==null?void 0:u.original_price)??i,originalPriceIncludingTax:(u==null?void 0:u.original_price_including_tax)??i,discounts:(u==null?void 0:u.discounts)??[]}},sn=(n,i,u)=>{const _=n==null?void 0:n.price,c=n==null?void 0:n.priceIncludingTax,l=n==null?void 0:n.originalPrice,t=u?l==null?void 0:l.value:c==null?void 0:c.value,E={originalPrice:l,baseOriginalPrice:{value:t,currency:l==null?void 0:l.currency},baseDiscountedPrice:{value:c==null?void 0:c.value,currency:c==null?void 0:c.currency},baseExcludingTax:{value:_==null?void 0:_.value,currency:_==null?void 0:_.currency}},R={originalPrice:l,baseOriginalPrice:{value:l==null?void 0:l.value,currency:c==null?void 0:c.currency},baseDiscountedPrice:{value:i==null?void 0:i.value,currency:_==null?void 0:_.currency},baseExcludingTax:{value:_==null?void 0:_.value,currency:_==null?void 0:_.currency}},g={singleItemPrice:{value:u?l.value:c.value,currency:c.currency},baseOriginalPrice:{value:t,currency:c.currency},baseDiscountedPrice:{value:c.value,currency:c.currency}};return{includeAndExcludeTax:E,excludeTax:R,includeTax:g}},tn=n=>{var i,u,_,c,l;return{senderName:((i=n.gift_card)==null?void 0:i.sender_name)||"",senderEmail:((u=n.gift_card)==null?void 0:u.sender_email)||"",recipientEmail:((_=n.gift_card)==null?void 0:_.recipient_email)||"",recipientName:((c=n.gift_card)==null?void 0:c.recipient_name)||"",message:((l=n.gift_card)==null?void 0:l.message)||""}},yn=n=>{var i,u,_,c;return{label:((u=(i=n==null?void 0:n.product)==null?void 0:i.thumbnail)==null?void 0:u.label)||"",url:((c=(_=n==null?void 0:n.product)==null?void 0:_.thumbnail)==null?void 0:c.url)||""}},D=n=>{var q,x,G,k,F,v,A,s,h,f,O,N,S,M,p,C,b,T;const{quantityCanceled:i,quantityInvoiced:u,quantityOrdered:_,quantityRefunded:c,quantityReturned:l,quantityShipped:t,quantityReturnRequested:E}=cn(n),R=w(n),g=((q=n==null?void 0:n.prices)==null?void 0:q.original_price.value)*(n==null?void 0:n.quantity_ordered)>((x=n==null?void 0:n.prices)==null?void 0:x.price.value)*(n==null?void 0:n.quantity_ordered),a=I(n==null?void 0:n.quantity_ordered),y={value:((G=n==null?void 0:n.product_sale_price)==null?void 0:G.value)||0,currency:(k=n==null?void 0:n.product_sale_price)==null?void 0:k.currency};return{selectedOptions:(n==null?void 0:n.selected_options)??[],productSalePrice:n==null?void 0:n.product_sale_price,status:(n==null?void 0:n.status)??"",type:n==null?void 0:n.__typename,eligibleForReturn:(n==null?void 0:n.eligible_for_return)??!1,productSku:(n==null?void 0:n.product_sku)??"",productName:(n==null?void 0:n.product_name)??"",productUrlKey:(n==null?void 0:n.product_url_key)??"",quantityCanceled:i,quantityInvoiced:u,quantityOrdered:_,quantityRefunded:c,quantityReturned:l,quantityShipped:t,quantityReturnRequested:E,id:n==null?void 0:n.id,discounted:g,total:{value:((F=n==null?void 0:n.product_sale_price)==null?void 0:F.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((v=n==null?void 0:n.product_sale_price)==null?void 0:v.currency)||""},totalInclTax:{value:((A=n==null?void 0:n.product_sale_price)==null?void 0:A.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(s=n==null?void 0:n.product_sale_price)==null?void 0:s.currency},price:y,prices:w(n),itemPrices:R,taxCalculations:sn(R,y,g),priceInclTax:{value:((h=n==null?void 0:n.product_sale_price)==null?void 0:h.value)??0,currency:(f=n==null?void 0:n.product_sale_price)==null?void 0:f.currency},totalQuantity:a,regularPrice:{value:(M=(S=(N=(O=n==null?void 0:n.product)==null?void 0:O.price_range)==null?void 0:N.maximum_price)==null?void 0:S.regular_price)==null?void 0:M.value,currency:(T=(b=(C=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:C.maximum_price)==null?void 0:b.regular_price)==null?void 0:T.currency},product:d(n==null?void 0:n.product),thumbnail:yn(n),giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?tn(n):void 0,configurableOptions:nn(n),bundleOptions:n.__typename==="BundleOrderItem"?un(n.bundle_options):null,downloadableLinks:n.__typename==="DownloadableOrderItem"?_n(n==null?void 0:n.downloadable_links):null}},e=n=>n==null?void 0:n.filter(i=>i.__typename).map(i=>D(i)),Rn=n=>({token:(n==null?void 0:n.token)??"",email:(n==null?void 0:n.email)??"",status:(n==null?void 0:n.status)??"",number:(n==null?void 0:n.number)??"",id:(n==null?void 0:n.id)??"",carrier:n.carrier??"",coupons:(n==null?void 0:n.applied_coupons)??[],orderDate:(n==null?void 0:n.order_date)??"",isVirtual:(n==null?void 0:n.is_virtual)??!1,availableActions:(n==null?void 0:n.available_actions)??[],orderStatusChangeDate:(n==null?void 0:n.order_status_change_date)??"",shippingMethod:(n==null?void 0:n.shipping_method)??""}),B=(n,i)=>{var s,h,f,O,N,S,M,p,C;const u=Rn(n),_=L(n==null?void 0:n.billing_address),c=L(n==null?void 0:n.shipping_address),l=(s=n.shipments)==null?void 0:s.map(b=>({...b,items:b.items.map(T=>({id:T.id,productName:T.product_name,productSku:T.product_sku,quantityShipped:T.quantity_shipped,orderItem:D(T.order_item)}))})),t=e(n.items),E=((h=gn(n==null?void 0:n.returns))==null?void 0:h.ordersReturn)??[],R=i?E.filter(b=>b.returnNumber===i):E,g=e(n.items_eligible_for_return),a=an(n==null?void 0:n.total),y=(f=n==null?void 0:n.payment_methods)==null?void 0:f[0],q=n==null?void 0:n.shipping_method,x=t==null?void 0:t.reduce((b,T)=>b+(T==null?void 0:T.totalQuantity),0),G={amount:((O=a==null?void 0:a.totalShipping)==null?void 0:O.value)??0,currency:((N=a==null?void 0:a.totalShipping)==null?void 0:N.currency)||"",code:(u==null?void 0:u.shippingMethod)??""},k=[{code:(y==null?void 0:y.type)??"",name:(y==null?void 0:y.name)??""}],F=a==null?void 0:a.subtotalExclTax,v=a==null?void 0:a.subtotalInclTax,A={...u,...a,subtotalExclTax:F,subtotalInclTax:v,billingAddress:_,shippingAddress:c,shipments:l,items:t,returns:R,itemsEligibleForReturn:g,totalQuantity:x,shippingMethod:q,shipping:G,payments:k};return z(A,(C=(p=(M=(S=$==null?void 0:$.getConfig())==null?void 0:S.models)==null?void 0:M.OrderDataModel)==null?void 0:p.transformer)==null?void 0:C.call(p,n))},En=(n,i,u)=>{var _,c,l,t,E,R,g;if((t=(l=(c=(_=i==null?void 0:i.data)==null?void 0:_.customer)==null?void 0:c.orders)==null?void 0:l.items)!=null&&t.length&&n==="orderData"){const a=(g=(R=(E=i==null?void 0:i.data)==null?void 0:E.customer)==null?void 0:R.orders)==null?void 0:g.items[0];return B(a,u)}return null},gn=n=>{var l,t,E,R,g;if(!((l=n==null?void 0:n.items)!=null&&l.length))return null;const i=n==null?void 0:n.items,u=n==null?void 0:n.page_info,c={ordersReturn:[...i].sort((a,y)=>+y.number-+a.number).map(a=>{var v,A;const{order:y,status:q,number:x,created_at:G}=a,k=((A=(v=a==null?void 0:a.shipping)==null?void 0:v.tracking)==null?void 0:A.map(s=>{const{status:h,carrier:f,tracking_number:O}=s;return{status:h,carrier:f,trackingNumber:O}}))??[],F=a.items.map(s=>{var p;const h=s==null?void 0:s.quantity,f=s==null?void 0:s.status,O=s==null?void 0:s.request_quantity,N=s==null?void 0:s.uid,S=s==null?void 0:s.order_item,M=((p=e([S]))==null?void 0:p.reduce((C,b)=>b,{}))??{};return{uid:N,quantity:h,status:f,requestQuantity:O,...M}});return{createdReturnAt:G,returnStatus:q,token:y==null?void 0:y.token,orderNumber:y==null?void 0:y.number,returnNumber:x,items:F,tracking:k}}),...u?{pageInfo:{pageSize:u.page_size,totalPages:u.total_pages,currentPage:u.current_page}}:{}};return z(c,(g=(R=(E=(t=$==null?void 0:$.getConfig())==null?void 0:t.models)==null?void 0:E.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:g.call(R,{...i,...u}))},xn=(n,i)=>{var _,c;if(!((_=n==null?void 0:n.data)!=null&&_.guestOrder))return null;const u=(c=n==null?void 0:n.data)==null?void 0:c.guestOrder;return B(u,i)},Tn=(n,i)=>{var _,c;if(!((_=n==null?void 0:n.data)!=null&&_.guestOrderByToken))return null;const u=(c=n==null?void 0:n.data)==null?void 0:c.guestOrderByToken;return B(u,i)},bn=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders(filter: { number: { eq: $orderNumber } }) { @@ -19,23 +19,7 @@ import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as ...RETURNS_FRAGMENT } items_eligible_for_return { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } applied_coupons { code @@ -79,23 +63,7 @@ import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as ...ADDRESS_FRAGMENT } items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } total { ...ORDER_SUMMARY_FRAGMENT @@ -107,12 +75,13 @@ import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as ${Q} ${K} ${j} - ${P} - ${D} ${V} ${X} ${H} -`,gn=async({orderId:n,returnRef:i,queryType:u,returnsPageSize:_=50})=>await J(bn,{method:"GET",cache:"force-cache",variables:{orderNumber:n,pageSize:_}}).then(l=>yn(u??"orderData",l,i)).catch(Y),pn=` + ${J} + ${P} + ${W} +`,pn=async({orderId:n,returnRef:i,queryType:u,returnsPageSize:_=50})=>await Z(bn,{method:"GET",cache:"force-cache",variables:{orderNumber:n,pageSize:_}}).then(c=>En(u??"orderData",c,i)).catch(Y),hn=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -178,23 +147,7 @@ import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as ...ADDRESS_FRAGMENT } items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } total { ...ORDER_SUMMARY_FRAGMENT @@ -204,9 +157,10 @@ import{merge as z,Initializer as m}from"@dropins/tools/lib.js";import{events as ${Q} ${K} ${j} - ${P} - ${D} ${V} ${X} ${H} -`,An=async(n,i)=>await J(pn,{method:"GET",cache:"no-cache",variables:{token:n}}).then(u=>{var _;return(_=u.errors)!=null&&_.length&&u.errors[0].message==="Please login to view the order."?o(u.errors):Tn(u,i)}).catch(Y),hn="orderData",On=async n=>{var s;const i=typeof(n==null?void 0:n.orderRef)=="string"?n==null?void 0:n.orderRef:"",u=typeof(n==null?void 0:n.returnRef)=="string"?n==null?void 0:n.returnRef:"",_=i&&typeof(n==null?void 0:n.orderRef)=="string"&&((s=n==null?void 0:n.orderRef)==null?void 0:s.length)>20,l=(n==null?void 0:n.orderData)??null;if(l){L.emit("order/data",{...l,returnNumber:u});return}if(!i)return;const c=_?await An(i,u):await gn({orderId:i,returnRef:u,queryType:hn});c?L.emit("order/data",{...c,returnNumber:u}):L.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},Z=new m({init:async n=>{const i={};Z.config.setConfig({...i,...n}),On(n??{}).catch(console.error)},listeners:()=>[]}),C=Z.config;export{B as a,Gn as b,An as c,C as d,gn as g,Z as i,En as t}; + ${J} + ${P} + ${W} +`,fn=async(n,i)=>await Z(hn,{method:"GET",cache:"no-cache",variables:{token:n}}).then(u=>{var _;return(_=u.errors)!=null&&_.length&&u.errors[0].message==="Please login to view the order."?r(u.errors):Tn(u,i)}).catch(Y),On="orderData",vn=async n=>{var t;const i=typeof(n==null?void 0:n.orderRef)=="string"?n==null?void 0:n.orderRef:"",u=typeof(n==null?void 0:n.returnRef)=="string"?n==null?void 0:n.returnRef:"",_=i&&typeof(n==null?void 0:n.orderRef)=="string"&&((t=n==null?void 0:n.orderRef)==null?void 0:t.length)>20,c=(n==null?void 0:n.orderData)??null;if(c){U.emit("order/data",{...c,returnNumber:u});return}if(!i)return;const l=_?await fn(i,u):await pn({orderId:i,returnRef:u,queryType:On});l?U.emit("order/data",{...l,returnNumber:u}):U.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},m=new o({init:async n=>{const i={};m.config.setConfig({...i,...n}),vn(n??{}).catch(console.error)},listeners:()=>[]}),$=m.config;export{B as a,xn as b,fn as c,$ as d,pn as g,m as i,gn as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js index b43948882..f98da5277 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,6 +1,6 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAILS_FRAGMENT as i,ORDER_ITEM_DETAILS_FRAGMENT as A,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as D,ORDER_SUMMARY_FRAGMENT as c,ADDRESS_FRAGMENT as u,GUEST_ORDER_FRAGMENT as G}from"../fragments.js";import{f as a,h as R}from"./fetch-graphql.js";import{a as T}from"./initialize.js";const N=` +import{PRODUCT_DETAILS_FRAGMENT as T,PRICE_DETAILS_FRAGMENT as i,GIFT_CARD_DETAILS_FRAGMENT as d,ORDER_ITEM_DETAILS_FRAGMENT as A,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as c,ORDER_SUMMARY_FRAGMENT as D,ADDRESS_FRAGMENT as u,ORDER_ITEM_FRAGMENT as M,GUEST_ORDER_FRAGMENT as N}from"../fragments.js";import{f as a,h as R}from"./fetch-graphql.js";import{a as s}from"./initialize.js";const G=` mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { cancelOrder(input: { order_id: $orderId, reason: $reason }) { error @@ -55,23 +55,7 @@ import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAI ...ADDRESS_FRAGMENT } items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } total { ...ORDER_SUMMARY_FRAGMENT @@ -79,14 +63,15 @@ import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAI } } } - ${d} - ${s} + ${T} ${i} + ${d} ${A} - ${D} ${c} + ${D} ${u} -`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return a(N,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const E=T(n.cancelOrder.order);_(E)}).catch(()=>t())},O=` + ${M} +`,I=async(r,e,E,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return a(G,{variables:{orderId:r,reason:e}}).then(({errors:n,data:o})=>{if(n)return R(n);if(o.cancelOrder.error!=null){t();return}const _=s(o.cancelOrder.order);E(_)}).catch(()=>t())},O=` mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION( $token: String! $reason: String! @@ -98,5 +83,5 @@ import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAI } } } - ${G} -`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return a(O,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const E=T(n.requestGuestOrderCancel.order);_(E)}).catch(()=>t())};export{M as c,S as r}; + ${N} +`,p=async(r,e,E,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return a(O,{variables:{token:r,reason:e}}).then(({errors:n,data:o})=>{if(n)return R(n);o.requestGuestOrderCancel.error!=null&&t();const _=s(o.requestGuestOrderCancel.order);E(_)}).catch(()=>t())};export{I as c,p as r}; diff --git a/scripts/__dropins__/storefront-order/fragments.js b/scripts/__dropins__/storefront-order/fragments.js index a4a01367a..8adeee220 100644 --- a/scripts/__dropins__/storefront-order/fragments.js +++ b/scripts/__dropins__/storefront-order/fragments.js @@ -1,6 +1,6 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -const R=` +const T=` fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { __typename uid @@ -26,7 +26,7 @@ const R=` telephone vat_id } -`,t=` +`,_=` fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { __typename canonical_url @@ -49,7 +49,7 @@ const R=` } } } -`,_=` +`,t=` fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { prices { price_including_tax { @@ -124,6 +124,30 @@ const R=` } } } +`,E=` + fragment DOWNLOADABLE_ORDER_ITEMS_FRAGMENT on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } +`,R=` + fragment ORDER_ITEM_FRAGMENT on OrderItemInterface { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ...DOWNLOADABLE_ORDER_ITEMS_FRAGMENT + } + + ${E} `,i=` fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { grand_total { @@ -166,7 +190,7 @@ const R=` label } } -`,E=` +`,u=` fragment RETURNS_FRAGMENT on Returns { __typename items { @@ -207,7 +231,7 @@ const R=` } } } -`,u=` +`,c=` fragment GUEST_ORDER_FRAGMENT on CustomerOrder { email id @@ -273,34 +297,19 @@ const R=` ...ADDRESS_FRAGMENT } items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } + ...ORDER_ITEM_FRAGMENT } total { ...ORDER_SUMMARY_FRAGMENT } } - ${t} ${_} + ${t} ${r} ${n} ${a} ${i} ${e} - ${E} -`;export{e as ADDRESS_FRAGMENT,a as BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT,r as GIFT_CARD_DETAILS_FRAGMENT,u as GUEST_ORDER_FRAGMENT,n as ORDER_ITEM_DETAILS_FRAGMENT,i as ORDER_SUMMARY_FRAGMENT,_ as PRICE_DETAILS_FRAGMENT,t as PRODUCT_DETAILS_FRAGMENT,R as REQUEST_RETURN_ORDER_FRAGMENT,E as RETURNS_FRAGMENT}; + ${u} + ${R} +`;export{e as ADDRESS_FRAGMENT,a as BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT,E as DOWNLOADABLE_ORDER_ITEMS_FRAGMENT,r as GIFT_CARD_DETAILS_FRAGMENT,c as GUEST_ORDER_FRAGMENT,n as ORDER_ITEM_DETAILS_FRAGMENT,R as ORDER_ITEM_FRAGMENT,i as ORDER_SUMMARY_FRAGMENT,t as PRICE_DETAILS_FRAGMENT,_ as PRODUCT_DETAILS_FRAGMENT,T as REQUEST_RETURN_ORDER_FRAGMENT,u as RETURNS_FRAGMENT}; From 887a0908317fe05edb5c6eaaea55c7370aee73bd Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 12:32:11 +0100 Subject: [PATCH 5/9] Add privacy policy slot content (auth, checkout) --- blocks/commerce-checkout/commerce-checkout.js | 34 ++++++++++++++++++- .../commerce-create-account.js | 24 +++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/blocks/commerce-checkout/commerce-checkout.js b/blocks/commerce-checkout/commerce-checkout.js index a20ba410e..6719886ba 100644 --- a/blocks/commerce-checkout/commerce-checkout.js +++ b/blocks/commerce-checkout/commerce-checkout.js @@ -187,6 +187,31 @@ export default async function decorate(block) { block.appendChild(checkoutFragment); + const authPrivacyPolicyConsentSlot = { + PrivacyPolicyConsent: async (ctx) => { + const wrapper = document.createElement('span'); + Object.assign(wrapper.style, { + color: 'var(--color-neutral-700)', + font: 'var(--type-details-caption-2-font)', + display: 'block', + marginBottom: 'var(--spacing-medium)', + }); + + const link = document.createElement('a'); + link.href = '/privacy-policy'; + link.target = '_blank'; + link.textContent = 'Privacy Policy'; + + wrapper.append( + 'By creating an account, you acknowledge that you have read and agree to our ', + link, + ', which outlines how we collect, use, and protect your personal data.', + ); + + ctx.appendChild(wrapper); + }, + }; + // Global state let initialized = false; @@ -250,7 +275,11 @@ export default async function decorate(block) { displayOverlaySpinner(); }, }, - signUpFormConfig: {}, + signUpFormConfig: { + slots: { + ...authPrivacyPolicyConsentSlot, + }, + }, resetPasswordFormConfig: {}, })(signInForm); @@ -738,6 +767,9 @@ export default async function decorate(block) { routeRedirectOnEmailConfirmationClose: () => '/customer/account', inputsDefaultValueSet, addressesData, + slots: { + ...authPrivacyPolicyConsentSlot, + }, })(signUpForm); await showModal(signUpForm); diff --git a/blocks/commerce-create-account/commerce-create-account.js b/blocks/commerce-create-account/commerce-create-account.js index 7819412e5..ae704cb33 100644 --- a/blocks/commerce-create-account/commerce-create-account.js +++ b/blocks/commerce-create-account/commerce-create-account.js @@ -16,6 +16,30 @@ export default async function decorate(block) { hideCloseBtnOnEmailConfirmation: true, routeSignIn: () => CUSTOMER_LOGIN_PATH, routeRedirectOnSignIn: () => CUSTOMER_ACCOUNT_PATH, + slots: { + PrivacyPolicyConsent: async (ctx) => { + const wrapper = document.createElement('span'); + Object.assign(wrapper.style, { + color: 'var(--color-neutral-700)', + font: 'var(--type-details-caption-2-font)', + display: 'block', + marginBottom: 'var(--spacing-medium)', + }); + + const link = document.createElement('a'); + link.href = '/privacy-policy'; + link.target = '_blank'; + link.textContent = 'Privacy Policy'; + + wrapper.append( + 'By creating an account, you acknowledge that you have read and agree to our ', + link, + ', which outlines how we collect, use, and protect your personal data.', + ); + + ctx.appendChild(wrapper); + }, + }, })(block); } } From 1f9b4a8bf1244150cb8ec10af7da9177741cd8b4 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 12:40:50 +0100 Subject: [PATCH 6/9] Remove redundant comments --- blocks/header/header.css | 4 ++-- blocks/header/header.js | 2 -- blocks/header/renderAuthCombine.js | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/blocks/header/header.css b/blocks/header/header.css index 9d4d92843..83b039d9d 100644 --- a/blocks/header/header.css +++ b/blocks/header/header.css @@ -377,7 +377,7 @@ header .nav-search-input .search_autocomplete .popover-container { } } -/* TODO - CSS for authCombine demo (Auth Drop-In) */ +/* CSS for authCombine */ #auth-combine-modal { position: fixed; top: 0; @@ -410,7 +410,7 @@ header .nav-search-input .search_autocomplete .popover-container { } } -/* TODO - CSS for auth dropdown demo (Auth Drop-In) */ +/* CSS for auth dropdown */ .dropdown-wrapper.nav-tools-wrapper .nav-dropdown-button { font: var(--type-body-1-default-font) !important; diff --git a/blocks/header/header.js b/blocks/header/header.js index c8eade44a..4169cb92d 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -9,7 +9,6 @@ import { publishShoppingCartViewEvent } from '@dropins/storefront-cart/api.js'; import { getMetadata } from '../../scripts/aem.js'; import { loadFragment } from '../fragment/fragment.js'; -// TODO: Following two imports added for demo purpose (Auth Drop-In) import renderAuthCombine from './renderAuthCombine.js'; import { renderAuthDropdown } from './renderAuthDropdown.js'; @@ -281,7 +280,6 @@ export default async function decorate(block) { navWrapper.append(nav); block.append(navWrapper); - // TODO: Following statements added for demo purpose (Auth Drop-In) renderAuthCombine( navSections, () => !isDesktop.matches && toggleMenu(nav, navSections, false), diff --git a/blocks/header/renderAuthCombine.js b/blocks/header/renderAuthCombine.js index d26988aa7..332c5c90c 100644 --- a/blocks/header/renderAuthCombine.js +++ b/blocks/header/renderAuthCombine.js @@ -1,5 +1,4 @@ /* eslint-disable implicit-arrow-linebreak */ -// TODO - This module supposed to add link to authCombine container for demo purposes /* eslint-disable import/no-unresolved */ /* eslint-disable import/no-extraneous-dependencies */ import { render as authRenderer } from '@dropins/storefront-auth/render.js'; From 28211e4c32fe1eb7dffd9fdb23658fea232428b3 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 12:46:47 +0100 Subject: [PATCH 7/9] Improve focus trapping --- blocks/header/renderAuthCombine.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/blocks/header/renderAuthCombine.js b/blocks/header/renderAuthCombine.js index 332c5c90c..1fc645ab7 100644 --- a/blocks/header/renderAuthCombine.js +++ b/blocks/header/renderAuthCombine.js @@ -138,7 +138,7 @@ const onHeaderLinkClick = (element) => { signInModal.setAttribute('id', 'auth-combine-modal'); signInModal.classList.add('auth-combine-modal-overlay'); - const cycleFocus = (event) => { + const trapFocus = (event) => { if (!signInModal) return; const key = event.key.toLowerCase(); @@ -147,7 +147,7 @@ const onHeaderLinkClick = (element) => { event.preventDefault(); signInModal.click(); element?.focus(); - window.removeEventListener('keydown', cycleFocus); + window.removeEventListener('keydown', trapFocus); return; } @@ -165,7 +165,12 @@ const onHeaderLinkClick = (element) => { requestAnimationFrame(() => firstElement.focus(), 10); } - if (key === 'tab') { + if (key === 'tab' && event.shiftKey) { + if (document.activeElement === firstElement) { + event.preventDefault(); + lastElement.focus(); + } + } else if (key === 'tab') { if (document.activeElement === lastElement) { event.preventDefault(); firstElement.focus(); @@ -176,13 +181,13 @@ const onHeaderLinkClick = (element) => { } }; - window.addEventListener('keydown', cycleFocus); + window.addEventListener('keydown', trapFocus); signInModal.onclick = () => { signInModal.remove(); document.body.style.overflow = 'auto'; viewportMeta.setAttribute('content', originalViewportContent); - window.removeEventListener('keydown', cycleFocus); + window.removeEventListener('keydown', trapFocus); }; const signInForm = document.createElement('div'); From 957b4858005a507145a428f880a070637f342b88 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 15:06:14 +0100 Subject: [PATCH 8/9] Bump storefront-order to 1.0.4 --- package-lock.json | 8 ++++---- package.json | 2 +- .../storefront-order/containers/OrderSearch.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5617ea93a..e60a2742a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@dropins/storefront-auth": "~1.0.3", "@dropins/storefront-cart": "~1.0.2", "@dropins/storefront-checkout": "~1.0.0", - "@dropins/storefront-order": "~1.0.3", + "@dropins/storefront-order": "~1.0.4", "@dropins/storefront-pdp": "~1.0.0", "@dropins/tools": "^0.40.0" }, @@ -1818,9 +1818,9 @@ "integrity": "sha512-tNCmgVEWEW2OzyNll69jTUTsT3wNG8yJ4HRZ/MrBJF+5/B/o3O+dfYTs4RUpIohXC8sGPkAjXCn5k6BQyo7QUA==" }, "node_modules/@dropins/storefront-order": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.3.tgz", - "integrity": "sha512-DAWhQ4h3cDPx8ZlUbqz2D2f3g/t3TRqOZOH6koBhJRQleWKF6+hEE9mIaWdkzuJAapw+jqT3DHhcT9sCHi+Gbg==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@dropins/storefront-order/-/storefront-order-1.0.4.tgz", + "integrity": "sha512-ivneDqZdnAPOnJEIgB/t8cLtiskdudviLfBfpVmmtOiUb1igd9JlgdWByNu7B4BZwQyWckcFtbNOKQC5aG1VFQ==" }, "node_modules/@dropins/storefront-pdp": { "version": "1.0.0", diff --git a/package.json b/package.json index cada03a2e..1ef58f02f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@dropins/storefront-auth": "~1.0.3", "@dropins/storefront-cart": "~1.0.2", "@dropins/storefront-checkout": "~1.0.0", - "@dropins/storefront-order": "~1.0.3", + "@dropins/storefront-order": "~1.0.4", "@dropins/storefront-pdp": "~1.0.0", "@dropins/tools": "^0.40.0" } diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index 6eaf75b62..c4e3384a8 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderSearch.js +++ b/scripts/__dropins__/storefront-order/containers/OrderSearch.js @@ -1,3 +1,3 @@ /*! Copyright 2025 Adobe All Rights Reserved. */ -import{jsx as t,jsxs as q}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as V,Icon as k,Button as C}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as U}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as H}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as B}from"../chunks/getGuestOrder.js";import{useText as z,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/initialize.js";const X=s=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},w.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),Z=({onError:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),n=z({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,i,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number",isUnique:!1}],[n]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=H(e.target);await B(o).then(m=>{m||u({text:n.invalidSearch,type:"warning"}),N.emit("order/data",m)}).catch(async m=>{var S;let d=!0;s==null||s({error:m.message});const h=r?await x():{email:""};(h==null?void 0:h.email)===(o==null?void 0:o.email)?f(i,{orderRef:o.number}):d=a==null?void 0:a({render:h===null||((S=m==null?void 0:m.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:m.message,type:"warning"})}).finally(()=>{p(!1)})},[r,s,a,i,n.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},ne=({className:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:n}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return t("div",{className:L(["order-order-search",s]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:n})})},j=({onSubmit:s,loading:r,inLineAlert:a,fieldsConfig:i})=>q(M,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(V,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(k,{source:X})}):null,t(U,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:i,onSubmit:s,children:t("div",{className:"order-order-search-form__button-container",children:t(C,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{ne as OrderSearch,ne as default}; +import{jsx as t,jsxs as q}from"@dropins/tools/preact-jsx-runtime.js";import{classes as L}from"@dropins/tools/lib.js";import{Card as M,InLineAlert as V,Icon as k,Button as C}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as U}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as H}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as B}from"../chunks/getGuestOrder.js";import{useText as z,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/initialize.js";const X=i=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},w.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),Z=({onError:i,isAuth:r,renderSignIn:a,routeCustomerOrder:s,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),m=z({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(s,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,s,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(s,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,s,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname",isUnique:!1},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number",isUnique:!1}],[m]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=H(e.target);await B(o).then(n=>{n||u({text:m.invalidSearch,type:"warning"}),N.emit("order/data",n)}).catch(async n=>{var S;let d=!0;i==null||i({error:n.message});const h=r?await x():{email:""};if((h==null?void 0:h.email)===(o==null?void 0:o.email)){f(s,{orderRef:o.number});return}d=a==null?void 0:a({render:h===null||((S=n==null?void 0:n.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:n.message,type:"warning"})}).finally(()=>{p(!1)})},[r,i,a,s,m.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},me=({className:i,isAuth:r,renderSignIn:a,routeCustomerOrder:s,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:m}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:s,routeGuestOrder:c});return t("div",{className:L(["order-order-search",i]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:m})})},j=({onSubmit:i,loading:r,inLineAlert:a,fieldsConfig:s})=>q(M,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(V,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(k,{source:X})}):null,t(U,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:s,onSubmit:i,children:t("div",{className:"order-order-search-form__button-container",children:t(C,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{me as OrderSearch,me as default}; From 7c5f66d0cf3c1da8e797defcadc98fd675dd7f43 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Thu, 6 Feb 2025 17:02:11 +0100 Subject: [PATCH 9/9] Fix code duplication --- blocks/commerce-checkout/commerce-checkout.js | 29 ++----------------- .../commerce-create-account.js | 29 ++++--------------- scripts/constants.js | 27 +++++++++++++++++ 3 files changed, 36 insertions(+), 49 deletions(-) diff --git a/blocks/commerce-checkout/commerce-checkout.js b/blocks/commerce-checkout/commerce-checkout.js index 6719886ba..53d24381e 100644 --- a/blocks/commerce-checkout/commerce-checkout.js +++ b/blocks/commerce-checkout/commerce-checkout.js @@ -58,11 +58,12 @@ import OrderProductList from '@dropins/storefront-order/containers/OrderProductL import OrderStatus from '@dropins/storefront-order/containers/OrderStatus.js'; import ShippingStatus from '@dropins/storefront-order/containers/ShippingStatus.js'; import { render as OrderProvider } from '@dropins/storefront-order/render.js'; -import { getUserTokenCookie } from '../../scripts/initializers/index.js'; // Block-level import createModal from '../modal/modal.js'; +// Scripts +import { getUserTokenCookie } from '../../scripts/initializers/index.js'; import { estimateShippingCost, getCartAddress, isCartEmpty, @@ -70,6 +71,7 @@ import { scrollToElement, setAddressOnCart, } from '../../scripts/checkout.js'; +import { authPrivacyPolicyConsentSlot } from '../../scripts/constants.js'; function createMetaTag(property, content, type) { if (!property || !type) { @@ -187,31 +189,6 @@ export default async function decorate(block) { block.appendChild(checkoutFragment); - const authPrivacyPolicyConsentSlot = { - PrivacyPolicyConsent: async (ctx) => { - const wrapper = document.createElement('span'); - Object.assign(wrapper.style, { - color: 'var(--color-neutral-700)', - font: 'var(--type-details-caption-2-font)', - display: 'block', - marginBottom: 'var(--spacing-medium)', - }); - - const link = document.createElement('a'); - link.href = '/privacy-policy'; - link.target = '_blank'; - link.textContent = 'Privacy Policy'; - - wrapper.append( - 'By creating an account, you acknowledge that you have read and agree to our ', - link, - ', which outlines how we collect, use, and protect your personal data.', - ); - - ctx.appendChild(wrapper); - }, - }; - // Global state let initialized = false; diff --git a/blocks/commerce-create-account/commerce-create-account.js b/blocks/commerce-create-account/commerce-create-account.js index ae704cb33..21af0163e 100644 --- a/blocks/commerce-create-account/commerce-create-account.js +++ b/blocks/commerce-create-account/commerce-create-account.js @@ -3,7 +3,11 @@ import { SignUp } from '@dropins/storefront-auth/containers/SignUp.js'; import { render as authRenderer } from '@dropins/storefront-auth/render.js'; import { checkIsAuthenticated } from '../../scripts/configs.js'; -import { CUSTOMER_ACCOUNT_PATH, CUSTOMER_LOGIN_PATH } from '../../scripts/constants.js'; +import { + authPrivacyPolicyConsentSlot, + CUSTOMER_ACCOUNT_PATH, + CUSTOMER_LOGIN_PATH, +} from '../../scripts/constants.js'; // Initialize import '../../scripts/initializers/auth.js'; @@ -17,28 +21,7 @@ export default async function decorate(block) { routeSignIn: () => CUSTOMER_LOGIN_PATH, routeRedirectOnSignIn: () => CUSTOMER_ACCOUNT_PATH, slots: { - PrivacyPolicyConsent: async (ctx) => { - const wrapper = document.createElement('span'); - Object.assign(wrapper.style, { - color: 'var(--color-neutral-700)', - font: 'var(--type-details-caption-2-font)', - display: 'block', - marginBottom: 'var(--spacing-medium)', - }); - - const link = document.createElement('a'); - link.href = '/privacy-policy'; - link.target = '_blank'; - link.textContent = 'Privacy Policy'; - - wrapper.append( - 'By creating an account, you acknowledge that you have read and agree to our ', - link, - ', which outlines how we collect, use, and protect your personal data.', - ); - - ctx.appendChild(wrapper); - }, + ...authPrivacyPolicyConsentSlot, }, })(block); } diff --git a/scripts/constants.js b/scripts/constants.js index 31c9a3a26..648f4b1a7 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -1,4 +1,5 @@ export const SUPPORT_PATH = '/support'; +export const PRIVACY_POLICY_PATH = '/privacy-policy'; // GUEST export const ORDER_STATUS_PATH = '/order-status'; @@ -22,3 +23,29 @@ export const SALES_ORDER_VIEW_PATH = '/sales/order/view/'; // TRACKING export const UPS_TRACKING_URL = 'https://www.ups.com/track'; + +// REUSABLE SLOTS +export const authPrivacyPolicyConsentSlot = { + PrivacyPolicyConsent: async (ctx) => { + const wrapper = document.createElement('span'); + Object.assign(wrapper.style, { + color: 'var(--color-neutral-700)', + font: 'var(--type-details-caption-2-font)', + display: 'block', + marginBottom: 'var(--spacing-medium)', + }); + + const link = document.createElement('a'); + link.href = PRIVACY_POLICY_PATH; + link.target = '_blank'; + link.textContent = 'Privacy Policy'; + + wrapper.append( + 'By creating an account, you acknowledge that you have read and agree to our ', + link, + ', which outlines how we collect, use, and protect your personal data.', + ); + + ctx.appendChild(wrapper); + }, +};