import{a2 as I,j as e,ad as z,A as u,z as T,ac as C,V as g,b as v,r as k,d1 as L,m as F,i as y,I as R,d4 as G,bY as O,bV as V,aw as b}from"./index-DnB1XXdB.js";import{S as E}from"./Select-RXijXI1w.js";import{u as D,a as H,b as U}from"./styles-Ph5RSrcV.js";import{a as P,H as $,W as M,P as W}from"./Work-D3nWOd1G.js";import{P as A}from"./Phone-SkqePKWB.js";import{A as X}from"./Add-Dmtzz_h1.js";import{useFormikContext as Y,FastField as f}from"./formik.esm-CViySNZ7.js";import{A as K}from"./Accordion-B6z9hydE.js";import{F as q}from"./Switch-BWuGlUof.js";import{_ as J}from"./usePlacesAutocompleteService-BE2Z_pob.js";import{M as N}from"./schema-DL3SvpT6.js";const Q=I(e.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");function Z({variant:t="outlined",small:n=!0,children:o=null,className:a="",...s}){const r=D();return t==="text"?e.jsx(z,{variant:"text",disableRipple:!0,className:u([r.button,"text",a]),...s,children:o}):e.jsx(T,{variant:t,className:u([r.button,{small:n},a]),...s,children:o})}function ee({children:t=null,label:n="",style:o={},required:a=!1,...s}){const r=H(s);return e.jsxs("div",{className:r.root,style:o,children:[!!n&&e.jsxs("p",{className:r.label,children:[n,a&&" *"]}),e.jsx(E,{...s,style:{width:"100%"},children:t})]})}function te({disabled:t,field:{onBlur:n,...o},form:{isSubmitting:a},onBlur:s,helperText:r,...m}){return{variant:m.variant,disabled:t??a,onBlur:s??function(l){n(l??o.name)},...o,...m}}function Ne(t){return e.jsx(ee,{...te(t)})}function oe({classes:t,...n}){return e.jsxs(E,{...n,className:t.select,renderValue:o=>{const a={cell:e.jsx(P,{className:u([t.iconLabel,"cell"])}),home:e.jsx($,{className:u([t.iconLabel,"home"])}),work:e.jsx(M,{className:u([t.iconLabel,"work"])}),fax:e.jsx(W,{className:u([t.iconLabel,"fax"])}),other:e.jsx(A,{className:u([t.iconLabel,"other"]),size:22})};return e.jsx("div",{className:t.selectValue,children:e.jsx("div",{className:t.iconWrapper,children:a[o]})})},children:[e.jsxs(C,{value:"cell",children:[e.jsx("div",{className:t.iconWrapper,children:e.jsx(P,{className:u([t.iconLabel,"cell"])})}),e.jsx(g,{id:"common.phoneTypes.cell"})]}),e.jsxs(C,{value:"home",children:[e.jsx("div",{className:t.iconWrapper,children:e.jsx($,{className:u([t.iconLabel,"home"])})}),e.jsx(g,{id:"common.phoneTypes.home"})]}),e.jsxs(C,{value:"work",children:[e.jsx("div",{className:t.iconWrapper,children:e.jsx(M,{className:u([t.iconLabel,"work"])})}),e.jsx(g,{id:"common.phoneTypes.work"})]}),e.jsxs(C,{value:"fax",children:[e.jsx("div",{className:t.iconWrapper,children:e.jsx(W,{className:u([t.iconLabel,"fax"])})}),e.jsx(g,{id:"common.phoneTypes.fax"})]}),e.jsxs(C,{value:"other",children:[e.jsx("div",{className:t.iconWrapper,children:e.jsx(A,{className:u([t.iconLabel,"other"]),size:22})}),e.jsx(g,{id:"common.phoneTypes.other"})]})]})}function se({classes:t,index:n,value:o={},error:a="",onChange:s=()=>{},onDelete:r=()=>{},hasText:m}){const d=v(),[l,c]=k.useState(o),h=(p,i=!1)=>x=>{const w={...l,[p]:x.target.value};c(w),i&&s(w)},j=()=>{s(l)};return e.jsxs("div",{className:t.item,children:[e.jsx("div",{className:t.labelWrapper,children:e.jsxs("p",{className:t.label,children:[e.jsx(g,{id:"common.phone"}),` ${typeof n>"u"?"":n+1}`]})}),e.jsxs("div",{className:t.inputsWrapper,children:[e.jsx(oe,{value:l.type,onChange:h("type",!0),classes:t}),m&&e.jsx(L,{className:t.input,error:!!a.text,helperText:a.text,value:l.text,onChange:h("text"),onBlur:j,placeholder:d.formatMessage({id:"common.placeholder.label"}),inputProps:{maxLength:100}}),e.jsx(L,{className:t.input,error:!!a.phone,helperText:a.phone,value:l.phone,onChange:h("phone"),onBlur:j,placeholder:d.formatMessage({id:"common.placeholder.phone"}),inputProps:{maxLength:40}}),e.jsx("button",{type:"button",className:t.delete,onClick:r,children:e.jsx(Q,{})})]})]})}function ne({classes:t={},arrayHelpers:n,id:o="",value:a,errors:s,name:r="",hasText:m=!0,buttonVariant:d="outlined",smallButton:l=!0}){const c=U({classes:t}),h=o||Date.now(),j=()=>{n.push({id:`${h}-phone-${Date.now()}`,type:"work",phone:"",...m?{text:""}:{}})};return e.jsx("div",{className:c.root,children:e.jsx("div",{className:c.wrapper,children:e.jsxs("div",{className:c.container,children:[e.jsxs("div",{className:c.list,children:[(a||[]).map((p,i)=>{const x=p.id||`Phones-Phone--${h}-${r}-phone-${i.toString()}`;return e.jsx(se,{classes:c,error:(s||[])[i],value:p,hasText:m,onDelete:()=>n.remove(i),onChange:w=>n.replace(i,w)},x)}),typeof s=="string"&&!!s&&e.jsx("p",{className:u([c.messageError,"error-message"]),children:s})]}),e.jsx("div",{className:c.controls,children:e.jsxs(Z,{variant:d,small:l,onClick:j,children:[e.jsx(X,{}),e.jsx(g,{id:"common.addPhone"})]})})]})})})}function ve(t){function n(o){return e.jsx(ne,{...t,arrayHelpers:o})}return n}const ae=F(()=>({root:{width:"100%"},simpleTitle:{display:"block",color:y.black,fontSize:16,fontWeight:600,lineHeight:"22px",marginBottom:9},simpleContainer:{display:"grid",gap:22}}),"Location-Wrapper"),re=F((t,n,o)=>({root:{borderRadius:4,backgroundColor:y.secondary.lightBlue,padding:12,display:"flex",alignItems:"center",[t.breakpoints.only("xs")]:{padding:" 16px 12px"}},selector:{...R.centerFlexI,flex:1,height:52,border:`3px solid ${y.gray.normal}`,borderRadius:8,backgroundColor:y.white,color:y.gray.normal,[t.breakpoints.only("xs")]:{width:"auto",flex:1},[`&.${o.selector} + .${o.selector}`]:{marginLeft:11,[t.breakpoints.only("xs")]:{marginLeft:12}},[`&.${o.selected}`]:{borderColor:y.primary.blue,color:y.black}},selected:{}}),"Location-TypeSelector"),le=F(()=>({root:{width:"100%",display:"flex",alignItems:"flex-end"},buttonWrapper:{},button:{height:50,minWidth:0,width:150,marginLeft:12},inputWrapper:{position:"relative",flex:1},menu:{position:"absolute",width:"100%",borderRadius:4,overflowX:"hidden",overflowY:"auto",zIndex:1300,maxHeight:300,padding:8,paddingRight:0,top:"calc(100% + 4px)",left:0,boxShadow:G}}),"Location-GoogleAutoComplete"),_=F((t,n,o)=>({root:{width:"100%"},label:{display:"block",color:y.gray.darkest,fontSize:13,fontWeight:600,lineHeight:"18px",marginBottom:9},fullForm:{display:"flex",flexDirection:"column",gap:"12px"},row:{display:"flex",gap:"12px"},street:{flexShrink:0,width:"calc((100% - 12px) / 2)"},number:{[`&.${o.streetNumberFirst}`]:{order:-1}},streetNumberFirst:{},smallField:{maxWidth:250},switchWrapper:{marginTop:12},hidden:{display:"none"}}),"Location-FullAddress");function Se({type:t="accordion",children:n,accordionProps:o={}}){const a=ae(),r=v().formatMessage({id:"builder.formsStep2.location.label"}),{values:m}=Y(),{expanded:d,disabled:l,defaultExpanded:c}=o,h=typeof d!="function"?d:d(m),[j,p]=k.useState(!l&&(typeof d>"u"?c:h));if(k.useEffect(()=>{p(!l&&(typeof d>"u"?c:h))},[l]),t==="accordion"){const{onToggleExpand:i}=o,x={disabled:typeof l!="function"?l:l(m),expanded:j,onChange:(w,B)=>p(B)};return typeof d<"u"&&(x.expanded=!x.disabled&&d,x.onChange=i),e.jsx(K,{title:r,...x,children:n})}return e.jsxs("div",{className:a.root,children:[e.jsx("p",{className:a.simpleTitle,children:r}),e.jsx("div",{className:a.simpleContainer,children:n})]})}function Ce({value:t="full",onChange:n=()=>{}}){const o=re(),a=v(),s=[{type:"full",label:a.formatMessage({id:"builder.formsStep2.location.types.full"})},{type:"url",label:a.formatMessage({id:"builder.formsStep2.location.types.url"})},{type:"coordinates",label:a.formatMessage({id:"builder.formsStep2.location.types.coordinates"})}];return e.jsx("div",{className:o.root,children:s.map(r=>e.jsx("button",{type:"button",className:u(o.selector,{[o.selected]:r.type===t}),onClick:()=>n(r.type),children:r.label},`location-typeselector--${r.type}`))})}const S=(t,n,o="long_name")=>{const a=t.address_components.find(s=>s.types.includes(n));return a?a[o]:""};function ie({name:t,change:n=()=>{},disabled:o=!1}){const a=v(),s=le(),r=p=>{n({customData:{name:t,value:p}})},[m,d]=k.useState(!1),{placesService:l,placePredictions:c,getPlacePredictions:h}=J({apiKey:"AIzaSyDIM-M0SGbPGAOUn5zt93b3e9nXzpjmCy0"}),j=p=>{l==null||l.getDetails({placeId:p},i=>{const x={street:S(i,"route","short_name"),number:S(i,"street_number"),city:S(i,"locality"),state:S(i,"administrative_area_level_1","short_name"),country:S(i,"country"),postalCode:S(i,"postal_code")};r(x)})};return e.jsxs("div",{className:s.root,children:[e.jsxs("div",{className:s.inputWrapper,children:[e.jsx(L,{id:"location-google-input",type:"text",label:a.formatMessage({id:"builder.formsStep2.location.placeholder.googleInput"}),disabled:o,onFocus:()=>d(!0),onBlur:()=>d(!1),onChange:p=>{const i=p.target.value.trim();i&&i.length>2&&h({input:i})}}),e.jsx(O,{in:!!(c!=null&&c.length)&&m,unmountOnExit:!0,children:e.jsx(V,{className:s.menu,children:c.map((p,i)=>e.jsx(C,{onClick:()=>j(p==null?void 0:p.place_id),children:p.description},`AddressAutocomplete-placePredictions--${i.toString()}`))})})]}),e.jsx("div",{className:s.buttonWrapper,children:e.jsx(T,{variant:"outlined",size:"small",className:s.button,onClick:()=>{r(o?void 0:{streetNumberFirst:!1,street:"",number:"",postalCode:"",city:"",state:"",country:""})},children:o?e.jsx(g,{id:"builder.formsStep2.location.fullAddress.clear"}):e.jsx(g,{id:"builder.formsStep2.location.fullAddress.manual"})})})]})}const ce=t=>!t||t.type!=="full"?!0:!t.data||!Object.prototype.hasOwnProperty.call(t.data,"street");function we({name:t="address",value:n,change:o=()=>{}}){const a=v(),s=_(),r=ce(n),m=!!(n!=null&&n.streetNumberFirst);return e.jsxs("div",{className:s.root,children:[e.jsx(ie,{name:t,change:o,disabled:!r}),!r&&e.jsxs("div",{className:s.fullForm,children:[e.jsx("div",{className:s.row,children:e.jsx(f,{id:"location-streetNumberFirst",type:"checkbox",name:`${t}.streetNumberFirst`,label:a.formatMessage({id:"builder.formsStep2.vcard.info.streetNumberFirst.label"}),component:q,onChange:o})}),e.jsxs("div",{className:s.row,children:[e.jsx(f,{simpleErrors:!0,id:"location-street",type:"text",name:`${t}.street`,label:a.formatMessage({id:"builder.formsStep2.location.placeholder.street"}),inputProps:{maxLength:N.street},component:b,onChange:o,className:s.street}),e.jsx(f,{simpleErrors:!0,id:"location-number",type:"text",name:`${t}.number`,className:u([s.smallField,s.number],{[s.streetNumberFirst]:m}),label:a.formatMessage({id:"builder.formsStep2.location.placeholder.number"}),inputProps:{maxLength:N.number},component:b,onChange:o}),e.jsx(f,{simpleErrors:!0,id:"location-postalCode",type:"text",name:`${t}.postalCode`,className:s.smallField,label:a.formatMessage({id:"builder.formsStep2.location.placeholder.postalCode"}),inputProps:{maxLength:N.postalCode},component:b,onChange:o})]}),e.jsxs("div",{className:s.row,children:[e.jsx(f,{simpleErrors:!0,id:"location-city",type:"text",name:`${t}.city`,label:a.formatMessage({id:"builder.formsStep2.location.placeholder.city"}),inputProps:{maxLength:N.city},component:b,onChange:o}),e.jsx(f,{simpleErrors:!0,id:"location-state",type:"text",name:`${t}.state`,label:a.formatMessage({id:"builder.formsStep2.location.placeholder.state"}),inputProps:{maxLength:N.state},component:b,onChange:o})]}),e.jsx("div",{className:s.row,children:e.jsx(f,{simpleErrors:!0,id:"location-country",type:"text",name:`${t}.country`,label:a.formatMessage({id:"builder.formsStep2.location.placeholder.country"}),inputProps:{maxLength:N.country},component:b,onChange:o})})]})]})}function ke({name:t="address",change:n=()=>{}}){const o=v();return e.jsx(f,{simpleErrors:!0,id:"location-url",type:"text",name:`${t}.url`,label:o.formatMessage({id:"builder.formsStep2.location.types.url"}),placeholder:"https://...",component:b,onChange:n})}function Fe({name:t="address",change:n=()=>{}}){const o=v(),a=_(),s=r=>m=>{const{target:d,customData:l}=m,c=l||d;r({customData:{name:c.name,value:c.value.replace(",",".")}})};return e.jsxs("div",{className:a.row,children:[e.jsx(f,{simpleErrors:!0,id:"location-latitude",type:"number",name:`${t}.latitude`,label:o.formatMessage({id:"builder.formsStep2.location.types.latitude"}),component:b,onChange:s(n),inputProps:{maxLength:N.latlong}}),e.jsx(f,{simpleErrors:!0,id:"location-longitude",type:"number",name:`${t}.longitude`,label:o.formatMessage({id:"builder.formsStep2.location.types.longitude"}),component:b,onChange:s(n),inputProps:{maxLength:N.latlong}})]})}export{Z as B,Fe as C,Ne as F,Ce as T,ke as U,Se as W,we as a,Q as b,ve as f};