import{h as G,m as A,r as J}from"../js/utils.68c800e0.js";import{aq as E,f as I,i as V,j as i,U as g,a0 as w,M as N,R as D,ae as U,an as z,h as W}from"../js/vendor-vue-ui.f00a1236.js";import{b as C,u as Z,y as Q,aq as y}from"../js/app-core.b862f9c8.js";import{l as j}from"../js/index.18357c0f.js";import{B as K}from"../js/Input.af82b72e.js";import{B as X}from"../js/Select.952b21a0.js";import{B as Y}from"../js/Toggle.b43ed20a.js";import{C as ee}from"../js/ImageUploader.b7594f11.js";import{_ as te}from"../js/_plugin-vue_export-helper.eefbdd86.js";import{_ as a,a as R,U as oe}from"../js/vendor-other.7b559694.js";import"../js/vendor-lodash.d3ad8b99.js";import"../js/Index.3967c277.js";import"../js/Close.de45e465.js";import"../js/Pencil.1ca5815a.js";import"../js/Trash.c3e8db0b.js";import"../js/Caret.e6c9f7cc.js";import"../js/Button.6c09d515.js";import"../js/Img.2d9fe1ad.js";import"../js/Plus.542c86d0.js";const se=G`
`,ae="aioseo/locationmap",ne="AIOSEO Local - Map",le="Displays a location map.",ie="aioseo",re={locationId:{type:"number",default:0},showLabel:{type:"boolean",default:!0},showIcon:{type:"boolean",default:!0},customMarker:{type:"string",default:null},width:{type:"string",default:"100%"},height:{type:"string",default:"450px"},label:{type:"string",default:null},dataObject:{type:"string",default:null},updated:{type:"string",default:null}},ce={html:!1},de={name:ae,title:ne,description:le,category:ie,attributes:re,supports:ce},u="all-in-one-seo-pack",ue={setup(){return{postEditorStore:Z(),rootStore:C()}},components:{BaseInput:K,BaseSelect:X,BaseToggle:Y,CoreImageUploader:ee},data(){return{locationsList:[],strings:{selectLocation:this.rootStore.aioseo.localBusiness.postTypeSingleLabel,showLabel:a("Show label",u),showIcon:a("Show icon",u),businessInfo:a("Business Info",u),mapDisplay:a("Map Display",u),width:a("Width",u),height:a("Height",u),customMarker:a("Custom Marker",u),minimumSize:R(a("%1$sThe custom marker should be: 100x100 px.%2$s If the image exceeds those dimensions it could (partially) cover the info popup.",u),"",""),label:a("Label",u)}}},methods:{getLocationOptions(t){let e=this.locationsList.find(r=>r.value===t);return!e&&!this.isLocationPostType()&&(e=this.locationsList.find(r=>!!r),e&&(this.$root.$data.locationId=e.value)),e},isLocationPostType(){return this.postEditorStore.currentPost.postType===this.rootStore.aioseo.localBusiness.postTypeName}},created(){this.$root.$data.locations&&this.$root.$data.locations.forEach(t=>{this.locationsList.push({value:t.id,label:t.title.rendered})})}},pe={class:"aioseo-location-map-sidebar"},me={key:0,class:"sidebar-row"},ge={class:"title"},fe={class:"sidebar-row"},be={class:"sidebar-row"},he={class:"sidebar-row"},we={class:"title"},ye={class:"sidebar-row"},ve={class:"title"},Se={class:"sidebar-row dimensions"},Le={key:1,class:"sidebar-row labels"},$e={class:"title"};function _e(t,e,r,v,n,S){const o=E("base-select"),b=E("base-toggle"),c=E("core-image-uploader"),L=E("base-input");return I(),V("div",pe,[n.locationsList.length&&!S.isLocationPostType()?(I(),V("div",me,[i("p",ge,g(n.strings.selectLocation),1),w(o,{size:"medium",options:n.locationsList,modelValue:S.getLocationOptions(t.$root.$data.locationId),"onUpdate:modelValue":e[0]||(e[0]=l=>t.$root.$data.locationId=l.value),"track-by":"value"},null,8,["options","modelValue"])])):N("",!0),i("div",fe,[w(b,{modelValue:t.$root.$data.showLabel,"onUpdate:modelValue":e[1]||(e[1]=l=>t.$root.$data.showLabel=l)},{default:D(()=>[U(g(n.strings.showLabel),1)]),_:1},8,["modelValue"])]),i("div",be,[w(b,{modelValue:t.$root.$data.showIcon,"onUpdate:modelValue":e[2]||(e[2]=l=>t.$root.$data.showIcon=l)},{default:D(()=>[U(g(n.strings.showIcon),1)]),_:1},8,["modelValue"])]),i("div",he,[i("p",we,g(n.strings.customMarker),1),w(c,{class:"aioseo-image-uploader--no-icon","img-preview-max-width":"100px","img-preview-max-height":"100px","base-size":"small",description:n.strings.minimumSize,modelValue:t.$root.$data.customMarker,"onUpdate:modelValue":e[3]||(e[3]=l=>t.$root.$data.customMarker=l)},null,8,["description","modelValue"])]),i("div",ye,[i("p",ve,g(n.strings.mapDisplay),1)]),i("div",Se,[i("div",null,[i("label",null,g(n.strings.width)+":",1),w(L,{size:"small",modelValue:t.$root.$data.width,"onUpdate:modelValue":e[4]||(e[4]=l=>t.$root.$data.width=l)},null,8,["modelValue"])]),i("div",null,[i("div",null,[i("label",null,g(n.strings.height)+":",1),w(L,{size:"small",modelValue:t.$root.$data.height,"onUpdate:modelValue":e[5]||(e[5]=l=>t.$root.$data.height=l)},null,8,["modelValue"])])])]),t.$root.$data.showLabel?(I(),V("div",Le,[i("p",$e,g(n.strings.label),1),w(L,{size:"small",modelValue:t.$root.$data.label,"onUpdate:modelValue":e[6]||(e[6]=l=>t.$root.$data.label=l)},null,8,["modelValue"])])):N("",!0)])}const Ee=te(ue,[["render",_e]]),p="all-in-one-seo-pack",{name:x,title:ke,description:Re,category:Be,supports:Ie,attributes:Ve}=de,f=window.wp,Me=f.serverSideRender||f.components.ServerSideRender,M=f.blockEditor?.InspectorControls||f.editor.InspectorControls,T=f.components.PanelBody,Te=f.components.Disabled,Ce=f.data.withSelect,k={},q=[],F=[],Pe={title:ke,description:Re,category:Be,supports:Ie,attributes:Ve,icon:se,edit:Ce(function(t){const e=C();return{locations:t("core").getEntityRecords("postType",e.aioseo.localBusiness.postTypeName,{per_page:100})}})(function(t){const e=C(),r=Z(),v=Q(),n=v.options.localBusiness?.locations.general.multiple,{setAttributes:S,attributes:o,className:b,clientId:c,isSelected:L,toggleSelection:l}=t;let{locations:h}=t;const m="aioseo-location-map-"+c,$=r.currentPost.postType===e.aioseo.localBusiness.postTypeName;if(o.label=o.label||a("Our location:",p),o.updated=o.updated||Date.now(),o.dataObject=o.dataObject||$?JSON.stringify(r.currentPost.local_seo.maps):null,n&&h===null)return React.createElement("div",null,a("Loading...",p));if(h=h===null?[]:h,!n&&o.locationId)return React.createElement("div",null,a("Please enable multiple locations before using this block.",p));if(n&&h.length===0)return React.createElement("div",null,R(a("No %1$s found",p),e.aioseo.localBusiness.postTypePluralLabel));o.locationId=!o.locationId&&$?r.currentPost.id:o.locationId;const B=h.find(s=>s.id===o.locationId),P=$?r.currentPost.local_seo.maps:B?B.maps:null,_={id:m,parent:document.querySelector(".block-editor"),subtree:!0,loop:!1,done:function(s){A(c,q);let d=z({name:"Blocks/LocationMap",data:function(){return k[c]},watch:{$data:{handler:function(H){S(H)},deep:!0}},render:()=>W(Ee)});d=j(d),d.mount(s),q.push({id:c,app:d})}};if(L&&(k[c]={},Object.keys(o).forEach(function(s){k[c][s]=o[s]}),k[c].locations=h,y(_)),f.data.useSelect(s=>s("core/edit-post").getActiveGeneralSidebarName())==="edit-post/block"&&(typeof l!="function"||l(!0)),$&&y({id:m+"-watcher",parent:document.querySelector(".block-editor"),subtree:!0,done:function(s){A(c,F);let d=z({name:"Blocks/LocationMapWatcher",data:function(){return r.currentPost.local_seo.maps},watch:{$data:{handler:function(){S({updated:Date.now()})},deep:!0}},render:()=>W("div")});d=j(d),d.mount(s),F.push({id:c,app:d})}}),n){if(!o.locationId)return React.createElement(React.Fragment,null,React.createElement(M,null,React.createElement(T,{title:a("Block Settings",p),initialOpen:!0,onToggle:y(_)},React.createElement("div",{className:b,id:m}))),React.createElement("div",null,R(a("Select a %1$s",p),e.aioseo.localBusiness.postTypeSingleLabel)));if(!P){const s=oe("post.php",{post:o.locationId,action:"edit"});return React.createElement(React.Fragment,null,React.createElement(M,null,React.createElement(T,{title:a("Block Settings",p),initialOpen:!0,onToggle:y(_)},React.createElement("div",{className:b,id:m}))),React.createElement("div",{dangerouslySetInnerHTML:{__html:R(a("Please configure the map for this location: %1$s",p),''+B.title.rendered+"")}}))}}const O="#"+m+"-preview .aioseo-local-map";return y({selector:O,parent:document.querySelector(".block-editor"),subtree:!0,done:function(){const s=P||v.options.localBusiness.maps;setTimeout(function(){document.dispatchEvent(new CustomEvent(e.aioseo.localBusiness.mapLoadEvent,{detail:{element:O,mapOptions:s.mapOptions,customMarker:o.customMarker||s.customMarker||v.options.localBusiness.maps.customMarker,instance:o,placeId:v.options.localBusiness.maps.mapsEmbedApiEnabled?s.placeId:null,infoWindowContent:s.infoWindowContent?s.infoWindowContent:null}}))},2e3)}}),React.createElement(React.Fragment,null,React.createElement(M,null,React.createElement(T,{title:a("Block Settings",p),initialOpen:!0,onToggle:y(_)},React.createElement("div",{className:b,id:m}))),React.createElement("div",null,React.createElement("div",{className:b,id:`${m}-preview`},React.createElement(Te,null,React.createElement(Me,{block:x,attributes:{...o}}))),React.createElement("div",{id:`${m}-watcher`})))}),save:function(){return null}};J({name:x,settings:Pe});