"use strict";(self.webpackChunkdotcms_ui=self.webpackChunkdotcms_ui||[]).push([[8047],{48047:(m,d,h)=>{h.r(d),h.d(d,{dot_card_view:()=>u});var l=h(15861),i=h(55956);const o=(t,s)=>t&&t.length&&s&&"string"==typeof s?t.filter(({data:{inode:e}})=>s.split(",").includes(e)).map(({data:e})=>e):[],u=class{constructor(t){(0,i.r)(this,t),this.selected=(0,i.c)(this,"selected",7),this.cardClick=(0,i.c)(this,"cardClick",7),this.selection=[],this.items=[],this.value=void 0}watchItems(t){this.selection=o(t,this.value)}watchValue(t){this.selection=o(this.items,t)}getValue(){var t=this;return(0,l.Z)(function*(){return t.selection})()}clearValue(){var t=this;return(0,l.Z)(function*(){t.value="",t.getCards().forEach(e=>{e.checked=!1})})()}componentDidLoad(){this.selection=o(this.items,this.value),this.cards=this.getCards()}clearMenu(){this.cards.forEach(t=>{t.hideMenu()})}render(){var t=this;const s=(t=>t&&"string"==typeof t?t.split(","):[])(this.value);return(0,i.h)(i.H,null,this.items.map(e=>{return(0,i.h)("dot-card-contentlet",{onContextMenu:(n=(0,l.Z)(function*(c){c.preventDefault();const a=c.target;t.clearMenu(),a.showMenu(c.x,c.y)}),function(a){return n.apply(this,arguments)}),onContextMenuClick:()=>{this.clearMenu()},onClick:()=>{this.clearMenu(),this.cardClick.emit(e.data)},key:e.data.inode,checked:s.includes(e.data.inode),onCheckboxChange:({detail:{originalTarget:n,shiftKey:c}})=>{let a=!1;c&&n.checked&&this.cards.forEach(r=>{(r===n||r===this.lastChecked)&&(a=!a),a&&(r.checked=!0,this.setValue(n,r.item.data))}),this.lastChecked=n,this.setValue(n,e.data)},item:e});var n}))}setValue(t,s){t.checked?this.selection.push(s):this.selection=this.selection.filter(({identifier:e})=>e!==s.identifier),this.value=this.selection.map(({inode:e})=>e).join(","),this.selected.emit(this.selection)}getCards(){return this.el.shadowRoot.querySelectorAll("dot-card-contentlet")}get el(){return(0,i.g)(this)}static get watchers(){return{items:["watchItems"],value:["watchValue"]}}};u.style=':host{display:grid;grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));grid-gap:var(--basic-padding-2)}dot-card-contentlet{height:100%}dot-card-contentlet:before{content:"";display:inline-block;flex:0 0 0;height:0;padding-bottom:calc(100%)}'}}]);