import{h as C,m as V,r as A}from"../js/utils.3c550046.js";import{c as I}from"../js/runtime-dom.esm-bundler.f6259c83.js";import{o as b}from"../js/helpers.2a6f0df7.js";import{l as P}from"../js/index.7c01c5f2.js";import{u as N,a as O}from"../js/index.ed1fc0db.js";import{B as H}from"../js/Select.4ddf605b.js";import{_ as D}from"../js/_plugin-vue_export-helper.eefbdd86.js";import{a6 as M,o as Z,c as j,a as E,$ as F,m as T,h as U}from"../js/runtime-core.esm-bundler.4f558f23.js";import"../js/translations.d159963e.js";import{_ as a,s as h}from"../js/default-i18n.20001971.js";import"../js/Caret.b694929e.js";import"../js/Close.8fb798f7.js";const q=C`
<svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
	<path d="M17.2001 7.2L19.0361 9.036L17.7641 10.308L10.0001 2.544L2.23611 10.308L0.964111 9.036L10.0001 0L14.8001 4.8V2.4H17.2001V7.2ZM10.0001 4.248L17.2001 11.436V18.6H2.80011V11.436L10.0001 4.248ZM12.4001 17.4V11.4H7.60011V17.4H12.4001Z" fill="black"/>
</svg>
`,z="https://schemas.wp.org/wp/5.8/block.json",G="aioseo/locations",J="AIOSEO Local - Locations",K="Displays locations.",Q="aioseo",W="all-in-one-seo-pack",X={categoryId:{type:"number",default:0}},Y={html:!1},ee={$schema:z,name:G,title:J,description:K,category:Q,textdomain:W,attributes:X,supports:Y},te={setup(){return{postEditorStore:N(),rootStore:O()}},components:{BaseSelect:H},data(){return{locationCategories:[],strings:{selectLocation:this.rootStore.aioseo.localBusiness.taxonomySingleLabel}}},methods:{getCategoryOptions(e){let t=this.locationCategories.find(s=>s.value===e);return t||(t=this.locationCategories.find(s=>s.value===this.postEditorStore.currentPost.localBusinessCategory)||this.locationCategories.find(s=>!!s),t&&(this.$root.$data.categoryId=t.value)),t}},created(){this.$root.$data.categories&&this.$root.$data.categories.forEach(e=>{this.locationCategories.push({value:e.id,label:e.name})})}},oe={class:"aioseo-locations-sidebar"},ne={class:"sidebar-row"},se={class:"title"};function ae(e,t,s,c,o,p){const u=M("base-select");return Z(),j("div",oe,[E("div",ne,[E("p",se,F(o.strings.selectLocation),1),T(u,{size:"medium",options:o.locationCategories,modelValue:p.getCategoryOptions(e.$root.$data.categoryId),"onUpdate:modelValue":t[0]||(t[0]=n=>e.$root.$data.categoryId=n.value),"track-by":"value"},null,8,["options","modelValue"])])])}const ie=D(te,[["render",ae]]),i="all-in-one-seo-pack",{name:k,title:re,description:le,category:ce,supports:ue,attributes:de}=ee,r=window.wp,me=r.serverSideRender||r.components.ServerSideRender;var B;const $=((B=r.blockEditor)==null?void 0:B.InspectorControls)||r.editor.InspectorControls,L=r.components.PanelBody,pe=r.data.withSelect,m={},R=[],ge={title:re,description:le,category:ce,supports:ue,attributes:de,icon:q,edit:pe(function(e){return{categories:e("core").getEntityRecords("taxonomy",window.aioseo.localBusiness.taxonomyName)}})(function(e){var y,S,_,v,w;const t=(w=(v=(_=(S=(y=window==null?void 0:window.aioseo)==null?void 0:y.options)==null?void 0:S.localBusiness)==null?void 0:_.locations)==null?void 0:v.general)==null?void 0:w.multiple,{setAttributes:s,attributes:c,clientId:o,isSelected:p,toggleSelection:u}=e;let{categories:n}=e;const g="aioseo-"+o;if(r.data.useSelect(l=>l("core/edit-post").getActiveGeneralSidebarName())==="edit-post/block"&&(typeof u!="function"||u(!0)),t&&n===null)return React.createElement("div",null,a("Loading...",i));if(n=n===null?[]:n,!t)return React.createElement("div",null,a("Please enable multiple locations before using this block.",i));if(n.length===0)return React.createElement("div",null,h(a("No %1$s found",i),window.aioseo.localBusiness.taxonomyPluralLabel));const f={id:g,parent:document.querySelector(".block-editor"),subtree:!0,loop:!1,done:function(l){V(o,R);let d=I({name:"Blocks/Locations",data:function(){return m[o]},watch:{$data:{handler:function(x){s(x)},deep:!0}},render:()=>U(ie)});d=P(d),d.mount(l),R.push({id:o,app:d})}};return p&&(m[o]={},Object.keys(c).forEach(l=>{m[o][l]=c[l]}),m[o].categories=n,b(f)),n!==null&&n.length===0?React.createElement("div",null,h(a("No %1$s found",i),window.aioseo.localBusiness.taxonomyPluralLabel)):c.categoryId?React.createElement(React.Fragment,null,React.createElement($,null,React.createElement(L,{title:a("Block Settings",i),initialOpen:!0,onToggle:b(f)},React.createElement("div",{id:g}))),React.createElement(me,{block:k,attributes:{...c}})):React.createElement(React.Fragment,null,React.createElement($,null,React.createElement(L,{title:a("Block Settings",i),initialOpen:!0,onToggle:b(f)},React.createElement("div",{id:g}))),React.createElement("div",null,h(a("Select a %1$s",i),window.aioseo.localBusiness.taxonomySingleLabel)))}),save:function(){return null}};A({name:k,settings:ge});
