var __awaiter=this&&this.__awaiter||function(e,t,n,i){function l(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function a(e){try{s(i.next(e))}catch(t){r(t)}}function o(e){try{s(i["throw"](e))}catch(t){r(t)}}function s(e){e.done?n(e.value):l(e.value).then(a,o)}s((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,l,r,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(e){return function(t){return s([e,t])}}function s(a){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,l&&(r=a[0]&2?l["return"]:a[0]?l["throw"]||((r=l["return"])&&r.call(l),0):l.next)&&!(r=r.call(l,a[1])).done)return r;if(l=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;l=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(o){a=[6,o];l=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-9910f372.system.js","./p-b771bfdd.system.js","./p-da7f8c42.system.js","./p-4cf88a4b.system.js"],(function(e){"use strict";var t,n,i,l,r,a;return{setters:[function(e){t=e.r;n=e.c;i=e.g},function(e){l=e.i},function(e){r=e.c},function(e){a=e.T}],execute:function(){var o;(function(e){e["DESELECT_COLUMN"]="Deselect column";e["SELECT_COLUMN"]="Select Column"})(o||(o={}));var s="td.anj-selectable";var c=e("anj_column_selection",function(){function e(e){var i=this;t(this,e);this.cellClickListener=function(e){return i.onCellClick(e)};this.cellKeyListener=l(this.onCellClick.bind(this));this.tableWillUpdateListener=function(){return i.onTableWillChange()};this.tableDidUpdateListener=function(){return i.onTableDidChange()};this.anjColumnSelect=n(this,"anjColumnSelect",7)}e.prototype.componentWillLoad=function(){this.table=this.element.closest("anj-table")};e.prototype.componentDidLoad=function(){this.table.addEventListener("anjTableWillUpdate",this.tableWillUpdateListener);this.table.addEventListener("anjTableDidUpdate",this.tableDidUpdateListener)};e.prototype.componentDidUnload=function(){this.onTableWillChange();this.table.removeEventListener("anjTableWillUpdate",this.tableWillUpdateListener);this.table.removeEventListener("anjTableDidUpdate",this.tableDidUpdateListener)};e.prototype.onTableWillChange=function(){var e=this;Array.from(this.table.querySelectorAll(s)).forEach((function(t){t.removeEventListener("click",e.cellClickListener);t.removeEventListener("keyup",e.cellKeyListener)}))};e.prototype.onTableDidChange=function(){return __awaiter(this,void 0,void 0,(function(){var e;var t=this;return __generator(this,(function(n){switch(n.label){case 0:return[4,this.table.getColumns()];case 1:e=n.sent();Array.from(this.table.querySelectorAll(s)).forEach((function(n){var i=r(e,n);var l=t.table.selectedColumnFields.includes(i.field);n.tabIndex=0;n.setAttribute("aria-label",l?t.translator(o.DESELECT_COLUMN)+": "+i.name:t.translator(o.SELECT_COLUMN)+": "+i.name);n.addEventListener("click",t.cellClickListener);n.addEventListener("keyup",t.cellKeyListener)}));return[2]}}))}))};e.prototype.onCellClick=function(e){var t=e.target;var n=t.tagName==="TD"?t:t.closest("td");var i=n.dataset.columnField;this.table.selectedColumnFields=this.table.selectedColumnFields.includes(i)?[]:[i];this.anjColumnSelect.emit({field:i,selectedColumnFields:this.table.selectedColumnFields})};Object.defineProperty(e.prototype,"element",{get:function(){return i(this)},enumerable:true,configurable:true});Object.defineProperty(e,"style",{get:function(){return".anj-table .anj-cell.anj-selected-col,.anj-table .anj-header-cell.anj-selected-col{background-color:var(--anj-background)!important}"},enumerable:true,configurable:true});return e}());a.injectProps(c,["translator"])}}}));