import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { a as getLang, l as filterData, t as tinyMDtoHTML } from './helpers.js';
import { d as defineCustomElement$4 } from './component4.js';
import { d as defineCustomElement$3 } from './component5.js';
import { d as defineCustomElement$2 } from './component.js';
import { d as defineCustomElement$1 } from './component13.js';

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

var dayjs_min = {exports: {}};

(function (module, exports) {
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
}(dayjs_min));

const dayjs = dayjs_min.exports;

const styleCss = "x-datatable x-datatable-col{display:none}x-datatable.fluid>.toolbar{padding-left:0.5rem;padding-right:0.5em}x-datatable.fluid>.wrap{border-radius:0;-webkit-box-shadow:none;box-shadow:none;border-right:none !important;border-left:none !important}x-datatable>.toolbar{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;width:100%}x-datatable>.toolbar x-input{max-width:18rem;margin-right:0.5rem;margin-bottom:0.5rem}x-datatable>.toolbar x-input .input-container{border-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.35)}.is-dark-mode x-datatable>.toolbar x-input .input-container{border-color:var(--color-dark-tint, #414141)}x-datatable>.toolbar x-input .filters{z-index:9999;position:absolute;margin:2px 0 0;top:54px;list-style:none;padding:0 0.5rem 0.5rem;background-color:var(--color-border-lucid, #f7f7f7);border:1px solid var(--color-border-tinted, #d9d8db);min-width:14rem;max-width:100%;font-family:\"Poppins\", \"Arial\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", \"Liberation Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";display:none;width:100%;-webkit-box-shadow:0px 12px 10px -8px rgba(0, 0, 0, 0.1);box-shadow:0px 12px 10px -8px rgba(0, 0, 0, 0.1);border-radius:0.5rem}x-datatable>.toolbar x-input .filters.active{display:block;-webkit-animation:fadeIn 0.3s;animation:fadeIn 0.3s}x-datatable>.toolbar x-input .filters .arrow{position:absolute;top:calc(-0.6rem - 1px);right:1rem;width:1.2rem;height:1.2rem;display:block;background-color:var(--color-border-lucid, #f7f7f7);border:1px solid var(--color-border-tinted, #d9d8db);border-right:none;border-bottom:none;-webkit-transform:rotate(45deg);transform:rotate(45deg);border-top-left-radius:0.25rem}.is-dark-mode x-datatable>.toolbar x-input .filters .arrow{background-color:var(--color-dark-shade, #1a1a1a);border:1px solid var(--color-dark-tint, #414141);border-right:none;border-bottom:none}.is-dark-mode x-datatable>.toolbar x-input .filters{background-color:var(--color-dark-shade, #1a1a1a);border:1px solid var(--color-dark-tint, #414141)}x-datatable>.toolbar x-input .filters:empty{display:none !important}x-datatable>.toolbar x-input .filters x-datatable-filter{display:block}x-datatable>.toolbar>div{display:block}x-datatable>.toolbar>div:empty{display:none}x-datatable>.toolbar>div x-button{margin-right:0.5rem;margin-bottom:0.5rem}x-datatable>.toolbar>div x-button:last-of-type{margin-right:0}x-datatable>.wrap{position:relative;max-width:100%;width:100%;margin:1rem auto;margin-top:0;overflow-x:auto;background-color:var(--color-white, #FFFFFF);border:1px solid rgba(var(--color-border-rgb, 200, 199, 204), 0.35);-webkit-box-shadow:0px 3px 1rem rgba(var(--color-border-rgb, 200, 199, 204), 0.2);box-shadow:0px 3px 1rem rgba(var(--color-border-rgb, 200, 199, 204), 0.2);border-radius:0.5rem}.is-dark-mode x-datatable>.wrap{color:var(--color-text-light, #FEFEFE);background-color:var(--color-black, #000000);-webkit-box-shadow:0px 3px 1rem rgba(var(--color-black-rgb, 0, 0, 0), 0.35);box-shadow:0px 3px 1rem rgba(var(--color-black-rgb, 0, 0, 0), 0.35);border:1px solid var(--color-dark-tint, #414141)}x-datatable table{position:relative;width:100%;border:none;border-collapse:collapse;overflow:hidden}x-datatable table [data-align=left]{text-align:left}x-datatable table [data-align=center]{text-align:center}x-datatable table [data-align=right]{text-align:right}x-datatable table thead th{white-space:nowrap;border:0 solid transparent;padding:1.25rem 1.25rem;font-weight:600;text-transform:uppercase;font-size:0.75rem;line-height:1em;color:inherit;vertical-align:middle;position:relative}x-datatable table thead th:hover .sortable{opacity:1}x-datatable table thead th:not(:last-child)::after{content:\"\";width:1px;border-right:1px solid rgba(var(--color-border-rgb, 200, 199, 204), 0.35);position:absolute;right:0;top:1rem;bottom:1rem}.is-dark-mode x-datatable table thead th:not(:last-child)::after{border-color:var(--color-dark-tint, #414141)}x-datatable table thead th .sortable{cursor:pointer;-webkit-transition:0.4s;transition:0.4s;opacity:0.3;position:absolute;right:0;left:0;top:0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;-ms-flex-pack:center;justify-content:center;-ms-flex-direction:column;flex-direction:column}x-datatable table thead th .sortable i{pointer-events:none;margin-right:0.5rem;margin-top:-0.1rem;margin-bottom:-0.1rem;-webkit-transform-origin:center;transform-origin:center;-webkit-transition:0.4s;transition:0.4s;font-size:0.5rem}x-datatable table thead th .sortable i.asc{-webkit-transform:rotate(180deg);transform:rotate(180deg)}x-datatable table thead th .sortable[data-sort]{opacity:0.8}x-datatable table thead th .sortable[data-sort=asc] i.desc{display:none}x-datatable table thead th .sortable[data-sort=desc] i.asc{display:none}x-datatable table thead th>span i[class^=icon-]{font-size:1.25rem !important}x-datatable table tbody tr{-webkit-transition:background-color 0.4s, border 0.4s, -webkit-box-shadow 0.3s;transition:background-color 0.4s, border 0.4s, -webkit-box-shadow 0.3s;transition:background-color 0.4s, border 0.4s, box-shadow 0.3s;transition:background-color 0.4s, border 0.4s, box-shadow 0.3s, -webkit-box-shadow 0.3s}x-datatable table tbody tr.group td{padding:0.5rem 0.6rem}x-datatable table tbody tr.group td>div{background-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.2);border-radius:0.25rem;padding:0.125rem 0.65rem;font-weight:bolder;font-size:0.85rem}x-datatable table tbody tr:hover:not(.group){background-color:hsla(0, 0%, 74.5%, 0.1);cursor:pointer;-webkit-box-shadow:inset 0 1px 0 rgba(var(--color-border-rgb, 200, 199, 204), 0.1), inset 0 -1px 0 rgba(var(--color-border-rgb, 200, 199, 204), 0.1);box-shadow:inset 0 1px 0 rgba(var(--color-border-rgb, 200, 199, 204), 0.1), inset 0 -1px 0 rgba(var(--color-border-rgb, 200, 199, 204), 0.1)}x-datatable table tbody tr td{padding:0.875rem 1.25rem;color:var(--color-text-tint, #656565);-webkit-box-sizing:content-box;box-sizing:content-box;vertical-align:middle;white-space:nowrap}.is-dark-mode x-datatable table tbody tr td{color:var(--color-text-light-shade, #d8d8d8)}x-datatable table tbody tr td .cell-template x-icon{font-size:1.75rem !important;margin:0 1px !important}x-datatable table tbody tr td .cell-template x-button button,x-datatable table tbody tr td .cell-template x-button a{padding:0.9rem 0.25rem;max-height:1.75rem;height:1.2rem;font-size:0.875rem}x-datatable table tbody tr td .cell-template x-button button x-icon,x-datatable table tbody tr td .cell-template x-button a x-icon{font-size:1rem !important}x-datatable table tbody tr td tt{font-family:inherit}x-datatable table tbody tr td x-tooltip{display:block}x-datatable table tbody tr td[data-type=date],x-datatable table tbody tr td[data-type=time]{text-align:center;padding-top:0.5rem;padding-bottom:0.5rem}x-datatable table tbody tr td[data-type=date] p,x-datatable table tbody tr td[data-type=time] p{font-size:0.6rem;display:block;text-align:inherit;line-height:1em;font-weight:bolder;padding:2px 0px;margin:0px;text-transform:uppercase;opacity:0.85}x-datatable table tbody tr td[data-type=date] h5,x-datatable table tbody tr td[data-type=time] h5{font-size:1.25rem;display:block;text-align:inherit;line-height:1em;font-weight:bolder;padding:0px;margin:0px}x-datatable table tbody tr td[data-type=date] div{text-align:center}x-datatable table tbody tr td[data-type=time] div{text-align:left;display:inline-block}x-datatable table tbody tr td[data-type=time] p{padding-left:0.2rem}x-datatable table .message td{padding:0.6rem}x-datatable table .message td x-alert{margin-bottom:0px;padding:1.2rem 1.5rem;padding-left:3.5rem;-webkit-animation:0.3s fadeInUp;animation:0.3s fadeInUp}x-datatable table .message td x-alert x-icon{width:2.5rem;height:2.5rem;font-size:2.5rem !important;top:0.6rem;left:0.6rem;-webkit-animation:none;animation:none}x-datatable table .loading td{padding:0.6rem}x-datatable table .show-more td{border-top:1px solid rgba(var(--color-border-rgb, 200, 199, 204), 0.2);text-align:center;cursor:pointer;background-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.05);font-size:0.85rem;-webkit-transition:0.3s;transition:0.3s}x-datatable table .show-more td:hover{background-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.1)}.is-dark-mode x-datatable table .show-more td:hover{background-color:rgba(50, 50, 50, 0.25)}x-datatable table .empty td{padding-top:4rem;padding-bottom:4rem;-webkit-transition:0.4s;transition:0.4s;text-align:center;opacity:0.8;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}x-datatable table .empty td i[class^=icon-]{font-size:6rem;display:block;margin:0 auto 1rem}x-datatable table .empty td p{font-size:1.25rem}x-datatable .pagination{font-size:0.8rem;margin-top:-0.35rem;margin-bottom:1rem;padding:0 1rem;opacity:0.5;color:var(--color-text, #4A4A4A)}.is-dark-mode x-datatable .pagination{color:var(--color-text-light, #FEFEFE)}x-datatable-filter{display:none;border-bottom:1px dashed rgba(var(--color-default-rgb, 155, 155, 155), 0.2);padding:0px}x-datatable-filter x-datatable-filter-item{border-bottom:1px dashed rgba(var(--color-default-rgb, 155, 155, 155), 0.2);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;color:var(--color-text, #4A4A4A);text-decoration:none;padding:0.5rem 0.25rem;border-radius:0.2rem;line-height:1em}.is-dark-mode x-datatable-filter x-datatable-filter-item{color:var(--color-text-light, #FEFEFE)}x-datatable-filter x-datatable-filter-item x-icon{width:1em;height:1em;line-height:1em;margin-right:0.5rem;-webkit-animation:0.3s fadeInLeft;animation:0.3s fadeInLeft}x-datatable-filter x-datatable-filter-item:hover{cursor:pointer;background-color:rgba(var(--color-default-rgb, 155, 155, 155), 0.2);border-color:transparent}x-datatable-filter:last-child{border:none}x-datatable-filter .form-between{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}x-datatable-filter .form-between b{white-space:nowrap}x-datatable-filter .form-between .field-container{-ms-flex:1;flex:1}x-datatable-filter .filter-header{display:block;background-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.3);padding:0.45rem 0.5rem;padding-right:1.5rem;border-radius:0.35rem;position:relative;cursor:pointer;-webkit-animation:0.3s fadeIn;animation:0.3s fadeIn}x-datatable-filter .filter-header.is-ready{background-color:var(--color-primary-lucid, #e3eafd);color:var(--color-primary-shaded, #2e52a9)}.is-dark-mode x-datatable-filter .filter-header.is-ready{background-color:var(--color-primary-shaded, #2e52a9);color:var(--color-primary-lucid, #e3eafd)}.is-dark-mode x-datatable-filter .filter-header{background-color:rgba(var(--color-border-rgb, 200, 199, 204), 0.3)}x-datatable-filter .filter-header h5{font-size:0.75rem;line-height:1.35em;margin:0px}x-datatable-filter .filter-header p{font-size:0.75rem;line-height:1.3em;margin:0px;overflow:hidden;white-space:nowrap}x-datatable-filter .filter-header i{font-size:0.8em}x-datatable-map{display:none}@media (max-width: 576px){x-datatable>.toolbar{display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse;-ms-flex-pack:justify;justify-content:space-between;width:100%}x-datatable>.toolbar x-input{max-width:100%;margin-right:0}x-datatable>.toolbar>div [slot=actions]{width:100%;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}x-datatable>.toolbar>div x-button{width:100%}}";
const XDatatableCellStyle0 = styleCss;

const ColumnProps = ['class', 'data', 'resizable', 'sortable', 'type', 'width', 'align', 'mapping', 'label'];
const XDatatableCell = /*@__PURE__*/ proxyCustomElement(class XDatatableCell extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.value = undefined;
        this.row = undefined;
        this.col = undefined;
    }
    /**
     * On element is mounted
     */
    componentWillLoad() {
        this.valueMapping = this.col.mapping.find(map => map.to === '_');
        this.updateValue();
        dayjs.locale(getLang());
    }
    /**
     * On element is updated
     */
    componentWillUpdate() {
        this.updateValue();
    }
    /**
     * Update the value on changes
     */
    updateValue() {
        const lastValue = this.value;
        this.value = String(this.row[this.col.field]);
        if (lastValue != this.value) {
            this.attrs = this.getExtraAttributes();
        }
        if (this.valueMapping) {
            if (this.valueMapping.from) {
                this.value = this.row[this.valueMapping.from];
            }
            else if (Object.keys(this.valueMapping.value).includes(this.value)) {
                this.value = this.valueMapping.value[this.value];
            }
        }
    }
    /**
     * Compute the column attributes
     */
    getExtraAttributes() {
        const attrs = this.col
            .getAttributeNames()
            .filter(attr => !ColumnProps.includes(attr) && !attr.startsWith('on'))
            .reduce((acc, attr) => {
            acc[attr] = this.col.getAttribute(attr);
            return acc;
        }, {});
        if (this.col.mapping.length > 0) {
            this.col.mapping
                .filter(map => map.to && map.to != '_')
                .forEach(map => {
                var _a;
                if (map.from) {
                    attrs[map.to] = (_a = this.row[map.from]) !== null && _a !== void 0 ? _a : null;
                }
                else if (Object.keys(map.value).includes(this.value)) {
                    attrs[map.to] = map.value[this.value];
                }
            });
        }
        return attrs;
    }
    /**
     * Verify if the column has extra attribute
     */
    has(attr) {
        return Object.keys(this.attrs).length && this.attrs.hasOwnProperty(attr);
    }
    /**
     * Add tooltip to element
     */
    renderWithTooltip(content) {
        if (this.has('description')) {
            return h("x-tooltip", { content: this.attrs.description }, content);
        }
        return content;
    }
    /**
     * Bold type render
     */
    renderBoldType() {
        return h("strong", null, this.value);
    }
    /**
     * Amount type render
     */
    renderAmountType() {
        const value = Number(this.value);
        if (Number.isNaN(value)) {
            return h("div", null, h("span", { class: "muted" }, "\u2022\u2022\u2022"));
        }
        return h("div", null, this.has('prepend') && h("span", { class: "muted" }, this.attrs.prepend), h("span", null, value.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",")), this.has('append') && h("span", { class: "muted" }, this.attrs.append));
    }
    /**
     * Date type render
     */
    renderDateType() {
        const date = dayjs(this.value);
        if (!date.isValid()) {
            return h("div", null, h("h5", { class: "muted" }, "\u2022\u2022"));
        }
        return h("div", null, h("p", null, date.format('MMM')), h("h5", null, date.format('DD')), h("p", null, date.format('YYYY')));
    }
    /**
     * Number type render
     */
    renderNumberType() {
        return h("div", null, this.has('prepend') && h("span", { class: "muted" }, this.attrs.prepend), this.has('fixed') && !Number.isNaN(this.attrs.fixed) ?
            Number.parseFloat(this.value).toFixed(parseInt(this.attrs.fixed)) :
            this.value, this.has('append') && h("span", { class: "muted" }, this.attrs.append));
    }
    /**
     * Time type render
     */
    renderTimeType() {
        const date = dayjs(this.value);
        if (!date.isValid()) {
            return h("div", null, h("h5", { class: "muted" }, "\u2022\u00A0:\u00A0\u2022"));
        }
        return h("div", null, h("h5", null, date.format('h:mm')), h("p", null, date.format('A')));
    }
    /**
     * Badge type render
     */
    renderBadgeType() {
        return this.renderWithTooltip(h("x-badge", Object.assign({}, this.attrs), this.value));
    }
    /**
     * Icon type render
     */
    renderIconType() {
        return this.renderWithTooltip(h("x-icon", Object.assign({ size: "2rem", name: this.value }, this.attrs)));
    }
    /**
     * Image type render
     */
    renderImageType() {
        return this.renderWithTooltip(h("x-avatar", Object.assign({ size: "2rem", image: this.value }, this.attrs)));
    }
    /**
     * Template type render
     */
    renderTemplateType() {
        return h("div", { class: "cell-template", innerHTML: filterData(this.col.content, this.row) });
    }
    /**
     * Default type render
     */
    renderDefaultType() {
        if (this.has('description')) {
            return h("div", null, h("p", { class: "m-0" }, this.value), h("small", { class: "m-0 muted", innerHTML: tinyMDtoHTML(this.attrs.description, this.row) }));
        }
        return this.value;
    }
    /**
     * Stringify the element
     */
    renderCell() {
        switch (this.col.type) {
            case 'bold': return this.renderBoldType();
            case 'amount': return this.renderAmountType();
            case 'date': return this.renderDateType();
            case 'number': return this.renderNumberType();
            case 'time': return this.renderTimeType();
            case 'badge': return this.renderBadgeType();
            case 'icon': return this.renderIconType();
            case 'image': return this.renderImageType();
            case 'template': return this.renderTemplateType();
            default: return this.renderDefaultType();
        }
    }
    /**
     * Render element
     */
    render() {
        return h(Host, { key: '6a78f0bbc44553e4912df14786d205c9cc098db5' }, this.renderCell());
    }
    static get style() { return XDatatableCellStyle0; }
}, [0, "x-datatable-cell", {
        "row": [16],
        "col": [16],
        "value": [32]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["x-datatable-cell", "x-avatar", "x-badge", "x-icon", "x-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "x-datatable-cell":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, XDatatableCell);
            }
            break;
        case "x-avatar":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "x-badge":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "x-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "x-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { XDatatableCell as X, defineCustomElement as d };
