PageSourceSearch

https://reshenie.biz/wp-content/plugins/cost-calculator-builder/fr…/vue3/dist/assets/TwoPoints-BSCHqoq5.js

js reshenie.biz collected 2026-10-07 18:15:55 UTC 10,032 bytes, 2 lines download raw bytes

1import{a as fe,t as _e,l as w,o as Z,b as C,n as E,g as G,q as n,p as F,v as g,u as i,E as R,w as he,G as ee,I as oe,A as we}from"./convert-case-to-camel-case.utils-B96Ovk8c.js";import{_ as K,b as ye}from"./ThankYouPage-DHaQSOkm.js";import{n as Ne,f as be,j as Ce,p as Le,o as Se}from"./widget-DYNY5uv3.js";import{L as ke,u as Pe}from"./index-4dvs59fm.js";import{u as Te}from"./translationsStore-Bq8ZrLB6.js";import{_ as xe}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./jquery-C7OTzgKr.js";const Fe={class:"ccb-two-points-location"},Ie={class:"ccb-two-points-location__input-wrapper"},Me={class:"label"},De={class:"ccb-two-points-location__description"},$e={key:0},Oe={key:1,class:"ccb-two-points-location__adressname"},Ve={class:"ccb-location-modal"},Be={class:"ccb-location-modal__body"},Ae={class:"ccb-location-modal__sidebar"},Ee={class:"ccb-location-modal__inputs"},Ge={class:"ccb-location-modal__input"},Re={for:"latitude"},Ke=["id","placeholder"],qe={class:"ccb-location-modal__input"},je={for:"longitude"},Ue=["id","placeholder"],ze={class:"ccb-location-modal__distance"},He=["id"],Je={class:"ccb-location-modal__footer"},Qe=fe({__name:"TwoPoints",props:{field:{}},setup(te){const ae=te,{field:o}=_e(ae),se=Le(),q=Ne(),y=be(),j=Se(),c=Te(),U=Ce(),I=w(),{getGoogleApiKey:ne,mapOptions:le,generateId:ie,getMeasure:k,getMarkerIconPath:z,calculateValueByEachCost:re,eachCost:ce,generateGoogleLink:H}=Pe();let L=ie(4),P=w({lat:51.554867,lng:-.109112}),e=w({from:{addressName:"",coordinates:{lat:0,lng:0}},to:{addressName:"",coordinates:{lat:0,lng:0}}}),m=w(""),N=w("from"),f=w(null),v=w({from:null,to:null});const de=new ke({apiKey:ne(),version:"weekly",libraries:["places","geometry"]});Z(()=>{o.value.displayValue&&(e.value.from.addressName=o.value.userSelectedOptions.twoPoints.from.addressName,e.value.to.addressName=o.value.userSelectedOptions.twoPoints.to.addressName,setTimeout(()=>{e.value.from.coordinates=o.value.userSelectedOptions.twoPoints.from.coordinates,e.value.to.coordinates=o.value.userSelectedOptions.twoPoints.to.coordinates,m.value=o.value.userSelectedOptions.distance,P.value=o.value.userSelectedOptions.twoPoints.from.coordinates,P.value=o.value.userSelectedOptions.twoPoints.to.coordinates,D("from",o.value.userSelectedOptions.twoPoints.from.coordinates),D("to",o.value.userSelectedOptions.twoPoints.to.coordinates),$()},100))}),Z(()=>{"geolocation"in navigator?navigator.geolocation.getCurrentPosition(t=>{const a=t.coords.latitude,s=t.coords.longitude;let l={lat:a,lng:s};P.value=l,M()},()=>{M()}):M()});let T;const M=()=>{de.load().then(async()=>{const{Map:t}=await google.maps.importLibrary("maps");T=new t(document.getElementById(L),{...le(),mapId:L,center:{...P.value}});const a=document.getElementById(B.value),s=document.getElementById(A.value),l=new google.maps.places.SearchBox(a),r=new google.maps.places.SearchBox(s);l.addListener("places_changed",()=>{Q(l,"from")}),r.addListener("places_changed",()=>{Q(r,"to")}),google.maps.event.addListener(T,"click",d=>{if(N){const p={lat:d.latLng?d.latLng.lat():0,lng:d.latLng?d.latLng.lng():0};e.value[N.value].coordinates=p,D(N.value,p);const _=N.value==="from"?B.value:A.value;new google.maps.Geocoder().geocode({location:d.latLng},(u,x)=>{var b;if(x==="OK"&&u&&u.length>0){const S=u[0].formatted_address;(b=document.getElementById(_))==null||b.setAttribute("value",S),e.value[N.value].addressName=S,e.value.from.coordinates&&e.value.to.coordinates&&$()}else console.error("Geocoding failed:",x)})}})})},ue=()=>{V.value&&ve()},ve=()=>{o.value.value=parseFloat(re(parseFloat(m.value),Y.value).toFixed(2)),o.value.displayValue=ge.value,o.value.extraDisplayView=[`${c.getTranslations.from}: ${e.value.from.addressName.length>30?e.value.from.addressName.slice(0,30)+"...":e.value.from.addressName}`,`${c.getTranslations.toDestination}: ${e.value.to.addressName.length>34?e.value.to.addressName.slice(0,34)+"...":e.value.to.addressName}`,`${X.value}`];const t={distance:m.value,distance_view:X.value,measure:k(),eachCost:o.value.eachCost,twoPoints:{from:{addressName:e.value.from.addressName,coordinates:e.value.from.coordinates,addressLink:H(e.value.from.coordinates)},to:{addressName:e.value.to.addressName,coordinates:e.value.to.coordinates,addressLink:H(e.value.to.coordinates)}}};o.value.userSelectedOptions=t,y.updateField(o.value.alias,o.value),q.applyConditionForField(o.value.alias),y.getPageBreakEnabled&&y.getActivePage.action==="not_skip"&&U.checkPageFieldsConditions(),O()},J=t=>{N.value=t},me=()=>{o.value.userSelectedOptions={},Object.values(v.value).forEach(t=>{t&&(t.map=null)}),v.value.from=null,v.value.to=null,f.value!==null&&f.value.setMap(null),m.value="0",e.value={from:{addressName:"",coordinates:{lat:0,lng:0}},to:{addressName:"",coordinates:{lat:0,lng:0}}},o.value.value=0,o.value.displayValue="",o.value.extraDisplayView=[],y.updateField(o.value.alias,o.value),q.applyConditionForField(o.value.alias),y.getPageBreakEnabled&&y.getActivePage.action==="not_skip"&&U.checkPageFieldsConditions(),O()},D=async(t,a)=>{t==="from"&&v.value.from?(v.value.from.map=null,v.value.from=null):t==="to"&&v.value.to&&(v.value.to.map=null,v.value.to=null);const s=document.createElement("img");s.style.width="40px",s.style.height="40px",s.src=z();const{AdvancedMarkerElement:l}=await google.maps.importLibrary("marker"),r=new l({position:a,map:T});z()&&(r.content=s),t==="from"?v.value.from=r:v.value.to=r},Q=(t,a)=>{var p,_,h,u;const s=t.getPlaces()||[];if(!Array.isArray(s)||(s==null?void 0:s.length)===0)return;const l=s[0],r={lat:((_=(p=l==null?void 0:l.geometry)==null?void 0:p.location)==null?void 0:_.lat())||0,lng:((u=(h=l==null?void 0:l.geometry)==null?void 0:h.location)==null?void 0:u.lng())||0},d=l.formatted_address;e.value[a].coordinates={lat:r.lat,lng:r.lng},e.value[a].addressName=d||"",e.value.from.coordinates&&e.value.to.coordinates&&$()},$=async()=>{try{const t=await W();m.value=t,f.value&&(f.value.setMap(null),f.value=null);const a=new google.maps.DirectionsService;f.value=new google.maps.DirectionsRenderer({suppressMarkers:!0}),f.value&&f.value.setMap(T);const s=[{location:e.value.from.coordinates,stopover:!0},{location:e.value.to.coordinates,stopover:!0}],l=new google.maps.LatLng(e.value.from.coordinates),r=new google.maps.LatLng(e.value.to.coordinates),d={origin:l,destination:r,waypoints:s,travelMode:google.maps.TravelMode.DRIVING};a.route(d,(p,_)=>{var h;_==="OK"&&((h=f.value)==null||h.setDirections(p),W().then(u=>{m.value=u}))})}catch(t){throw t}},W=()=>{const t=new google.maps.DirectionsService,a=[{location:new google.maps.LatLng(e.value.from.coordinates.lat,e.value.from.coordinates.lng),stopover:!0},{location:new google.maps.LatLng(e.value.to.coordinates.lat,e.value.to.coordinates.lng),stopover:!0}],s={origin:new google.maps.LatLng(e.value.from.coordinates.lat,e.value.from.coordinates.lng),destination:new google.maps.LatLng(e.value.to.coordinates.lat,e.value.to.coordinates.lng),waypoints:a,travelMode:google.maps.TravelMode.DRIVING};return new Promise(l=>{t.route(s,(r,d)=>{var p,_;if(d==="OK"){const h=((_=(p=r==null?void 0:r.routes[0])==null?void 0:p.legs)==null?void 0:_.reduce((x,b)=>{var S;return x+(((S=b==null?void 0:b.distance)==null?void 0:S.value)||0)},0))||0;let u;k()==="miles"?u=(h*621371e-9).toFixed(2):u=(h*.001).toFixed(2),l(u)}})})},pe=()=>{I.value.showPopup()},O=()=>{I.value.hidePopup()},ge=C(()=>{var t;return o.value.useCurrency?se.getCommonFieldDisplayView(o.value):((t=o.value.value)==null?void 0:t.toString())||""}),X=C(()=>{const t=j.getCurrencyOptions(o.value),a=t.currency,s=t.currencyPosition;let l=0;o.value.value&&(l=ce(parseFloat(m.value),Y.value));const r=j.parseCurrencyPosition(l.toString(),a,s||"left");let d=o.value.useCurrency?`${r}`:l;return`${c.getTranslations.distance}: ${m.value} ${k()} x ${d}`}),V=C(()=>e.value.from.addressName&&e.value.to.addressName&&m.value),Y=C(()=>{var t;return{value:{pricingType:o.value.pricingType,eachCost:String(o.value.eachCost),distanceCostList:o.value.distanceCostList.map(a=>({from:a.from,to:a.to,cost:String(a.cost)})),lastDistanceCost:{cost:String(((t=o.value.lastDistanceCost)==null?void 0:t.cost)||"0")}}}}),B=C(()=>`${o.value.alias}
1-locationFrom-${L}`),A=C(()=>`${o.value.alias}-locationTo-${L}`);return(t,a)=>(G(),E("div",Fe,[n("div",Ie,[n("button",{class:"ccb-two-points-location__action",onClick:pe},[a[4]||(a[4]=n("span",{class:"icon"},[n("i",{class:"ccb-icon-location"})],-1)),n("span",Me,g(i(c).getTranslations.openMap),1)]),n("div",De,[V.value?(G(),E("span",Oe,[n("span",null,g(i(c).getTranslations.from)+":",1),R(" "+g(i(e).from.addressName)+" ",1),a[5]||(a[5]=n("br",null,null,-1)),n("span",null,g(i(c).getTranslations.to)+":",1),R(" "+g(i(e).to.addressName),1)])):(G(),E("span",$e,g(i(c).getTranslations.chooseFromMap),1))])]),F(ye,{ref_key:"popup",ref:I},{default:he(()=>[n("div",Ve,[n("div",Be,[n("div",Ae,[n("div",Ee,[n("div",Ge,[n("label",Re,g(i(c).getTranslations.from),1),ee(n("input",{id:B.value,type:"text",placeholder:i(c).getTranslations.enterAddress,"onUpdate:modelValue":a[0]||(a[0]=s=>i(e).from.addressName=s),onClick:a[1]||(a[1]=s=>J("from"))},null,8,Ke),[[oe,i(e).from.addressName]])]),n("div",qe,[n("label",je,g(i(c).getTranslations.toDestination),1),ee(n("input",{id:A.value,"onUpdate:modelValue":a[2]||(a[2]=s=>i(e).to.addressName=s),type:"text",placeholder:i(c).getTranslations.enterAddress,onClick:a[3]||(a[3]=s=>J("to"))},null,8,Ue),[[oe,i(e).to.addressName]])])]),n("div",ze,[R(g(i(c).getTranslations.distance)+": ",1),n("span",null,g(`${i(m)} ${i(k)()}`),1)])]),n("div",{id:i(L),class:"ccb-location-modal__map"},null,8,He)]),n("div",Je,[F(K,{type:"light",text:i(c).getTranslations.clearLocation,class:we(["clear",{disable:!V.value}]),onClick:me},null,8,["text","class"]),F(K,{type:"light",text:i(c).getTranslations.cancel,onClick:O},null,8,["text"]),F(K,{type:"success",text:i(c).getTranslations.saveLocation,onClick:ue},null,8,["text"])])])]),_:1},512)]))}}),ao=xe(Qe,[["__scopeId","data-v-ee7c327b"]]);export{ao as default};
2//# sourceMappingURL=TwoPoints-BSCHqoq5.js.map

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.