!(function (t, e) { "function" == typeof define && define.amd ? define(["jquery"], function (a) { return (t.Tablesaw = e(a, t)); }) : "object" == typeof exports ? (module.exports = e( "document" in t ? require("jquery") : require("jquery")(t), t )) : (t.Tablesaw = e(jQuery, t)); })("undefined" != typeof window ? window : this, function (t, e) { "use strict"; var a = e.document, s = /complete|loaded/.test(a.readyState); a.addEventListener("DOMContentLoaded", function () { s = !0; }); var n, i, o, l, r, c, h, d, u, b = { i18n: { modeStack: "Stack", modeSwipe: "Swipe", modeToggle: "Toggle", modeSwitchColumnsAbbreviated: "Cols", modeSwitchColumns: "Columns", columnToggleButton: "Columns", columnToggleError: "No eligible columns.", sort: "Sort", swipePreviousColumn: "Previous column", swipeNextColumn: "Next column", }, mustard: "head" in a && (!e.blackberry || e.WebKitPoint) && !e.operamini, $: t, _init: function (t) { b.$(t || a).trigger("enhance.tablesaw"); }, init: function (t) { (s = s || /complete|loaded/.test(a.readyState)) ? b._init(t) : "addEventListener" in a && a.addEventListener("DOMContentLoaded", function () { b._init(t); }); }, }; return ( t(a).on("enhance.tablesaw", function () { "undefined" != typeof TablesawConfig && TablesawConfig.i18n && (b.i18n = t.extend(b.i18n, TablesawConfig.i18n || {})), (b.i18n.modes = [ b.i18n.modeStack, b.i18n.modeSwipe, b.i18n.modeToggle, ]); }), b.mustard && t(a.documentElement).addClass("tablesaw-enhanced"), (function () { var s = "tablesaw-bar", n = { create: "tablesawcreate", destroy: "tablesawdestroy", refresh: "tablesawrefresh", resize: "tablesawresize", }, i = {}; b.events = n; var o = function (e) { if (!e) throw new Error("Tablesaw requires an element."); (this.table = e), (this.$table = t(e)), (this.$thead = this.$table.children().filter("thead").eq(0)), (this.$tbody = this.$table.children().filter("tbody")), (this.mode = this.$table.attr("data-tablesaw-mode") || "stack"), (this.$toolbar = null), (this.attributes = { subrow: "data-tablesaw-subrow", ignorerow: "data-tablesaw-ignorerow", }), this.init(); }; (o.prototype.init = function () { if (!this.$thead.length) throw new Error( "tablesaw: a is required, but none was found." ); if (!this.$thead.find("th").length) throw new Error( "tablesaw: no header cells found. Are you using inside of ?" ); this.$table.attr("id") || this.$table.attr("id", "tablesaw-" + Math.round(1e4 * Math.random())), this.createToolbar(), this._initCells(), this.$table.data("tablesaw", this), this.$table.trigger(n.create, [this]); }), (o.prototype.getConfig = function (e) { var a = t.extend(i, e || {}); return t.extend( a, "undefined" != typeof TablesawConfig ? TablesawConfig : {} ); }), (o.prototype._getPrimaryHeaderRow = function () { return this._getHeaderRows().eq(0); }), (o.prototype._getHeaderRows = function () { return this.$thead .children() .filter("tr") .filter(function () { return !t(this).is("[data-tablesaw-ignorerow]"); }); }), (o.prototype._getRowIndex = function (t) { return t.prevAll().length; }), (o.prototype._getHeaderRowIndeces = function () { var e = this, a = []; return ( this._getHeaderRows().each(function () { a.push(e._getRowIndex(t(this))); }), a ); }), (o.prototype._getPrimaryHeaderCells = function (t) { return (t || this._getPrimaryHeaderRow()).find("th"); }), (o.prototype._$getCells = function (e) { var a = this; return t(e) .add(e.cells) .filter(function () { var e = t(this), s = e.parent(), n = e.is("[colspan]"); return !( s.is("[" + a.attributes.subrow + "]") || (s.is("[" + a.attributes.ignorerow + "]") && n) ); }); }), (o.prototype._getVisibleColspan = function () { var e = 0; return ( this._getPrimaryHeaderCells().each(function () { var a = t(this); "none" !== a.css("display") && (e += parseInt(a.attr("colspan"), 10) || 1); }), e ); }), (o.prototype.getColspanForCell = function (e) { var a = this._getVisibleColspan(), s = 0; return ( e.closest("tr").data("tablesaw-rowspanned") && s++, e.siblings().each(function () { var e = t(this), a = parseInt(e.attr("colspan"), 10) || 1; "none" !== e.css("display") && (s += a); }), a - s ); }), (o.prototype.isCellInColumn = function (e, a) { return t(e) .add(e.cells) .filter(function () { return this === a; }).length; }), (o.prototype.updateColspanCells = function (e, a, s) { var n = this, i = n._getPrimaryHeaderRow(); this.$table .find("[rowspan][data-tablesaw-priority]") .each(function () { var e = t(this); if ("persist" === e.attr("data-tablesaw-priority")) { var a = e.closest("tr"), s = parseInt(e.attr("rowspan"), 10); s > 1 && ((a = a.next()).data("tablesaw-rowspanned", !0), s--); } }), this.$table .find("[colspan],[data-tablesaw-maxcolspan]") .filter(function () { return t(this).closest("tr")[0] !== i[0]; }) .each(function () { var i = t(this); if (void 0 === s || n.isCellInColumn(a, this)) { var o = n.getColspanForCell(i); e && void 0 !== s && i[0 === o ? "addClass" : "removeClass"](e); var l = parseInt(i.attr("data-tablesaw-maxcolspan"), 10); l ? o > l && (o = l) : i.attr("data-tablesaw-maxcolspan", i.attr("colspan")), i.attr("colspan", o); } }); }), (o.prototype._findPrimaryHeadersForCell = function (t) { for ( var e = this._getPrimaryHeaderRow(), a = this._getRowIndex(e), s = [], n = 0; n < this.headerMapping.length; n++ ) if (n !== a) for (var i = 0; i < this.headerMapping[n].length; i++) this.headerMapping[n][i] === t && s.push(this.headerMapping[a][i]); return s; }), (o.prototype.getRows = function () { var e = this; return this.$table.find("tr").filter(function () { return t(this).closest("table").is(e.$table); }); }), (o.prototype.getBodyRows = function (e) { return (e ? t(e) : this.$tbody).children().filter("tr"); }), (o.prototype.getHeaderCellIndex = function (t) { for (var e = this.headerMapping[0], a = 0; a < e.length; a++) if (e[a] === t) return a; return -1; }), (o.prototype._initCells = function () { this.$table.find("[data-tablesaw-maxcolspan]").each(function () { var e = t(this); e.attr("colspan", e.attr("data-tablesaw-maxcolspan")); }); var e = this.getRows(), a = []; e.each(function (t) { a[t] = []; }), e.each(function (e) { var s = 0; t(this) .children() .each(function () { for ( var t = parseInt( this.getAttribute("data-tablesaw-maxcolspan") || this.getAttribute("colspan"), 10 ), n = parseInt(this.getAttribute("rowspan"), 10); a[e][s]; ) s++; if (((a[e][s] = this), t)) for (var i = 0; i < t - 1; i++) s++, (a[e][s] = this); if (n) for (var o = 1; o < n; o++) a[e + o][s] = this; s++; }); }); for (var s = this._getHeaderRowIndeces(), n = 0; n < a[0].length; n++) for (var i = 0, o = s.length; i < o; i++) { var l, r = a[s[i]][n], c = s[i]; for (r.cells || (r.cells = []); c < a.length; ) r !== (l = a[c][n]) && r.cells.push(l), c++; } this.headerMapping = a; }), (o.prototype.refresh = function () { this._initCells(), this.$table.trigger(n.refresh, [this]); }), (o.prototype._getToolbarAnchor = function () { var t = this.$table.parent(); return t.is(".tablesaw-overflow") ? t : this.$table; }), (o.prototype._getToolbar = function (t) { return t || (t = this._getToolbarAnchor()), t.prev().filter("." + s); }), (o.prototype.createToolbar = function () { var e = this._getToolbarAnchor(), a = this._getToolbar(e); a.length || (a = t("
").addClass(s).insertBefore(e)), (this.$toolbar = a), this.mode && this.$toolbar.addClass("tablesaw-mode-" + this.mode); }), (o.prototype.destroy = function () { this._getToolbar().each(function () { this.className = this.className.replace( /\btablesaw-mode\-\w*\b/gi, "" ); }); var s = this.$table.attr("id"); t(a).off("." + s), t(e).off("." + s), this.$table.trigger(n.destroy, [this]), this.$table.removeData("tablesaw"); }), (t.fn.tablesaw = function () { return this.each(function () { t(this).data("tablesaw") || new o(this); }); }); var l = t(a); l.on("enhance.tablesaw", function (e) { if (b.mustard) { var a = t(e.target); a.parent().length && (a = a.parent()), a .find("table") .filter( "[data-tablesaw],[data-tablesaw-mode],[data-tablesaw-sortable]" ) .tablesaw(); } }); var r, c, h = !1; l.on("scroll.tablesaw", function () { (h = !0), e.clearTimeout(r), (r = e.setTimeout(function () { h = !1; }, 300)); }), t(e).on("resize", function () { h || (e.clearTimeout(c), (c = e.setTimeout(function () { l.trigger(n.resize); }, 150))); }), (b.Table = o); })(), (n = "tablesaw-stack"), (i = "tablesaw-cell-label"), (o = "tablesaw-cell-content"), (l = "tablesaw-stack"), (r = "data-tablesaw-no-labels"), (c = "data-tablesaw-hide-empty"), ((h = function (e, a) { (this.tablesaw = a), (this.$table = t(e)), (this.labelless = this.$table.is("[" + r + "]")), (this.hideempty = this.$table.is("[" + c + "]")), this.$table.data(l, this); }).prototype.init = function () { if ((this.$table.addClass(n), !this.labelless)) { var e = this; this.$table .find("th, td") .filter(function () { return !t(this).closest("thead").length; }) .filter(function () { return !( t(this).is("[" + r + "]") || t(this) .closest("tr") .is("[" + r + "]") || (e.hideempty && !t(this).html()) ); }) .each(function () { var s = t(a.createElement("b")).addClass(i), n = t(this); t(e.tablesaw._findPrimaryHeadersForCell(this)).each(function (e) { var n = t(this.cloneNode(!0)), i = n.find(".tablesaw-sortable-btn"); n.find(".tablesaw-sortable-arrow").remove(); var o = n.find("[data-tablesaw-checkall]"); if ((o.closest("label").remove(), o.length)) s = t([]); else { e > 0 && s.append(a.createTextNode(", ")); for (var l, r = i.length ? i[0] : n[0]; (l = r.firstChild); ) s[0].appendChild(l); } }), s.length && !n.find("." + o).length && n.wrapInner(""); var l = n.find("." + i); l.length ? l.replaceWith(s) : (n.prepend(a.createTextNode(" ")), n.prepend(s)); }); } }), (h.prototype.destroy = function () { this.$table.removeClass(n), this.$table.find("." + i).remove(), this.$table.find("." + o).each(function () { t(this).replaceWith(t(this.childNodes)); }); }), t(a) .on(b.events.create, function (t, e) { "stack" === e.mode && new h(e.table, e).init(); }) .on(b.events.refresh, function (e, a) { "stack" === a.mode && t(a.table).data(l).init(); }) .on(b.events.destroy, function (e, a) { "stack" === a.mode && t(a.table).data(l).destroy(); }), (b.Stack = h), (d = { _create: function () { return t(this).each(function () { t(this) .trigger("beforecreate.tablesawbtn") .tablesawbtn("_init") .trigger("create.tablesawbtn"); }); }, _init: function () { var e = t(this), a = this.getElementsByTagName("select")[0]; return ( a && t(this) .addClass("btn-select tablesaw-btn-select") .tablesawbtn("_select", a), e ); }, _select: function (e) { var s = function (e, s) { var n, i, o = t(s).find("option"), l = a.createElement("span"), r = !1; if ( (l.setAttribute("aria-hidden", "true"), (l.innerHTML = " "), o.each(function () { this.selected && (l.innerHTML = this.text); }), (i = e.childNodes), o.length > 0) ) { for (var c = 0, h = i.length; c < h; c++) (n = i[c]) && "SPAN" === n.nodeName.toUpperCase() && (e.replaceChild(l, n), (r = !0)); r || e.insertBefore(l, e.firstChild); } }; s(this, e), t(this).on("change refresh", function () { s(this, e); }); }, }), (t.fn.tablesawbtn = function (e, a, s, n) { return this.each(function () { return e && "string" == typeof e ? t.fn.tablesawbtn.prototype[e].call(this, a, s, n) : t(this).data("tablesawbtnactive") ? t(this) : (t(this).data("tablesawbtnactive", !0), void t.fn.tablesawbtn.prototype._create.call(this)); }); }), t.extend(t.fn.tablesawbtn.prototype, d), (function () { var s = "tablesaw-coltoggle", n = function (e) { (this.$table = t(e)), this.$table.length && ((this.tablesaw = this.$table.data("tablesaw")), (this.attributes = { btnTarget: "data-tablesaw-columntoggle-btn-target", set: "data-tablesaw-columntoggle-set", }), (this.classes = { columnToggleTable: "tablesaw-columntoggle", columnBtnContain: "tablesaw-columntoggle-btnwrap tablesaw-advance", columnBtn: "tablesaw-columntoggle-btn tablesaw-nav-btn down", popup: "tablesaw-columntoggle-popup", priorityPrefix: "tablesaw-priority-", }), (this.set = []), (this.$headers = this.tablesaw._getPrimaryHeaderCells()), this.$table.data(s, this)); }; (n.prototype.initSet = function () { var e = this.$table.attr(this.attributes.set); if (e) { var a = this.$table[0]; this.set = t("table[" + this.attributes.set + "='" + e + "']") .filter(function () { return this !== a; }) .get(); } }), (n.prototype.init = function () { if (this.$table.length) { var n, i, o, l, r, c, h = this, d = this.tablesaw.getConfig({ getColumnToggleLabelTemplate: function (t) { return ( "" ); }, }); this.$table.addClass(this.classes.columnToggleTable), (i = (n = this.$table.attr("id")) + "-popup"), (c = t( "
" )), (o = t( "" + b.i18n.columnToggleButton + "" )), (l = t( "
" )), (r = t("
")), (this.$popup = l); var u = !1; this.$headers.each(function () { var e = t(this), a = e.attr("data-tablesaw-priority"), s = h.tablesaw._$getCells(this); a && "persist" !== a && (s.addClass(h.classes.priorityPrefix + a), t(d.getColumnToggleLabelTemplate(e.text())) .appendTo(r) .find('input[type="checkbox"]') .data("tablesaw-header", this), (u = !0)); }), u || r.append(""), r.appendTo(l), r.find('input[type="checkbox"]').on("change", function (e) { var a; (v(e.target), h.set.length) && (t(h.$popup) .find("input[type='checkbox']") .each(function (t) { if (this === e.target) return (a = t), !1; }), t(h.set).each(function () { var n = t(this) .data(s) .$popup.find("input[type='checkbox']") .get(a); n && ((n.checked = e.target.checked), v(n)); })); }), o.appendTo(c); var f, p = t(this.$table.attr(this.attributes.btnTarget)); c.appendTo(p.length ? p : this.tablesaw.$toolbar), o.on("click.tablesaw", function (s) { s.preventDefault(), c.is(".visible") ? m() : (c.addClass("visible"), o.removeClass("down").addClass("up"), t(a).off("click." + n, m), e.clearTimeout(f), (f = e.setTimeout(function () { t(a).on("click." + n, m); }, 15))); }), l.appendTo(c), (this.$menu = r); var w, g = this.$table.closest(".tablesaw-overflow"); if (g.css("-webkit-overflow-scrolling")) g.on("scroll", function () { var a = t(this); e.clearTimeout(w), (w = e.setTimeout(function () { a.css("-webkit-overflow-scrolling", "auto"), e.setTimeout(function () { a.css("-webkit-overflow-scrolling", "touch"); }, 0); }, 100)); }); t(e).on(b.events.resize + "." + n, function () { h.refreshToggle(); }), this.initSet(), this.refreshToggle(); } function v(t) { var e = t.checked, a = h.getHeaderFromCheckbox(t), s = h.tablesaw._$getCells(a); s[e ? "removeClass" : "addClass"]("tablesaw-toggle-cellhidden"), s[e ? "addClass" : "removeClass"]("tablesaw-toggle-cellvisible"), h.updateColspanCells(a, e), h.$table.trigger("tablesawcolumns"); } function m(e) { (e && t(e.target).closest("." + h.classes.popup).length) || (t(a).off("click." + n), o.removeClass("up").addClass("down"), c.removeClass("visible")); } }), (n.prototype.getHeaderFromCheckbox = function (e) { return t(e).data("tablesaw-header"); }), (n.prototype.refreshToggle = function () { var t = this; this.$menu.find("input").each(function () { var e = t.getHeaderFromCheckbox(this); this.checked = "table-cell" === t.tablesaw._$getCells(e).eq(0).css("display"); }), this.updateColspanCells(); }), (n.prototype.updateColspanCells = function (t, e) { this.tablesaw.updateColspanCells("tablesaw-toggle-cellhidden", t, e); }), (n.prototype.destroy = function () { this.$table.removeClass(this.classes.columnToggleTable), this.$table.find("th, td").each(function () { t(this) .removeClass("tablesaw-toggle-cellhidden") .removeClass("tablesaw-toggle-cellvisible"), (this.className = this.className.replace( /\bui\-table\-priority\-\d\b/g, "" )); }); }), t(a).on(b.events.create, function (t, e) { "columntoggle" === e.mode && new n(e.table).init(); }), t(a).on(b.events.destroy, function (e, a) { "columntoggle" === a.mode && t(a.table).data(s).destroy(); }), t(a).on(b.events.refresh, function (e, a) { "columntoggle" === a.mode && t(a.table).data(s).refreshToggle(); }), (b.ColumnToggle = n); })(), (function () { function e(e) { var a = []; return ( t(e.childNodes).each(function () { var e = t(this); e.is("input, select") ? a.push(e.val()) : e.is(".tablesaw-cell-label") || a.push((e.text() || "").replace(/^\s+|\s+$/g, "")); }), a.join("") ); } var s = "tablesaw-sortable", n = "table[data-" + s + "]", i = "[data-" + s + "-switch]", o = { sortCol: "data-tablesaw-sortable-col", defaultCol: "data-tablesaw-sortable-default-col", numericCol: "data-tablesaw-sortable-numeric", subRow: "data-tablesaw-subrow", ignoreRow: "data-tablesaw-ignorerow", }, l = { head: s + "-head", ascend: s + "-ascending", descend: s + "-descending", switcher: s + "-switch", tableToolbar: "tablesaw-bar-section", sortButton: s + "-btn", }, r = { _create: function (e) { return t(this).each(function () { if (t(this).data(s + "-init")) return !1; t(this) .data(s + "-init", !0) .trigger("beforecreate." + s) [s]("_init", e) .trigger("create." + s); }); }, _init: function () { var a, n, r, c = t(this), h = c.data("tablesaw"); function d(e) { t.each(e, function (e, a) { var s = t(a); s.removeAttr(o.defaultCol), s.removeClass(l.ascend), s.removeClass(l.descend); }); } c.addClass(s), (a = c .children() .filter("thead") .find("th[" + o.sortCol + "]")), (r = a), t.each(r, function (e, a) { t(a).addClass(l.head); }), (function (e, a) { t.each(e, function (e, s) { var n = t("