import{d as ve,r,b as w,p as me,c as _,e as h,f as m,u as s,w as fe,aY as ye,g as V,q as ke,A as E,F as B,j as G,k as I,i as f,m as Y,t as Ae,G as Ce,h as u,aZ as be,y as Me,R as Pe,S as De,_ as Le}from"./index.76214426.js";import{P as Ee,x as Se,E as we,s as Be,h as Ve}from"./loading.4e3235da.js";import{g as Fe}from"./setting.299e0353.js";const xe=C=>(Pe("data-v-faa3ecf8"),C=C(),De(),C),Re={key:0,class:"position-range-map"},Ne={key:0,class:"search-wrap"},Ge={class:"content-left"},Ie={key:1,class:"content-right"},Te={key:2,class:"content-right"},Je={key:1,class:"district-search"},Ue=xe(()=>V("div",{class:"district-search-title"},"\u884C\u653F\u533A\u57DF\u5212\u5B9A",-1)),je=Y("\u67E5\u8BE2"),ze=ve({props:{vid:{default:"amap-vue-range"},center:null,modelValue:{type:Boolean,default:!1}},emits:["update"],setup(C,{emit:F}){const x=C;let T=r(!1);const b=w({level:"province",address:""}),l=w({key:"",securityJsCode:"",google_key:"",map_type:2,plugin:[{enableHighAccuracy:!0,timeout:1e4,maximumAge:0,convert:!0,showButton:!0,buttonPosition:"LB",showMarker:!0,showCircle:!0,panToLocation:!0,zoomToAccuracy:!0}]}),J=r([]),Z=r(null);let $=r(!0),v=r([]),g=r([]),P=r("");const U=w({list:[]});(()=>{Fe().then(e=>{l.key=e.key,l.securityJsCode=e.securityJsCode,l.google_key=e.google_key,l.map_type=e.map_type||1,l.map_type==1&&be({key:l.key,securityJsCode:l.securityJsCode,version:"2.0",plugins:["AMap.DistrictSearch","AMap.Polygon","AMap.MouseTool","AMap.PolyEditor","AMap.Marker","AMap.Geocoder"],AMapUI:{version:"1.1",plugins:["overlay/SimpleMarker"]}}),T.value=!0,R.value=!0})})();let j=r(null),R=r(!1);me(()=>x.modelValue,e=>{e.length<=0||(j.value=setInterval(()=>{console.log(R.value,"is_load.value"),R.value&&(l.map_type==1&&(v.value=e),l.map_type==2&&(e.forEach((o,t)=>{o.draggable=!0,o.editable=!0,o.geodesic=!0,o.strokeColor="#4589ef",o.strokeOpacity=1,o.fillColor="#71a3ef",o.strokeWeight=2;const a=[];o.path.forEach(n=>{a.push({lat:n[1]?n[1]:n.lat,lng:n[0]?n[0]:n.lng})}),o.path=a}),g.value=e),console.log(g.value,"googlePath.value================"),clearInterval(j.value))},1e3))},{immediate:!0});const z=r(0),O=r(0),W=r(0),q=r(0),Q=(e,o)=>{const t=e.latLng,a=t.lat(),n=t.lng();z.value=n,O.value=a},X=(e,o)=>{const t=e.latLng,a=t.lat(),n=t.lng();W.value=n,q.value=a;const i=W.value-z.value,D=q.value-O.value;g.value.forEach((A,L)=>{o==L&&A.path.forEach((M,S)=>{M.lat=M.lat+D,M.lng=M.lng+i})}),y()},ee=(e,o)=>{g.value.splice(o,1),y()},oe=e=>{const o=e.latLng,t=Number(o.lat()),a=Number(o.lng());g.value.push({draggable:!0,editable:!0,geodesic:!0,strokeColor:"#4589ef",fillColor:"#71a3ef",strokeOpacity:1,strokeWeight:2,path:[{lat:t,lng:a},{lat:t+.002,lng:a+.002},{lat:t+.002,lng:a-.002}]}),y(),Me(()=>{console.log("googlePath",g),console.log("googlePath.value",g.value),K(g.value[g.value.length-1])})},te=(e,o)=>{let t=J.value[o].polygon;if(console.log(t),t){const a=t.getPath().getArray().map(i=>({lat:i.lat(),lng:i.lng()}));console.log("path",a);let n=r([]);a.forEach(i=>{n.value.push([i.lng,i.lat])}),g.value[o].path=n}y()},y=()=>{l.map_type==1&&F("update",v.value),l.map_type==2&&F("update",g.value)},le=e=>{l.map_type==1&&v.value.push({path:[[e.lnglat.lng,e.lnglat.lat],[e.lnglat.lng+.002,e.lnglat.lat+.002],[e.lnglat.lng-.002,e.lnglat.lat+.002]]})},ae=(e,o)=>{l.map_type==1&&(v.value[o].path=e.target._opts.path),y()},ne=(e,o)=>{console.log(e,o,"handlePolygonRightClick"),l.map_type==1&&v.value.splice(o,1)},se=(e,o)=>{l.map_type==1&&(v.value[o].path=e.target._opts.path),y()},ce=(e,o)=>{console.log(e,"handlePolygonAddNode",e.target._opts.path),l.map_type==1&&(v.value[o].path=e.target._opts.path),y()},re=(e,o)=>{console.log(e,"handlePolygonRemoveNode",e.target._opts.path),l.map_type==1&&(v.value[o].path=e.target._opts.path),y()},ue=e=>{l.map_type==1&&N(e.poi.location.lng,e.poi.location.lat)},k=r([x.center[0],x.center[1]]),H=w({position:k.value}),N=(e,o)=>{k.value=[e,o],H.position=k.value},K=e=>{console.log(e),e&&J.value.push(e)},pe=()=>{let e=P.value;if(!!e){Be({text:"\u52A0\u8F7D\u4E2D..."});var o=new google.maps.places.AutocompleteSessionToken;console.log(o);var t=new google.maps.places.AutocompleteService;t.getPlacePredictions({input:e,sessionToken:o},(a,n)=>{U.list=a,console.log(a),console.log(n),Ve()})}},ie=e=>{console.log(e);var o=new google.maps.Geocoder;o.geocode({placeId:e.place_id},function(t,a){if(a=="OK"){console.log(t);let n=t[0].geometry.location.lat(),i=t[0].geometry.location.lng();console.log(n,i),N(i,n)}})};r([]),r(null);const ge=()=>{var e={level:b.level,address:b.address};new AMap.DistrictSearch({extensions:"all",level:e.level}).search(e.address,function(o,t){if(console.log("result",t),console.log("status",o),o=="complete"){var a=t.districtList[0].boundaries;if(console.log("bounds",a),a){a.forEach(i=>{let D=i.map(A=>(console.log("item",A),[A.lng,A.lat]));v.value.push({path:D})});let n=t.districtList[0].center;N(n.lng,n.lat),F("update",v.value)}}})};return(e,o)=>{const t=_("el-tag"),a=_("el-amap-control-tool-bar"),n=_("el-amap-marker"),i=_("el-amap-search-box"),D=_("el-amap-polygon"),A=_("el-amap"),L=_("el-option"),M=_("el-select"),S=_("el-form-item"),de=_("el-input"),_e=_("el-button"),he=_("el-form");return h(),m(B,null,[s(T)?(h(),m("div",Re,[s(l).map_type==2?(h(),m("div",Ne,[fe(V("input",{placeholder:"\u8BF7\u8F93\u5165\u5730\u5740\u540D\u79F0",type:"text",id:"position-search-input",class:"position-search-input",onBlur:pe,"onUpdate:modelValue":o[0]||(o[0]=p=>ke(P)?P.value=p:P=p)},null,544),[[ye,s(P)]])])):E("",!0),V("div",null,[(h(!0),m(B,null,G(s(U).list,(p,d)=>(h(),I(t,{type:"primary",style:{"margin-right":"10px","margin-top":"10px"},onClick:c=>ie(p)},{default:f(()=>[Y(Ae(p.description),1)]),_:2},1032,["onClick"]))),256))]),V("div",Ge,[Ce(e.$slots,"default",{},void 0,!0)]),s(l).map_type==1?(h(),m("div",Ie,[u(A,{ref:"amap",vid:C.vid,center:k.value,plugin:s(l).plugin,zoom:15,"amap-key":s(l).key,"amap-version":"2.0.1",onClick:le},{default:f(()=>[u(a,{visible:!0}),u(n,{position:s(H).position,draggable:!1},null,8,["position"]),u(i,{class:"search-box",onSelect:ue}),(h(!0),m(B,null,G(s(v),(p,d)=>(h(),I(D,{path:p.path,key:d,visible:!0,editable:s($),draggable:!0,onDragend:c=>ae(c,d),onRightclick:c=>ne(c,d),onAdjust:c=>se(c,d),onAddnode:c=>ce(c,d),onRemovenode:c=>re(c,d)},null,8,["path","editable","onDragend","onRightclick","onAdjust","onAddnode","onRemovenode"]))),128))]),_:1},8,["vid","center","plugin","amap-key"])])):E("",!0),s(l).map_type==2?(h(),m("div",Te,[u(s(we),{ref_key:"googlemap",ref:Z,"api-key":s(l).google_key,style:{width:"100%",height:"500px"},center:{lat:k.value[1],lng:k.value[0]},onClick:o[1]||(o[1]=p=>oe(p)),zoom:15},{default:f(()=>[u(s(Ee),{options:{position:{lat:k.value[1],lng:k.value[0]}}},null,8,["options"]),(h(!0),m(B,null,G(s(g),(p,d)=>(h(),I(s(Se),{options:p,ref_for:!0,ref:K,key:d,onDragstart:c=>Q(c),onDragend:c=>X(c,d),onMouseup:c=>te(c,d),onClick:c=>ee(c,d)},null,8,["options","onDragstart","onDragend","onMouseup","onClick"]))),128))]),_:1},8,["api-key","center"])])):E("",!0)])):E("",!0),s(l).map_type==1?(h(),m("div",Je,[Ue,u(he,null,{default:f(()=>[u(S,{label:"\u884C\u653F\u7EA7\u522B"},{default:f(()=>[u(M,{modelValue:s(b).level,"onUpdate:modelValue":o[2]||(o[2]=p=>s(b).level=p),placeholder:"\u8BF7\u9009\u62E9\u884C\u653F\u7EA7\u522B",clearable:""},{default:f(()=>[u(L,{label:"\u7701",value:"province"}),u(L,{label:"\u5E02",value:"city"}),u(L,{label:"\u533A",value:"district"})]),_:1},8,["modelValue"])]),_:1}),u(S,{label:"\u540D\u79F0"},{default:f(()=>[u(de,{modelValue:s(b).address,"onUpdate:modelValue":o[3]||(o[3]=p=>s(b).address=p),placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0",clearable:""},null,8,["modelValue"])]),_:1}),u(S,null,{default:f(()=>[u(_e,{type:"primary",onClick:ge},{default:f(()=>[je]),_:1})]),_:1})]),_:1})])):E("",!0)],64)}}});const Ke=Le(ze,[["__scopeId","data-v-faa3ecf8"]]);export{Ke as P};