"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[667],{667:function(e,t,s){s.r(t),s.d(t,{default:function(){return y}});var r=s(6252),i=s(9963);const o={class:"entities-selectors-container"},n={key:0,class:"selector search-container col-11"},l={class:"selector actions-container col-1 pull-right"};function c(e,t,s,c,u,a){const p=(0,r.up)("DropdownItem"),h=(0,r.up)("Dropdown");return(0,r.wg)(),(0,r.iD)("div",o,[Object.keys(s.entityGroups.id||{}).length?((0,r.wg)(),(0,r.iD)("div",n,[(0,r.wy)((0,r._)("input",{ref:"search",type:"text",class:"search-bar",title:"Filter by name, plugin or ID",placeholder:"🔎","onUpdate:modelValue":t[0]||(t[0]=e=>u.searchTerm=e)},null,512),[[i.nr,u.searchTerm]])])):(0,r.kq)("",!0),(0,r._)("div",l,[(0,r.Wm)(h,{title:"Actions","icon-class":"fas fa-ellipsis"},{default:(0,r.w5)((()=>[(0,r.Wm)(p,{"icon-class":"fas fa-sync-alt",text:"Refresh",onClick:t[1]||(t[1]=t=>e.$emit("refresh"))}),(0,r.Wm)(p,{"icon-class":"fas fa-square-root-variable",text:"Set Variable",onClick:t[2]||(t[2]=t=>e.$emit("show-variable-modal"))}),(0,r.Wm)(h,{title:"Group by",text:"Group by","icon-class":"fas fa-object-ungroup",ref:"groupingSelector"},{default:(0,r.w5)((()=>[((0,r.wg)(!0),(0,r.iD)(r.HY,null,(0,r.Ko)(a.visibleGroupings,(e=>((0,r.wg)(),(0,r.j4)(p,{key:e,text:a.prettifyGroupingName(e),"item-class":{selected:s.value?.grouping===e},onClick:t=>a.onGroupingChanged(e)},null,8,["text","item-class","onClick"])))),128))])),_:1},512),(0,r.Wm)(h,{title:"Filter groups",text:"Filter groups","icon-class":{fas:!0,"fa-filter":!0,active:a.hasActiveFilter},ref:"groupSelector","keep-open-on-item-click":""},{default:(0,r.w5)((()=>[((0,r.wg)(!0),(0,r.iD)(r.HY,null,(0,r.Ko)(a.sortedGroups,(e=>((0,r.wg)(),(0,r.j4)(p,(0,r.dG)({key:e,text:e,ref_for:!0},a.iconForGroup(e),{"item-class":{selected:!!u.selectedGroups[e]},onClick:(0,i.iM)((t=>a.toggleGroup(e)),["stop"])}),null,16,["text","item-class","onClick"])))),128))])),_:1},8,["icon-class"])])),_:1})])])}var u=s(8637),a=s(2787),p=s(815),h=s(7369),d=s(1359),g=s(5250),f={name:"Selector",emits:["input","refresh","show-variable-modal"],mixins:[u.Z],components:{Dropdown:a.Z,DropdownItem:p.Z},props:{entityGroups:{type:Object,required:!0},value:{type:Object,required:!0}},data(){return{selectedGroups:{},searchTerm:""}},computed:{visibleGroupings(){return Object.keys(this.entityGroups).filter((e=>"id"!==e))},hasActiveFilter(){return Object.values(this.selectedGroups).filter((e=>!1===e)).length>0},sortedGroups(){return Object.keys(this.entityGroups[this.value?.grouping]||{}).sort()},typesMeta(){return h},isGroupFilterActive(){return Object.keys(this.selectedGroups).length!==this.sortedGroups.length},selectedEntities(){if(!this.searchTerm?.length)return this.entityGroups.id;const e=this.searchTerm.toLowerCase().trim();return Object.values(this.entityGroups.id).filter((t=>{if(!this.selectedGroups[t[this.value?.grouping]])return!1;if(!e?.length)return!0;for(const s of["id","external_id","name","plugin"]){if(!t[s])continue;const r=t[s].toString().toLowerCase();if(r.indexOf(e)>=0)return!0}return!1})).reduce(((e,t)=>(e[t.id]=t,e)),{})}},methods:{prettifyGroupingName(e){return e?(e=this.prettify(e),e.endsWith("y")&&(e=e.slice(0,e.length-1)+"ie"),e+="s",e):""},iconForGroup(e){if("plugin"===this.value.grouping&&d[e]){const t=d[e];return{"icon-class":t["class"]?.length||!t.imgUrl?.length?t["class"]:"fas fa-gears","icon-url":t.imgUrl}}return{}},sync(){const e={...this.value};e.searchTerm=this.searchTerm,e.selectedEntities=this.selectedEntities,e.selectedGroups=this.selectedGroups,this.$emit("input",e)},refreshGroupFilter(){this.selectedGroups=Object.keys(this.entityGroups[this.value?.grouping]||{}).reduce(((e,t)=>(e[t]=!0,e)),{}),this.sync()},toggleGroup(e){this.selectedGroups[e]=!this.selectedGroups[e],this.sync()},processEntityUpdate(e){const t=e[this.value?.grouping];t&&null==this.selectedGroups[t]&&(this.selectedGroups[t]=!0)},onGroupingChanged(e){if(!this.entityGroups[e]||e===this.value?.grouping)return!1;const t={...this.value};t.grouping=e,this.$emit("input",t)}},mounted(){this.refreshGroupFilter(),this.$watch((()=>this.value?.grouping),(()=>{this.refreshGroupFilter()})),this.$watch((()=>this.searchTerm),this.sync),g.$.onEntity(this.processEntityUpdate)}},m=s(3744);const G=(0,m.Z)(f,[["render",c],["__scopeId","data-v-334516c0"]]);var y=G}}]);
//# sourceMappingURL=667.6ae5a2a6.js.map