@dropins/storefront-account 0.1.0-alpha15 → 0.1.0-alpha17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/api/fragments/CustomerFragment.graphql.d.ts +2 -0
  2. package/api/getCustomer/graphql/getCustomer.graphql.d.ts +1 -1
  3. package/api/getStoreConfig/getStoreConfig.d.ts +4 -0
  4. package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +2 -0
  5. package/api/getStoreConfig/index.d.ts +2 -0
  6. package/api/index.d.ts +4 -0
  7. package/api/updateCustomer/graphql/updateCustomer.graphql.d.ts +2 -0
  8. package/api/updateCustomer/index.d.ts +2 -0
  9. package/api/updateCustomer/updateCustomer.d.ts +2 -0
  10. package/api/updateCustomerEmail/graphql/updateCustomerEmail.graphql.d.ts +2 -0
  11. package/api/updateCustomerEmail/index.d.ts +2 -0
  12. package/api/updateCustomerEmail/updateCustomerEmail.d.ts +5 -0
  13. package/api/updateCustomerPassword/graphql/updateCustomerPassword.graphql.d.ts +2 -0
  14. package/api/updateCustomerPassword/index.d.ts +2 -0
  15. package/api/updateCustomerPassword/updateCustomerPassword.d.ts +4 -0
  16. package/api.js +1 -9
  17. package/chunks/CustomerInformationCard.js +1 -0
  18. package/chunks/getOrderHistoryList.js +17 -6
  19. package/chunks/removeCustomerAddress.js +8 -8
  20. package/chunks/updateCustomer.js +57 -0
  21. package/components/ChangePassword/ChangePassword.d.ts +5 -0
  22. package/components/ChangePassword/index.d.ts +3 -0
  23. package/components/CustomerInformationCard/CustomerInformationCard.d.ts +5 -0
  24. package/components/CustomerInformationCard/index.d.ts +3 -0
  25. package/components/EditCustomerInformation/EditCustomerInformation.d.ts +5 -0
  26. package/components/EditCustomerInformation/index.d.ts +3 -0
  27. package/components/index.d.ts +3 -0
  28. package/containers/AddressForm.js +1 -1
  29. package/containers/Addresses.js +1 -1
  30. package/containers/CustomerInformation/CustomerInformation.d.ts +5 -0
  31. package/containers/CustomerInformation/index.d.ts +3 -0
  32. package/containers/CustomerInformation.d.ts +3 -0
  33. package/containers/CustomerInformation.js +1 -0
  34. package/containers/OrdersList.js +1 -1
  35. package/containers/index.d.ts +1 -0
  36. package/data/models/customer.d.ts +10 -2
  37. package/data/models/index.d.ts +1 -0
  38. package/data/models/order-history-list.d.ts +2 -0
  39. package/data/models/store-config.d.ts +5 -0
  40. package/data/transforms/index.d.ts +1 -0
  41. package/data/transforms/transform-store-config.d.ts +5 -0
  42. package/hooks/components/useChangePassword.d.ts +26 -0
  43. package/hooks/components/usePasswordValidationMessage.d.ts +16 -0
  44. package/hooks/containers/useCustomerInformation.d.ts +50 -0
  45. package/hooks/containers/useGetStoreConfigs.d.ts +7 -0
  46. package/hooks/useInLineAlert.d.ts +7 -0
  47. package/i18n/en_US.json.d.ts +51 -0
  48. package/lib/validationChangePassword.d.ts +17 -0
  49. package/lib/validationUniqueSymbolsPassword.d.ts +2 -0
  50. package/package.json +1 -1
  51. package/render.js +3 -3
  52. package/types/addresses.types.d.ts +2 -2
  53. package/types/api/getCustomer.types.d.ts +11 -0
  54. package/types/api/getOrderHistoryList.types.d.ts +14 -0
  55. package/types/api/storeConfig.types.d.ts +13 -0
  56. package/types/api/updateCustomerPassword.types.d.ts +15 -0
  57. package/types/customerInformation.types.d.ts +61 -0
  58. package/types/form.types.d.ts +3 -0
  59. package/types/index.d.ts +4 -0
  60. package/types/notification.types.d.ts +19 -0
  61. package/types/ordersList.types.d.ts +10 -0
  62. package/chunks/AddressFormWrapper.js +0 -1
@@ -0,0 +1,2 @@
1
+ export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n dob\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n";
2
+ //# sourceMappingURL=CustomerFragment.graphql.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const GET_CUSTOMER = "\n query GET_CUSTOMER {\n customer {\n firstname\n lastname\n email\n }\n }\n";
1
+ export declare const GET_CUSTOMER: string;
2
2
  //# sourceMappingURL=getCustomer.graphql.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { StoreConfigModel } from '../../data/models';
2
+
3
+ export declare const getStoreConfig: () => Promise<StoreConfigModel>;
4
+ //# sourceMappingURL=getStoreConfig.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n";
2
+ //# sourceMappingURL=getStoreConfig.graphql.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './getStoreConfig';
2
+ //# sourceMappingURL=index.d.ts.map
package/api/index.d.ts CHANGED
@@ -9,4 +9,8 @@ export * from './updateCustomerAddress';
9
9
  export * from './getCustomer';
10
10
  export * from './removeCustomerAddress';
11
11
  export * from './getOrderHistoryList';
