"use strict";(self.webpackChunktainacan=self.webpackChunktainacan||[]).push([[1202],{93030(e,t,a){a.d(t,{A:()=>n});var i=a(75552),s=a(8926);const n={mixins:[s.s,s.F],emits:["input","update-parent-collapse"],data:function(){return{selected:"",options:[],taxonomy:"",taxonomyId:""}},watch:{facetsFromItemSearch:{handler:function(){this.isUsingElasticSearch&&this.loadOptions()},immediate:!0,deep:!0},isLoadingItems:{handler:function(){this.isUsingElasticSearch&&(this.isLoadingOptions=this.isLoadingItems)},immediate:!0},query:{handler:function(){this.updateSelectedValues()},deep:!0}},mounted:function(){this.isUsingElasticSearch||this.loadOptions()},created:function(){this.filter.metadatum&&this.filter.metadatum.metadata_type_object&&this.filter.metadatum.metadata_type_object.options&&this.filter.metadatum.metadata_type_object.options.taxonomy&&this.filter.metadatum.metadata_type_object.options.taxonomy_id&&(this.taxonomyId=this.filter.metadatum.metadata_type_object.options.taxonomy_id,this.taxonomy=this.filter.metadatum.metadata_type_object.options.taxonomy),this.$eventBusSearchEmitter.on("hasToReloadFacets",this.reloadOptions)},beforeUnmount:function(){null!=this.getOptionsValuesCancel&&this.getOptionsValuesCancel.cancel("Facet search Canceled."),this.$eventBusSearchEmitter.off("hasToReloadFacets",this.reloadOptions)},methods:{getFocusRestoreElement:function(){var e=this.$refs.filterSelect&&this.$refs.filterSelect.$el;return e?e.querySelector("select")||e:null},getUnescapedLabel:function(e){return"function"==typeof _.unescape?_.unescape(e):e},reloadOptions:function(e){!this.isUsingElasticSearch&&e&&this.loadOptions()},loadOptions:function(){var e=this;null!=this.getOptionsValuesCancel&&this.getOptionsValuesCancel.cancel("Facet search Canceled.");var t=this.getValuesTaxonomy({metadatumId:this.metadatumId,isRepositoryLevel:this.isRepositoryLevel,number:this.filter.max_options});t.request.then((function(t){t&&t.data&&t.data.values&&e.$emit("update-parent-collapse",t.data.values.length>0),e.$nextTick((function(){return e.tryRestoreFocus()}))})).catch((function(t){(0,i.FZ)(t)||e.$console.log("Error on facets request: ",t)})),this.getOptionsValuesCancel=t.source},updateSelectedValues:function(){var e=this;if(!this.query||!this.query.taxquery||!Array.isArray(this.query.taxquery))return!1;this.selected="";var t=this.query.taxquery.findIndex((function(t){return t.taxonomy==e.taxonomy}));if(t>=0){var a=this.query.taxquery[t];this.selected!=a.terms&&(this.selected=a.terms)}},onSelect:function(e){this.$emit("input",{filter:"selectbox",taxonomy:this.taxonomy,metadatum_id:this.metadatumId,collection_id:this.collectionId,terms:e})},prepareOptionsForTaxonomy:function(e){this.options=[],this.options=e.slice(),this.updateSelectedValues()}}}},77016(e,t,a){a.d(t,{X:()=>l});var i=a(6934),s={class:"block"},n={value:""},o=["value"];function l(e,t,a,l,r,c){var d=(0,i.g2)("b-select");return(0,i.uX)(),(0,i.CE)("div",s,[(0,i.bF)(d,{ref:"filterSelect",loading:e.isLoadingOptions,disabled:!e.isLoadingOptions&&r.options.length<=0,"model-value":r.selected,"aria-labelledby":"filter-label-id-"+e.filter.id,placeholder:e.filter.placeholder?e.filter.placeholder:e.$i18n.get("label_selectbox_init"),expanded:"","onUpdate:modelValue":t[0]||(t[0]=function(t){e.resetPage(),c.onSelect(t)})},{default:(0,i.k6)((function(){return[(0,i.Lk)("option",n,(0,i.v_)(e.filter.placeholder?e.filter.placeholder:e.$i18n.get("label_selectbox_init")),1),((0,i.uX)(!0),(0,i.CE)(i.FK,null,(0,i.pI)(r.options,(function(e,t){return(0,i.uX)(),(0,i.CE)("option",{key:t,value:e.value},(0,i.v_)(c.getUnescapedLabel(e.label)+(e.total_items?" ("+e.total_items+")":"")),9,o)})),128))]})),_:1},8,["loading","disabled","model-value","aria-labelledby","placeholder"])])}},1202(e,t,a){a.r(t),a.d(t,{default:()=>n});var i=a(7955),s=a(89881);const n=(0,a(66262).A)(s.A,[["render",i.X]])},89881(e,t,a){a.d(t,{A:()=>i.A});var i=a(93030)},7955(e,t,a){a.d(t,{X:()=>i.X});var i=a(77016)}}]);