import{i as S}from"./app-core.61d75c0b.js";import{ax as O,as as d,f as h,Q as B,R as o,B as n,j as i,a0 as g,ae as f,U as p,i as k,M as V,T as b,P as C}from"./vendor-vue-ui.d70c869f.js";import{S as T}from"./Caret.c4a084e6.js";import{S as w}from"./Close.cee3494e.js";import{_ as A}from"./_plugin-vue_export-helper.eefbdd86.js";import{_ as E}from"./vendor-other.2cdd5822.js";const P="all-in-one-seo-pack",j={emits:["open","close","update:modelValue"],components:{Multiselect:O,SvgCaret:T,SvgClose:w},props:{options:{type:Array,required:!0},trackBy:{type:String,default(){return"value"}},multiple:Boolean,taggable:Boolean,filterable:Boolean,searchable:{type:Boolean,default(){return!0}},placeholder:{type:String,default(){return""}},customLabel:{type:Function,default:({label:t})=>t},name:String,modelValue:[String,Array,Number,Object],ajaxSearch:Function,noDataText:String,popperClass:String,loading:Boolean,disabled:Boolean,size:String,openDirection:{type:String,default(){return null}},groupValues:String,groupLabel:String,closeOnSelect:{type:Boolean,default(){return!0}},tagPlaceholder:String,allowEmpty:{type:Boolean,default(){return!1}},preserveOptions:{type:Boolean,default(){return!0}}},data(){return{isLoading:!1,internalOptions:[],strings:{searchPlaceholder:E("Type to search...",P)}}},watch:{options(){this.resetFirstLastOption()}},computed:{effectiveOptions(){if(this.preserveOptions){const t=[...this.internalOptions];return this.options.forEach(s=>{t.some(e=>e.value===s.value)||t.push(s)}),t}return this.options}},methods:{addTag(t){t.split(",").forEach(s=>{const e={label:s,value:s};this.preserveOptions?this.internalOptions.some(a=>a.value===e.value)||this.internalOptions.push(e):this.options.some(a=>a.value===e.value)||this.options.push(e),this.modelValue.some(a=>a.value===e.value)||this.modelValue.push(e)}),this.$emit("update:modelValue",this.modelValue),this.$refs["aioseo-select"].$el.focus()},searchChange(t){t&&this.ajaxSearch&&(this.isLoading=!0,S(()=>{this.ajaxSearch(t).then(()=>this.isLoading=!1)},500))},resetFirstLastOption(){this.$nextTick(()=>{if(!this.$refs["aioseo-select"])return;const t=this.$refs["aioseo-select"]?.$el?.querySelectorAll("li.multiselect__element")||[];t.forEach((s,e)=>{s.classList.remove("last"),s.classList.remove("first"),e===0&&s.classList.add("first"),e===t.length-1&&s.classList.add("last")})})}},mounted(){this.resetFirstLastOption(),this.preserveOptions&&0<this.options.length&&(this.internalOptions=[...this.options])}},F={class:"multiselect__tag"},M={class:"multiselect__tag-value"},N=["onClick"],x=["innerHTML"],z={class:"multiselect__select"};function D(t,s,e,a,m,r){const _=d("svg-close"),v=d("svg-caret"),y=d("multiselect");return h(),B(y,{class:C(["aioseo-select",[{[e.size]:e.size},{multiple:e.multiple}]]),modelValue:e.modelValue,"onUpdate:modelValue":s[0]||(s[0]=l=>t.$emit("update:modelValue",l)),options:r.effectiveOptions,multiple:e.multiple,taggable:e.taggable,placeholder:e.placeholder||m.strings.searchPlaceholder,"tag-placeholder":e.tagPlaceholder,"show-labels":!1,"track-by":e.trackBy,"custom-label":e.customLabel,"allow-empty":e.allowEmpty||!!e.multiple,filterable:e.filterable,"internal-search":!0,loading:m.isLoading,searchable:e.searchable,"open-direction":e.openDirection,"group-values":e.groupValues,"group-label":e.groupLabel,disabled:e.disabled,"close-on-select":e.closeOnSelect,onSearchChange:r.searchChange,onTag:r.addTag,onOpen:s[1]||(s[1]=l=>t.$emit("open")),onClose:s[2]||(s[2]=l=>t.$emit("close")),ref:"aioseo-select"},{singleLabel:o(({option:l})=>[n(t.$slots,"singleLabel",{option:l},()=>[f(p(l.label),1)])]),tag:o(({option:l,search:c,remove:u})=>[n(t.$slots,"tag",{option:l,search:c,remove:u},()=>[i("div",F,[i("div",M,p(l.label),1),i("div",{class:"multiselect__tag-remove",onClick:b(L=>u(l),["stop"])},[g(_,{onClick:b(L=>u(l),["stop"])},null,8,["onClick"])],8,N)])])]),option:o(({option:l,search:c})=>[n(t.$slots,"option",{option:l,search:c},()=>[f(p(l.$isLabel?l.$groupLabel:l.label)+" ",1),l.docLink?(h(),k("span",{key:0,class:"docLink",innerHTML:l.docLink},null,8,x)):V("",!0)])]),caret:o(({toggle:l})=>[n(t.$slots,"caret",{toggle:l},()=>[i("div",z,[g(v)])])]),noOptions:o(()=>[n(t.$slots,"noOptions")]),noResult:o(()=>[n(t.$slots,"noResult")]),_:3},8,["class","modelValue","options","multiple","taggable","placeholder","tag-placeholder","track-by","custom-label","allow-empty","filterable","loading","searchable","open-direction","group-values","group-label","disabled","close-on-select","onSearchChange","onTag"])}const G=A(j,[["render",D]]);export{G as B};
