import{g as $}from"./activity-c9a7a2d3.js";import{g as P}from"./plan-2fedc155.js";import{p as _,d as j,f as V,T as N,o as J,ad as K,i as w,a as O,c as R,j as x,k as c,e as n,a4 as b,ah as S,m as F,v as q,l as X,ai as Y,D as z,_ as G}from"./index-deffec86.js";import{q as H}from"./map-4f55c240.js";import{g as Q}from"./common-8a6acaa7.js";import{y as W}from"./Cascader-11493146.js";const Z=()=>{const l=_({plan_id:"",name:"",area_level:"",type_tag_ids:"",tag_group_id_list:[],lat:"",lng:"",is_community_sport:1,area_ids:[],province:"",city:"",county:"",company_area_community_id:"",address:"",street:null}),C=async a=>{try{const{data:t}=await $({activity_id:a});p(t)}catch{}},i=async a=>{if(l.value.plan_id=a,!a)return;const{data:t}=await P({plan_id:a});p(t)},p=a=>{Object.keys(l.value).forEach(t=>{a[t]&&(l.value[t]=a[t])}),a.type_tag_ids&&(l.value.tag_group_id_list=u(a.type_tag_ids_array)),a.province&&a.city&&(l.value.area_ids=[a.province,a.city,a.county])},u=(a=[])=>{const t=[];return a.forEach(g=>{g.tag_ids.forEach(r=>{t.push([+g.tag_group_id,+r.tag_id])})}),t};return{form:l,getActivityInfo:C,setPlan:i}},pe=Z,ee={class:"map-container"},te={class:"select-item"},ae={class:"select-item pt10"},oe=["src"],se=j({__name:"index",props:{address:{},longitude:{},latitude:{}},emits:["update:address","update:latitude","update:longitude","getAreaInfo"],setup(l,{emit:C}){const i=_(!1),p=_(!0),u=C,a=W[0].children.map(o=>o.code),t=l,g=V(()=>t.latitude&&t.longitude&&Number(t.latitude)&&Number(t.longitude)?`https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${N}&coord=${t.longitude},${t.latitude}&referer=myapp`:`https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${N}&referer=myapp`),r=V({get:()=>t.address,set:o=>{u("update:address",o)}}),y=V({get:()=>t.latitude,set:o=>{u("update:latitude",o)}}),f=V({get:()=>t.longitude,set:o=>{u("update:longitude",o)}}),U=()=>{i.value=!0},A=async o=>{var d;const e=o.data;if(e&&e.module=="locationPicker"){try{const{result:m}=await H(e.latlng.lat,e.latlng.lng),{ad_info:v,address_reference:s}=m,I=53,E=+v.adcode.slice(0,4),D=+v.adcode,M=+s.town.id,T={province:I,city:E,county:D,street:M,company_area_community_id:""},L=((d=k.value.find(h=>h.company_area_id==E))==null?void 0:d.next)||[];if(!B.value.includes(+E)||!L.length||L.findIndex(h=>h.company_area_id==D)==-1){z({type:"warning",message:"\u5F53\u524D\u8D26\u53F7\u4E0D\u5728\u8BE5\u533A\u57DF\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9"});return}a.includes(E+"")&&u("getAreaInfo",T)}catch{}f.value=e.latlng.lng,y.value=e.latlng.lat,r.value=e.poiaddress+e.poiname,i.value=!1}},B=_([]),k=_([]);return J(async()=>{window.addEventListener("message",A,!1);try{const{data:o}=await Q({});B.value=o[0].next.map(e=>e.company_area_id),k.value=o[0].next}catch{}}),K(()=>{window.removeEventListener("message",A,!1)}),(o,e)=>{const d=w("el-input"),m=w("el-button"),v=w("el-dialog");return O(),R("div",ee,[x("div",te,[c(d,{modelValue:n(r),"onUpdate:modelValue":e[0]||(e[0]=s=>b(r)?r.value=s:null),class:"mr10",placeholder:"\u8BF7\u8F93\u5165\u8BE6\u7EC6\u5730\u5740"},null,8,["modelValue"]),c(m,{type:"primary",icon:n(S),onClick:U},null,8,["icon"])]),x("div",ae,[c(d,{modelValue:n(y),"onUpdate:modelValue":e[1]||(e[1]=s=>b(y)?y.value=s:null),disabled:n(p),class:"mr10 lng"},{append:F(()=>e[4]||(e[4]=[q("\u7ECF\u5EA6")])),_:1},8,["modelValue","disabled"]),c(d,{modelValue:n(f),"onUpdate:modelValue":e[2]||(e[2]=s=>b(f)?f.value=s:null),disabled:n(p),class:"mr10 lng"},{append:F(()=>e[5]||(e[5]=[q("\u7EAC\u5EA6")])),_:1},8,["modelValue","disabled"]),X('  @click="isDisabled = !isDisabled"  '),c(m,{type:"primary",icon:n(Y)},null,8,["icon"])]),c(v,{modelValue:n(i),"onUpdate:modelValue":e[3]||(e[3]=s=>b(i)?i.value=s:null),"destroy-on-close":"",width:"55%",title:"\u9009\u62E9\u5730\u70B9",class:"map_dialog"},{default:F(()=>[x("iframe",{width:"100%",class:"iframe",allow:"geolocation",src:n(g)},null,8,oe)]),_:1},8,["modelValue"])])}}});const me=G(se,[["__scopeId","data-v-b40f76f7"]]);export{me as M,pe as u};
