"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@dialpad/dialtone-icons/vue2"),s=require("../../localization/index.cjs"),c=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),p=require("../button/button.cjs"),u=require("../popover/popover.cjs"),d=require("../checkbox/checkbox.cjs"),_=require("../checkbox-group/checkbox-group.cjs"),f=require("../button/button-constants.cjs"),n=require("../popover/popover-constants.cjs"),v={name:"DtFilterPill",components:{DtCheckboxGroup:_.default,DtCheckbox:d.default,DtPopover:u.default,DtButton:p.default,DtIconClose:r.DtIconClose,DtIconChevronDown:r.DtIconChevronDown},inheritAttrs:!1,props:{value:{type:Array,default:()=>[]},alphaTooltipText:{type:String,default:""},disabled:{type:Boolean,default:!1},hideClear:{type:Boolean,default:!1},label:{type:String,default:void 0},omegaTooltipText:{type:String,default:""},popoverAppendTo:{type:[HTMLElement,String],default:"body",validator:t=>n.POPOVER_APPEND_TO_VALUES.includes(t)||t instanceof HTMLElement},popoverFallbackPlacements:{type:Array,default:()=>["auto"]},popoverMaxHeight:{type:String,default:""},popoverMaxWidth:{type:String,default:""},popoverPadding:{type:String,default:"large",validator:t=>Object.keys(n.POPOVER_PADDING_CLASSES).some(e=>e===t)},popoverPlacement:{type:String,default:"bottom-start"},size:{type:String,default:"sm",validator:t=>Object.keys(f.BUTTON_SIZE_MODIFIERS).includes(t)}},emits:["clear","open","update:value"],data(){return{isOpen:!1,i18n:new s.DialtoneLocalization,filters:this.value}},computed:{buttonKind(){return this.isActive?"default":"muted"},clearButtonAriaLabel(){return this.omegaTooltipText||this.i18n.$t("DIALTONE_FILTER_PILL_CLEAR_BUTTON_LABEL")},clearButtonTitle(){if(!this.omegaTooltipText)return this.clearButtonAriaLabel},activeFilters(){return this.filters.filter(t=>t.active).map(t=>t.name)},activeFilterList(){return this.activeFilters.length<=2?this.activeFilters.join(", "):this.activeFilters.slice(0,2).join(", ")+", + "+(this.activeFilters.length-2)},isActive(){return this.activeFilterList.length>0},hasClear(){return!this.hideClear&&this.activeFilterList.length>0}},watch:{isOpen(t){this.$emit("open",t)},filters(t){this.$emit("update:value",t)}},methods:{clearFilter(t){this.filters=this.filters.map(e=>(delete e.active,e)),this.$emit("clear",t)},updateFilters(t,e){this.filters=this.filters.map(i=>i.name!==t.name?i:{...i,active:e})}}};var h=function(){var e=this,i=e._self._c;return i("div",{staticClass:"d-filter-pill",attrs:{"data-qa":"dt-filter-pill"}},[i("dt-popover",{attrs:{"append-to":e.popoverAppendTo,"fallback-placements":e.popoverFallbackPlacements,"max-height":e.popoverMaxHeight,"max-width":e.popoverMaxWidth,modal:!1,padding:e.popoverPadding,placement:e.popoverPlacement},scopedSlots:e._u([{key:"anchor",fn:function({attrs:l}){return[i("dt-button",e._b({directives:[{name:"dt-tooltip",rawName:"v-dt-tooltip",value:e.alphaTooltipText,expression:"alphaTooltipText"}],class:["d-filter-pill__primary",{"d-filter-pill--selected":e.isActive,"d-filter-pill__primary--has-clear":e.hasClear}],attrs:{active:e.isActive,disabled:e.disabled,kind:e.buttonKind,size:e.size,"data-qa":"dt-filter-pill__button","icon-position":"right",importance:"outlined"},on:{click:function(a){e.isOpen=!0}},scopedSlots:e._u([{key:"icon",fn:function({iconSize:a}){return[i("dt-icon-chevron-down",{staticClass:"d-filter-pill__icon",attrs:{size:a,"data-qa":"dt-filter-pill__icon"}})]}}],null,!0)},"dt-button",l,!1),[i("span",{staticClass:"d-filter-pill__label"},[e._t("default",function(){return[i("span",{staticClass:"d-filter-pill__label-alpha",domProps:{textContent:e._s(e.label)}}),e.activeFilterList?i("span",{staticClass:"d-filter-pill__label-omega",domProps:{textContent:e._s(e.activeFilterList)}}):e._e()]})],2)])]}},{key:"content",fn:function({close:l}){return[e._t("content",function(){return[e.value.length?i("dt-checkbox-group",{attrs:{"selected-values":e.activeFilters,"aria-label":e.label,name:"contact-centers"}},e._l(e.filters,function(a){return i("dt-checkbox",{key:a.name,attrs:{label:a.name,value:a.name},on:{input:o=>e.updateFilters(a,o)}})}),1):e._e()]},{close:l})]}}],null,!0),model:{value:e.isOpen,callback:function(l){e.isOpen=l},expression:"isOpen"}}),e.hasClear?i("dt-button",{directives:[{name:"dt-tooltip",rawName:"v-dt-tooltip",value:e.omegaTooltipText,expression:"omegaTooltipText"}],class:["d-filter-pill__clear",{"d-filter-pill__clear--selected":e.isActive}],attrs:{active:e.isActive,"aria-label":e.clearButtonAriaLabel,disabled:e.disabled,kind:e.buttonKind,size:e.size,title:e.clearButtonTitle,"data-qa":"dt-filter-pill__clear-button",importance:"outlined"},on:{click:e.clearFilter},scopedSlots:e._u([{key:"icon",fn:function({iconSize:l}){return[i("dt-icon-close",{attrs:{size:l}})]}}],null,!1,2924703597)}):e._e()],1)},m=[],b=c.n(v,h,m);const g=b.exports;exports.default=g;
//# sourceMappingURL=filter-pill.cjs.map
