import{a as $,C as H,k as L,b as S,O as K,o as R,m as c,g as d,p as o,n as _,D as r,u as a,w as U,F as Z,H as j,M as q,ac as J,I as Q}from"./convert-case-to-camel-case.utils-DDUpNI96.js";import{a as y,_ as W}from"./ThankYouPage-bf4cLsjC.js";import{c as X,n as Y,m as ee,d as te}from"./widget-BUAABBRb.js";import{L as oe,u as ae}from"./index-DWn1DH8g.js";import{u as se}from"./translationsStore-DBJu9sBR.js";import{_ as le}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CEuXXsrq.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";const ie={class:"ccb-multiply-location"},ne={class:"ccb-multiply-location__input-wrapper"},ce={class:"label"},de={class:"ccb-multiply-location__description"},re={key:0},ue={key:1,class:"ccb-multiply-location__adressname"},pe={class:"ccb-location-modal"},me={class:"ccb-location-modal__body"},_e={class:"ccb-location-modal__sidebar"},ve={class:"ccb-location-modal__title"},ge={class:"ccb-location-modal__locations"},be=["name","value","checked"],fe={class:"ccb-radio-label"},ye=["id"],he={class:"ccb-location-modal__footer"},ke=$({__name:"MultiplyLocation",props:{field:{}},setup(C){const v=X(),w=Y(),i=se(),M=ee(),N=te(),x=C,{field:e}=H(x),g=L(),{getGoogleApiKey:F,mapOptions:T,generateId:B,parseLocationCoordinates:n,generateGoogleLink:V,getMeasure:I,getPickUpIconPath:h}=ae(),D=new oe({apiKey:F(),version:"weekly",libraries:["places","geometry"]});let k=B(4),b=L(!0);const A=()=>{g.value.showPopup()},u=()=>{g.value.hidePopup()};let p;const E=()=>{let t=e.value.multiplyLocations[0].coordinates;D.load().then(()=>{const s=document.getElementById(k);s&&(p=new google.maps.Map(s,{...T(),center:{...n(t)}}),P.value.forEach(l=>{let m={position:n(l.coordinates),map:p};h()&&(m.icon={url:h(),scaledSize:new google.maps.Size(40,40)}),new google.maps.Marker(m)}))})},G=()=>{let t=e.value.multiplyLocations[0].coordinates;e.value.selectedPoint={addressName:"",coordinates:t,label:""},b.value=!0,f(),u()},O=()=>{if(e.value.selectedPoint.addressName){b.value=!1;const t={addressName:e.value.selectedPoint.addressName,coordinates:n(e.value.selectedPoint.coordinates),addressLink:V(n(e.value.selectedPoint.coordinates)),measure:I()};e.value.userSelectedOptions=t,f(),u()}else u()},z=S(()=>{let t=e.value.selectedPoint.label||e.value.selectedPoint.addressName||"";return t.length>15?t.slice(0,25)+"...":t}),f=(t,s)=>{t&&t!==e.value.alias||(e.value.displayValue=z.value,v.updateField(e.value.alias,e.value,s),w.applyConditionForField(e.value.alias),v.getPageBreakEnabled&&v.getActivePage.action==="not_skip"&&N.checkPageFieldsConditions())};M.add("updateGeolocation",t=>{setTimeout(()=>{f(t,!0)},100)});const P=S(()=>Array.isArray(e.value.multiplyLocations)?e.value.multiplyLocations:[]);return K(()=>e.value.selectedPoint,t=>{t&&t.coordinates&&(p.panTo(n(t.coordinates)),p.setZoom(15))},{deep:!0}),R(()=>{E()}),(t,s)=>(d(),c("div",ie,[o("div",ne,[o("button",{class:"ccb-multiply-location__action",onClick:A},[s[1]||(s[1]=o("span",{class:"icon"},[o("i",{class:"ccb-icon-location"})],-1)),o("span",ce,r(a(i).getTranslations.openMap),1)]),o("div",de,[!a(e).selectedPoint.addressName&&!a(e).selectedPoint.label?(d(),c("span",re,r(a(i).getTranslations.chooseFromMap),1)):(d(),c("span",ue,r(a(e).selectedPoint.addressName||a(e).selectedPoint.label),1))])]),_(W,{ref_key:"popup",ref:g},{default:U(()=>[o("div",pe,[o("div",me,[o("div",_e,[o("div",ve,r(a(i).getTranslations.selectLocation),1),o("div",ge,[(d(!0),c(Z,null,j(P.value,l=>(d(),c("div",{key:l.addressName,class:"ccb-default-radio"},[o("label",null,[q(o("input",{"onUpdate:modelValue":s[0]||(s[0]=m=>a(e).selectedPoint=m),type:"radio",name:l.label,value:l,checked:a(e).selectedPoint.coordinates===l.coordinates},null,8,be),[[J,a(e).selectedPoint]]),o("span",fe,r(l.label.length?l.label:l.addressName),1)])]))),128))])]),o("div",{id:a(k),class:"ccb-location-modal__map"},null,8,ye)]),o("div",he,[_(y,{type:"light",text:a(i).getTranslations.clearLocation,class:Q(["clear",{disable:a(b)}]),onClick:G},null,8,["text","class"]),_(y,{type:"light",text:a(i).getTranslations.cancel,onClick:u},null,8,["text"]),_(y,{type:"success",text:a(i).getTranslations.saveLocation,onClick:O},null,8,["text"])])])]),_:1},512)]))}}),Te=le(ke,[["__scopeId","data-v-21d067b2"]]);export{Te as default};
//# sourceMappingURL=MultiplyLocation-CgwPZ4kK.js.map
