PageSourceSearch

https://www.bodylogicglobal.com/spa-assets/ShopEnrollmentPage-D7sVb8U6.js

js bodylogicglobal.com collected 2026-09-24 23:13:55 UTC 30,524 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-DYa0OnEO.js";import{u as Oe,h as ze,a as o,L as _e}from"./vendor-react-Dabp1iwk.js";import{f as Be}from"./useMoneyFormat-DIPucH4p.js";import{u as Ge,f as Ve,S as ue,o as qe,P as Ue,M as Ke,w as He,m as We,a0 as Ye}from"./main-NH_LOf-E.js";import{u as fe,M as d}from"./vendor-intl-CsoMs0rR.js";import{u as Ee,F as Ie}from"./vendor-form-DkAvd-8k.js";import{u as Qe}from"./ShopContext-TA2AG-TE.js";import{u as Xe}from"./useShopBasePath-ezr8357T.js";import{u as Ze,S as Je,F as Y,a as es,v as ss}from"./useShopFormConfig-B6JxW-lr.js";import{r as ts,d as as}from"./usernameMode-CknP8y87.js";import{S as rs}from"./ShopHelmet-DsFTSJdv.js";import{S as is}from"./ShopBreadcrumb-QgcYo1si.js";import{S as ls}from"./ShopCheckoutStepper-BbAreALA.js";import{i as ns,p as os,d as ds}from"./genericFieldsUtils-DLyE1fHO.js";import{D as ms}from"./DynamicAddressForm-DDePWQYD.js";import{G as cs}from"./GoogleAddressAutocomplete-DxyQYucS.js";import{a as pe}from"./addressUtils-CUFVbD9z.js";import{G as Ce}from"./GroupSelectReact-ByoPkVby.js";import{O as be}from"./OrderEntryBffService-DEyaWyud.js";import{r as us}from"./productFormatters-oEsm3TTK.js";import"./index-T2wezXTF.js";import"./useGatewayPaymentReturn-DKuxpKeW.js";import"./phoneUtils-DXe9y6B0.js";import"./ShopRoutes-Bsb02b5Y.js";import"./ProductsBffService-Dj6xwccx.js";import"./QuantityStepper-1zlUQnWt.js";import"./cartLineIdentity-DjtFau5e.js";import"./useIsMobile-DZ8cDhGP.js";import"./CustomerBffService-B6J6JqqU.js";import"./FormConfigurationError-BfSAI6Fw.js";import"./esm-CLaZnVNX.js";import"./config-DstB3tS0.js";const Re=a=>{const t=/^generic_?field_?(\d{1,2})$/i.exec(a??"");if(!t)return null;const n=Number(t[1]);return n>=1&&n<=20?`genericField${n}`:null},hs=({fields:a,values:t,onChange:n,errors:j={},idPrefix:N})=>{const{formatMessage:I}=fe();if(a.length===0)return null;const c=p=>p?I({id:p}):"";return e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"my-5"}),e.jsx("h4",{className:"fw-bolder fs-5 text-gray-800 mb-5",children:e.jsx(d,{id:"messages.label.newCQ.ExtendedInformation"})}),e.jsx("div",{className:"row g-4",children:a.map(p=>{const y=Re(p.name);if(y===null)return null;const D={type:p.type??void 0,typeCad:p.typeCad??void 0,listValues:p.listValues??void 0},h=ns(D)?os(D.listValues):null,S=ds(D),T=j[y],M=c(p.label);return e.jsx("div",{className:"col-12 col-sm-6",children:e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:`${N}-${y}`,className:`form-label fw-semibold fs-7${p.mandatory?" required":""}`,children:M}),h?e.jsxs("select",{id:`${N}-${y}`,className:`form-select form-select-sm${T?" is-invalid":""}`,value:t[y]??"",onChange:k=>n(y,k.target.value),children:[e.jsx("option",{value:"",children:I({id:"message.selectOne"})}),h.map(k=>e.jsx("option",{value:k,children:I({id:k})},k))]}):e.jsx("input",{id:`${N}-${y}`,type:S?"number":"text",inputMode:S?"numeric":void 0,className:`form-control form-control-sm${T?" is-invalid":""}`,value:t[y]??"",onChange:k=>n(y,k.target.value)}),T&&e.jsx("div",{className:"invalid-feedback d-block",children:T})]})},p.name)})})]})},Te=a=>Ye.sanitize(a,{USE_PROFILES:{html:!0}}),xs=[{key:"personal",labelId:"message.personalInfo",icon:"ki-user",sort:1},{key:"kit",labelId:"messages.label.StartKit",icon:"ki-package",sort:2},{key:"confirm",labelId:"message.review",icon:"ki-check",sort:3}],ps=[{key:"personal",labelId:"message.personalInfo",icon:"ki-user",sort:1}],bs=[{value:"F",labelId:"message.female"},{value:"M",labelId:"message.male"},{value:"U",labelId:"message.label.unspecified"}],fs=({form:a,onChange:t,errors:n,sponsor:j,onSponsorChange:N,terms:I,optionalFields:c,documentTypes:p,termsAccepted:y,onTermsChange:D,onNext:h,phoneConfig:S,addressMethods:T,countryCode:M,isFormMode:k=!1,isSubmitting:Q=!1,submitError:m,emailExists:X,loginPath:te,usernameField:ae,nameFields:re,genericFields:$,genericValues:Z,onGenericChange:he})=>{const ie=fe(),{formatMessage:v}=ie,le=ie.messages["shop.enrollment.documentId.placeholder"]?v({id:"shop.enrollment.documentId.placeholder"}):void 0,w=o.useMemo(()=>ts(ae),[ae]),r=as(w,a);o.useEffect(()=>{!w.editable&&a.username!==r&&t("username",r)},[w.editable,r,a.username,t]);const J=Ee({mode:"onSubmit",defaultValues:{documentType:a.documentType,taxRegimeId:a.taxRegimeId,birthDate:a.birthDate,gender:a.gender}});o.useEffect(()=>{const s=J.watch(x=>{x.documentType!==void 0&&x.documentType!==a.documentType&&t("documentType",String(x.documentType??"")),x.taxRegimeId!==void 0&&x.taxRegimeId!==a.taxRegimeId&&t("taxRegimeId",String(x.taxRegimeId??"")),x.birthDate!==void 0&&x.birthDate!==a.birthDate&&t("birthDate",String(x.birthDate??"")),x.gender!==void 0&&x.gender!==a.gender&&t("gender",String(x.gender??""))});return()=>s.unsubscribe()},[J,t,a.documentType,a.taxRegimeId,a.birthDate,a.gender]);const[V,z]=o.useState((j==null?void 0:j.customerName)??""),[ne,_]=o.useState([]),[L,oe]=o.useState(!1),[E,B]=o.use
1State(!1),[de,q]=o.useState(-1),ee=o.useRef(null),se=o.useCallback(async s=>{if(!s.trim()){_([]),B(!1);return}oe(!0),B(!1);try{const P=(await ue.findConsultants({name:s.trim()})).data,O=((P==null?void 0:P.consultants)??[]).map(U=>({customerName:U.fullname,documentId:U.documentid,internalCode:U.personid!=null?String(U.personid):void 0}));_(O),O.length===0&&B(!0)}catch{_([])}finally{oe(!1)}},[]),me=s=>{if(z(s),j&&N(null),q(-1),ee.current&&clearTimeout(ee.current),!s.trim()){_([]),B(!1);return}ee.current=setTimeout(()=>se(s),400)},H=s=>{N(s),z(s.customerName),_([]),B(!1),q(-1)},ce=()=>{N(null),z(""),_([]),B(!1),q(-1)};return e.jsx("div",{className:"card card-custom shadow-sm",children:e.jsxs("div",{className:"card-body p-6 p-md-8",children:[k&&X&&e.jsxs("div",{className:"alert alert-warning d-flex align-items-center gap-3 mb-6",role:"alert",children:[e.jsx("i",{className:"ki-outline ki-information-5 fs-3 text-warning","aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx(d,{id:"shop.register.error.emailExists"}),te&&e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:te,className:"fw-semibold text-primary",children:e.jsx(d,{id:"shop.register.loginLink"})})]})]})]}),k&&m&&!X&&e.jsxs("div",{className:"alert alert-danger d-flex align-items-center gap-3 mb-6",role:"alert",children:[e.jsx("i",{className:"ki-outline ki-information-3 fs-4 text-danger flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{children:m})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"form-label fw-semibold fs-7",children:e.jsx(d,{id:"message.sponsor"})}),e.jsxs("div",{className:"position-relative",children:[e.jsxs("div",{className:"position-relative",children:[e.jsx("div",{className:"position-absolute top-50 start-0 translate-middle-y ms-3",style:{zIndex:1},children:L?e.jsx("div",{className:"spinner-border spinner-border-sm text-primary",role:"status",children:e.jsx("span",{className:"visually-hidden",children:"..."})}):e.jsx("i",{className:"ki-outline ki-magnifier fs-2 text-gray-500","aria-hidden":"true"})}),e.jsx("input",{type:"text",className:"form-control form-control-sm",style:{height:35,paddingLeft:45,paddingRight:j?40:15},placeholder:v({id:"message.placeholder.seachCustomer"}),value:V,onChange:s=>me(s.target.value),autoComplete:"off"}),j&&e.jsx("button",{type:"button",className:"position-absolute top-50 end-0 translate-middle-y me-2 btn btn-icon btn-sm",style:{width:28,height:28},onClick:ce,tabIndex:-1,"aria-label":v({id:"message.control.clear"}),children:e.jsx("i",{className:"ki-outline ki-cross fs-6","aria-hidden":"true"})})]}),ne.length>0&&e.jsx("div",{className:"position-absolute w-100 bg-white border rounded shadow-lg mt-1",style:{maxHeight:8*48,overflowY:"auto",zIndex:2},children:ne.map((s,x)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer${x===de?" bg-light-info text-primary fw-semibold":" hover-bg-light-info"}`,style:{transition:"all 0.15s ease-in-out"},onMouseEnter:()=>q(x),onMouseLeave:()=>q(-1),onMouseDown:P=>{P.preventDefault(),H(s)},children:[e.jsx("p",{className:"fw-semibold text-gray-800 mb-0 fs-6",children:s.customerName}),e.jsx("p",{className:"text-muted fs-7 mb-0",children:s.documentId})]},`${s.documentId}-${x}`))}),E&&e.jsxs("div",{className:"text-center py-4 border rounded mt-1 bg-white",children:[e.jsx("i",{className:"ki-outline ki-search-list fs-2x text-gray-400 d-block mb-2","aria-hidden":"true"}),e.jsx("div",{className:"text-gray-600 fw-semibold",children:e.jsx(d,{id:"message.label.noRecordsFoundMessage",values:{query:V}})})]})]}),e.jsx("p",{className:"text-muted fs-7 mt-2 mb-0",children:e.jsx(d,{id:"messages.label.formWarnFielSponsor"})})]}),e.jsx("hr",{className:"my-5"}),e.jsx("h3",{className:"fw-bolder fs-4 text-gray-900 mb-6",children:e.jsx(d,{id:"message.personalData"})}),e.jsx(Ie,{...J,children:e.jsxs("div",{className:"row g-4",children:[e.jsx(Je,{fields:re,values:{firstName:a.firstName,middleName:a.middleName,lastName:a.lastName,secondLastName:a.secondLastName},onChange:(s,x)=>t(s,x),errors:n,idPrefix:"enroll"}),e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-email",type:"email",label:v({id:"message.control.email"}),value:a.email,onChange:s=>t("email",s),required:!0,autoComplete:"email",error:n.email,size:"sm"})}),e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-confirmEmail",type:"email",label:v({id:"message.label.confirmEmail"}),value:a.confirmEmail,onChange:s=>
1t("confirmEmail",s),required:!0,autoComplete:"off",error:n.confirmEmail,size:"sm"})}),e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(es,{id:"enroll-phone",label:v({id:"message.label.contactPhone"}),value:a.phone,onChange:s=>t("phone",s),required:!0,error:n.phone,phoneMask:S==null?void 0:S.phoneMask,countryCode:S==null?void 0:S.countryCode})}),c.showDocumentType&&p.length>0&&e.jsx(Ce,{name:"documentType",label:"message.label.documentType",options:p.map(s=>({value:String(s.id),label:s.name})),className:"col-12 col-sm-6"}),c.showDocumentId&&e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-documentId",type:"text",label:v({id:"message.label.documentid"}),value:a.documentId,onChange:s=>t("documentId",s),error:n.documentId,size:"sm",placeholder:le})}),c.showBirthDate&&e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(qe,{id:"enroll-birthDate",label:v({id:"message.birthDate"}),value:a.birthDate,onChange:s=>t("birthDate",s),onChangeISO:s=>t("birthDate",s),inputSize:"sm",name:"birthDate"})}),c.showGender&&e.jsx("div",{className:"col-12 col-sm-6",children:e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"enroll-gender",className:`form-label fw-semibold fs-7${c.genderMandatory?" required":""}`,children:e.jsx(d,{id:"message.gender"})}),e.jsxs("select",{id:"enroll-gender",className:`form-select form-select-sm${n.gender?" is-invalid":""}`,value:a.gender,onChange:s=>t("gender",s.target.value),children:[e.jsx("option",{value:"",children:v({id:"message.label.select"})}),bs.map(s=>e.jsx("option",{value:s.value,children:v({id:s.labelId})},s.value))]}),n.gender&&e.jsx("div",{className:"invalid-feedback",children:n.gender})]})}),c.showRut&&e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-rut",type:"text",label:v({id:"shop.register.rut"}),value:a.rut,onChange:s=>t("rut",s),size:"sm"})}),c.showTaxRegime&&e.jsx(Ce,{name:"taxRegimeId",label:v({id:"shop.register.taxRegime"}),options:c.taxRegimes.map(s=>({value:String(s.id),label:s.name})),className:"col-12 col-sm-6"})]})}),c.showAddress&&M&&e.jsxs(cs,{enabled:!0,children:[e.jsx("hr",{className:"my-5"}),e.jsx(Ie,{...T,children:e.jsx(ms,{addressType:"home",countryCode:M,titleMessageId:"message.label.addressInformation",showLoading:!0})})]}),e.jsx(hs,{fields:$,values:Z,onChange:he,errors:n,idPrefix:"enroll"}),e.jsx("hr",{className:"my-5"}),e.jsx("h4",{className:"fw-bolder fs-5 text-gray-800 mb-5",children:e.jsx(d,{id:"message.label.passwordInfo"})}),e.jsxs("div",{className:"row g-4",children:[w.visible&&e.jsx("div",{className:"col-12 col-sm-6",children:e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"enroll-username",className:"form-label fw-semibold fs-7",children:e.jsx(d,{id:"message.label.user"})}),e.jsx("input",{id:"enroll-username",type:"text",className:"form-control form-control-sm",value:r,onChange:s=>w.editable&&t("username",s.target.value),readOnly:!w.editable,tabIndex:w.editable?void 0:-1}),w.noticeMessageId&&e.jsx("div",{className:"form-text fs-8",children:e.jsx(d,{id:w.noticeMessageId})})]})}),!w.visible&&w.noticeMessageId&&e.jsx("div",{className:"col-12",children:e.jsx("div",{className:"alert alert-light-primary d-flex align-items-center p-0 mb-4",children:e.jsx("span",{className:"fs-7 text-muted",children:e.jsx(d,{id:w.noticeMessageId})})})}),e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-password",type:"password",label:v({id:"message.control.password"}),value:a.password,onChange:s=>t("password",s),required:!0,autoComplete:"new-password",error:n.password,size:"sm"})}),e.jsx("div",{className:"col-12 col-sm-6",children:e.jsx(Y,{id:"enroll-confirmPassword",type:"password",label:v({id:"message.label.confirmPassword"}),value:a.confirmPassword,onChange:s=>t("confirmPassword",s),required:!0,autoComplete:"new-password",error:n.confirmPassword,size:"sm"})})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("hr",{className:"my-5"}),e.jsx("h4",{className:"fw-bolder fs-5 text-gray-800 mb-4",children:e.jsx(d,{id:"message.label.terms"})}),I.type==="TEXT"&&I.content?e.jsx("div",{className:"p-4 rounded border mb-4 fs-7 text-muted",style:{maxHeight:220,overflowY:"auto"},dangerouslySetInnerHTML:{__html:Te(I.content)}}):e.jsx("p",{className:"fs-6 text-muted mb-4",children:e.jsx("a",{href:I.url,target:"_blank",rel:"noreferrer",className:"text-primary fw-semibold",children:e.jsx(d,{id:"shop.enrollment.terms.readLink"})})}),e.jsxs("div",{className:"form-check",children:[e.jsx("input",{id:"enroll-terms",type:"checkbox",className:`form-check-input bg-primary border-0${n.terms?" is-invalid":""}`,checked:y,onChange:s=>D(s.target.checked)}),e.jsx("label",{htmlFor:"enroll-terms",className:"form-check-label fs-7",children:e.jsx(d,{id:"message.label.AceptContract"})}),n.terms&&e.jsx("div",{className:"invalid-feedback",children:n.terms})]})]}),e.jsx("div",{className:"d-flex justify-content-end mt-6",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:h,disabled:k&&Q,children:k&&Q?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),e.jsx(d,{id:"message.saving"})]}):k?e.jsx(d,{id:"message.finish"}):e.jsxs(e.Fragment,{children:[e.jsx(d,{id:"message.pagination.next"}),e.jsx("i",{className:"ki-outline ki-arrow-right fs-6 ms-2","aria-hidden":"true"})]})})})]})})},gs=({kits:a,selectedKitSku:t,onKitSelect:n,onNext:j,onBack:N,formatCurrency:I})=>e.jsx("div",{className:"card card-custom shadow-sm",children:e.jsxs("div",{className:"card-body p-6 p-md-8",children:[a.length===0?e.jsx("p",{className:"text-muted fs-6 mb-6",children:e.jsx(d,{id:"shop.enrollment.kit.none"})}):e.jsx("div",{className:"row g-4 mb-6",children:a.map(c=>{const p=t===c.sku;return e.jsx("div",{className:"col-12 col-md-4",children:e.jsx("button",{type:"button",className:`card w-100 text-start border-2 p-0 cursor-pointer h-100 ${p?"border-gray-900":"border-gray-200"}`,onClick:()=>n(c),"aria-pressed":p,children:e.jsxs("div",{className:"card-body p-5 d-flex flex-column",children:[e.jsx("div",{className:"mb-3 d-flex justify-content-center",children:e.jsxs("div",{className:"position-relative w-150px h-150px",children:[e.jsx("div",{className:"d-flex w-100 h-100 align-items-center justify-content-center",children:e.jsx("i",{className:"ki-outline ki-picture fs-3x text-muted","aria-hidden":"true"})}),e.jsx("img",{src:us(c.imageUrl),alt:c.name,className:"w-150px h-150px position-absolute top-0 start-0",style:{objectFit:"contain"},onError:y=>{y.currentTarget.style.display="none"}})]})}),e.jsx("p",{className:"fw-bolder fs-5 text-gray-900 mb-2",children:c.name}),c.description&&e.jsx("div",{className:"text-muted fs-7 mb-3 flex-grow-1",dangerouslySetInnerHTML:{__html:Te(Ue(c.description))}}),e.jsx("p",{className:"fw-bold text-primary fs-4 mb-0 mt-auto",children:I(c.price,c.currency,c.orderEntryDecimalPlaces??null)})]})})},c.sku)})}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("button",{type:"button",className:"btn btn-primary btn-sm",onClick:N,children:[e.jsx("i",{className:"ki-outline ki-arrow-left fs-6 me-2","aria-hidden":"true"}),e.jsx(d,{id:"shop.enrollment.back"})]}),e.jsxs("button",{type:"button",className:"btn btn-primary btn-sm",onClick:j,disabled:a.length>0&&!t,children:[e.jsx(d,{id:"message.pagination.next"}),e.jsx("i",{className:"ki-outline ki-arrow-right fs-6 ms-2","aria-hidden":"true"})]})]})]})}),js=({personal:a,sponsor:t,selectedKit:n,isSubmitting:j,submitError:N,emailExists:I,loginPath:c,onConfirm:p,onBack:y,formatCurrency:D,addressData:h,showAddress:S})=>e.jsx("div",{className:"card card-custom shadow-sm",children:e.jsxs("div",{className:"card-body p-6 p-md-8",children:[I&&e.jsxs("div",{className:"alert alert-warning d-flex align-items-center gap-3 mb-6",role:"alert",children:[e.jsx("i",{className:"ki-outline ki-information-5 fs-3 text-warning","aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx(d,{id:"shop.register.error.emailExists"})," ",e.jsx(_e,{to:c,className:"fw-semibold text-primary",children:e.jsx(d,{id:"shop.register.loginLink"})})]})]}),N&&e.jsxs("div",{className:"alert alert-danger d-flex align-items-center gap-3 mb-6",role:"alert",children:[e.jsx("i",{className:"ki-outline ki-information-3 fs-4 text-danger flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{children:N})]}),e.jsxs("div",{className:"row g-4",children:[e.jsx("div",{className:`col-12 ${S&&(h!=null&&h.street)?"col-md-4":"col-md-6"}`,children:e.jsxs("div",{className:"bg-light-secondary rounded p-5 h-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-3",children:[e.jsx("i",{className:"ki-outline ki-user fs-4 text-primary","aria-hidden":"true"}),e.jsx("h4",{className:"fw-bolder fs-6 mb-0",children:e.jsx(d,{id:"message.personalInfo"})})]}),e.jsx("p",{className:"mb-1 fw-semibold",children:[a.firstName,a.middleName,a.lastName,a.secondLastName].filter(
1Boolean).join(" ")}),e.jsx("p",{className:"text-muted mb-1 fs-7",children:a.email}),e.jsx("p",{className:"text-muted mb-1 fs-7",children:a.phone}),a.documentId&&e.jsx("p",{className:"text-muted mb-1 fs-7",children:a.documentId}),a.birthDate&&e.jsx("p",{className:"text-muted mb-0 fs-7",children:Ke(a.birthDate)})]})}),S&&h&&h.street&&e.jsx("div",{className:"col-12 col-md-4",children:e.jsxs("div",{className:"bg-light-secondary rounded p-5 h-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-3",children:[e.jsx("i",{className:"ki-outline ki-geolocation fs-4 text-primary","aria-hidden":"true"}),e.jsx("h4",{className:"fw-bolder fs-6 mb-0",children:e.jsx(d,{id:"message.label.addressInformation"})})]}),e.jsxs("p",{className:"mb-1 fw-semibold",children:[h.street,h.exteriorNumber?` #${h.exteriorNumber}`:""]}),h.county&&e.jsx("p",{className:"text-muted mb-1 fs-7",children:h.county}),e.jsx("p",{className:"text-muted mb-1 fs-7",children:[h.city,h.state].filter(Boolean).join(", ")}),e.jsx("p",{className:"text-muted mb-0 fs-7",children:[h.country,h.zipCode].filter(Boolean).join(" ")})]})}),e.jsx("div",{className:`col-12 ${S&&(h!=null&&h.street)?"col-md-4":"col-md-6"}`,children:e.jsxs("div",{className:"bg-light-secondary rounded p-5 h-100",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-3",children:[e.jsx("i",{className:"ki-outline ki-people fs-4 text-primary","aria-hidden":"true"}),e.jsx("h4",{className:"fw-bolder fs-6 mb-0",children:e.jsx(d,{id:"message.sponsor.register"})})]}),(t==null?void 0:t.customerName)&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-1 fw-semibold",children:t.customerName}),e.jsx("p",{className:"text-muted mb-0 fs-7",children:t.documentId})]})]})}),n&&e.jsx("div",{className:"col-12",children:e.jsxs("div",{className:"bg-light-secondary rounded p-5",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-3",children:[e.jsx("i",{className:"ki-outline ki-package fs-4 text-primary","aria-hidden":"true"}),e.jsx("h4",{className:"fw-bolder fs-6 mb-0",children:e.jsx(d,{id:"messages.info.kit"})})]}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsx("p",{className:"fw-semibold mb-0",children:n.name}),e.jsx("p",{className:"fw-bold text-primary mb-0 fs-5",children:D(n.price,n.currency,n.orderEntryDecimalPlaces??null)})]})]})})]}),e.jsxs("div",{className:"d-flex justify-content-between mt-8",children:[e.jsxs("button",{type:"button",className:"btn btn-primary btn-sm",onClick:y,disabled:j,children:[e.jsx("i",{className:"ki-outline ki-arrow-left fs-6 me-2","aria-hidden":"true"}),e.jsx(d,{id:"shop.enrollment.back"})]}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:p,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),e.jsx(d,{id:"message.saving"})]}):e.jsx(d,{id:"message.finish"})})]})]})}),Zs=()=>{var we;const a=fe(),{formatMessage:t}=a,n=Oe(),{distributorSlug:j}=ze(),{consultantProfile:N,isConsultantSite:I,setActiveOrderId:c,refreshCartCount:p,distributorId:y,distributorSlug:D}=Qe(),{saveAuth:h,establishSession:S}=Ge(),T=Xe(),{phoneConfig:M,emailRegex:k,nameFields:Q}=Ze();Ve("shop.join",void 0,{distributorSlug:D??void 0,distributorId:y??void 0});const[m,X]=o.useState(null),[te,ae]=o.useState(!0),re=o.useRef(!1);o.useEffect(()=>{re.current||(re.current=!0,ue.getEnrollmentConfig().then(l=>{const u=l.data;X(u)}).catch(()=>{X({documentTypes:[],starterKits:[],terms:{type:"LINK",url:"/shop/faq",content:""},optionalFields:{showRut:!1,showTaxRegime:!1,showDocumentType:!1,showDocumentId:!1,showBirthDate:!1,showAddress:!1,showGender:!1,genderMandatory:!1,taxRegimes:[]}})}).finally(()=>ae(!1)))},[]);const $=(m==null?void 0:m.registrationWizard)!==!1,Z=$?xs:ps,[he,ie]=o.useState(""),v=((we=m==null?void 0:m.optionalFields)==null?void 0:we.showAddress)===!0;o.useEffect(()=>{v&&be.getAddressConfig().then(l=>{var b;const u=l.data,i=(((b=u==null?void 0:u.data)==null?void 0:b.countryCode)??(u==null?void 0:u.countryCode)??"").toString().trim();i&&ie(i)}).catch(()=>{})},[v]);const[le,w]=o.useState(0),[r,J]=o.useState({firstName:"",middleName:"",lastName:"",secondLastName:"",email:"",confirmEmail:"",username:"",phone:"",password:"",confirmPassword:"",rut:"",taxRegimeId:"",documentType:"",documentId:"",b
1irthDate:"",gender:""}),V=Ee({mode:"onSubmit"}),[z,ne]=o.useState({}),_=o.useCallback((l,u)=>{ne(i=>({...i,[l]:u}))},[]),[L,oe]=o.useState(I&&N?{customerName:N.name,documentId:N.slug,internalCode:N.distributorId??void 0}:null),[E,B]=o.useState(null),[de,q]=o.useState(!1),[ee,se]=o.useState({}),[me,H]=o.useState(!1),[ce,s]=o.useState(null),[x,P]=o.useState(!1),O=o.useRef(!1),U=j?`/auth/login?returnUrl=/shop/${j}/my-orders`:"/auth/login?returnUrl=/shop/my-orders",ge=(l,u,i)=>{const b=Be(l,i,a.locale);return u?`${u} ${b}`:b},je=()=>{const l={},u=k??/^[^\s@]+@[^\s@]+\.[^\s@]+$/;if(Object.assign(l,ss(Q,r,i=>t({id:i}))),(!r.email.trim()||!u.test(r.email))&&(l.email=t({id:"shop.register.error.emailInvalid"})),r.confirmEmail!==r.email&&(l.confirmEmail=t({id:"shop.register.error.emailMismatch"})),!r.phone.trim())l.phone=t({id:"shop.register.error.phoneRequired"});else if(M!=null&&M.phoneMask){const i=(M.phoneMask.match(/9/g)??[]).length;r.phone.replace(/\D/g,"").length<i&&(l.phone=t({id:"shop.register.error.phoneRequired"}))}return r.password.length<8&&(l.password=t({id:"shop.register.error.passwordLength"})),r.password!==r.confirmPassword&&(l.confirmPassword=t({id:"shop.register.error.passwordMismatch"})),ve.forEach(i=>{const b=Re(i.name);b===null||!i.mandatory||(z[b]??"").trim()||(l[b]=t({id:"message.label.fieldRequired"}))}),K.showGender&&K.genderMandatory&&!r.gender.trim()&&(l.gender=t({id:"message.label.fieldRequired"})),de||(l.terms=t({id:"shop.enrollment.error.termsRequired"})),se(l),Object.keys(l).length===0},Ne=()=>{w(l=>Math.min(l+1,Z.length-1)),se({}),window.scrollTo({top:0,behavior:"smooth"})},ye=()=>{w(l=>Math.max(l-1,0)),se({}),window.scrollTo({top:0,behavior:"smooth"})},Me=()=>{if(E&&!E.inStock){He.fire({icon:"warning",title:t({id:"shop.enrollment.error.kitOutOfStock"}),confirmButtonText:t({id:"message.accept"}),customClass:{confirmButton:"btn btn-primary btn-sm"},buttonsStyling:!1});return}Ne()},Le=async()=>{var l;if(je()&&!O.current){O.current=!0,H(!0),s(null),P(!1);try{const u=V.getValues(),i=K.showAddress?pe(u):null,b=i&&((l=i.street)==null?void 0:l.trim()),f=(await ue.enrollConsultant({firstName:r.firstName.trim(),middleName:r.middleName.trim()||void 0,lastName:r.lastName.trim(),secondLastName:r.secondLastName.trim()||void 0,email:r.email.trim().toLowerCase(),phone:r.phone.trim(),password:r.password,sponsorId:(L==null?void 0:L.internalCode)||void 0,rut:r.rut.trim()||void 0,taxRegimeId:r.taxRegimeId||void 0,documentType:r.documentType||void 0,documentId:r.documentId.trim()||void 0,birthDate:r.birthDate||void 0,gender:r.gender||void 0,...z,address:b?{street:i.street,exteriorNumber:i.exteriorNumber||void 0,city:i.city||"",state:i.state||"",country:i.country||"",zipCode:i.zipCode||void 0,label:i.label||void 0,observations:i.observations||void 0,county:i.county||void 0,sublocality:i.sublocality||void 0,geoCode:i.geoCode||void 0,metadata:i.metadata||void 0}:void 0})).data;if(!(f!=null&&f.token)){s((f==null?void 0:f.message)??t({id:"shop.enrollment.error.generic"}));return}await S(f.token,{beforeFinalize:async()=>{await We({icon:"success",title:t({id:"shop.enrollment.welcome"}),confirmText:t({id:"message.accept"})}),window.location.href="/dashboard"}})}catch(u){const i=u==null?void 0:u.response,b=i==null?void 0:i.status,C=i==null?void 0:i.data;if(b===409&&(C==null?void 0:C.errorCode)==="DUPLICATE_DOCUMENT")s(t({id:"duplicateData.document.duplicateDocument"}));else if(b===409)P(!0);else if(b===422&&(C==null?void 0:C.errorCode)==="ADDRESS_CITY_UNRESOLVABLE")s(t({id:"shop.enrollment.error.addressCity"}));else{const f=C==null?void 0:C.message;s(f??t({id:"shop.enrollment.error.generic"}))}}finally{O.current=!1,H(!1)}}},Pe=async()=>{var l,u,i,b,C;if(!O.current){O.current=!0,H(!0),s(null),P(!1);try{const f=E!=null,G=V.getValues(),g=K.showAddress?pe(G):null,R=g&&((l=g.street)==null?void 0:l.trim()),F=(await ue.enrollConsultant({firstName:r.firstName.trim(),middleName:r.middleName.trim()||void 0,lastName:r.lastName.trim(),secondLastName:r.secondLastName.trim()||void 0,email:r.email.trim().toLowerCase(),phone:r.phone.trim(),password:r.password,sponsorId:(L==null?void 0:L.internalCode)||void 0,kitSku:f?E.sku:void 0,kitOecCode:f?E.oecCode:void 0,kitProductId:f?E.productId:void 0,rut:r.rut.trim()||void 0,taxRegimeId:r.taxRegimeId||void 0,documentType:r.documentType||void 0,documentId:r.documentId.trim()||void 0,birthDate:r.birthDate||void 0,gender:r.gender||void 0,...z,address:R?{street:g.street,exteriorNumber:g.exteriorNumber||void 0,city:g.city||"",state:g.state||"",country:g.country||"",zipCode:g.zipCode||void 0,label:g.label||void 0,observations:g.observations||void 0,county:g.county||void 0,sublocality:g.sublocality||void 0,geoCode:g.geoCode||void 0,metadata:g.metadata||void 0}:void 0})).data;if(!(F!=null&&F.token)){s((F==null?void 0:F.message)??t({id:"shop.enrollment.error.generic"}));return}if(h(F.token),f&&((u=F.selectedKit)!=null&&u.sku))try{const A=(await be.startOrder({customerId:F.userId,orderType:"registry",forceNew:!0})).data,W=((i=A==null?void 0:A.data)==null?void 0:i.orderId)??(A==null?void 0:A.orderId);if(W){c(W),await be.addToCart(W,F.selectedKit.sku,1),await p(W),n(`${T}/checkout`,{replace:!0});return}}catch(ke){const A=ke,W=(C=(b=A==null?void 0:A.response)==null?void 0:b.data)==null?void 0:C.message;s(W??t({id:"shop.enrollment.error.kitAddFailed"}));return}n(T,{replace:!0})}catch(f){const G=f==null?void 0:f.response,g=G==null?void 0:G.status,R=G==null?void 0:G.data;
1if(g===409&&(R==null?void 0:R.errorCode)==="DUPLICATE_DOCUMENT")s(t({id:"duplicateData.document.duplicateDocument"}));else if(g===409)P(!0);else if(g===422&&(R==null?void 0:R.errorCode)==="ADDRESS_CITY_UNRESOLVABLE")w(0),s(t({id:"shop.enrollment.error.addressCity"}));else{const Se=R==null?void 0:R.message;s(Se??t({id:"shop.enrollment.error.generic"}))}}finally{O.current=!1,H(!1)}}},Fe=(m==null?void 0:m.terms)??{type:"LINK",url:"/shop/faq",content:""},K=(m==null?void 0:m.optionalFields)??{showRut:!1,showTaxRegime:!1,showDocumentType:!1,showDocumentId:!1,showBirthDate:!1,showAddress:!1,showGender:!1,genderMandatory:!1,taxRegimes:[]},Ae=(m==null?void 0:m.documentTypes)??[],ve=o.useMemo(()=>(m==null?void 0:m.genericFields)??[],[m]),De=o.useMemo(()=>(m==null?void 0:m.starterKits)??[],[m]),xe=Z[le],$e=()=>{var l;switch(xe==null?void 0:xe.key){case"personal":return e.jsx(fs,{form:r,onChange:(u,i)=>J(b=>({...b,[u]:i})),errors:ee,sponsor:L,onSponsorChange:oe,terms:Fe,optionalFields:K,documentTypes:Ae,termsAccepted:de,onTermsChange:q,onNext:$?()=>{je()&&Ne()}:Le,phoneConfig:M,addressMethods:V,countryCode:he,usernameField:((l=m==null?void 0:m.loginConfig)==null?void 0:l.username)??{fieldName:"username",label:"message.label.user",mode:"EMAIL"},nameFields:Q,genericFields:ve,genericValues:z,onGenericChange:_,isFormMode:!$,isSubmitting:me,submitError:$?void 0:ce,emailExists:$?void 0:x,loginPath:$?void 0:U});case"kit":return e.jsx(gs,{kits:De,selectedKitSku:(E==null?void 0:E.sku)??"",onKitSelect:B,onNext:Me,onBack:ye,formatCurrency:ge});case"confirm":return e.jsx(js,{personal:r,sponsor:L,selectedKit:E,isSubmitting:me,submitError:ce,emailExists:x,loginPath:U,onConfirm:Pe,onBack:ye,formatCurrency:ge,addressData:K.showAddress?pe(V.getValues()):null,showAddress:K.showAddress});default:return null}};return te?e.jsx("div",{className:"d-flex justify-content-center align-items-center py-16",children:e.jsx("span",{className:"spinner-border text-primary",role:"status","aria-hidden":"true"})}):e.jsxs("div",{className:"container-fluid py-4 py-md-6",children:[e.jsx(rs,{titleKey:"shop.enrollment.title"}),e.jsx(is,{crumbs:[{label:t({id:"message.home"}),to:T},{label:t({id:"shop.enrollment.title"})}]}),$&&e.jsx("div",{className:"mb-5",children:e.jsx(ls,{steps:Z.map(l=>({key:l.key,label:t({id:l.labelId}),icon:l.icon,sort:l.sort})),currentIndex:le})}),$e()]})};export{Zs as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.