12
+ export * from './updateCustomerPassword';
13
+ export * from './getStoreConfig';
14
+ export * from './updateCustomerEmail';
15
+ export * from './updateCustomer';
12
16
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const UPDATE_CUSTOMER_V2 = "\n mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {\n updateCustomerV2(input:$input) {\n customer {\n email\n }\n }\n }\n";
2
+ //# sourceMappingURL=updateCustomer.graphql.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './updateCustomer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const updateCustomer: (form: Record<string, string>) => Promise<string>;
2
+ //# sourceMappingURL=updateCustomer.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const UPDATE_CUSTOMER_EMAIL = "\n mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) {\n updateCustomerEmail(email:$email password:$password) {\n customer {\n email\n }\n }\n }\n";
2
+ //# sourceMappingURL=updateCustomerEmail.graphql.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './updateCustomerEmail';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export declare const updateCustomerEmail: ({ email, password, }: {
2
+ email: string;
3
+ password: string;
4
+ }) => Promise<string>;
5
+ //# sourceMappingURL=updateCustomerEmail.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const CHANGE_CUSTOMER_PASSWORD = "\n mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) {\n changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) {\n email\n }\n }\n";
2
+ //# sourceMappingURL=updateCustomerPassword.graphql.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './updateCustomerPassword';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { ChangeCustomerPasswordProps } from '../../types';
2
+
3
+ export declare const updateCustomerPassword: ({ currentPassword, newPassword, }: ChangeCustomerPasswordProps) => Promise<string>;
4
+ //# sourceMappingURL=updateCustomerPassword.d.ts.map
package/api.js CHANGED
@@ -1,9 +1 @@
1
- import{Initializer as c}from"@dropins/tools/lib.js";import{f as n,h as d,a as u}from"./chunks/removeCustomerAddress.js";import{e as T,d as x,g as y,j as Q,i as k,k as w,l as z,r as O,s as R,b,c as v,u as M}from"./chunks/removeCustomerAddress.js";import{g as U}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const s=new c({init:async t=>{const a={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};s.config.setConfig({...a,...t})},listeners:()=>[]}),G=s.config,f=t=>{var a,r,e,i,o,m;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((i=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:i.firstname)||"",lastname:((m=(o=t==null?void 0:t.data)==null?void 0:o.customer)==null?void 0:m.lastname)||""}},h=`
2
- query GET_CUSTOMER {
3
- customer {
4
- firstname
5
- lastname
6
- email
7
- }
8
- }
9
- `,A=async()=>await n(h,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?d(t.errors):f(t)}).catch(u);export{G as config,T as createCustomerAddress,n as fetchGraphQl,x as getAttributesForm,y as getConfig,Q as getCountries,A as getCustomer,k as getCustomerAddress,U as getOrderHistoryList,w as getRegions,s as initialize,z as removeCustomerAddress,O as removeFetchGraphQlHeader,R as setEndpoint,b as setFetchGraphQlHeader,v as setFetchGraphQlHeaders,M as updateCustomerAddress};
1
+ import{Initializer as r}from"@dropins/tools/lib.js";import{d as m,f as u,c as f,g as p,h as c,e as C,i as h,j as l,r as A,s as x,a as H,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as b,a as z,c as v,b as w,u as y}from"./chunks/updateCustomer.js";import{g as P}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const e=new r({init:async t=>{const s={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};e.config.setConfig({...s,...t})},listeners:()=>[]}),n=e.config;export{n as config,m as createCustomerAddress,u as fetchGraphQl,f as getAttributesForm,p as getConfig,c as getCountries,b as getCustomer,C as getCustomerAddress,P as getOrderHistoryList,h as getRegions,z as getStoreConfig,e as initialize,l as removeCustomerAddress,A as removeFetchGraphQlHeader,x as setEndpoint,H as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,v as updateCustomer,G as updateCustomerAddress,w as updateCustomerEmail,y as updateCustomerPassword};
@@ -0,0 +1 @@
1
+ import{jsx as a,Fragment as Q,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{classes as J,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as qe,Input as Pe,InputDate as We,Checkbox as xe,TextArea as je,Card as he,Skeleton as we,SkeletonRow as W,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as De}from"@dropins/tools/components.js";import{useRef as Ye,useState as Z,useEffect as ee,useCallback as V,useMemo as Qe}from"@dropins/tools/preact-hooks.js";import{k as et,o as Re,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 se}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 _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:d,forwardFormRef:l,slots:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,billingCheckBoxValue:C,shippingCheckBoxValue:y,showBillingCheckBox:F,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N})=>a("div",{className:J(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,shippingCheckBoxValue:y,billingCheckBoxValue:C,showShippingCheckBox:L,showBillingCheckBox:F,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N,forwardFormRef:l,showSaveCheckBox:r,saveCheckBoxValue:d})}),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 O,z;const{requiredFieldError:d,lengthTextError:l,numericError:c,alphaNumWithSpacesError:o,alphaNumericError:i,alphaError:u,emailError:f,dateError:C,urlError:y,dateLengthError:F}=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||!((O=s==null?void 0:s.validateRules)!=null&&O.length))return x;const t=ct(s==null?void 0:s.validateRules),A=t.MIN_TEXT_LENGTH??1,m=t.MAX_TEXT_LENGTH??255,_=t.DATE_RANGE_MIN,N=t.DATE_RANGE_MAX;if(!gt(e,+A,+m)&&!(_||N))return{[L]:l.replace("{min}",A).replace("{max}",m)};if(!At(e,+_,+N)&&(_||N))return{[L]:F.replace("{min}",Te(_)).replace("{max}",Te(N))};const S={numeric:{validate:it,error:c},"alphanum-with-spaces":{validate:ut,error:o},alphanumeric:{validate:pt,error:i},alpha:{validate:ft,error:u},email:{validate:mt,error:f},date:{validate:ht,error:C},url:{validate:Lt,error:y}}[t.INPUT_VALIDATION];return S&&!S.validate(e)&&!((z=r[L])!=null&&z.length)?{[L]:S.error}:x},Ve=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 d=e[r],l=r.match(/^(.*)Multiline_(\d+)$/);if(l){const c=l[1],o=parseInt(l[2],10);n[c]||(n[c]=[]),n[c].push({index:o,value:d})}else Object.keys(e).filter(o=>o.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((l,c)=>l.index-c.index),s[r]=d.map(l=>l.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Ve(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Re(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=et(e,"camelCase",{firstname:"firstName",lastname:"lastName"}),r=Mt(bt(n));if(!s)return r;const[d,l]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...l&&{regionId:+l}}}},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]!==""),Be=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:l})=>{const c=se({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),o=Ye(null),[i,u]=Z({}),[f,C]=Z({}),[y,F]=Z({}),[L,x]=Z(!0),[t,A]=Z(!1),[m,_]=Z(!1),[N,I]=Z(!0);ee(()=>{const p=()=>{if(o.current){const E=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,w=o.current.querySelector(".account-address-form--saveAddressBook");w&&(w.style.gridRow=String(E-1))}};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[e==null?void 0:e.length]);const S=V((p=!1)=>{let g=!0;const E={...f};let w=null;for(const[R,$]of Object.entries(i)){const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(R)),h=ye($.toString(),U,c,E);h[R]&&(Object.assign(E,h),g=!1),w||(w=Object.keys(E).find(M=>E[M])||null)}if(p||C(E),w&&o.current&&!p){const R=o.current.elements.namedItem(w);R==null||R.focus()}return g},[f,e,i,c]),O=V((p,g,E,w)=>{const R={...me(o),[g]:p,...g.includes("countryCode")?{region:""}:{}},$={data:ae(R,!0),isDataValid:Ze(E,R)};S(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify($)),n==null||n($,{},w)},[S,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:p,errorList:g}=vt(e);u(E=>({...p,...E})),C(g),F(g)}},[JSON.stringify(e)]),ee(()=>{if(m)return;const p=me(o),g=sessionStorage.getItem(`${d}_addressData`);if($e(i)&&$e(y)){let E={};const w=Ze(y,i);g?E=JSON.parse(g).data:E=ae(p,!0)??{},n==null||n({data:E,isDataValid:w},{},null),_(!0)}},[i,y]),ee(()=>{var R;if(!N)return;const p=me(o),g=!!(p!=null&&p.countryCode),E=!!((R=p==null?void 0:p.region)!=null&&R.length);p&&g&&!E&&Be(n)&&!l&&O(p==null?void 0:p.region,"region",y,null)},[N,L,e,o,n,O,y,t,l]);const z=V(p=>{const{name:g,value:E,type:w,checked:R}=p==null?void 0:p.target,$=w==="checkbox"?R:E;u(M=>{const j={...M,[g]:$};return g==="countryCode"&&(j.region="",x(!0),A(!1)),j}),r==null||r({[g]:$}),_(!0);const U=e==null?void 0:e.find(M=>M.customUpperCode.includes(g));let h={...f};if(U){const M=ye($.toString(),U,c,h);M&&Object.assign(h,M),C(h)}O($,g,y,p)},[r,e,f,c,O,y,L]),b=V(p=>{const{name:g}=p==null?void 0:p.target,E=e==null?void 0:e.find(w=>w.customUpperCode===g);g==="region"&&(E!=null&&E.options.length)&&I(!1),I(g==="countryCode")},[]),q=V(p=>{const{name:g,value:E,type:w,checked:R}=p==null?void 0:p.target,$=w==="checkbox"?R:E,U=e==null?void 0:e.find(h=>h.customUpperCode===g);if(U){const h={...f},M=ye($.toString(),U,c,h);M&&Object.assign(h,M),C(h)}},[f,e,c]),B=V(p=>{p.preventDefault();const g=S();s==null||s(p,g)},[S,s]);return{formData:i,errors:f,formRef:o,handleInputChange:z,onFocus:b,handleBlur:q,handleSubmit:B,handleValidationSubmit:S}};var re=(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))(re||{});const _t=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:l,onBlur:c,onFocus:o,slots:i})=>{const u=`${d}__field`,f=(t,A)=>{if(!(i!=null&&i[`AddressFormInput_${t.code}`]))return;const m={inputName:t.customUpperCode,handleOnChange:l,handleOnBlur:c,handleOnFocus:o,errorMessage:A,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:i[`AddressFormInput_${t.code}`],context:m})},C=(t,A,m)=>{var N;const _=((N=t.options.find(I=>I.isDefault))==null?void 0:N.value)??A??t.defaultValue;return a(Q,{children:f(t,m)??a(le,{error:m,className:J([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(qe,{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:o,handleSelect:l,defaultValue:_,value:_})},t.id)})},y=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(Pe,{id:t.code,type:"text",name:t.customUpperCode,value:A??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:c,onFocus:o,onChange:l})},t.id)}),F=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:c,onChange:l,disabled:e||t.disabled})},t.id)}),L=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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:c,onChange:l})},t.id)}),x=(t,A,m)=>a(Q,{children:f(t,m)??a(le,{error:m,className:J([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,label:`${t.label} ${t.required?"*":""}`,onBlur:c,onChange:l})},t.id)});return n.length?a(Q,{children:n.map(t=>{const A=r==null?void 0:r[t.customUpperCode],m=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case re.TEXT:return t.options.length?C(t,m,A):y(t,m,A);case re.MULTILINE:return y(t,m,A);case re.SELECT:return C(t,m,A);case re.DATE:return F(t,m,A);case re.BOOLEAN:return L(t,m,A);case re.TEXTAREA:return x(t,m,A);default:return null}})}):null}),ze=({testId:e,withCard:s=!0})=>{const n=k(we,{"data-testid":e||"skeletonLoader",children:[a(W,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(W,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:J(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>k(we,{"data-testid":"addressFormLoader",children:[a(W,{variant:"heading",size:"medium"}),a(W,{variant:"empty",size:"medium"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large",fullWidth:!0}),a(W,{size:"large",fullWidth:!0,lines:3}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large"}),a(W,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:l,children:c,className:o="defaultForm",fieldsConfig:i,onSubmit:u,onChange:f,forwardFormRef:C,regionOptions:y,showSaveCheckBox:F,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=se({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{formData:A,errors:m,formRef:_,handleInputChange:N,handleBlur:I,handleSubmit:S,handleValidationSubmit:O,onFocus:z}=Et({fieldsConfig:i,onSubmit:u,onChange:f,setInputChange:s,regionOptions:y,formName:d,isWaitingForResponse:e});return lt(C,()=>{const b=me(_);return{handleValidationSubmit:O,formData:ae(b,!0)}}),n||!(i!=null&&i.length)?a(Nt,{}):k("form",{className:J(["account-form",o]),onSubmit:S,name:d,ref:_,children:[a(_t,{className:o,loading:l,fields:i,onChange:N,onBlur:I,errors:m,values:A,onFocus:z,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:N}}}):null,F?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:b=>{N(b),L==null||L(b)}})}):null,c]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:l,keysSortOrder:c,addressData:o,loading:i,setAddressId:u,handleRenderModal:f,handleRenderForm:C})=>{const y=l?"minifiedView":"fullSizeView",F=se({actionRemove:`Account.${y}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${y}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${y}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${y}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${y}.Addresses.addressCard.defaultLabelText`}),L=F.cardLabelBilling.toLocaleUpperCase(),x=F.cardLabelShipping.toLocaleUpperCase(),t=F.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]),m=_e(()=>{u==null||u(o==null?void 0:o.id),f==null||f()},[f,o==null?void 0:o.id,u]),_=_e(()=>{u==null||u(o==null?void 0:o.id),C==null||C()},[C,o==null?void 0:o.id,u]),N=be(()=>{if(!c)return[];const{region:b,...q}=o,B={...q,...b};return c.filter(({name:p})=>B[p]).map(p=>({name:p.name,orderNumber:p.orderNumber,value:B[p.name],label:p.label}))},[o,c]),{shippingLabel:I,billingLabel:S,hideShipping:O,hideBilling:z}=A;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:i?a(ze,{}):k(Q,{children:[k("div",{className:"account-address-card__action",children:[f?a(de,{type:"button",variant:"tertiary",onClick:m,"data-testid":"removeButton",children:F.actionRemove}):null,C?a(de,{type:"button",variant:"tertiary",onClick:_,className:"account-address-card__action--editbutton","data-testid":"editButton",children:F.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:N}}):a(Q,{children:N.map((b,q)=>{const B=b.label?`${b.label}: ${b==null?void 0:b.value}`:b==null?void 0:b.value;return a("p",{"data-testid":`${b.name}_${q}`,children:B},q)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?k("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:x}):null,o!=null&&o.defaultBilling?a(pe,{label:L}):null]}):null,s?k("div",{className:"account-address-card__labels",children:[!O&&(o!=null&&o.defaultShipping)?a(pe,{label:I}):null,!z&&(o!=null&&o.defaultBilling)?a(pe,{label:S}):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:d})=>{const l=r?"minifiedView":"fullSizeView",c=se({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",i=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?c.viewAllAddressesButton:c.addNewAddressButton,f=e?c.differentAddressButton:u;return k(o,{...i,className:J(["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:f}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:l,closeModal:c})=>{const o=e?"minifiedView":"fullSizeView",i=se({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return r?k(Ge,{title:a("h3",{children:i.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:c,children:[d?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}),k("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:c,variant:"secondary",disabled:d,children:i.actionCancel}),a(de,{disabled:d,onClick:l,children:i.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",l=se({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),c=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:It,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!c.text?null:a(Je,{className:J(["account-empty-list",n?"account-empty-list--minified":"",r]),message:c.text,icon:a(Se,{source:c.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const c=s[0],i=Object.values(c.region).every(f=>!!f)?{}:{region:{...c.region,regionId:0}};return!!await Ce({addressId:Number(c==null?void 0:c.id),defaultShipping:!1,defaultBilling:!1,...i})}const n=s.filter(c=>c.id!==e&&(c.defaultBilling||c.defaultShipping)||c.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"],t1=["email","firstname","lastname","middlename","gender","dob","date_of_birth","prefix","suffix"],Ue=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,l)=>Number(l.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:l,onSuccess:c})=>{const[o,i]=Z(""),[u,f]=Z(!1),[C,y]=Z(!1),[F,L]=Z(!1),[x,t]=Z(!1),[A,m]=Z(!1),[_,N]=Z(""),[I,S]=Z([]),[O,z]=Z([]),b=V(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(h=>{const[M,j]=h;if(M){const X=M.map(({name:D,orderNumber:ne,label:te})=>({name:rt(D),orderNumber:ne,label:St.includes(D)?null:te}));z(X)}if(j)if(d){const X=j.filter(D=>!!D.defaultShipping||!!D.defaultBilling);S(X)}else S(j)}).finally(()=>{L(!1)})},[d]);ee(()=>{b()},[b]),ee(()=>{var h;if(I.length)if(n===0)m(!0),i("0");else{const M=I.find(X=>+X.id===n)||Ue(I,e,s)[0],j={data:ae(M),isDataValid:!ve(M)};i(n.toString()||((h=M==null?void 0:M.id)==null?void 0:h.toString())),r==null||r(j)}},[I,n,r,s,e]);const q=V(h=>{N(h),m(!1)},[]),B=V((h,M)=>{const j=(h==null?void 0:h.target).value;i(j);const X={data:ae(M),isDataValid:!ve(ae(M))};r==null||r(X),j!=="0"&&m(!1)},[r]),p=V(()=>{y(!0)},[]),g=V(()=>{N(""),y(!1),f(!1)},[]),E=V(()=>{f(!0)},[]),w=V(async()=>{t(!0),await wt(_,I),st(+_).then(()=>{b(),g()}).finally(()=>{t(!1)})},[I,_,g,b]),R=V(()=>{m(!1)},[]),$=V(()=>{Be(l)&&d&&!A?window.location.href=l():(m(!0),N(""))},[A,l,d]),U=V(async()=>{await b(),await(c==null?void 0:c())},[b,c]);return{keysSortOrder:O,submitLoading:x,isModalRendered:u,isFormRendered:C,loading:F,addNewAddress:A,addressesList:I,addressId:_,handleRenderForm:p,handleRenderModal:E,removeAddress:w,onCloseBtnClick:g,setEditingAddressId:q,closeNewAddressForm:R,redirectToAddressesRoute:$,handleOnSuccess:U,handleSelectAddressOption:B,selectedAddressOption:o}},r1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:l="",showFormLoader:c=!1,onAddressData:o,forwardFormRef:i,className:u,showSaveCheckBox:f=!1,saveCheckBoxValue:C=!1,selectShipping:y=!1,selectBilling:F=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:A=!1,withActionsInFullSizeView:m=!0,inputsDefaultValueSet:_,showShippingCheckBox:N=!0,showBillingCheckBox:I=!0,shippingCheckBoxValue:S=!0,billingCheckBoxValue:O=!0,routeAddressesPage:z,onSuccess:b,onError:q})=>{var K;const B=t?"minifiedView":"fullSizeView",p=se({containerTitle:`Account.${B}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${B}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${B}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${B}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${B}.Addresses.newAddressFormTitle`}),{keysSortOrder:g,submitLoading:E,isModalRendered:w,isFormRendered:R,loading:$,addNewAddress:U,addressesList:h,addressId:M,handleRenderForm:j,handleRenderModal:X,removeAddress:D,onCloseBtnClick:ne,handleOnSuccess:te,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ce,handleSelectAddressOption:ie,selectedAddressOption:ue}=Rt({defaultSelectAddressId:l,minifiedView:t,routeAddressesPage:z,onSuccess:b,onAddressData:o,selectShipping:y,selectBilling:F}),H=s??(y&&F?"selectedAddress":y?"selectedShippingAddress":F?"selectedBillingAddress":"default"),P=L?k("div",{className:"account-addresses-wrapper--select-view",children:[(K=Ue(h,y,F))==null?void 0:K.map((v,Y)=>k(Ne,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:H,id:`${H}_${v.id}`,value:v.id,checked:ue===(v==null?void 0:v.id.toString()),onChange:ge=>ie(ge,v)}),a("label",{htmlFor:`${H}_${v.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:y,selectBilling:F,minifiedView:t,addressData:v,keysSortOrder:g,loading:$})})]},v.id)),a("input",{"data-testid":"radio-0",type:"radio",name:H,id:`${H}_addressActions`,value:"0",checked:ue==="0",onChange:v=>ie(v,{})}),a("label",{htmlFor:`${H}_addressActions`,className:"account-addresses-wrapper__label",children:U?a("div",{className:J(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",U]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:H,showFormLoader:c,isOpen:U,forwardFormRef:i,showSaveCheckBox:f,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:O,addressesFormTitle:d||p.differentAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:N,showBillingCheckBox:I,onCloseBtnClick:oe,onSuccess:te,onError:q,onChange:o})}):h!=null&&h.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:U,routeAddressesPage:ce}):null})]}):k(Q,{children:[h.map(v=>a(Ne,{children:M===v.id&&R?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:M===v.id&&R,addressFormId:M,inputsDefaultValueSet:v,addressesFormTitle:p.editAddressFormTitle,showShippingCheckBox:N,showBillingCheckBox:I,shippingCheckBoxValue:S,billingCheckBoxValue:O,onCloseBtnClick:ne,onSuccess:te,onError:q})}):a(Me,{slots:n,minifiedView:t,addressData:v,keysSortOrder:g,loading:$,setAddressId:Le,handleRenderModal:t&&A||!t&&m?X:void 0,handleRenderForm:t&&A||!t&&m?j:void 0},v.id)},v.id)),a("div",{className:"account-addresses__footer",children:U?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:U,addressesFormTitle:p.newAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:!!(h!=null&&h.length),showBillingCheckBox:!!(h!=null&&h.length),shippingCheckBoxValue:S,billingCheckBoxValue:O,onCloseBtnClick:oe,onSuccess:te,onError:q})}):a(Fe,{minifiedView:t,addNewAddress:U,routeAddressesPage:ce})})]});return k("div",{children:[a("div",{children:x?a(Xe,{title:r||p.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),k("div",{className:J(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(Ot,{minifiedView:t,addressData:h==null?void 0:h.find(v=>v.id===M),keysSortOrder:g,submitLoading:E,open:w,closeModal:ne,onRemoveAddress:D}),$?a(ze,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:H,isOpen:!(h!=null&&h.length),forwardFormRef:i,showSaveCheckBox:f,saveCheckBoxValue:C,shippingCheckBoxValue:S,billingCheckBoxValue:O,inputsDefaultValueSet:_,showShippingCheckBox:N,showBillingCheckBox:I,onCloseBtnClick:oe,onSuccess:te,onError:q,onChange:o}):a(xt,{isEmpty:!(h!=null&&h.length),typeList:"address",minifiedView:t}),P]})]})}),ke={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:re.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Ht={...ke,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Vt={...ke,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},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const l=r[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),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:d,isRequiredRegion:l,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:d,required:l,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={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?r[l]=e[l]:d.push({attribute_code:Re(l),value:e[l]})}),d.length>0&&(r.custom_attributesV2=d),r},Oe=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]=Ve(x)),s.includes(L)&&r.push(x)}const{street:l,streetMultiline_2:c,streetMultiline_1:o,region:i,...u}=e,[f,C]=i?i.split(","):[void 0,void 0],y=C&&f?{regionId:+C,regionCode:f}:{region:f};return Ut({...u,...d,region:{...y},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 l=s.find(c=>(c==null?void 0:c.id)===d.regionId);l?n[r]={...d,text:l.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((l,c)=>{n[`${r}Multiline_${c+2}`]=l})):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:l,showShippingCheckBox:c,showBillingCheckBox:o,inputsDefaultValueSet:i,onCloseBtnClick:u,onSuccess:f,onError:C,formName:y})=>{const[F,L]=Z({text:"",type:"success"}),[x,t]=Z(e??!1),[A,m]=Z(r||""),[_,N]=Z([]),[I,S]=Z([]),[O,z]=Z([]),[b,q]=Z([]),[B,p]=Z([]),[g,E]=Z(!1),[w,R]=Z(!1),[$,U]=Z(()=>{var H,P;const T=sessionStorage.getItem(`${y}_addressData`);return T?{countryCode:(P=(H=JSON.parse(T))==null?void 0:H.data)==null?void 0:P.countryCode}:i}),[h,M]=Z(!1),[j,X]=Z(!1),[D,ne]=Z(()=>{var P,K;const T=sessionStorage.getItem(`${y}_addressData`);return T?(K=(P=JSON.parse(T))==null?void 0:P.data)==null?void 0:K.saveAddressBook:n}),te=V(T=>{ne(T.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(A?"customer_address_edit":"customer_register_address").then(T=>{N(T)})},[A]),ee(()=>{M(!0),nt().then(({availableCountries:T,countriesWithRequiredRegion:H,optionalZipCountries:P})=>{S(T),q(H),p(P),M(!1)})},[]),ee(()=>{if($!=null&&$.countryCode){M(!0),X(!0);const T=$==null?void 0:$.countryCode;at(T).then(H=>{z(H);const P=b.find(v=>v===T),K=B.find(v=>v===T);E(!!P),R(!K),M(!1),X(!1)})}},[$==null?void 0:$.countryCode,b,B]);const Le=V(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=V(async(T,H)=>{if(!H)return null;t(!0);const P=Ie(T.target),K=Oe(P);await Ce(K).then(()=>{var v;f==null||f(),u==null||u(),(v=T==null?void 0:T.target)==null||v.reset()}).catch(v=>{L(Y=>({...Y,text:v.message,type:"error"})),C==null||C(v)}).finally(()=>{m(""),t(!1)})},[u,C,f]),ce=V(async(T,H)=>{if(!H)return;t(!0);const{saveAddressBook:P,...K}=Ie(T.target),v=Oe(K);await dt(v).then(()=>{var Y;f==null||f(),u==null||u(),(Y=T==null?void 0:T.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),C==null||C(Y)}).finally(()=>{m(""),t(!1)})},[u,C,f]),ie=Qe(()=>{if(!_.length)return[];const T={...Ht,defaultValue:l,isHidden:s&&!D?!0:!c},H={...Vt,defaultValue:d,isHidden:s&&!D?!0:!o},P=[..._,T,H],K=sessionStorage.getItem(`${y}_addressData`),v=K?kt(JSON.parse(K).data,O):{},Y=Bt(qt(v,i),P);return zt({fields:Y,addressId:A,countryOptions:I,disableField:h,regionOptions:O,isRequiredRegion:g,isRequiredPostCode:w})},[_,l,s,D,c,d,o,y,O,i,A,I,h,g,w]),ue=V(T=>{U(H=>({...H,...T}))},[]);return{isWaitingForResponse:j,regionOptions:O,saveCheckBoxAddress:D,inLineAlert:F,addressId:A,submitLoading:x,normalizeFieldsConfig:ie,handleSaveCheckBoxAddress:te,handleUpdateAddress:oe,handleCreateAddress:ce,handleOnCloseForm:Le,handleInputChange:ue}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:c,addressesFormTitle:o,className:i,addressFormId:u,inputsDefaultValueSet:f,showShippingCheckBox:C=!0,showBillingCheckBox:y=!0,shippingCheckBoxValue:F=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:A,onSuccess:m,onError:_,onChange:N})=>{const I=se({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:S,inLineAlert:O,addressId:z,submitLoading:b,normalizeFieldsConfig:q,handleUpdateAddress:B,handleCreateAddress:p,handleOnCloseForm:g,handleSaveCheckBoxAddress:E,saveCheckBoxAddress:w,handleInputChange:R,regionOptions:$}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:f,shippingCheckBoxValue:F,billingCheckBoxValue:L,showShippingCheckBox:C,showBillingCheckBox:y,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:m,onError:_,onCloseBtnClick:A,formName:s});return x?k("div",{className:J(["account-address-form-wrapper",i]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,O.text?a(De,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:O.type,variant:"secondary",heading:O.text,icon:O.icon}):null,k(Tt,{regionOptions:$,forwardFormRef:l,slots:c,className:"account-address-form",name:s||"addressesForm",fieldsConfig:q,onSubmit:t||(z?B:p),setInputChange:R,loading:b,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:E,saveCheckBoxAddress:w,onChange:N,isWaitingForResponse:S,children:[z?a("input",{type:"hidden",name:"addressId",value:z,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:J(["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:B,handleCreateAddress:p,addressId:z}}):a(Q,{children:r?null:k(Q,{children:[a(de,{type:"button",onClick:g,variant:"secondary",disabled:b,children:I.secondaryButton}),a(de,{disabled:b,children:I.primaryButton})]})})})]})]}):null};export{fe as A,ze as C,xt as E,Tt as F,$t as S,r1 as a,Be as c,t1 as d,Ie as g,Ut as n};
@@ -1,4 +1,4 @@
1
- import{t as l,m as i,f as m,h as _,a as p}from"./removeCustomerAddress.js";const f=(t,r="en-US",s={})=>{const e={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},a=new Date(t);return isNaN(a.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,e).format(a)},g=t=>{var d,c;if(!((c=(d=t.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:r,page_info:s,total_count:n,date_of_first_order:e}=t.data.customer.orders;return{items:r.map(o=>{const u={...o,order_date:f(o.order_date),shipping_address:l(o.shipping_address),billing_address:l(o.billing_address)};return i(u,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(n,"camelCase",{}),dateOfFirstOrder:i(e,"camelCase",{})}},y=`
1
+ import{t as u,k as i,f as _,l as f,m as p}from"./removeCustomerAddress.js";const g=(r,a="en-US",s={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},e=new Date(r);return isNaN(e.getTime())?"Invalid Date":new Intl.DateTimeFormat(a,t).format(e)},y=r=>{var d,c;if(!((c=(d=r.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:a,page_info:s,total_count:o,date_of_first_order:t}=r.data.customer.orders,{returns:e}=r.data.customer;return{items:a.map(n=>{const l={...n,returns:e==null?void 0:e.items.filter(m=>m.order.id===n.id),order_date:g(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(t,"camelCase",{})}},h=`
2
2
  fragment AddressesList on OrderAddress {
3
3
  city
4
4
  company
@@ -15,7 +15,7 @@ fragment AddressesList on OrderAddress {
15
15
  suffix
16
16
  telephone
17
17
  vat_id
18
- }`,h=`
18
+ }`,O=`
19
19
  fragment OrderSummary on OrderTotal {
20
20
  __typename
21
21
  grand_total {
@@ -49,9 +49,18 @@ fragment OrderSummary on OrderTotal {
49
49
  }
50
50
  label
51
51
  }
52
- }`,O=`
52
+ }`,S=`
53
53
  query GET_CUSTOMER_ORDERS_LIST($currentPage: Int, $pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) {
54
54
  customer {
55
+ returns {
56
+ items {
57
+ uid
58
+ number
59
+ order {
60
+ id
61
+ }
62
+ }
63
+ }
55
64
  orders(currentPage: $currentPage, pageSize: $pageSize, filter: $filter, sort: $sort) {
56
65
  page_info {
57
66
  page_size
@@ -96,7 +105,9 @@ fragment OrderSummary on OrderTotal {
96
105
  quantity_shipped
97
106
  quantity_invoiced
98
107
  product {
99
- small_image {
108
+ sku
109
+ url_key
110
+ small_image {
100
111
  url
101
112
  }
102
113
  }
@@ -108,6 +119,6 @@ fragment OrderSummary on OrderTotal {
108
119
  }
109
120
  }
110
121
  }
111
- ${y}
112
122
  ${h}
113
- `,S={sort_direction:"DESC",sort_field:"CREATED_AT"},T=async(t,r,s)=>{const n=r.includes("viewAll")?{}:{order_date:JSON.parse(r)};return await m(O,{method:"GET",cache:"no-cache",variables:{pageSize:t,currentPage:s,filter:n,sort:S}}).then(e=>{var a;return(a=e.errors)!=null&&a.length?_(e.errors):g(e)}).catch(p)};export{T as g};
123
+ ${O}
124
+ `,E={sort_direction:"DESC",sort_field:"CREATED_AT"},C=async(r,a,s)=>{const o=a.includes("viewAll")?{}:{order_date:JSON.parse(a)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:r,currentPage:s,filter:o,sort:E}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?f(t.errors):y(t)}).catch(p)};export{C as g};
@@ -1,4 +1,4 @@
1
- import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),A=`
1
+ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),A=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:A;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?a(i,e,r):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,_])=>{const u=r&&r[c]?r[c]:o(c);return i[u]=n.includes(typeof _)||_===null?_:a(_,e,r),i},{}):t},{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),p=`
2
2
  query GET_ATTRIBUTES_FORM($formCode: String!) {
3
3
  attributesForm(formCode: $formCode) {
4
4
  items {
@@ -30,7 +30,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
30
30
  }
31
31
  }
32
32
  }
33
- `,p=`
33
+ `,R=`
34
34
  query GET_ATTRIBUTES_FORM_SHORT {
35
35
  attributesForm(formCode: "customer_register_address") {
36
36
  items {
@@ -44,13 +44,13 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
44
44
  }
45
45
  }
46
46
  }
47
- `,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},h=t=>{const e=t.map(r=>r.message).join(" ");throw Error(e)},b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),R=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:R;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?a(i,e,r):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,_])=>{const u=r&&r[c]?r[c]:o(c);return i[u]=n.includes(typeof _)||_===null?_:a(_,e,r),i},{}):t},S=t=>{let e=[];for(const r of t)if(!(r.frontend_input!=="MULTILINE"||r.multiline_count<2))for(let n=2;n<=r.multiline_count;n++){const o={...r,is_required:!1,name:`${r.code}_multiline_${n}`,code:`${r.code}_multiline_${n}`,id:`${r.code}_multiline_${n}`};e.push(o)}return e},y=t=>{var i,c,_;const e=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const r=(_=e.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:_.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),n=S(r);return r.concat(n).map(u=>{var g;const l=u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),m=(g=u.options)==null?void 0:g.map(E=>({isDefault:E.is_default,text:E.label,value:E.value}));return a({...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 e={};for(const r in t){const n=t[r];!Array.isArray(n)||n.length===0||(r==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(e[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?e[r]=o:e[`${r}_multiline_${i+1}`]=o}):e[r]=n[0])}return e},O=t=>{var e,r,n;return a({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:((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:((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",{})},$=t=>{var r,n;const e=((n=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:n.addresses)||[];return e.length?e.map(O).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},d=t=>{var c,_;if(!((_=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&_.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:e,storeConfig:r}=t.data,n=r==null?void 0:r.countries_with_required_region.split(","),o=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:e.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:n,optionalZipCountries:o}},G=t=>{var r,n;return(n=(r=t==null?void 0:t.data)==null?void 0:r.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:_}=o;return!!(i&&c&&_)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>await s(t!=="shortRequest"?A:p,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):y(e)}).catch(f),I=`
47
+ `,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},h=t=>{const e=t.map(r=>r.message).join(" ");throw Error(e)},S=t=>{let e=[];for(const r of t)if(!(r.frontend_input!=="MULTILINE"||r.multiline_count<2))for(let n=2;n<=r.multiline_count;n++){const o={...r,is_required:!1,name:`${r.code}_multiline_${n}`,code:`${r.code}_multiline_${n}`,id:`${r.code}_multiline_${n}`};e.push(o)}return e},y=t=>{var i,c,_;const e=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const r=(_=e.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:_.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),n=S(r);return r.concat(n).map(u=>{var g;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),m=(g=u.options)==null?void 0:g.map(E=>({isDefault:E.is_default,text:E.label,value:E.value}));return a({...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 e={};for(const r in t){const n=t[r];!Array.isArray(n)||n.length===0||(r==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(e[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?e[r]=o:e[`${r}_multiline_${i+1}`]=o}):e[r]=n[0])}return e},d=t=>{var e,r,n;return a({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:((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:((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",{})},O=t=>{var r,n;const e=((n=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:n.addresses)||[];return e.length?e.map(d).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},$=t=>{var c,_;if(!((_=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&_.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:e,storeConfig:r}=t.data,n=r==null?void 0:r.countries_with_required_region.split(","),o=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:e.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:n,optionalZipCountries:o}},N=t=>{var r,n;return(n=(r=t==null?void 0:t.data)==null?void 0:r.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:_}=o;return!!(i&&c&&_)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>await s(t!=="shortRequest"?p:R,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):y(e)}).catch(f),G=`
48
48
  mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {
49
49
  createCustomerAddress(input:$input) {
50
50
  firstname
51
51
  }
52
52
  }
53
- `,L=async t=>await s(I,{method:"POST",variables:{input:a(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(e=>{var r,n,o;return(r=e.errors)!=null&&r.length?h(e.errors):((o=(n=e==null?void 0:e.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),M=`
53
+ `,L=async t=>await s(G,{method:"POST",variables:{input:a(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(e=>{var r,n,o;return(r=e.errors)!=null&&r.length?h(e.errors):((o=(n=e==null?void 0:e.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),I=`
54
54
  query GET_CUSTOMER_ADDRESS {
55
55
  customer {
56
56
  addresses {
@@ -80,7 +80,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
80
80
  }
81
81
  }
82
82
  }
83
- `,P=async()=>await s(M,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):$(t)}).catch(f),N=`
83
+ `,P=async()=>await s(I,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):O(t)}).catch(f),M=`
84
84
  query GET_COUNTRIES_QUERY {
85
85
  countries {
86
86
  two_letter_abbreviation
@@ -91,7 +91,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
91
91
  optional_zip_countries
92
92
  }
93
93
  }
94
- `,z=async()=>await s(N,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):d(t)}).catch(f),U=`
94
+ `,z=async()=>await s(M,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):$(t)}).catch(f),U=`
95
95
  query GET_REGIONS($countryCode: String!) {
96
96
  country(id: $countryCode) {
97
97
  id
@@ -102,7 +102,7 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
102
102
  }
103
103
  }
104
104
  }
105
- `,Z=async t=>await s(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):G(e)}).catch(f),w=`
105
+ `,Z=async t=>await s(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):N(e)}).catch(f),w=`
106
106
  mutation UPDATE_CUSTOMER_ADDRESS($id: Int!,
107
107
  $input: CustomerAddressInput) {
108
108
  updateCustomerAddress(id:$id, input:$input) {
@@ -113,4 +113,4 @@ import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}fr
113
113
  mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) {
114
114
  deleteCustomerAddress(id:$id)
115
115
  }
116
- `,W=async t=>await s(q,{method:"POST",variables:{id:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):e.data.deleteCustomerAddress}).catch(f);export{f as a,B as b,j as c,H as d,L as e,s as f,k as g,h,P as i,z as j,Z as k,W as l,a as m,R as n,b as o,Q as r,x as s,O as t,K as u};
116
+ `,W=async t=>await s(q,{method:"POST",variables:{id:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):e.data.deleteCustomerAddress}).catch(f);export{B as a,j as b,H as c,L as d,P as e,s as f,k as g,z as h,Z as i,W as j,a as k,h as l,f as m,b as n,A as o,Q as r,x as s,d as t,K as u};
@@ -0,0 +1,57 @@
1
+ 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=`
2
+ fragment BasicCustomerInfo on Customer {
3
+ date_of_birth
4
+ dob
5
+ email
6
+ firstname
7
+ gender
8
+ lastname
9
+ middlename
10
+ prefix
11
+ suffix
12
+ created_at
13
+ }
14
+ `,D=`
15
+ query GET_CUSTOMER {
16
+ customer {
17
+ ...BasicCustomerInfo
18
+ custom_attributes {
19
+ ... on AttributeValue {
20
+ code
21
+ value
22
+ }
23
+ code
24
+ }
25
+ }
26
+ }
27
+ ${x}`,k=async()=>await d(D,{method:"GET",cache:"no-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):y(t)}).catch(_),q=`
28
+ mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) {
29
+ changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) {
30
+ email
31
+ }
32
+ }
33
+ `,H=async({currentPassword:t,newPassword:a})=>await d(q,{method:"POST",variables:{currentPassword:t,newPassword:a}}).then(r=>{var m,u,c;return(m=r.errors)!=null&&m.length?l(r.errors):((c=(u=r==null?void 0:r.data)==null?void 0:u.changeCustomerPassword)==null?void 0:c.email)||""}).catch(_),F=`
34
+ query GET_STORE_CONFIG {
35
+ storeConfig {
36
+ autocomplete_on_storefront
37
+ minimum_password_length
38
+ required_character_classes_number
39
+ }
40
+ }
41
+ `,W=async()=>await d(F,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):v(t)}).catch(_),V=`
42
+ mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) {
43
+ updateCustomerEmail(email:$email password:$password) {
44
+ customer {
45
+ email
46
+ }
47
+ }
48
+ }
49
+ `,K=async({email:t,password:a})=>await d(V,{method:"POST",variables:{email:t,password:a}}).then(r=>{var m,u,c,i;return(m=r.errors)!=null&&m.length?l(r.errors):((i=(c=(u=r==null?void 0:r.data)==null?void 0:u.updateCustomerEmail)==null?void 0:c.customer)==null?void 0:i.email)||""}).catch(_),B=`
50
+ mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) {
51
+ updateCustomerV2(input:$input) {
52
+ customer {
53
+ email
54
+ }
55
+ }
56
+ }
57
+ `,Q=async t=>await d(B,{method:"POST",variables:{input:I(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(a=>{var r,m,u,c;return(r=a.errors)!=null&&r.length?l(a.errors):((c=(u=(m=a==null?void 0:a.data)==null?void 0:m.updateCustomerV2)==null?void 0:u.customer)==null?void 0:c.email)||""}).catch(_);export{W as a,K as b,Q as c,k as g,H as u};
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { ChangePasswordProps } from '../../types';
3
+
4
+ export declare const ChangePassword: FunctionComponent<ChangePasswordProps>;
5
+ //# sourceMappingURL=ChangePassword.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './ChangePassword';
2
+ export { ChangePassword as default } from './ChangePassword';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { CustomerInformationCardProps } from '../../types';
3
+
4
+ export declare const CustomerInformationCard: FunctionComponent<CustomerInformationCardProps>;
5
+ //# sourceMappingURL=CustomerInformationCard.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformationCard';
2
+ export { CustomerInformationCard as default } from './CustomerInformationCard';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'preact';
2
+ import { EditCustomerInformationProps } from '../../types';
3
+
4
+ export declare const EditCustomerInformation: FunctionComponent<EditCustomerInformationProps>;
5
+ //# sourceMappingURL=EditCustomerInformation.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './EditCustomerInformation';
2
+ export { EditCustomerInformation as default } from './EditCustomerInformation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -10,4 +10,7 @@ export * from './OrdersListCard';
10
10
  export * from './AccountLoaders';
11
11
  export * from './AddressesWrapper';
12
12
  export * from './AddressFormWrapper';
13
+ export * from './ChangePassword';
14
+ export * from './EditCustomerInformation';
15
+ export * from './CustomerInformationCard';
13
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- import{A as l,A as u}from"../chunks/AddressFormWrapper.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";export{l as AddressForm,u as default};
1
+ import{A as l,A as u}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";export{l as AddressForm,u as default};
@@ -1 +1 @@
1
- import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B}from"@dropins/tools/lib.js";import{a as C}from"../chunks/AddressFormWrapper.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const O=({hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,forwardFormRef:a,showSaveCheckBox:c,saveCheckBoxValue:f,selectShipping:n,selectBilling:l,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,showShippingCheckBox:W,showBillingCheckBox:b,shippingCheckBoxValue:g,billingCheckBoxValue:k,onAddressData:q,routeAddressesPage:w,onSuccess:y,onError:z})=>s("div",{className:B(["account-addresses",r]),"data-testid":"addressesid",children:s(C,{hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,onAddressData:q,forwardFormRef:a,selectShipping:n,selectBilling:l,showSaveCheckBox:c,saveCheckBoxValue:f,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,billingCheckBoxValue:k,shippingCheckBoxValue:g,showBillingCheckBox:b,showShippingCheckBox:W,routeAddressesPage:w,onSuccess:y,onError:z})});export{O as Addresses,O as default};
1
+ import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B}from"@dropins/tools/lib.js";import{a as C}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const O=({hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,forwardFormRef:a,showSaveCheckBox:c,saveCheckBoxValue:f,selectShipping:n,selectBilling:l,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,showShippingCheckBox:W,showBillingCheckBox:b,shippingCheckBoxValue:g,billingCheckBoxValue:k,onAddressData:q,routeAddressesPage:w,onSuccess:y,onError:z})=>s("div",{className:B(["account-addresses",r]),"data-testid":"addressesid",children:s(C,{hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,onAddressData:q,forwardFormRef:a,selectShipping:n,selectBilling:l,showSaveCheckBox:c,saveCheckBoxValue:f,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,billingCheckBoxValue:k,shippingCheckBoxValue:g,showBillingCheckBox:b,showShippingCheckBox:W,routeAddressesPage:w,onSuccess:y,onError:z})});export{O as Addresses,O as default};
@@ -0,0 +1,5 @@
1
+ import { CustomerInformationProps } from '../../types';
2
+ import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+
4
+ export declare const CustomerInformation: Container<CustomerInformationProps>;
5
+ //# sourceMappingURL=CustomerInformation.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformation';
2
+ export { CustomerInformation as default } from './CustomerInformation';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './CustomerInformation/index'
2
+ import _default from './CustomerInformation/index'
3
+ export default _default
@@ -0,0 +1 @@
1
+ import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{a as Ce,u as Pe,g as pe,c as ee,b as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length<e.minLength?t?{...l,icon:"error",status:"error"}:{...l,icon:"pending",status:"pending"}:l},[e,r.messageLengthPassword,a==null?void 0:a.length,t]);return{isValidUniqueSymbols:n,defaultLengthMessage:P}},Ae=({handleHideChangePassword:e,handleSetInLineAlert:t,inLineAlertProps:a})=>{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Re=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Re as CustomerInformation,Re as default};