
/* Smart UI v24.0.16 (2025-09-03) 
Copyright (c) 2011-2024 jQWidgets. 
License: https://htmlelements.com/license/ */ //

(()=>{"use strict";class e{_setRowProperty(e,t,a){const o=this,r=o.rowById[e];r&&(r[t]=a,o.stateSettings.autoSave&&o.stateSettings.current&&!o.stateSettings.loading&&o.saveState())}_setRowsProperty(e,t,a){const o=this;o._refreshLayout(),o._refreshRowHierarchy(!0);const r=o._recyclingRows;o.rows.canNotify=!1;for(let s=0;s<r.length;s++){const d=r[s];a&&-1===a.indexOf(d.id)||(d[e]=t,"expanded"===e&&o.dataSource&&(t?o.dataSource._expandedRowIds[d.data.$.id]=!0:delete o.dataSource._expandedRowIds[d.data.$.id]),d.data&&void 0!==d.data[e]&&(d.data[e]=t))}o.rows.canNotify=!0,o.refresh()}expandRowsToGroupLevel(e){this._expandCollapseGroupsToLevel(!0,e)}_expandCollapseGroupsToLevel(e,t){const a=this;a._refreshLayout(),a._refreshRowHierarchy(!0);const o=a._recyclingRows;a.rows.canNotify=!1;for(let r=0;r<o.length;r++){const s=o[r];s.data.level<t&&(s.expanded=s.data.expanded=e,a.dataSource&&(e?a.dataSource._expandedRowIds[s.data.$.id]=!0:delete a.dataSource._expandedRowIds[s.data.$.id]))}a.rows.canNotify=!0,a.refresh()}_applyThreeStates(e){const t=this,a=e!==t.rowHierarchy;if(!t.rowHierarchy)return;const o=a?e.children:t.rowHierarchy.filter((e=>{if(0===e.level)return e}));let r=0,s=0;for(let d=0;d<o.length;d++){const c=o[d];e.checked&&(c.checked=!0),!1===c.leaf&&t._applyThreeStates(c),a&&(c.checked?r++:null===c.checked&&s++)}a&&(r===e.children.length?e.checked=!0:0===r&&0===s?e.checked=!1:t.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1)}_hasThreeStates(e,t){const a=this;let o=e;for(e!==t&&(e.checked?e.checked=!1:e.checked=!0);o.parent;){const e=o.parent,t=e.children;let r=0,s=0;for(let e=0;e<t.length;e++)t[e].checked?r++:a.checkBoxes.hasThreeStates&&null===t[e].checked&&s++;r===e.children.length?e.checked=!0:0===r&&0===s?e.checked=!1:a.checkBoxes.hasThreeStates?e.checked=null:e.checked=!1,o=e}e.leaf||function e(t,a){const o=t.children;for(let t=0;t<o.length;t++){const r=o[t];r.checked=a,!1===r.leaf&&e(r,a)}}(e,e.checked)}_expandCollapseGroup(e,t){const a=this;if(!a.grouping.enabled||!a.rowHierarchy)return;e&&e.indexOf&&e.indexOf("Item")>=0&&(e=e.replace("Item",""));const o=(""+e).split(".");let r=a.rowHierarchy[o[0]];if(!r)return;const s=a.rows.canNotify;a.rows.canNotify=!1,null===t&&(t=!r.expanded),r.expanded=r.data.expanded=t,a._saveRowState(r.id,!r.expanded);for(let e=1;e<o.length&&(r=r.children[o[e]],r&&!r.leaf);e++)r.expanded=r.data.expanded=t;a.rows.canNotify=s,a._refresh(),a.stateSettings.autoSave&&a.stateSettings.current&&!a.stateSettings.loading&&a.saveState()}_saveRowState(e,t=!1){const a=this,o=a.rowById[e];if(o&&a.dataSource){if(t)return void delete a.dataSource._expandedRowIds[o.data.$.id];a.dataSource._expandedRowIds[o.data.$.id]=!0}}expandRow(e){const t=this;t.grouping.enabled?t._expandCollapseGroup(e,!0):e&&Array.isArray(e)?t._setRowsProperty("expanded",!0,e):(t._setRowProperty(e,"expanded",!0),t._saveRowState(e))}expandAllRows(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!0,99):e._setRowsProperty("expanded",!0)}collapseAllRows(){const e=this;e.grouping.enabled?e._expandCollapseGroupsToLevel(!1,99):e._setRowsProperty("expanded",!1)}toggleRow(e){const t=this;if(t.grouping.enabled)return void t._expandCollapseGroup(e,null);const a=t.rowById[e];a&&(a.expanded?a.expanded=!1:a.expanded=!0)}collapseRow(e){const t=this;t.grouping.enabled?t._expandCollapseGroup(e,!1):e&&Array.isArray(e)?t._setRowsProperty("expanded",!1,e):(t._setRowProperty(e,"expanded",!1),t._saveRowState(e,!0))}checkRow(e){const t=this;e&&Array.isArray(e)?t._setRowsProperty("checked",!0,e):t._setRowProperty(e,"checked",!0)}uncheckRow(e){const t=this;e&&Array.isArray(e)?t._setRowsProperty("checked",!1,e):t._setRowProperty(e,"checked",!1)}checkAllRows(){this._setRowsProperty("checked",!0)}uncheckAllRows(){this._setRowsProperty("checked",!1)}}Smart.Utilities.Grid.Tree=e})();