From f7f40a040d3b64ceece170918ce42e84c5671c44 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Thu, 28 Nov 2024 14:03:38 +0200 Subject: [PATCH] updated account dropin --- .../graphql/getCustomerAddress.graphql.d.ts | 2 +- .../chunks/CustomerInformationCard.js | 2 +- .../chunks/removeCustomerAddress.js | 20 ++++---- .../chunks/updateCustomer.js | 2 +- .../configs/mockDefaultAddress.config.d.ts | 47 ++++--------------- .../transform-customer-address.d.ts | 1 - scripts/__dropins__/storefront-account/reload | 2 +- .../types/api/getCustomerAddress.type.d.ts | 4 ++ 8 files changed, 28 insertions(+), 52 deletions(-) diff --git a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts index 0386fdb80d..1a32153512 100644 --- a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; +export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n middlename\n fax\n prefix\n suffix\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; //# sourceMappingURL=getCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js index 3e6716731c..bc07bbbcc7 100644 --- a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -1 +1 @@ -import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as we,TextArea as De,Card as he,Skeleton as xe,SkeletonRow as D,Button as oe,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as N,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{k as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as ot}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as dt,useImperativeHandle as lt,useMemo as be,useCallback as _e}from"@dropins/tools/preact-compat.js";import{Fragment as Ne}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:o,forwardFormRef:d,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:C,shippingCheckBoxValue:g,showBillingCheckBox:I,showShippingCheckBox:L,isOpen:w,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:_,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:C,showShippingCheckBox:L,showBillingCheckBox:I,isOpen:w,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:_,onChange:T,forwardFormRef:d,showSaveCheckBox:r,saveCheckBoxValue:o})}),ct=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),it=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=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),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var x,V;const{requiredFieldError:o,lengthTextError:d,numericError:c,alphaNumWithSpacesError:l,alphaNumericError:i,alphaError:u,emailError:p,dateError:C,urlError:g,dateLengthError:I}=n,L=s==null?void 0:s.customUpperCode,w={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:o};if(!(s!=null&&s.required)&&!e||!((x=s==null?void 0:s.validateRules)!=null&&x.length))return w;const t=ct(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,_=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+A,+f)&&!(_||T))return{[L]:d.replace("{min}",A).replace("{max}",f)};if(!At(e,+_,+T)&&(_||T))return{[L]:I.replace("{min}",Te(_)).replace("{max}",Te(T))};const z={numeric:{validate:it,error:c},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:i},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:C},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((V=r[L])!=null&&V.length)?{[L]:z.error}:w},Be=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}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const o=e[r],d=r.match(/^(.*)Multiline_(\d+)$/);if(d){const c=d[1],l=parseInt(d[2],10);n[c]||(n[c]=[]),n[c].push({index:l,value:o})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:o}]:s[r]=o}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const o=n[r];o.sort((d,c)=>d.index-c.index),s[r]=o.map(d=>d.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const o=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=o:n.push({code:Ve(r),value:o}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName"}),r=Mt(bt(n));if(!s)return r;const[o,d]=r.region?r.region.split(","):[];return{...r,region:{regionCode:o,...d&&{regionId:+d}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,o)=>(o.name&&(r[o.name]=o.type==="checkbox"?o.checked:o.value),r),{})},Ze=(e,s)=>Object.keys(e).every(r=>r in s&&s[r]!==""),ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:o})=>(r&&n&&(s.initialData[n]=o||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:o,isWaitingForResponse:d})=>{const c=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"}),l=Qe(null),[i,u]=N({}),[p,C]=N({}),[g,I]=N({}),[L,w]=N(!0),[t,A]=N(!1),[f,_]=N(!1),[T,Z]=N(!0),[z,x]=N(!1);ee(()=>{const m=()=>{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 m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[e==null?void 0:e.length]);const V=k((m=!1)=>{let v=!0;const y={...p};let M=null;for(const[O,h]of Object.entries(i)){const $=e==null?void 0:e.find(S=>S.customUpperCode.includes(O)),U=ye(h.toString(),$,c,y);U[O]&&(Object.assign(y,U),v=!1),M||(M=Object.keys(y).find(S=>y[S])||null)}if(m||C(y),M&&l.current&&!m){const O=l.current.elements.namedItem(M);O==null||O.focus()}return v},[p,e,i,c]),b=k((m,v,y,M)=>{const O={...me(l),[v]:m,...v.includes("countryCode")?{region:""}:{}},h={data:ae(O,!0),isDataValid:Ze(y,O)};x(h.isDataValid),V(!0),["selectedShippingAddress","selectedBillingAddress"].includes(o)&&sessionStorage.setItem(`${o}_addressData`,JSON.stringify(h)),console.log("data",h),n==null||n(h,{},M)},[V,o,n]);ee(()=>{if(e!=null&&e.length){const{initialData:m,errorList:v}=vt(e);u(y=>({...m,...y})),C(v),I(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const m=me(l),v=sessionStorage.getItem(`${o}_addressData`);if($e(i)&&$e(g)){let y={};const M=Ze(g,i);v?y=JSON.parse(v).data:y=ae(m,!0)??{},console.log("data",y),n==null||n({data:y,isDataValid:M},{},null),x(M),_(!0)}},[i,g]),ee(()=>{var O;if(!T)return;const m=me(l),v=!!(m!=null&&m.countryCode),y=!!((O=m==null?void 0:m.region)!=null&&O.length);m&&v&&!y&&ze(n)&&!d&&b(m==null?void 0:m.region,"region",g,null)},[T,L,e,l,n,b,g,t,d]);const H=k((m,v)=>{const{name:y,value:M,type:O,checked:h}=m==null?void 0:m.target,$=O==="checkbox"?h:M;u(B=>{const te={...B,[y]:$};return y==="countryCode"&&(te.region="",w(!0),A(!1)),te}),r==null||r({[y]:$}),_(!0);const U=e==null?void 0:e.find(B=>B.customUpperCode.includes(y));let S=v?{...v}:{...p};if(U){const B=ye($.toString(),U,c,S);B&&Object.assign(S,B),C(S)}b($,y,g,m)},[r,e,p,c,b,g,L]),q=k(m=>{const{name:v}=m==null?void 0:m.target,y=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(y!=null&&y.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((m,v)=>{const{name:y,value:M,type:O,checked:h}=m==null?void 0:m.target,$=O==="checkbox"?h:M,U=e==null?void 0:e.find(S=>S.customUpperCode===y);if(U){const S=v?{...v}:{...p},B=ye($.toString(),U,c,S);B&&Object.assign(S,B),C(S)}},[p,e,c]),K=k(m=>{m.preventDefault();const v=V();s==null||s(m,v)},[V,s]);return{isDataValid:z,formData:i,errors:p,formRef:l,handleInputChange:H,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:V}};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=Ee(({loading:e,values:s,fields:n=[],errors:r,className:o="",onChange:d,onBlur:c,onFocus:l,slots:i})=>{const u=`${o}__field`,p=(t,A)=>{if(!(i!=null&&i[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:d,handleOnBlur:c,handleOnFocus:l,errorMessage:A,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:i[`AddressFormInput_${t.code}`],context:f},t.id)},C=(t,A,f)=>{var T;const _=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??A??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${o}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:c,onFocus:l,handleSelect:d,defaultValue:_,value:_})},t.id)})},g=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${o}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onFocus:l,onChange:d})},t.id)}),I=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${o}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:A||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:d,disabled:e||t.disabled})},t.id)}),L=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${o}--${t.id}`,disabled:e,children:a(we,{id:t.code,name:t.customUpperCode,checked:A||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:d})},t.id)}),w=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${o}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:d})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?C(t,f,A):g(t,f,A);case se.MULTILINE:return g(t,f,A);case se.SELECT:return C(t,f,A);case se.DATE:return I(t,f,A);case se.BOOLEAN:return L(t,f,A);case se.TEXTAREA:return w(t,f,A);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(xe,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>j(xe,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(dt(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:o,loading:d,children:c,className:l="defaultForm",fieldsConfig:i,onSubmit:u,onChange:p,forwardFormRef:C,regionOptions:g,showSaveCheckBox:I,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:w})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:A,formData:f,errors:_,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:x,handleValidationSubmit:V,onFocus:b}=Et({fieldsConfig:i,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:o,isWaitingForResponse:e});return lt(C,()=>{const H=me(T);return{handleValidationSubmit:V,formData:ae(H,!0),isDataValid:A}}),n||!(i!=null&&i.length)?a(Nt,{}):j("form",{className:X(["account-form",l]),onSubmit:x,name:o,ref:T,children:[a(_t,{className:l,loading:d,fields:i,onChange:Z,onBlur:z,errors:_,values:f,onFocus:b,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,I?a("div",{className:"account-address-form--saveAddressBook",children:a(we,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:w,onChange:H=>{Z(H),L==null||L(H)}})}):null,c]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:o="secondary",minifiedView:d,keysSortOrder:c,addressData:l,loading:i,setAddressId:u,handleRenderModal:p,handleRenderForm:C})=>{const g=d?"minifiedView":"fullSizeView",I=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=I.cardLabelBilling.toLocaleUpperCase(),w=I.cardLabelShipping.toLocaleUpperCase(),t=I.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const b={shippingLabel:w,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:b:b},[L,t,w,r,n,s]),f=_e(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),_=_e(()=>{u==null||u(l==null?void 0:l.id),C==null||C()},[C,l==null?void 0:l.id,u]),T=be(()=>{if(!c)return[];const{region:b,...H}=l,q={...H,...b};return c.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,c]),{shippingLabel:Z,billingLabel:z,hideShipping:x,hideBilling:V}=A;return a(he,{variant:o,className:"account-address-card","data-testid":"addressCard",children:i?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(oe,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:I.actionRemove}):null,C?a(oe,{type:"button",variant:"tertiary",onClick:_,className:"account-address-card__action--editbutton","data-testid":"editButton",children:I.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((b,H)=>{const q=b.label?`${b.label}: ${b==null?void 0:b.value}`:b==null?void 0:b.value;return a("p",{"data-testid":`${b.name}_${H}`,children:q},H)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:w}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!x&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!V&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.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},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.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"}),G.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"})))),$t=e=>G.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},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.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"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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:"#3D3D3D"})),It=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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:"#D6D6D6"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:o})=>{const d=r?"minifiedView":"fullSizeView",c=ne({viewAllAddressesButton:`Account.${d}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${d}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${d}.Addresses.differentAddressButton`}),l=e?"span":"button",i=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?c.viewAllAddressesButton:c.addNewAddressButton,p=e?c.differentAddressButton:u;return j(l,{...i,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:o,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:o,onRemoveAddress:d,closeModal:c})=>{const l=e?"minifiedView":"fullSizeView",i=ne({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?j(Ge,{title:a("h3",{children:i.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:c,children:[o?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:i.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("div",{className:"account-address-modal__buttons",children:[a(oe,{type:"button",onClick:c,variant:"secondary",disabled:o,children:i.actionCancel}),a(oe,{disabled:o,onClick:d,children:i.actionConfirm})]})]}):null},wt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const o=n?"minifiedView":"fullSizeView",d=ne({addressesMessage:`Account.${o}.EmptyList.Addresses.message`,ordersListMessage:`Account.${o}.EmptyList.OrdersList.message`}),c=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:d.addressesMessage})};case"orders":return{icon:It,text:a("p",{children:d.ordersListMessage})};default:return{icon:"",text:""}}},[e,d]);return!s||!e||!c.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:c.text,icon:a(Se,{source:c.icon}),"data-testid":"emptyList"})},xt=async(e,s)=>{if(s.length===1){const c=s[0],i=Object.values(c.region).every(p=>!!p)?{}:{region:{...c.region,regionId:0}};return!!await Ce({addressId:Number(c==null?void 0:c.id),defaultShipping:!1,defaultBilling:!1,...i})}const n=s.filter(c=>c.id!==e&&(c.defaultBilling||c.defaultShipping)||c.id!==e),r=s[s.length-1],o=n[0]||((r==null?void 0:r.id)!==e?r:null);return!o||!o.id?!1:!!await Ce({addressId:+o.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing"],r1=["email","firstname","lastname","middlename","gender","dob","date_of_birth","prefix","suffix"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((o,d)=>Number(d.defaultShipping)-Number(o.defaultShipping)):n?r.sort((o,d)=>Number(d.defaultBilling)-Number(o.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:o,routeAddressesPage:d,onSuccess:c})=>{const[l,i]=N(""),[u,p]=N(!1),[C,g]=N(!1),[I,L]=N(!1),[w,t]=N(!1),[A,f]=N(!1),[_,T]=N(""),[Z,z]=N([]),[x,V]=N([]),b=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(h=>{const[$,U]=h;if($){const S=$.map(({name:B,orderNumber:te,label:re})=>({name:rt(B),orderNumber:te,label:St.includes(B)?null:re}));V(S)}if(U)if(o){const S=U.filter(B=>!!B.defaultShipping||!!B.defaultBilling);z(S)}else z(U)}).finally(()=>{L(!1)})},[o]);ee(()=>{b()},[b]),ee(()=>{var h;if(Z.length)if(n===0)f(!0),i("0");else{const $=Z.find(S=>+S.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};i(n.toString()||((h=$==null?void 0:$.id)==null?void 0:h.toString())),r==null||r(U)}},[Z,n,r,s,e]);const H=k(h=>{T(h),f(!1)},[]),q=k((h,$)=>{const U=(h==null?void 0:h.target).value;i(U);const S={data:ae($),isDataValid:!ve(ae($))};r==null||r(S),U!=="0"&&f(!1)},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),m=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await xt(_,Z),st(+_).then(()=>{b(),K()}).finally(()=>{t(!1)})},[Z,_,K,b]),y=k(()=>{f(!1)},[]),M=k(()=>{ze(d)&&o&&!A?window.location.href=d():(f(!0),T(""))},[A,d,o]),O=k(async()=>{await b(),await(c==null?void 0:c())},[b,c]);return{keysSortOrder:x,submitLoading:w,isModalRendered:u,isFormRendered:C,loading:I,addNewAddress:A,addressesList:Z,addressId:_,handleRenderForm:P,handleRenderModal:m,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:H,closeNewAddressForm:y,redirectToAddressesRoute:M,handleOnSuccess:O,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:o="",defaultSelectAddressId:d="",showFormLoader:c=!1,onAddressData:l,forwardFormRef:i,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:C=!1,selectShipping:g=!1,selectBilling:I=!1,selectable:L=!1,withHeader:w=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:_,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:x=!0,routeAddressesPage:V,onSuccess:b,onError:H})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:m,isModalRendered:v,isFormRendered:y,loading:M,addNewAddress:O,addressesList:h,addressId:$,handleRenderForm:U,handleRenderModal:S,removeAddress:B,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:de,redirectToAddressesRoute:ce,handleSelectAddressOption:ie,selectedAddressOption:ue}=Rt({defaultSelectAddressId:d,minifiedView:t,routeAddressesPage:V,onSuccess:b,onAddressData:l,selectShipping:g,selectBilling:I}),R=s??(g&&I?"selectedAddress":g?"selectedShippingAddress":I?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(h,g,I))==null?void 0:J.map((E,Y)=>j(Ne,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:R,id:`${R}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ie(ge,E)}),a("label",{htmlFor:`${R}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:I,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:R,id:`${R}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ie(E,{})}),a("label",{htmlFor:`${R}_addressActions`,className:"account-addresses-wrapper__label",children:O?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",O]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:R,showFormLoader:c,isOpen:O,forwardFormRef:i,showSaveCheckBox:p,saveCheckBoxValue:C,shippingCheckBoxValue:z,billingCheckBoxValue:x,addressesFormTitle:o||P.differentAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:de,onSuccess:re,onError:H,onChange:l})}):h!=null&&h.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:O,routeAddressesPage:ce}):null})]}):j(Q,{children:[h.map(E=>a(Ne,{children:$===E.id&&y?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&y,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:x,onCloseBtnClick:te,onSuccess:re,onError:H})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&A||!t&&f?S:void 0,handleRenderForm:t&&A||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:O?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:O,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:!!(h!=null&&h.length),showBillingCheckBox:!!(h!=null&&h.length),shippingCheckBoxValue:z,billingCheckBoxValue:x,onCloseBtnClick:de,onSuccess:re,onError:H})}):a(Fe,{minifiedView:t,addNewAddress:O,routeAddressesPage:ce})})]});return j("div",{children:[a("div",{children:w?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(Ot,{minifiedView:t,addressData:h==null?void 0:h.find(E=>E.id===$),keysSortOrder:K,submitLoading:m,open:v,closeModal:te,onRemoveAddress:B}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:R,isOpen:!(h!=null&&h.length),forwardFormRef:i,showSaveCheckBox:p,saveCheckBoxValue:C,shippingCheckBoxValue:z,billingCheckBoxValue:x,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:de,onSuccess:re,onError:H,onChange:l}):a(wt,{isEmpty:!(h!=null&&h.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName},o=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const d=r[n.customUpperCode];n.customUpperCode==="region"&&typeof d=="object"?o.defaultValue=d.regionCode&&d.regionId?`${d.regionCode},${d.regionId}`:d.region??d.regionCode:o.defaultValue=d}return o}),Ie=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{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:o,isRequiredRegion:d,isRequiredPostCode:c})=>e.filter(i=>!(s&&(i.customUpperCode==="defaultShipping"||i.customUpperCode==="defaultBilling")&&i.defaultValue)).map(i=>i.customUpperCode==="countryCode"?{...i,options:n,disabled:r}:i.customUpperCode==="postcode"?{...i,required:c}:i.customUpperCode==="region"?{...i,options:o,required:d,disabled:r}:i),Ut=(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","dateOfBirth","prefix","suffix"],r={},o=[];return Object.keys(e).forEach(d=>{n.includes(d)?r[d]=e[d]:o.push({attribute_code:Ve(d),value:e[d]})}),o.length>0&&(r.custom_attributesV2=o),r},Oe=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],o={};for(const L in e){const w=e[L];n.includes(w)&&(o[L]=Be(w)),s.includes(L)&&r.push(w)}const{street:d,streetMultiline_2:c,streetMultiline_1:l,region:i,...u}=e,[p,C]=i?i.split(","):[void 0,void 0],g=C&&p?{regionId:+C,regionCode:p}:{region:p};return Ut({...u,...o,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const o=e[r];if(r==="region"&&o.regionId){const d=s.find(c=>(c==null?void 0:c.id)===o.regionId);d?n[r]={...o,text:d.text}:n[r]=o}else Array.isArray(o)?(n[r]=o[0]||"",o.slice(1).forEach((d,c)=>{n[`${r}Multiline_${c+2}`]=d})):n[r]=o}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:o,shippingCheckBoxValue:d,showShippingCheckBox:c,showBillingCheckBox:l,inputsDefaultValueSet:i,onCloseBtnClick:u,onSuccess:p,onError:C,formName:g})=>{const[I,L]=N({text:"",type:"success"}),[w,t]=N(e??!1),[A,f]=N(r||""),[_,T]=N([]),[Z,z]=N([]),[x,V]=N([]),[b,H]=N([]),[q,P]=N([]),[K,m]=N(!1),[v,y]=N(!1),[M,O]=N(()=>{var R,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(R=JSON.parse(F))==null?void 0:R.data)==null?void 0:W.countryCode}:i}),[h,$]=N(!1),[U,S]=N(!1),[B,te]=N(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[A]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:R,optionalZipCountries:W})=>{z(F),H(R),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),S(!0);const F=M==null?void 0:M.countryCode;at(F).then(R=>{V(R);const W=b.find(E=>E===F),J=q.find(E=>E===F);m(!!W),y(!J),$(!1),S(!1)})}},[M==null?void 0:M.countryCode,b,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),de=k(async(F,R)=>{if(!R)return null;t(!0);const W=Ie(F.target),J=Oe(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),C==null||C(E)}).finally(()=>{f(""),t(!1)})},[u,C,p]),ce=k(async(F,R)=>{if(!R)return;t(!0);const{saveAddressBook:W,...J}=Ie(F.target),E=Oe(J);await ot(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),C==null||C(Y)}).finally(()=>{f(""),t(!1)})},[u,C,p]),ie=et(()=>{if(!_.length)return[];const F={...Vt,defaultValue:d,isHidden:s&&!B?!0:!c},R={...Ht,defaultValue:o,isHidden:s&&!B?!0:!l},W=[..._,F,R],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,x):{},Y=Bt(qt(E,i),W);return zt({fields:Y,addressId:A,countryOptions:Z,disableField:h,regionOptions:x,isRequiredRegion:K,isRequiredPostCode:v})},[_,d,s,B,c,o,l,g,x,i,A,Z,h,K,v]),ue=k(F=>{O(R=>({...R,...F}))},[]);return{isWaitingForResponse:U,regionOptions:x,saveCheckBoxAddress:B,inLineAlert:I,addressId:A,submitLoading:w,normalizeFieldsConfig:ie,handleSaveCheckBoxAddress:re,handleUpdateAddress:de,handleCreateAddress:ce,handleOnCloseForm:Le,handleInputChange:ue}},jt=e=>{var o;if(!e)return{};if(e&&!Array.isArray(e.customAttributes))return e;const s={};(o=e==null?void 0:e.customAttributes)==null||o.forEach(d=>{d.code&&Object.prototype.hasOwnProperty.call(d,"value")&&(s[d.code]=d.value)});const{customAttributes:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:o=!1,forwardFormRef:d,slots:c,addressesFormTitle:l,className:i,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:C=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:I=!0,billingCheckBoxValue:L=!0,isOpen:w,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:_,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:x,addressId:V,submitLoading:b,normalizeFieldsConfig:H,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,handleInputChange:y,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:I,billingCheckBoxValue:L,showShippingCheckBox:C,showBillingCheckBox:g,saveCheckBoxValue:o,showSaveCheckBox:r,onSuccess:f,onError:_,onCloseBtnClick:A,formName:s});return w?j("div",{className:X(["account-address-form-wrapper",i]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,x.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:x.type,variant:"secondary",heading:x.text,icon:x.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:d,slots:c,className:"account-address-form",name:s||"addressesForm",fieldsConfig:H,onSubmit:t||(V?q:P),setInputChange:y,loading:b,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[V?a("input",{type:"hidden",name:"addressId",value:V,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:c!=null&&c.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:c.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:V}}):a(Q,{children:r?null:j(Q,{children:[a(oe,{type:"button",onClick:K,variant:"secondary",disabled:b,children:Z.secondaryButton}),a(oe,{disabled:b,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,wt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Ie as g,Ut as n}; +import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as xe,TextArea as De,Card as he,Skeleton as we,SkeletonRow as D,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as _,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{k as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as Ne}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:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:C,shippingCheckBoxValue:g,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:C,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=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),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var w,V;const{requiredFieldError:d,lengthTextError:o,numericError:i,alphaNumWithSpacesError:l,alphaNumericError:c,alphaError:u,emailError:p,dateError:C,urlError:g,dateLengthError:O}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((w=s==null?void 0:s.validateRules)!=null&&w.length))return x;const t=it(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,N=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+A,+f)&&!(N||T))return{[L]:o.replace("{min}",A).replace("{max}",f)};if(!At(e,+N,+T)&&(N||T))return{[L]:O.replace("{min}",Te(N)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:C},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((V=r[L])!=null&&V.length)?{[L]:z.error}:x},Be=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}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const i=o[1],l=parseInt(o[2],10);n[i]||(n[i]=[]),n[i].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((o,i)=>o.index-i.index),s[r]=d.map(o=>o.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Ve(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Mt(bt(n));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),{})},Ze=(e,s)=>Object.keys(e).every(r=>r in s&&s[r]!==""),ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:o})=>{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"}),l=Qe(null),[c,u]=_({}),[p,C]=_({}),[g,O]=_({}),[L,x]=_(!0),[t,A]=_(!1),[f,N]=_(!1),[T,Z]=_(!0),[z,w]=_(!1);ee(()=>{const m=()=>{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 m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[e==null?void 0:e.length]);const V=k((m=!1)=>{let v=!0;const y={...p};let M=null;for(const[I,h]of Object.entries(c)){const $=e==null?void 0:e.find(S=>S.customUpperCode.includes(I)),U=ye(h.toString(),$,i,y);U[I]&&(Object.assign(y,U),v=!1),M||(M=Object.keys(y).find(S=>y[S])||null)}if(m||C(y),M&&l.current&&!m){const I=l.current.elements.namedItem(M);I==null||I.focus()}return v},[p,e,c,i]),b=k((m,v,y,M)=>{const I={...me(l),[v]:m,...v.includes("countryCode")?{region:""}:{}},h={data:ae(I,!0),isDataValid:Ze(y,I)};w(h.isDataValid),V(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(h)),console.log("collectFormData=> ONE data",h),n==null||n(h,{},M)},[V,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:m,errorList:v}=vt(e);u(y=>({...m,...y})),C(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const m=me(l),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let y={};const M=Ze(g,c);v?y=JSON.parse(v).data:y=ae(m,!0)??{},n==null||n({data:y,isDataValid:M},{},null),w(M),N(!0),console.log("useEffect=> ONE data",{data:y,isDataValid:M},{},null)}},[c,g]),ee(()=>{var I;if(!T)return;const m=me(l),v=!!(m!=null&&m.countryCode),y=!!((I=m==null?void 0:m.region)!=null&&I.length);m&&v&&!y&&ze(n)&&!o&&b(m==null?void 0:m.region,"region",g,null)},[T,L,e,l,n,b,g,t,o]);const H=k((m,v)=>{const{name:y,value:M,type:I,checked:h}=m==null?void 0:m.target,$=I==="checkbox"?h:M;u(B=>{const te={...B,[y]:$};return y==="countryCode"&&(te.region="",x(!0),A(!1)),te}),r==null||r({[y]:$}),N(!0);const U=e==null?void 0:e.find(B=>B.customUpperCode.includes(y));let S=v?{...v}:{...p};if(U){const B=ye($.toString(),U,i,S);B&&Object.assign(S,B),C(S)}b($,y,g,m)},[r,e,p,i,b,g,L]),q=k(m=>{const{name:v}=m==null?void 0:m.target,y=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(y!=null&&y.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((m,v)=>{const{name:y,value:M,type:I,checked:h}=m==null?void 0:m.target,$=I==="checkbox"?h:M,U=e==null?void 0:e.find(S=>S.customUpperCode===y);if(U){const S=v?{...v}:{...p},B=ye($.toString(),U,i,S);B&&Object.assign(S,B),C(S)}},[p,e,i]),K=k(m=>{m.preventDefault();const v=V();s==null||s(m,v)},[V,s]);return{isDataValid:z,formData:c,errors:p,formRef:l,handleInputChange:H,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:V}};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 Nt=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:o,onBlur:i,onFocus:l,slots:c})=>{const u=`${d}__field`,p=(t,A)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:i,handleOnFocus:l,errorMessage:A,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},C=(t,A,f)=>{var T;const N=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??A??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:l,handleSelect:o,defaultValue:N,value:N})},t.id)})},g=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:l,onChange:o})},t.id)}),O=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:A||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:A||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)}),x=(t,A,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?C(t,f,A):g(t,f,A);case se.MULTILINE:return g(t,f,A);case se.SELECT:return C(t,f,A);case se.DATE:return O(t,f,A);case se.BOOLEAN:return L(t,f,A);case se.TEXTAREA:return x(t,f,A);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(we,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},_t=()=>j(we,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:o,children:i,className:l="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:C,regionOptions:g,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:A,formData:f,errors:N,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:w,handleValidationSubmit:V,onFocus:b}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(C,()=>{const H=me(T);return{handleValidationSubmit:V,formData:ae(H,!0),isDataValid:A}}),n||!(c!=null&&c.length)?a(_t,{}):j("form",{className:X(["account-form",l]),onSubmit:w,name:d,ref:T,children:[a(Nt,{className:l,loading:o,fields:c,onChange:Z,onBlur:z,errors:N,values:f,onFocus:b,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:H=>{Z(H),L==null||L(H)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:i,addressData:l,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:C})=>{const g=o?"minifiedView":"fullSizeView",O=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),x=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),A=be(()=>{const b={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:b:b},[L,t,x,r,n,s]),f=Ne(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),N=Ne(()=>{u==null||u(l==null?void 0:l.id),C==null||C()},[C,l==null?void 0:l.id,u]),T=be(()=>{if(!i)return[];const{region:b,...H}=l,q={...H,...b};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,i]),{shippingLabel:Z,billingLabel:z,hideShipping:w,hideBilling:V}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:O.actionRemove}):null,C?a(de,{type:"button",variant:"tertiary",onClick:N,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((b,H)=>{const q=b.label?`${b.label}: ${b==null?void 0:b.value}`:b==null?void 0:b.value;return a("p",{"data-testid":`${b.name}_${H}`,children:q},H)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:x}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!w&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!V&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.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},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.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"}),G.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"})))),$t=e=>G.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},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.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"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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:"#3D3D3D"})),Ot=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.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:"#D6D6D6"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return j(l,{...c,className:X(["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:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},It=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:o,closeModal:i})=>{const l=e?"minifiedView":"fullSizeView",c=ne({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?j(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("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:o,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",o=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Ot,text:a("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!i.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({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),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["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"],r1=["email","firstname","lastname","middlename","gender","dob","date_of_birth","prefix","suffix","fax"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:i})=>{const[l,c]=_(""),[u,p]=_(!1),[C,g]=_(!1),[O,L]=_(!1),[x,t]=_(!1),[A,f]=_(!1),[N,T]=_(""),[Z,z]=_([]),[w,V]=_([]),b=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(h=>{const[$,U]=h;if($){const S=$.map(({name:B,orderNumber:te,label:re})=>({name:rt(B),orderNumber:te,label:St.includes(B)?null:re}));V(S)}if(U)if(d){const S=U.filter(B=>!!B.defaultShipping||!!B.defaultBilling);z(S)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{b()},[b]),ee(()=>{var h;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(S=>+S.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((h=$==null?void 0:$.id)==null?void 0:h.toString())),r==null||r(U)}},[Z,n,r,s,e]);const H=k(h=>{T(h),f(!1)},[]),q=k((h,$)=>{const U=(h==null?void 0:h.target).value;c(U);const S={data:ae($),isDataValid:!ve(ae($))};r==null||r(S),U!=="0"&&f(!1)},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),m=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(N,Z),st(+N).then(()=>{b(),K()}).finally(()=>{t(!1)})},[Z,N,K,b]),y=k(()=>{f(!1)},[]),M=k(()=>{ze(o)&&d&&!A?window.location.href=o():(f(!0),T(""))},[A,o,d]),I=k(async()=>{await b(),await(i==null?void 0:i())},[b,i]);return{keysSortOrder:w,submitLoading:x,isModalRendered:u,isFormRendered:C,loading:O,addNewAddress:A,addressesList:Z,addressId:N,handleRenderForm:P,handleRenderModal:m,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:H,closeNewAddressForm:y,redirectToAddressesRoute:M,handleOnSuccess:I,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:o="",showFormLoader:i=!1,onAddressData:l,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:C=!1,selectShipping:g=!1,selectBilling:O=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:N,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:w=!0,routeAddressesPage:V,onSuccess:b,onError:H})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:m,isModalRendered:v,isFormRendered:y,loading:M,addNewAddress:I,addressesList:h,addressId:$,handleRenderForm:U,handleRenderModal:S,removeAddress:B,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:o,minifiedView:t,routeAddressesPage:V,onSuccess:b,onAddressData:l,selectShipping:g,selectBilling:O}),R=s??(g&&O?"selectedAddress":g?"selectedShippingAddress":O?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(h,g,O))==null?void 0:J.map((E,Y)=>j(_e,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:R,id:`${R}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${R}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:O,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:R,id:`${R}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${R}_addressActions`,className:"account-addresses-wrapper__label",children:I?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",I]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:R,showFormLoader:i,isOpen:I,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:C,shippingCheckBoxValue:z,billingCheckBoxValue:w,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:l})}):h!=null&&h.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:I,routeAddressesPage:ie}):null})]}):j(Q,{children:[h.map(E=>a(_e,{children:$===E.id&&y?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&y,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:te,onSuccess:re,onError:H})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&A||!t&&f?S:void 0,handleRenderForm:t&&A||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:I?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:I,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:!!(h!=null&&h.length),showBillingCheckBox:!!(h!=null&&h.length),shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:oe,onSuccess:re,onError:H})}):a(Fe,{minifiedView:t,addNewAddress:I,routeAddressesPage:ie})})]});return j("div",{children:[a("div",{children:x?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(It,{minifiedView:t,addressData:h==null?void 0:h.find(E=>E.id===$),keysSortOrder:K,submitLoading:m,open:v,closeModal:te,onRemoveAddress:B}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:R,isOpen:!(h!=null&&h.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:C,shippingCheckBoxValue:z,billingCheckBoxValue:w,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:l}):a(xt,{isEmpty:!(h!=null&&h.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...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(r,n.customUpperCode)){const o=r[n.customUpperCode];n.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{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:o,disabled:r}:c),Ut=(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","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(o=>{n.includes(o)?r[o]=e[o]:d.push({attribute_code:Ve(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Ie=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=Be(x)),s.includes(L)&&r.push(x)}const{street:o,streetMultiline_2:i,streetMultiline_1:l,region:c,...u}=e,[p,C]=c?c.split(","):[void 0,void 0],g=C&&p?{regionId:+C,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};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(i=>(i==null?void 0:i.id)===d.regionId);o?n[r]={...d,text:o.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((o,i)=>{n[`${r}Multiline_${i+2}`]=o})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:i,showBillingCheckBox:l,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:C,formName:g})=>{const[O,L]=_({text:"",type:"success"}),[x,t]=_(e??!1),[A,f]=_(r||""),[N,T]=_([]),[Z,z]=_([]),[w,V]=_([]),[b,H]=_([]),[q,P]=_([]),[K,m]=_(!1),[v,y]=_(!1),[M,I]=_(()=>{var R,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(R=JSON.parse(F))==null?void 0:R.data)==null?void 0:W.countryCode}:c}),[h,$]=_(!1),[U,S]=_(!1),[B,te]=_(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[A]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:R,optionalZipCountries:W})=>{z(F),H(R),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),S(!0);const F=M==null?void 0:M.countryCode;at(F).then(R=>{V(R);const W=b.find(E=>E===F),J=q.find(E=>E===F);m(!!W),y(!J),$(!1),S(!1)})}},[M==null?void 0:M.countryCode,b,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,R)=>{if(!R)return null;t(!0);const W=Oe(F.target),J=Ie(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),C==null||C(E)}).finally(()=>{f(""),t(!1)})},[u,C,p]),ie=k(async(F,R)=>{if(!R)return;t(!0);const{saveAddressBook:W,...J}=Oe(F.target),E=Ie(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),C==null||C(Y)}).finally(()=>{f(""),t(!1)})},[u,C,p]),ce=et(()=>{if(!N.length)return[];const F={...Vt,defaultValue:o,isHidden:s&&!B?!0:!i},R={...Ht,defaultValue:d,isHidden:s&&!B?!0:!l},W=[...N,F,R],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,w):{},Y=Bt(qt(E,c),W);return zt({fields:Y,addressId:A,countryOptions:Z,disableField:h,regionOptions:w,isRequiredRegion:K,isRequiredPostCode:v})},[N,o,s,B,i,d,l,g,w,c,A,Z,h,K,v]),ue=k(F=>{I(R=>({...R,...F}))},[]);return{isWaitingForResponse:U,regionOptions:w,saveCheckBoxAddress:B,inLineAlert:O,addressId:A,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,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:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:C=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:f,onError:N,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:w,addressId:V,submitLoading:b,normalizeFieldsConfig:H,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,handleInputChange:y,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:C,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:N,onCloseBtnClick:A,formName:s});return x?j("div",{className:X(["account-address-form-wrapper",c]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,w.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:w.type,variant:"secondary",heading:w.text,icon:w.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:o,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:H,onSubmit:t||(V?q:P),setInputChange:y,loading:b,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[V?a("input",{type:"hidden",name:"addressId",value:V,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:V}}):a(Q,{children:r?null:j(Q,{children:[a(de,{type:"button",onClick:K,variant:"secondary",disabled:b,children:Z.secondaryButton}),a(de,{disabled:b,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,xt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Oe as g,Ut as n}; diff --git a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js index 981b00682f..83dcf64a46 100644 --- a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js +++ b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js @@ -1,4 +1,4 @@ -import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}from"@dropins/tools/fetch-graphql.js";const b=t=>t.replace(/_([a-z])/g,(r,e)=>e.toUpperCase()),T=t=>t.replace(/([A-Z])/g,r=>`_${r.toLowerCase()}`),h=(t,r,e)=>{const n=["string","boolean","number"],o=r==="camelCase"?b:T;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?h(i,r,e):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,s])=>{const u=e&&e[c]?e[c]:o(c);return i[u]=n.includes(typeof s)||s===null?s:h(s,r,e),i},{}):t},{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:m,getConfig:k}=new S().getMethods(),p=` +import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}from"@dropins/tools/fetch-graphql.js";const S=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),g=(t,n,e)=>{const r=["string","boolean","number"],o=n==="camelCase"?S:p;return Array.isArray(t)?t.map(i=>r.includes(typeof i)||i===null?i:typeof i=="object"?g(i,n,e):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,a])=>{const u=e&&e[c]?e[c]:o(c);return i[u]=r.includes(typeof a)||a===null?a:g(a,n,e),i},{}):t},{setEndpoint:k,setFetchGraphQlHeader:H,removeFetchGraphQlHeader:J,setFetchGraphQlHeaders:K,fetchGraphQl:s,getConfig:L}=new C().getMethods(),T=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -44,18 +44,22 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr } } } -`,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},a=t=>{const r=t.map(e=>e.message).join(" ");throw Error(r)},R=t=>{let r=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let n=2;n<=e.multiline_count;n++){const o={...e,is_required:!1,name:`${e.code}_multiline_${n}`,code:`${e.code}_multiline_${n}`,id:`${e.code}_multiline_${n}`};r.push(o)}return r},y=t=>{var i,c,s;const r=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!r.length)return[];const e=(s=r.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:s.map(({code:u,...l})=>{const _=u!=="country_id"?u:"country_code";return{...l,name:_,id:_,code:_}}),n=R(e);return e.concat(n).map(u=>{var E;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),_=(E=u.options)==null?void 0:E.map(g=>({isDefault:g.is_default,text:g.label,value:g.value}));return h({...u,options:_,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const r={};for(const e in t){const n=t[e];!Array.isArray(n)||n.length===0||(e==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(r[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?r[e]=o:r[`${e}_multiline_${i+1}`]=o}):r[e]=n[0])}return r},O=t=>{var r,e,n;return h({firstname:(t==null?void 0:t.firstname)||"",lastname:(t==null?void 0:t.lastname)||"",city:(t==null?void 0:t.city)||"",company:(t==null?void 0:t.company)||"",country_code:(t==null?void 0:t.country_code)||"",region:{region:((r=t==null?void 0:t.region)==null?void 0:r.region)||"",region_code:((e=t==null?void 0:t.region)==null?void 0:e.region_code)||"",region_id:((n=t==null?void 0:t.region)==null?void 0:n.region_id)||""},telephone:(t==null?void 0:t.telephone)||"",id:(t==null?void 0:t.id)||"",vat_id:(t==null?void 0:t.vat_id)||"",postcode:(t==null?void 0:t.postcode)||"",default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},N=t=>{var e,n;const r=((n=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:n.addresses)||[];return r.length?r.map(O).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},d=t=>{var c,s;if(!((s=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&s.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:r,storeConfig:e}=t.data,n=e==null?void 0:e.countries_with_required_region.split(","),o=e==null?void 0:e.optional_zip_countries.split(",");return{availableCountries:r.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:_}=u;return{value:l,text:_}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:n,optionalZipCountries:o}},I=t=>{var e,n;return(n=(e=t==null?void 0:t.data)==null?void 0:e.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:s}=o;return!!(i&&c&&s)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>{const r=sessionStorage.getItem(`_account_${t}`);return r?JSON.parse(r):await m(t!=="shortRequest"?p:A,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var o;if((o=e.errors)!=null&&o.length)return a(e.errors);const n=y(e);return sessionStorage.setItem(`_account_${t}`,JSON.stringify(n)),n}).catch(f)},$=` +`,_=t=>{throw t instanceof DOMException&&t.name==="AbortError"||b.emit("error",{source:"auth",type:"network",error:t}),t},f=t=>{const n=t.map(e=>e.message).join(" ");throw Error(n)},y=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let r=2;r<=e.multiline_count;r++){const o={...e,is_required:!1,name:`${e.code}_multiline_${r}`,code:`${e.code}_multiline_${r}`,id:`${e.code}_multiline_${r}`};n.push(o)}return n},R=t=>{var i,c,a;const n=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!n.length)return[];const e=(a=n.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:a.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),r=y(e);return e.concat(r).map(u=>{var E;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":S(u.code),m=(E=u.options)==null?void 0:E.map(h=>({isDefault:h.is_default,text:h.label,value:h.value}));return g({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const n={};for(const e in t){const r=t[e];!Array.isArray(r)||r.length===0||(e==="custom_attributesV2"?r.forEach(o=>{typeof o=="object"&&"value"in o&&(n[o==null?void 0:o.code]=o==null?void 0:o.value)}):r.length>1?r.forEach((o,i)=>{i===0?n[e]=o:n[`${e}_multiline_${i+1}`]=o}):n[e]=r[0])}return n},N=t=>({prefix:(t==null?void 0:t.prefix)??"",suffix:(t==null?void 0:t.suffix)??"",firstname:(t==null?void 0:t.firstname)??"",lastname:(t==null?void 0:t.lastname)??"",middlename:(t==null?void 0:t.middlename)??""}),O=t=>({id:(t==null?void 0:t.id)??"",vat_id:(t==null?void 0:t.vat_id)??"",postcode:(t==null?void 0:t.postcode)??"",country_code:(t==null?void 0:t.country_code)??""}),I=t=>({company:(t==null?void 0:t.company)??"",telephone:(t==null?void 0:t.telephone)??"",fax:(t==null?void 0:t.fax)??""}),$=t=>{var e,r,o;return g({...N(t),...O(t),...I(t),city:(t==null?void 0:t.city)??"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)??"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)??"",region_id:((o=t==null?void 0:t.region)==null?void 0:o.region_id)??""},default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},G=t=>{var r,o;const n=((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.addresses)||[];return n.length?n.map($).sort((i,c)=>(Number(c.defaultBilling)||Number(c.defaultShipping))-(Number(i.defaultBilling)||Number(i.defaultShipping))):[]},M=t=>{var c,a;if(!((a=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&a.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:n,storeConfig:e}=t.data,r=e==null?void 0:e.countries_with_required_region.split(","),o=e==null?void 0:e.optional_zip_countries.split(",");return{availableCountries:n.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:r,optionalZipCountries:o}},U=t=>{var e,r;return(r=(e=t==null?void 0:t.data)==null?void 0:e.country)!=null&&r.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:a}=o;return!!(i&&c&&a)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},P=async t=>{const n=`_account_attributesForm_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(t!=="shortRequest"?T:A,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=R(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},w=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { createCustomerAddress(input:$input) { firstname } } -`,L=async t=>await m($,{method:"POST",variables:{input:h(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(r=>{var e,n,o;return(e=r.errors)!=null&&e.length?a(r.errors):((o=(n=r==null?void 0:r.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),G=` +`,d=async t=>await s(w,{method:"POST",variables:{input:g(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(n=>{var e,r,o;return(e=n.errors)!=null&&e.length?f(n.errors):((o=(r=n==null?void 0:n.data)==null?void 0:r.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(_),x=` query GET_CUSTOMER_ADDRESS { customer { addresses { firstname lastname + middlename + fax + prefix + suffix city company country_code @@ -80,7 +84,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr } } } -`,P=async()=>await m(G,{method:"GET",cache:"no-cache"}).then(t=>{var r;return(r=t.errors)!=null&&r.length?a(t.errors):N(t)}).catch(f),M=` +`,z=async()=>await s(x,{method:"GET",cache:"no-cache"}).then(t=>{var n;return(n=t.errors)!=null&&n.length?f(t.errors):G(t)}).catch(_),F=` query GET_COUNTRIES_QUERY { countries { two_letter_abbreviation @@ -91,7 +95,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr optional_zip_countries } } -`,J=async()=>{const t=sessionStorage.getItem("_account_countries");return t?JSON.parse(t):await m(M,{method:"GET",cache:"no-cache"}).then(r=>{var n;if((n=r.errors)!=null&&n.length)return a(r.errors);const e=d(r);return sessionStorage.setItem("_account_countries",JSON.stringify(e)),e}).catch(f)},U=` +`,Z=async()=>{const t="_account_countries",n=sessionStorage.getItem(t);return n?JSON.parse(n):await s(F,{method:"GET",cache:"no-cache"}).then(e=>{var o;if((o=e.errors)!=null&&o.length)return f(e.errors);const r=M(e);return sessionStorage.setItem(t,JSON.stringify(r)),r}).catch(_)},q=` query GET_REGIONS($countryCode: String!) { country(id: $countryCode) { id @@ -102,15 +106,15 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as S}fr } } } -`,z=async t=>await m(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(r=>{var e;return(e=r.errors)!=null&&e.length?a(r.errors):I(r)}).catch(f),w=` +`,W=async t=>{const n=`_account_regions_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(q,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=U(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},V=` mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, $input: CustomerAddressInput) { updateCustomerAddress(id:$id, input:$input) { firstname } } -`,Z=async t=>{const{addressId:r,...e}=t;return r?await m(w,{method:"POST",variables:{id:r,input:h(e,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(n=>{var o,i,c;return(o=n.errors)!=null&&o.length?a(n.errors):((c=(i=n==null?void 0:n.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(f):""},q=` +`,Y=async t=>{const{addressId:n,...e}=t;return n?await s(V,{method:"POST",variables:{id:n,input:g(e,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(r=>{var o,i,c;return(o=r.errors)!=null&&o.length?f(r.errors):((c=(i=r==null?void 0:r.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(_):""},B=` mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) { deleteCustomerAddress(id:$id) } -`,K=async t=>await m(q,{method:"POST",variables:{id:t}}).then(r=>{var e;return(e=r.errors)!=null&&e.length?a(r.errors):r.data.deleteCustomerAddress}).catch(f);export{B as a,j as b,H as c,L as d,P as e,m as f,k as g,J as h,z as i,K as j,h as k,a as l,f as m,b as n,T as o,Q as r,x as s,O as t,Z as u}; +`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,g as k,f as l,_ as m,S as n,p as o,J as r,k as s,$ as t,Y as u}; diff --git a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js index bf2d67bd23..b02fc81e38 100644 --- a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js +++ b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js @@ -1,4 +1,4 @@ -import{n as $,f as d,l,m as _,k as I}from"./removeCustomerAddress.js";const y=t=>{var r,m,u,c,i,h,C,f,o,e,E,g,T,S,w,n,O,P,b,A,R,U,N;const a=(u=(m=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:m.custom_attributes)==null?void 0:u.reduce((G,M)=>(G[$(M.code)]=M.value??"",G),{});return{email:((i=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:i.email)||"",firstName:((C=(h=t==null?void 0:t.data)==null?void 0:h.customer)==null?void 0:C.firstname)||"",lastName:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.lastname)||"",middleName:((E=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:E.middlename)||"",gender:(T=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:T.gender,dob:((w=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:w.dob)||"",dateOfBirth:((O=(n=t==null?void 0:t.data)==null?void 0:n.customer)==null?void 0:O.date_of_birth)||"",prefix:((b=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:b.prefix)||"",suffix:((R=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:R.suffix)||"",createdAt:((N=(U=t==null?void 0:t.data)==null?void 0:U.customer)==null?void 0:N.created_at)||"",...a}},v=t=>{var a,r,m,u;return{minLength:+((r=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:r.minimum_password_length)||3,requiredCharacterClasses:+((u=(m=t==null?void 0:t.data)==null?void 0:m.storeConfig)==null?void 0:u.required_character_classes_number)||0}},x=` +import{n as $,f as d,l,m as _,k as I}from"./removeCustomerAddress.js";const y=t=>{var r,m,u,c,i,h,C,f,o,e,E,g,T,S,w,n,O,P,b,A,R,U,N;const a=(u=(m=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:m.custom_attributes)==null?void 0:u.reduce((G,M)=>(G[$(M.code)]=M.value??"",G),{});return{email:((i=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:i.email)||"",firstName:((C=(h=t==null?void 0:t.data)==null?void 0:h.customer)==null?void 0:C.firstname)||"",lastName:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.lastname)||"",middleName:((E=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:E.middlename)||"",gender:((T=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:T.gender)||"1",dob:((w=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:w.dob)||"",dateOfBirth:((O=(n=t==null?void 0:t.data)==null?void 0:n.customer)==null?void 0:O.date_of_birth)||"",prefix:((b=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:b.prefix)||"",suffix:((R=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:R.suffix)||"",createdAt:((N=(U=t==null?void 0:t.data)==null?void 0:U.customer)==null?void 0:N.created_at)||"",...a}},v=t=>{var a,r,m,u;return{minLength:+((r=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:r.minimum_password_length)||3,requiredCharacterClasses:+((u=(m=t==null?void 0:t.data)==null?void 0:m.storeConfig)==null?void 0:u.required_character_classes_number)||0}},x=` fragment BasicCustomerInfo on Customer { date_of_birth dob diff --git a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts index c985d9cdcf..e1e41541a6 100644 --- a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts +++ b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts @@ -94,6 +94,10 @@ export declare const mockDefaultAddress: { streetMultiline_2: string; defaultShipping: boolean; defaultBilling: boolean; + fax: string; + middlename: string; + prefix: string; + suffix: string; }; export declare const mockResponseAddressWithText: { firstname: string; @@ -114,45 +118,10 @@ export declare const mockResponseAddressWithText: { default_shipping: boolean; default_billing: boolean; custom_attributesV2: never[]; -}; -export declare const mockResponseAddressEmpty: { - firstname: string; - lastname: string; - city: string; - company: string; - country_code: string; - region: { - region: string; - region_code: string; - region_id: string; - }; - telephone: string; - id: string; - vat_id: string; - postcode: string; - street: string[]; - default_shipping: boolean; - default_billing: boolean; - custom_attributesV2: never[]; -}; -export declare const mockDefaultAddressEmpty: { - firstname: string; - lastname: string; - city: string; - company: string; - countryCode: string; - region: { - region: string; - regionCode: string; - regionId: string; - }; - telephone: string; - id: string; - vatId: string; - postcode: string; - street: string; - defaultShipping: boolean; - defaultBilling: boolean; + fax: string; + middlename: string; + prefix: string; + suffix: string; }; export declare const mockResponseCountries: { two_letter_abbreviation: string; diff --git a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts index b87aad14d4..f623e26f76 100644 --- a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts +++ b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts @@ -1,7 +1,6 @@ import { CustomerAddressesModel } from '../models'; import { AddressResponse, UserAddressesProps } from '../../types'; -export declare const expandArraysInObject: (inputObject: UserAddressesProps) => Record; export declare const transformSingleAddress: (addressData: UserAddressesProps) => CustomerAddressesModel; export declare const transformMultipleAddresses: (response: AddressResponse) => CustomerAddressesModel[] | [ ]; diff --git a/scripts/__dropins__/storefront-account/reload b/scripts/__dropins__/storefront-account/reload index 391db9d6c9..2fa2408fc4 100644 --- a/scripts/__dropins__/storefront-account/reload +++ b/scripts/__dropins__/storefront-account/reload @@ -1 +1 @@ -{"at":1732522779616} \ No newline at end of file +{"at":1732795336523} \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts index 4efa9bc01d..cc57850f6e 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts @@ -4,6 +4,10 @@ export type RegionProps = { region_id: string | number; }; export interface UserAddressesProps { + middlename: string; + fax: string; + prefix: string; + suffix: string; firstname: string; lastname: string; city: string;