wunderbaum 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,61 +2,71 @@
2
2
  /*!
3
3
  * Wunderbaum - util
4
4
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
5
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
6
- */const t={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},i=function(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}().isMac,s=/[&<>"'/]/g,n=/[<>"'/]/g,r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function l(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function o(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function a(e){throw new Error(e)}function d(e){return(""+e).replace(s,(function(e){return r[e]}))}function c(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function h(e){return e.indexOf(">")>=0&&a("not implemented"),e}function u(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return u(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":const e=i.name,n=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=n?n.value:void 0;break;case"text":default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function p(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const f=new Set(["Alt","Control","Meta","Shift"]);function g(e){return e?"string"==typeof e?document.querySelector(e):e:null}function v(e){let i=e.key,s=e.type,n=[];return e.altKey&&n.push("Alt"),e.ctrlKey&&n.push("Control"),e.metaKey&&n.push("Meta"),e.shiftKey&&n.push("Shift"),"click"===s||"dblclick"===s?n.push(t[e.button]+s):"wheel"===s?n.push(s):f.has(i)||n.push(i),n.join("+")}function m(...e){for(let t=1;t<e.length;t++){let i=e[t];if(null!=i)for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function w(e){return Array.isArray(e)}function b(e){return 0===Object.keys(e).length&&e.constructor===Object}function y(e){return"function"==typeof e}function x(e){return"[object Object]"===Object.prototype.toString.call(e)}function E(...e){}function _(e,t,i,s){let n,r;e=g(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function C(e,t,i,s){let n,r,l=s||e,o=e[t],a=(...e)=>o.apply(l,e),d=e=>o.apply(l,e);e[t]=(...e)=>{try{return n=l._super,r=l._superApply,l._super=a,l._superApply=d,i.apply(l,e)}finally{l._super=n,l._superApply=r}}}function N(e,t,i){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);let n=e?e[t]:null;return null!=n?n:i}function k(e){if(e instanceof Set)return e;if("string"==typeof e){let t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}var T=Object.freeze({__proto__:null,MOUSE_BUTTONS:t,MAX_INT:9007199254740991,isMac:i,Deferred:class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}},assert:l,documentReady:o,documentReadyPromise:function(){return new Promise((e=>{o(e)}))},each:function(e,t){if(null==e)return e;let i=e.length,s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(let i in e)if(!1===t.call(e[s],i,e[i]))break;return e},error:a,escapeHtml:d,escapeRegex:c,escapeTooltip:function(e){return(""+e).replace(n,(function(e){return r[e]}))},extractHtmlText:h,getValueFromElem:u,setValueToElem:function e(t,i){const s=t.tagName;if("SPAN"===s&&t.classList.contains("wb-col")){const s=t,n=s.querySelector("input,select");if(n)return e(n,i);s.innerText=""+i}else if("INPUT"===s){const e=t;switch(e.type){case"checkbox":e.indeterminate=null==i,e.checked=!!i;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":e.valueAsDate=i;break;case"number":case"range":e.valueAsNumber=i;break;case"radio":l(!1,"not implemented");break;case"button":case"reset":case"submit":case"image":break;case"text":default:e.innerText=i}}else if("SELECT"===s){t.value=i}},elemFromHtml:p,elemFromSelector:g,eventToString:v,extend:m,isArray:w,isEmptyObject:b,isFunction:y,isPlainObject:x,noop:E,onEvent:_,overrideMethod:C,setTimeoutPromise:function(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(self))}catch(e){s(e)}}),t)}))},sleep:async function(e){return new Promise((t=>setTimeout(t,e)))},toggleCheckbox:function(e,t,i){const s=g(e);if(l("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t},getOption:N,toSet:k,type:function(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()}});
5
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
6
+ */const t={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},i=function(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}().isMac,s=/[&<>"'/]/g,n=/[<>"'/]/g,r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function l(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function o(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function a(e){throw new Error(e)}function d(e){return(""+e).replace(s,(function(e){return r[e]}))}function c(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function h(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return h(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":const e=i.name,n=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=n?n.value:void 0;break;default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function u(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const p=new Set(["Alt","Control","Meta","Shift"]);function f(e){return e?"string"==typeof e?document.querySelector(e):e:null}function g(e){return e?"string"==typeof e?document.querySelector(e):e:null}function v(e){let i=e.key,s=e.type,n=[];return e.altKey&&n.push("Alt"),e.ctrlKey&&n.push("Control"),e.metaKey&&n.push("Meta"),e.shiftKey&&n.push("Shift"),"click"===s||"dblclick"===s?n.push(t[e.button]+s):"wheel"===s?n.push(s):p.has(i)||n.push(i),n.join("+")}function m(...e){for(let t=1;t<e.length;t++){let i=e[t];if(null!=i)for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function b(e){return Array.isArray(e)}function w(e){return 0===Object.keys(e).length&&e.constructor===Object}function y(e){return"function"==typeof e}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function x(...e){}function _(e,t,i,s){let n,r;e=g(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function k(e,t,i,s){let n,r,l=s||e,o=e[t],a=(...e)=>o.apply(l,e),d=e=>o.apply(l,e);e[t]=(...e)=>{try{return n=l._super,r=l._superApply,l._super=a,l._superApply=d,i.apply(l,e)}finally{l._super=n,l._superApply=r}}}function C(e,t,i){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);let n=e?e[t]:null;return null!=n?n:i}function N(e){if(e instanceof Set)return e;if("string"==typeof e){let t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}var T=Object.freeze({__proto__:null,MOUSE_BUTTONS:t,MAX_INT:9007199254740991,isMac:i,Deferred:class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}},assert:l,documentReady:o,documentReadyPromise:function(){return new Promise((e=>{o(e)}))},each:function(e,t){if(null==e)return e;let i=e.length,s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(let i in e)if(!1===t.call(e[s],i,e[i]))break;return e},error:a,escapeHtml:d,escapeRegex:c,escapeTooltip:function(e){return(""+e).replace(n,(function(e){return r[e]}))},extractHtmlText:function(e){return e.indexOf(">")>=0&&a("Not implemented"),e},getValueFromElem:h,setValueToElem:function e(t,i){const s=t.tagName;if("SPAN"===s&&t.classList.contains("wb-col")){const s=t,n=s.querySelector("input,select");if(n)return e(n,i);s.innerText=""+i}else if("INPUT"===s){const e=t;switch(e.type){case"checkbox":e.indeterminate=null==i,e.checked=!!i;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":e.valueAsDate=i;break;case"number":case"range":e.valueAsNumber=i;break;case"radio":a("Not implemented");break;case"button":case"reset":case"submit":case"image":break;default:e.innerText=i}}else if("SELECT"===s){t.value=i}},elemFromHtml:u,elemFromSelector:f,eventTargetFromSelector:g,eventToString:v,extend:m,isArray:b,isEmptyObject:w,isFunction:y,isPlainObject:E,noop:x,onEvent:_,overrideMethod:k,setTimeoutPromise:function(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(self))}catch(e){s(e)}}),t)}))},sleep:async function(e){return new Promise((t=>setTimeout(t,e)))},toggleCheckbox:function(e,t,i){const s=f(e);if(l("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t},getOption:C,toSet:N,type:function(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()}});
7
7
  /*!
8
8
  * Wunderbaum - common
9
9
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
10
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
11
- */const S=22,M=new RegExp(/\.|\//);var L,A,I;!function(e){e.any="any",e.row="row",e.structure="structure",e.status="status"}(L||(L={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData"}(A||(A={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(I||(I={}));let D={error:"bi bi-exclamation-triangle",loading:"bi bi-arrow-repeat wb-spin",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-circle-dotted",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",doc:"bi bi-file-earmark"};var O,P;!function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(O||(O={})),function(e){e.row="row",e.cellNav="cellNav",e.cellEdit="cellEdit"}(P||(P={}));const z={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function R(e){return e=c(e.toLowerCase()),function(t){return t.title.toLowerCase().indexOf(e)>=0}}
10
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
11
+ */const M=22,S=new RegExp(/\.|\//);var L,A,I;!function(e){e.any="any",e.row="row",e.structure="structure",e.status="status",e.vscroll="vscroll",e.header="header"}(L||(L={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData"}(A||(A={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(I||(I={}));let D={error:"bi bi-exclamation-triangle",loading:"bi bi-arrow-repeat wb-spin",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-circle-dotted",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",doc:"bi bi-file-earmark"};var O,P;!function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(O||(O={})),function(e){e.row="row",e.cellNav="cellNav",e.cellEdit="cellEdit"}(P||(P={}));const R={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function q(e){return e=c(e.toLowerCase()),function(t){return t.title.toLowerCase().indexOf(e)>=0}}
12
12
  /*!
13
13
  * Wunderbaum - wb_extension_base
14
14
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
15
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
15
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
16
16
  */
17
- class q{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=m({},i):(this.extensionOpts=m({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
17
+ class z{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=m({},i):(this.extensionOpts=m({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
18
18
  /*!
19
19
  * debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
20
20
  * MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
21
21
  * Modified for TypeScript type annotations.
22
- */const F="object"==typeof global&&null!==global&&global.Object===Object&&global,V="object"==typeof globalThis&&null!==globalThis&&globalThis.Object==Object&&globalThis,H="object"==typeof self&&null!==self&&self.Object===Object&&self,U=V||F||H||Function("return this")();function j(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}function $(e,t=0,i={}){let s,n,r,l,o,a,d=0,c=!1,h=!1,u=!0;const p=!t&&0!==t&&"function"==typeof U.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const i=s,r=n;return s=n=void 0,d=t,l=e.apply(r,i),l}function g(e,t){return p?(U.cancelAnimationFrame(o),U.requestAnimationFrame(e)):setTimeout(e,t)}function v(e){const i=e-a;return void 0===a||i>=t||i<0||h&&e-d>=r}function m(){const e=Date.now();if(v(e))return w(e);o=g(m,function(e){const i=e-d,s=t-(e-a);return h?Math.min(s,r-i):s}(e))}function w(e){return o=void 0,u&&s?f(e):(s=n=void 0,l)}function b(...e){const i=Date.now(),r=v(i);if(s=e,n=this,a=i,r){if(void 0===o)return function(e){return d=e,o=g(m,t),c?f(e):l}(a);if(h)return o=g(m,t),f(a)}return void 0===o&&(o=g(m,t)),l}return t=+t||0,j(i)&&(c=!!i.leading,h="maxWait"in i,r=h?Math.max(+i.maxWait||0,t):r,u="trailing"in i?!!i.trailing:u),b.cancel=function(){void 0!==o&&function(e){if(p)return U.cancelAnimationFrame(e);clearTimeout(e)}(o),d=0,s=a=n=o=void 0},b.flush=function(){return void 0===o?l:w(Date.now())},b.pending=function(){return void 0!==o},b}
22
+ */const F="object"==typeof global&&null!==global&&global.Object===Object&&global,U="object"==typeof globalThis&&null!==globalThis&&globalThis.Object==Object&&globalThis,H="object"==typeof self&&null!==self&&self.Object===Object&&self,V=U||F||H||Function("return this")();function j(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}function K(e,t=0,i={}){let s,n,r,l,o,a,d=0,c=!1,h=!1,u=!0;const p=!t&&0!==t&&"function"==typeof V.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const i=s,r=n;return s=n=void 0,d=t,l=e.apply(r,i),l}function g(e,t){return p?(V.cancelAnimationFrame(o),V.requestAnimationFrame(e)):setTimeout(e,t)}function v(e){const i=e-a;return void 0===a||i>=t||i<0||h&&e-d>=r}function m(){const e=Date.now();if(v(e))return b(e);o=g(m,function(e){const i=e-d,s=t-(e-a);return h?Math.min(s,r-i):s}(e))}function b(e){return o=void 0,u&&s?f(e):(s=n=void 0,l)}function w(...e){const i=Date.now(),r=v(i);if(s=e,n=this,a=i,r){if(void 0===o)return function(e){return d=e,o=g(m,t),c?f(e):l}(a);if(h)return o=g(m,t),f(a)}return void 0===o&&(o=g(m,t)),l}return t=+t||0,j(i)&&(c=!!i.leading,h="maxWait"in i,r=h?Math.max(+i.maxWait||0,t):r,u="trailing"in i?!!i.trailing:u),w.cancel=function(){void 0!==o&&function(e){if(p)return V.cancelAnimationFrame(e);clearTimeout(e)}(o),d=0,s=a=n=o=void 0},w.flush=function(){return void 0===o?l:b(Date.now())},w.pending=function(){return void 0!==o},w}
23
23
  /*!
24
24
  * Wunderbaum - ext-filter
25
25
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
26
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
26
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
27
27
  */
28
- const K=new RegExp(c("￷"),"g"),W=new RegExp(c("￸"),"g");class B extends q{constructor(e){super(e,"filter",{autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"hide",noData:!0}),this.lastFilterArgs=null}init(){super.init();let e=this.getPluginOption("attachInput");e&&(this.queryInput=g(e),_(this.queryInput,"input",$((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}_applyFilterNoUpdate(e,t,i){return this.tree.runWithoutUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=Date.now(),l=0,o=this.tree,a=o.options,u=a.escapeTitles,p=a.autoCollapse,f=m({},a.filter,i),g="hide"===f.mode,v=!!f.leavesOnly&&!t;if("string"==typeof e){if(""===e)return o.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=f.fuzzy?e.split("").map(c).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):c(e);let t=new RegExp(s,"i"),i=new RegExp(c(e),"gi");e=e=>{if(!e.title)return!1;let s=u?e.title:h(e.title),r=s.match(t);return r&&f.highlight&&(u?(n=f.fuzzy?Q(s,r,u):s.replace(i,(function(e){return"￷"+e+"￸"})),e.titleWithHighlight=d(n).replace(K,"<mark>").replace(W,"</mark>")):f.fuzzy?e.titleWithHighlight=Q(s,r):e.titleWithHighlight=s.replace(i,(function(e){return"<mark>"+e+"</mark>"}))),!!r}}return o.filterMode=f.mode,this.lastFilterArgs=arguments,o.element.classList.toggle("wb-ext-filter-hide",!!g),o.element.classList.toggle("wb-ext-filter-dim",!g),o.element.classList.toggle("wb-ext-filter-hide-expanders",!!f.hideExpanders),o.root.subMatchCount=0,o.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),o.setStatus(A.ok),a.autoCollapse=!1,o.visit((i=>{if(v&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(l++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!f.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=p,0===l&&f.noData&&g&&o.root.setStatus(A.noData),o.logInfo(`Filter '${s}' found ${l} nodes in ${Date.now()-r} ms.`),l}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){let e=this.tree;e.filterMode&&this.lastFilterArgs&&e.options.filter.autoApply?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):e.logWarn("updateFilter(): no filter active.")}clearFilter(){let e=this.tree,t=e.options.escapeTitles;e.enableUpdate(!1),e.setStatus(A.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{if(e.match&&e._rowElem){let i=e._rowElem.querySelector("span.wb-title");t?i.textContent=e.title:i.innerHTML=e.title,e._callEvent("enhanceTitle",{titleElem:i})}delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e.subMatchBadge&&(e.subMatchBadge.remove(),delete e.subMatchBadge),e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}function Q(e,t,i=!1){let s=[];for(let e=1;e<t.length;e++){let i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}let n=e.split("");return i?s.forEach((function(e){n[e]="￷"+n[e]+"￸"})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"})),n.join("")}
28
+ const $="￷",W="￸",B=new RegExp(c("￷"),"g"),Q=new RegExp(c("￸"),"g");class Y extends z{constructor(e){super(e,"filter",{autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"hide",noData:!0}),this.lastFilterArgs=null}init(){super.init();let e=this.getPluginOption("attachInput");e&&(this.queryInput=f(e),_(this.queryInput,"input",K((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}_applyFilterNoUpdate(e,t,i){return this.tree.runWithoutUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=Date.now(),l=0,o=this.tree,a=o.options,h=a.autoCollapse,u=m({},a.filter,i),p="hide"===u.mode,f=!!u.leavesOnly&&!t;if("string"==typeof e){if(""===e)return o.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=u.fuzzy?e.split("").map(c).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):c(e);let t=new RegExp(s,"i"),i=new RegExp(c(e),"gi");e=e=>{if(!e.title)return!1;let s=e.title,r=s.match(t);return r&&u.highlight&&(n=u.fuzzy?function(e,t,i=!0){let s=[];for(let e=1;e<t.length;e++){let i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}let n=e.split("");i?s.forEach((function(e){n[e]=$+n[e]+W})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"}));return n.join("")}
29
29
  /*!
30
30
  * Wunderbaum - ext-keynav
31
31
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
32
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
33
- */class Y extends q{constructor(e){super(e,"keynav",{})}onKeyEvent(e){let t,i=e.event,s=v(i),n=e.node,r=this.tree,l=e.options,o=!0,a=!i.ctrlKey||l.autoActivate;const d=l.navigationMode;if(r.logDebug(`onKeyEvent: ${s}`),!1===r._callEvent("keydown",e))return!1;if(!1===r._callMethod("edit._preprocessKeyEvent",e))return!1;if(!n){const e=r.getActiveNode(),i=r.getFirstChild();if(!e&&i&&"ArrowDown"===s)return i.logInfo("Keydown: activate first node."),void i.setActive();t=e||i,t&&(t.setFocus(),n=r.getFocusNode(),n.logInfo("Keydown: force focus on active node."))}if(r.navMode===P.row){if(l.quicksearch&&1===s.length&&/^\w$/.test(s)){const e=Date.now();e-r.lastQuicksearchTime>500&&(r.lastQuicksearchTerm=""),r.lastQuicksearchTime=e,r.lastQuicksearchTerm+=s;let t=r.findNextNode(r.lastQuicksearchTerm,r.getActiveNode());return t&&t.setActive(!0,{event:i}),void i.preventDefault()}switch(s){case"ArrowLeft":n.expanded&&(s="Subtract");break;case"ArrowRight":if(n.expanded||!n.children&&!n.lazy){if(d===O.startRow)return void r.setCellMode(P.cellNav)}else s="Add"}switch(s){case"+":case"Add":n.setExpanded(!0);break;case"-":case"Subtract":n.setExpanded(!1);break;case" ":n.getOption("checkbox")?n.setSelected(!n.isSelected()):n.setActive(!0,{event:i});break;case"Enter":n.setActive(!0,{event:i});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:o=!1}}else switch(s){case" ":if(0===r.activeColIdx&&n.getOption("checkbox"))n.setSelected(!n.isSelected()),o=!0;else{const e=r.getActiveColElem(),t=null==e?void 0:e.querySelector("input[type=checkbox]");null==t||t.click()}break;case"Enter":0===r.activeColIdx&&n.isExpandable()&&(n.setExpanded(!n.isExpanded()),o=!0);break;case"Escape":r.navMode===P.cellEdit?(r.setCellMode(P.cellNav),o=!0):r.navMode===P.cellNav&&(r.setCellMode(P.row),o=!0);break;case"ArrowLeft":r.activeColIdx>0?(r.setColumn(r.activeColIdx-1),o=!0):d!==O.cell&&(r.setCellMode(P.row),o=!0);break;case"ArrowRight":r.activeColIdx<r.columns.length-1&&(r.setColumn(r.activeColIdx+1),o=!0);break;case"ArrowDown":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:o=!1}o&&i.preventDefault()}}
32
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
33
+ */(s,r,!0):s.replace(i,(function(e){return $+e+W})),e.titleWithHighlight=d(n).replace(B,"<mark>").replace(Q,"</mark>")),!!r}}return o.filterMode=u.mode,this.lastFilterArgs=arguments,o.element.classList.toggle("wb-ext-filter-hide",!!p),o.element.classList.toggle("wb-ext-filter-dim",!p),o.element.classList.toggle("wb-ext-filter-hide-expanders",!!u.hideExpanders),o.root.subMatchCount=0,o.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),o.setStatus(A.ok),a.autoCollapse=!1,o.visit((i=>{if(f&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(l++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!u.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=h,0===l&&u.noData&&p&&o.root.setStatus(A.noData),o.logInfo(`Filter '${s}' found ${l} nodes in ${Date.now()-r} ms.`),l}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){let e=this.tree;e.filterMode&&this.lastFilterArgs&&e.options.filter.autoApply?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):e.logWarn("updateFilter(): no filter active.")}clearFilter(){let e=this.tree;e.enableUpdate(!1),e.setStatus(A.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{if(e.match&&e._rowElem){let t=e._rowElem.querySelector("span.wb-title");t.textContent=e.title,e._callEvent("enhanceTitle",{titleElem:t})}delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e.subMatchBadge&&(e.subMatchBadge.remove(),delete e.subMatchBadge),e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}class X extends z{constructor(e){super(e,"keynav",{})}onKeyEvent(e){let t,i=e.event,s=v(i),n=e.node,r=this.tree,l=e.options,o=!0,a=!i.ctrlKey||l.autoActivate;const d=l.navigationMode;if(r.logDebug(`onKeyEvent: ${s}`),!1===r._callEvent("keydown",e))return!1;if(!1===r._callMethod("edit._preprocessKeyEvent",e))return!1;if(!n){const e=r.getActiveNode(),i=r.getFirstChild();if(!e&&i&&"ArrowDown"===s)return i.logInfo("Keydown: activate first node."),void i.setActive();t=e||i,t&&(t.setFocus(),n=r.getFocusNode(),n.logInfo("Keydown: force focus on active node."))}if(r.navMode===P.row){if(l.quicksearch&&1===s.length&&/^\w$/.test(s)){const e=Date.now();e-r.lastQuicksearchTime>500&&(r.lastQuicksearchTerm=""),r.lastQuicksearchTime=e,r.lastQuicksearchTerm+=s;let t=r.findNextNode(r.lastQuicksearchTerm,r.getActiveNode());return t&&t.setActive(!0,{event:i}),void i.preventDefault()}switch(s){case"ArrowLeft":n.expanded&&(s="Subtract");break;case"ArrowRight":if(n.expanded||!n.children&&!n.lazy){if(d===O.startRow)return void r.setCellMode(P.cellNav)}else s="Add"}switch(s){case"+":case"Add":n.setExpanded(!0);break;case"-":case"Subtract":n.setExpanded(!1);break;case" ":n.getOption("checkbox")?n.setSelected(!n.isSelected()):n.setActive(!0,{event:i});break;case"Enter":n.setActive(!0,{event:i});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:o=!1}}else switch(s){case" ":if(0===r.activeColIdx&&n.getOption("checkbox"))n.setSelected(!n.isSelected()),o=!0;else{const e=r.getActiveColElem(),t=null==e?void 0:e.querySelector("input[type=checkbox]");null==t||t.click()}break;case"Enter":0===r.activeColIdx&&n.isExpandable()&&(n.setExpanded(!n.isExpanded()),o=!0);break;case"Escape":r.navMode===P.cellEdit?(r.setCellMode(P.cellNav),o=!0):r.navMode===P.cellNav&&(r.setCellMode(P.row),o=!0);break;case"ArrowLeft":r.activeColIdx>0?(r.setColumn(r.activeColIdx-1),o=!0):d!==O.cell&&(r.setCellMode(P.row),o=!0);break;case"ArrowRight":r.activeColIdx<r.columns.length-1&&(r.setColumn(r.activeColIdx+1),o=!0);break;case"ArrowDown":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:o=!1}o&&i.preventDefault()}}
34
34
  /*!
35
35
  * Wunderbaum - ext-logger
36
36
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
37
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
38
- */class G extends q{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["enhanceTitle","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;C(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);let r=Date.now();const l=e._superApply(arguments);return console.debug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),l}))}}onKeyEvent(e){console.debug(`${this.prefix}: onKeyEvent()`,e)}}
37
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
38
+ */class G extends z{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["enhanceTitle","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;k(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);let r=Date.now();const l=e._superApply(arguments);return console.debug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),l}))}}onKeyEvent(e){console.debug(`${this.prefix}: onKeyEvent()`,e)}}
39
39
  /*!
40
40
  * Wunderbaum - ext-dnd
41
41
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
42
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
43
- */class J extends q{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,dragDrag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,dragDrop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&_(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&_(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.removeClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before"),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||w(e))return(e=k(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}autoScroll(e){let t=this.tree,i=t.options.dnd,s=t.scrollContainer,n=i.scrollSensitivity,r=i.scrollSpeed,l=0;const o=s.offsetTop;if(o+s.offsetHeight-e.pageY<n){s.scrollHeight-s.clientHeight-o>0&&(s.scrollTop=l=o+r)}else o>0&&e.pageY-o<n&&(s.scrollTop=l=o-r);return l}onDragEvent(e){const t=this.treeOpts.dnd,i=se.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){e.dataTransfer.effectAllowed=t.effectAllowed;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;let s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s.treeId=i.tree.id;const n=JSON.stringify(s);e.dataTransfer.setData("application/x-wunderbaum-node",n),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.addClass("wb-drag-source")}),0)}else"drag"===e.type||"dragend"===e.type&&(i.removeClass("wb-drag-source"),this.srcNode=null,this.lastTargetNode&&this._leaveNode());return!0}}onDropEvent(e){const t=se.getNode(e),i=this.treeOpts.dnd,s=e.dataTransfer;if(t){if("dragover"!==e.type&&this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+t+", ea: "+(null==s?void 0:s.effectAllowed)+", de: "+(null==s?void 0:s.dropEffect),", cy: "+e.offsetY,", r: "+this._calcDropRegion(e,this.lastAllowedDropRegions),e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==t&&this._leaveNode(),this.lastTargetNode=t,this.lastEnterStamp=Date.now(),i.preventVoidMoves&&t===this.srcNode||t.isStatusNode())return s.dropEffect="none",!0;let n=t._callEvent("dnd.dragEnter",{event:e});return n=this.unifyDragover(n),n?(this.lastAllowedDropRegions=n,this.lastDropEffect=s.dropEffect,t.addClass("wb-drop-target"),e.preventDefault(),!1):(s.dropEffect="none",!0)}if("dragover"===e.type){this.autoScroll(e);const s=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=s,i.autoExpandMS>0&&t.isExpandable(!0)&&!t._isLoading&&Date.now()-this.lastEnterStamp>i.autoExpandMS&&!1!==t._callEvent("dnd.dragExpand",{event:e})&&t.setExpanded(),!s)return;return t.toggleClass("wb-drop-over","over"===s),t.toggleClass("wb-drop-before","before"===s),t.toggleClass("wb-drop-after","after"===s),e.preventDefault(),!1}"dragleave"===e.type||"drop"===e.type&&(e.stopPropagation(),this._leaveNode(),t._callEvent("dnd.drop",{event:e,region:this.lastDropRegion,sourceNode:this.srcNode}))}else this._leaveNode()}}
42
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
43
+ */class J extends z{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,dragDrag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,dragDrop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&_(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&_(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.removeClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before"),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||b(e))return(e=N(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}autoScroll(e){let t=this.tree,i=t.options.dnd,s=t.scrollContainer,n=i.scrollSensitivity,r=i.scrollSpeed,l=0;const o=s.offsetTop;if(o+s.offsetHeight-e.pageY<n){s.scrollHeight-s.clientHeight-o>0&&(s.scrollTop=l=o+r)}else o>0&&e.pageY-o<n&&(s.scrollTop=l=o-r);return l}onDragEvent(e){const t=this.treeOpts.dnd,i=le.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){e.dataTransfer.effectAllowed=t.effectAllowed;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;let s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s.treeId=i.tree.id;const n=JSON.stringify(s);e.dataTransfer.setData("application/x-wunderbaum-node",n),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.addClass("wb-drag-source")}),0)}else"drag"===e.type||"dragend"===e.type&&(i.removeClass("wb-drag-source"),this.srcNode=null,this.lastTargetNode&&this._leaveNode());return!0}}onDropEvent(e){const t=le.getNode(e),i=this.treeOpts.dnd,s=e.dataTransfer;if(t){if("dragover"!==e.type&&this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+t+", ea: "+(null==s?void 0:s.effectAllowed)+", de: "+(null==s?void 0:s.dropEffect),", cy: "+e.offsetY,", r: "+this._calcDropRegion(e,this.lastAllowedDropRegions),e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==t&&this._leaveNode(),this.lastTargetNode=t,this.lastEnterStamp=Date.now(),i.preventVoidMoves&&t===this.srcNode||t.isStatusNode())return s.dropEffect="none",!0;let n=t._callEvent("dnd.dragEnter",{event:e});return n=this.unifyDragover(n),n?(this.lastAllowedDropRegions=n,this.lastDropEffect=s.dropEffect,t.addClass("wb-drop-target"),e.preventDefault(),!1):(s.dropEffect="none",!0)}if("dragover"===e.type){this.autoScroll(e);const s=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=s,i.autoExpandMS>0&&t.isExpandable(!0)&&!t._isLoading&&Date.now()-this.lastEnterStamp>i.autoExpandMS&&!1!==t._callEvent("dnd.dragExpand",{event:e})&&t.setExpanded(),!s)return;return t.toggleClass("wb-drop-over","over"===s),t.toggleClass("wb-drop-before","before"===s),t.toggleClass("wb-drop-after","after"===s),e.preventDefault(),!1}"dragleave"===e.type||"drop"===e.type&&(e.stopPropagation(),this._leaveNode(),t._callEvent("dnd.drop",{event:e,region:this.lastDropRegion,sourceNode:this.srcNode}))}else this._leaveNode()}}
44
+ /*!
45
+ * Wunderbaum - drag_observer
46
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
47
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
48
+ */class Z{constructor(e){this.start={x:0,y:0,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},this.dragElem=null,this.dragging=!1,this.events=["mousedown","mouseup","mousemove","keydown"],l(e.root),this.opts=m({thresh:5},e),this.root=e.root,this._handler=this.handleEvent.bind(this),this.events.forEach((e=>{this.root.addEventListener(e,this._handler)}))}disconnect(){this.events.forEach((e=>{this.root.removeEventListener(e,this._handler)}))}getDragElem(){return this.dragElem}isDragging(){return this.dragging}stopDrag(e){this.dragging&&this.opts.dragstop&&e&&(e.type="dragstop",this.opts.dragstop(e)),this.dragElem=null,this.dragging=!1}handleEvent(e){const t=e.type,i=this.opts,s={type:e.type,event:e,dragElem:this.dragElem,dx:e.pageX-this.start.x,dy:e.pageY-this.start.y,apply:void 0};switch(t){case"keydown":this.stopDrag(s);break;case"mousedown":if(this.dragElem){this.stopDrag(s);break}if(i.selector){let t=e.target;if(t.matches(i.selector))this.dragElem=t;else{if(t=t.closest(i.selector),!t)break;this.dragElem=t}}this.start.x=e.pageX,this.start.y=e.pageY,this.start.altKey=e.altKey,this.start.ctrlKey=e.ctrlKey,this.start.metaKey=e.metaKey,this.start.shiftKey=e.shiftKey;break;case"mousemove":if(!this.dragElem)break;if(!this.dragging){if(i.thresh){if(s.dx*s.dx+s.dy*s.dy<i.thresh*i.thresh)break}if(s.type="dragstart",!1===i.dragstart(s)){this.stopDrag(s);break}this.dragging=!0}this.dragging&&this.opts.drag&&(s.type="drag",this.opts.drag(s));break;case"mouseup":if(!this.dragging){this.stopDrag(s);break}0===e.button?s.apply=!0:s.apply=!1,this.stopDrag(s)}}}
49
+ /*!
50
+ * Wunderbaum - ext-grid
51
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
52
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
53
+ */class ee extends z{constructor(e){super(e,"grid",{}),this.observer=new Z({root:window.document,selector:"span.wb-col-resizer",thresh:4,dragstart:e=>this.tree.element.contains(e.dragElem),drag:e=>this.handleDrag(e),dragstop:e=>this.handleDrag(e)})}init(){super.init()}handleDrag(e){const t=le.getEventInfo(e.event);this.tree.log(`${e.type}(${e.dx})`,e,t)}}
44
54
  /*!
45
55
  * Wunderbaum - deferred
46
56
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
47
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
48
- */class X{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
57
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
58
+ */class te{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
49
59
  /*!
50
60
  * Wunderbaum - wunderbaum_node
51
61
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
52
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
53
- */const Z=new Set(["classes","expanded","icon","key","lazy","refKey","selected","title","tooltip","type"]),ee=new Set(["checkbox","expanded","extraClasses","folder","icon","iconTooltip","key","lazy","partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable","unselectableIgnore","unselectableStatus"]);class te{constructor(e,t,i){var s,n;if(this.refKey=void 0,this.children=null,this.lazy=!1,this.expanded=!1,this.selected=!1,this.extraClasses=new Set,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,l(!t||t.tree===e),l(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++te.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.type&&(this.type=""+i.type),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.colspan&&(this.colspan=!!i.colspan),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,this.selected=!0===i.selected,i.classes)for(const e of i.classes.split(" "))this.extraClasses.add(e.trim());for(const[e,t]of Object.entries(i))Z.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return"WunderbaumNode@"+this.key+"<'"+this.title+"'>"}_callEvent(e,t){return this.tree._callEvent(e,m({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){let i=t?t.before:null,s=[];try{this.tree.enableUpdate(!1),x(e)&&(e=[e]);for(let t of e){let e=t.children;delete t.children;let i=new te(this.tree,this,t);s.push(i),e&&i.addChildren(e,{redraw:!1})}if(this.children)if(null==i||0===this.children.length)this.children=this.children.concat(s);else{i=this.findDirectChild(i);let e=this.children.indexOf(i);l(e>=0,"insertBefore must be an existing child"),this.children.splice(e,0,...s)}else this.children=s;return this.tree.setModified(L.structure,this),s[0]}finally{this.tree.enableUpdate(!0)}}addNode(e,t="child"){switch("over"===t&&(t="child"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"firstChild":return this.addChildren(e,{before:0});case"child":return this.addChildren(e)}l(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}addClass(e){k(e).forEach((e=>{var t;this.extraClasses.add(e),null===(t=this._rowElem)||void 0===t||t.classList.add(e)}))}removeClass(e){k(e).forEach((e=>{var t;this.extraClasses.delete(e),null===(t=this._rowElem)||void 0===t||t.classList.remove(e)}))}toggleClass(e,t){k(e).forEach((e=>{var i;t?this.extraClasses.add(e):this.extraClasses.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}))}async expandAll(e=!0){this.visit((t=>{t.setExpanded(e)}))}findAll(e){const t=y(e)?e:R(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){let t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t=y(e)?e:R(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){let i=[],s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s,n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}isActive(){return this.tree.activeNode===this}isChildOf(e){return this.parent&&this.parent===e}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;for(var t=this.parent;t;){if(t===e)return!0;t===t.parent&&a("Recursive parent link: "+t),t=t.parent}return!1}isExpandable(e=!1){return!(!this.children||this.expanded&&e)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){var e=this.parent;return!e||e.children[0]===this}isLastSibling(){var e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){let e,t,i,s="hide"===this.tree.filterMode,n=this.getParentList(!1,!1);if(s&&!this.match&&!this.subMatchCount)return!1;for(e=0,t=n.length;e<t;e++)if(i=n[e],!i.expanded)return!1;return!0}_loadSourceObject(e){const t=this.tree;this._callEvent("receive",{response:e}),w(e)&&(e={children:e}),l(x(e)),l(e.children,"If `source` is an object, it must have a `children` property"),e.types&&m(t.types,e.types),this.addChildren(e.children),this._callEvent("load")}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n="string"==typeof e?e:e.url;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;const r=t.logTime(this+".load()");try{if(n){this.setStatus(A.loading);const e=await fetch(n,{method:"GET"});e.ok||a(`GET ${n} returned ${e.status}, ${e}`);const r=await e.json();if(this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(A.ok),r.columns&&(t.logInfo("Re-define columns",r.columns),l(!this.parent),t.columns=r.columns,delete r.columns,t.renderHeader()),this._loadSourceObject(r)}else this._loadSourceObject(e)}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(A.error,""+t),t}finally{this._requestId=0,t.logTimeEnd(r)}}async loadLazy(e=!1){const t=this.expanded;if(l(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(A.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(A.ok);l(w(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}` or false."),await this.load(e),t?(this.expanded=!0,this.tree.updateViewport()):this.render()}catch(e){this.setStatus(A.error,""+e)}}}log(...e){this.logDebug.apply(this,e)}logDebug(...e){this.tree.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.tree.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logWarn(...e){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}async makeVisible(e){let t,i=new X,s=[],n=this.getParentList(!1,!1),r=n.length,l=!(e&&!0===e.noAnimation),o=!(e&&!1===e.scrollIntoView);for(t=r-1;t>=0;t--)s.push(n[t].setExpanded(!0,e));return Promise.all(s).then((()=>{o?this.scrollIntoView(l).then((()=>{i.resolve()})):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");let s,n=this.tree,r=this.parent,o="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?o.isDescendantOf(this)&&a("Cannot move a node to its own descendant"):a("Cannot move system root"),o!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===o)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),l(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=o,o.hasChildren())switch(t){case"appendChild":o.children.push(this);break;case"before":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s,0,this);break;case"after":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s+1,0,this);break;default:a("Invalid mode "+t)}else o.children=[this];i&&e.visit(i,!0),o===r?o.triggerModifyChild("move",this):o.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((function(t){t.tree=e.tree}),!0)),n.updateViewport()}}async navigate(e,t){e=z[e]||e;let i=this.findRelatedNode(e);if(i){try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}return this.logWarn("Could not find related node '"+e+"'."),Promise.resolve(this)}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.updateViewport())}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){let e={},t=0,i=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;for(let s of this.tree.columns)e[s.id]={id:s.id,idx:t,elem:i?i[t]:null,info:s},t++;return e}_createIcon(e,t){let i,s=this.getOption("icon");return this._errorInfo?s=D.error:this._isLoading&&(s=D.loading),!1===s?null:("string"==typeof s||(s=this.statusNodeType?D[this.statusNodeType]:this.expanded?D.folderOpen:this.children?D.folder:D.doc),s.indexOf("<")>=0?i=p(s):M.test(s)?i=p(`<img src="${s}" class="wb-icon">`):(i=document.createElement("i"),i.className="wb-icon "+s),t?e.replaceChild(i,t):e.appendChild(i),i)}render(e){const t=this.tree,i=t.options,s=!1!==this.getOption("checkbox"),n=t.columns,r=this.type?t.types[this.type]:null,o=this.getLevel();let a,d,c,h,u=this._rowElem,p=null,f=null;const g=t.navMode===P.row?null:t.activeColIdx,v=!u;l(!this.isRootNode());let m=["wb-row"];if(this.expanded&&m.push("wb-expanded"),this.lazy&&m.push("wb-lazy"),this.selected&&m.push("wb-selected"),this===t.activeNode&&m.push("wb-active"),this===t.focusNode&&m.push("wb-focus"),this._errorInfo&&m.push("wb-error"),this._isLoading&&m.push("wb-loading"),this.statusNodeType&&m.push("wb-status-"+this.statusNodeType),this.match&&m.push("wb-match"),this.subMatchCount&&m.push("wb-submatch"),i.skeleton&&m.push("wb-skeleton"),u)d=u.querySelector("span.wb-node"),c=d.querySelector("span.wb-title"),f=d.querySelector("i.wb-expander"),p=d.querySelector("i.wb-checkbox"),h=d.querySelector("i.wb-icon");else{u=document.createElement("div"),u._wb_node=this,d=document.createElement("span"),d.classList.add("wb-node","wb-col"),u.appendChild(d);let e=0;s&&(p=document.createElement("i"),d.appendChild(p),e+=20);for(let t=o-1;t>0;t--)a=document.createElement("i"),a.classList.add("wb-indent"),d.appendChild(a),e+=20;if(o>i.minExpandLevel&&(f=document.createElement("i"),d.appendChild(f),e+=20),h=this._createIcon(d),h&&(e+=20),c=document.createElement("span"),c.classList.add("wb-title"),d.appendChild(c),this._callEvent("enhanceTitle",{titleSpan:c}),d._ofsTitlePx=e,t.options.dnd.dragStart&&(d.draggable=!0),!this.colspan&&n.length>1){let e=0;for(let t of n){let i;e++,"*"===t.id?i=d:(i=document.createElement("span"),i.classList.add("wb-col"),u.appendChild(i)),e===g&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",v&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}}if(u.className=m.join(" "),u.classList.add(...this.extraClasses),r&&r.classes&&u.classList.add(...r.classes),u.style.top=this._rowIdx*S+"px",f&&(this.isExpandable(!1)?this.expanded?f.className="wb-expander "+D.expanderExpanded:f.className="wb-expander "+D.expanderCollapsed:this._isLoading?f.className="wb-expander "+D.loading:this.lazy&&null==this.children?f.className="wb-expander "+D.expanderLazy:f.classList.add("wb-indent")),p&&(this.selected?p.className="wb-checkbox "+D.checkChecked:p.className="wb-checkbox "+D.checkUnchecked),this.titleWithHighlight?c.innerHTML=this.titleWithHighlight:t.options.escapeTitles?c.textContent=this.title:c.innerHTML=this.title,!i.skeleton)if(this.colspan){let e=t.element.clientWidth;c.style.width=e-d._ofsTitlePx-7+"px"}else c.style.width=n[0]._widthPx-d._ofsTitlePx-7+"px";this._rowElem=u,this.statusNodeType?this._callEvent("renderStatusNode",{isNew:v,nodeElem:d}):this.parent&&this._callEvent("render",{isNew:v,nodeElem:d,typeInfo:r,colInfosById:this._getRenderInfo()}),t.nodeListElement.appendChild(u)}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.updateViewport()}toDict(e=!1,t){const i={};if(ee.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),b(this.data)||(i.data=m({},this.data),b(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&w(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){let i=this.tree,s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));let n=s[e];if("function"==typeof n){let e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];let r=this.type?i.types[this.type]:void 0,l=r?r[e]:void 0;return void 0!==l?l:null!=n?n:t}async scrollIntoView(e){return this.tree.scrollTo(this)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger;if(!(null==t?void 0:t.noEvent)){let r=null==t?void 0:t.event;if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,orgEvent:r})))return;if(!1===this._callEvent("activate",{prevNode:s,orgEvent:r}))return i.activeNode=null,void(null==s||s.setDirty(L.status))}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,orgEvent:r})}s!==this&&(i.activeNode=this,null==s||s.setDirty(L.status),this.setDirty(L.status)),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.navMode!==P.row&&i.setColumn(t.colIdx),this.scrollIntoView()}setDirty(e){this.tree._disableUpdate||(e===L.structure?this.tree.updateViewport():this._rowElem&&this.render())}async setExpanded(e=!0,t){!e&&this.isExpanded()&&this.getLevel()<this.getOption("minExpandLevel")&&!N(t,"force")?this.logDebug("Ignored collapse request."):(e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e,this.setDirty(L.structure))}setIcon(){throw new Error("Not yet implemented")}setFocus(e=!0,t){const i=this.tree.focusNode;this.tree.focusNode=this,null==i||i.setDirty(L.status),this.setDirty(L.status)}setSelected(e=!0,t){!!e!==this.selected&&this._callEvent("select",{flag:e}),this.selected=!!e,this.setDirty(L.status)}setStatus(e,t,i){let s=this.tree,n=null;const r=e=>{let t=this.children,i=t?t[0]:null;return l(e.statusNodeType),l(!i||!i.isStatusNode()),n=this.addNode(e,"firstChild"),n.match=!0,s.setModified(L.structure),n};switch((()=>{let e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this.parent||r({statusNodeType:e,title:s.options.strings.loading+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!0,this._errorInfo=null;break;case"error":r({statusNodeType:e,title:s.options.strings.loadError+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo={message:t,details:i};break;case"noData":r({statusNodeType:e,title:t||s.options.strings.noData,checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo=null;break;default:a("invalid node status "+e)}return s.updateViewport(),n}setTitle(e){this.title=e,this.setDirty(L.status)}triggerModifyChild(e,t,i){this.tree.options.modifyChild&&(t&&t.parent!==this&&a("child "+t+" is not a child of "+this),this._callEvent("modifyChild",m({operation:e,child:t},i)))}triggerModify(e,t){this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i,s,n=!0,r=this.children;if(!0===t&&(n=e(this),!1===n||"skip"===n))return n;if(r)for(i=0,s=r.length;i<s&&(n=r[i].visit(e,!0),!1!==n);i++);return n}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){let i,s,n,r=this.parent.children;for(i=0,s=r.length;i<s;i++)if(n=r[i],(t||n!==this)&&!1===e(n))return!1;return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}te.sequence=0;
62
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
63
+ */const ie=new Set(["classes","expanded","icon","key","lazy","refKey","selected","title","tooltip","type"]),se=new Set(["checkbox","expanded","extraClasses","folder","icon","iconTooltip","key","lazy","partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable","unselectableIgnore","unselectableStatus"]);class ne{constructor(e,t,i){var s,n;if(this.refKey=void 0,this.children=null,this.lazy=!1,this.expanded=!1,this.selected=!1,this.extraClasses=new Set,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,l(!t||t.tree===e),l(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++ne.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.type&&(this.type=""+i.type),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.colspan&&(this.colspan=!!i.colspan),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,this.selected=!0===i.selected,i.classes)for(const e of i.classes.split(" "))this.extraClasses.add(e.trim());for(const[e,t]of Object.entries(i))ie.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return"WunderbaumNode@"+this.key+"<'"+this.title+"'>"}_callEvent(e,t){return this.tree._callEvent(e,m({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){let i=t?t.before:null,s=[];try{this.tree.enableUpdate(!1),E(e)&&(e=[e]);for(let t of e){let e=t.children;delete t.children;let i=new ne(this.tree,this,t);s.push(i),e&&i.addChildren(e,{redraw:!1})}if(this.children)if(null==i||0===this.children.length)this.children=this.children.concat(s);else{i=this.findDirectChild(i);let e=this.children.indexOf(i);l(e>=0,"insertBefore must be an existing child"),this.children.splice(e,0,...s)}else this.children=s;return this.tree.setModified(L.structure),s[0]}finally{this.tree.enableUpdate(!0)}}addNode(e,t="child"){switch("over"===t&&(t="child"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"firstChild":return this.addChildren(e,{before:0});case"child":return this.addChildren(e)}l(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}addClass(e){N(e).forEach((e=>{var t;this.extraClasses.add(e),null===(t=this._rowElem)||void 0===t||t.classList.add(e)}))}removeClass(e){N(e).forEach((e=>{var t;this.extraClasses.delete(e),null===(t=this._rowElem)||void 0===t||t.classList.remove(e)}))}toggleClass(e,t){N(e).forEach((e=>{var i;t?this.extraClasses.add(e):this.extraClasses.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}))}async expandAll(e=!0){this.visit((t=>{t.setExpanded(e)}))}findAll(e){const t=y(e)?e:q(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){let t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t=y(e)?e:q(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){let i=[],s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s,n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}isActive(){return this.tree.activeNode===this}isChildOf(e){return this.parent&&this.parent===e}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;for(var t=this.parent;t;){if(t===e)return!0;t===t.parent&&a("Recursive parent link: "+t),t=t.parent}return!1}isExpandable(e=!1){return!(!this.children||this.expanded&&e)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){var e=this.parent;return!e||e.children[0]===this}isLastSibling(){var e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){let e,t,i,s="hide"===this.tree.filterMode,n=this.getParentList(!1,!1);if(s&&!this.match&&!this.subMatchCount)return!1;for(e=0,t=n.length;e<t;e++)if(i=n[e],!i.expanded)return!1;return!0}_loadSourceObject(e){const t=this.tree;this._callEvent("receive",{response:e}),b(e)&&(e={children:e}),l(E(e)),l(e.children,"If `source` is an object, it must have a `children` property"),e.types&&m(t.types,e.types),this.addChildren(e.children),this._callEvent("load")}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n="string"==typeof e?e:e.url;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;const r=t.logTime(this+".load()");try{if(n){this.setStatus(A.loading);const e=await fetch(n,{method:"GET"});e.ok||a(`GET ${n} returned ${e.status}, ${e}`);const r=await e.json();if(this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(A.ok),r.columns&&(t.logInfo("Re-define columns",r.columns),l(!this.parent),t.columns=r.columns,delete r.columns,t.renderHeader()),this._loadSourceObject(r)}else this._loadSourceObject(e)}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(A.error,""+t),t}finally{this._requestId=0,t.logTimeEnd(r)}}async loadLazy(e=!1){const t=this.expanded;if(l(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(A.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(A.ok);l(b(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}` or false."),await this.load(e),t?(this.expanded=!0,this.tree.setModified(L.structure)):this.render()}catch(e){this.setStatus(A.error,""+e)}}}log(...e){this.logDebug.apply(this,e)}logDebug(...e){this.tree.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.tree.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logWarn(...e){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}async makeVisible(e){let t,i=new te,s=[],n=this.getParentList(!1,!1),r=n.length,l=!(e&&!0===e.noAnimation),o=!(e&&!1===e.scrollIntoView);for(t=r-1;t>=0;t--)s.push(n[t].setExpanded(!0,e));return Promise.all(s).then((()=>{o?this.scrollIntoView(l).then((()=>{i.resolve()})):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");let s,n=this.tree,r=this.parent,o="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?o.isDescendantOf(this)&&a("Cannot move a node to its own descendant"):a("Cannot move system root"),o!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===o)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),l(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=o,o.hasChildren())switch(t){case"appendChild":o.children.push(this);break;case"before":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s,0,this);break;case"after":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s+1,0,this);break;default:a("Invalid mode "+t)}else o.children=[this];i&&e.visit(i,!0),o===r?o.triggerModifyChild("move",this):o.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((function(t){t.tree=e.tree}),!0)),n.setModified(L.structure)}}async navigate(e,t){e=R[e]||e;let i=this.findRelatedNode(e);if(i){try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}return this.logWarn("Could not find related node '"+e+"'."),Promise.resolve(this)}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.setModified(L.structure))}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){let e={},t=0,i=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;for(let s of this.tree.columns)e[s.id]={id:s.id,idx:t,elem:i?i[t]:null,info:s},t++;return e}_createIcon(e,t){let i,s=this.getOption("icon");return this._errorInfo?s=D.error:this._isLoading&&(s=D.loading),!1===s?null:("string"==typeof s||(s=this.statusNodeType?D[this.statusNodeType]:this.expanded?D.folderOpen:this.children?D.folder:D.doc),s.indexOf("<")>=0?i=u(s):S.test(s)?i=u(`<img src="${s}" class="wb-icon">`):(i=document.createElement("i"),i.className="wb-icon "+s),t?e.replaceChild(i,t):e.appendChild(i),i)}render(e){const t=this.tree,i=t.options,s=!1!==this.getOption("checkbox"),n=t.columns,r=this.type?t.types[this.type]:null,o=this.getLevel();let a,d,c,h,u=this._rowElem,p=null,f=null;const g=t.navMode===P.row?null:t.activeColIdx,v=!u;l(!this.isRootNode());let m=["wb-row"];if(this.expanded&&m.push("wb-expanded"),this.lazy&&m.push("wb-lazy"),this.selected&&m.push("wb-selected"),this===t.activeNode&&m.push("wb-active"),this===t.focusNode&&m.push("wb-focus"),this._errorInfo&&m.push("wb-error"),this._isLoading&&m.push("wb-loading"),this.statusNodeType&&m.push("wb-status-"+this.statusNodeType),this.match&&m.push("wb-match"),this.subMatchCount&&m.push("wb-submatch"),i.skeleton&&m.push("wb-skeleton"),u)d=u.querySelector("span.wb-node"),c=d.querySelector("span.wb-title"),f=d.querySelector("i.wb-expander"),p=d.querySelector("i.wb-checkbox"),h=d.querySelector("i.wb-icon");else{u=document.createElement("div"),u._wb_node=this,d=document.createElement("span"),d.classList.add("wb-node","wb-col"),u.appendChild(d);let e=0;s&&(p=document.createElement("i"),d.appendChild(p),e+=20);for(let t=o-1;t>0;t--)a=document.createElement("i"),a.classList.add("wb-indent"),d.appendChild(a),e+=20;if(i.minExpandLevel&&o>i.minExpandLevel&&(f=document.createElement("i"),d.appendChild(f),e+=20),h=this._createIcon(d),h&&(e+=20),c=document.createElement("span"),c.classList.add("wb-title"),d.appendChild(c),this._callEvent("enhanceTitle",{titleSpan:c}),d._ofsTitlePx=e,t.options.dnd.dragStart&&(d.draggable=!0),!this.colspan&&n.length>1){let e=0;for(let t of n){let i;e++,"*"===t.id?i=d:(i=document.createElement("span"),i.classList.add("wb-col"),u.appendChild(i)),e===g&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",v&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}}if(u.className=m.join(" "),u.classList.add(...this.extraClasses),r&&r.classes&&u.classList.add(...r.classes),u.style.top=this._rowIdx*M+"px",f&&(this.isExpandable(!1)?this.expanded?f.className="wb-expander "+D.expanderExpanded:f.className="wb-expander "+D.expanderCollapsed:this._isLoading?f.className="wb-expander "+D.loading:this.lazy&&null==this.children?f.className="wb-expander "+D.expanderLazy:f.classList.add("wb-indent")),p&&(this.selected?p.className="wb-checkbox "+D.checkChecked:p.className="wb-checkbox "+D.checkUnchecked),this.titleWithHighlight?c.innerHTML=this.titleWithHighlight:c.textContent=this.title,!i.skeleton)if(this.colspan){let e=t.element.clientWidth;c.style.width=e-d._ofsTitlePx-7+"px"}else c.style.width=n[0]._widthPx-d._ofsTitlePx-7+"px";this._rowElem=u,this.statusNodeType?this._callEvent("renderStatusNode",{isNew:v,nodeElem:d}):this.parent&&this._callEvent("render",{isNew:v,nodeElem:d,typeInfo:r,colInfosById:this._getRenderInfo()}),t.nodeListElement.appendChild(u)}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.setModified(L.structure)}toDict(e=!1,t){const i={};if(se.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),w(this.data)||(i.data=m({},this.data),w(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&b(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){let i=this.tree,s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));let n=s[e];if("function"==typeof n){let e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];let r=this.type?i.types[this.type]:void 0,l=r?r[e]:void 0;return void 0!==l?l:null!=n?n:t}async scrollIntoView(e){return this.tree.scrollTo(this)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger;if(!(null==t?void 0:t.noEvent)){let r=null==t?void 0:t.event;if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,orgEvent:r})))return;if(!1===this._callEvent("activate",{prevNode:s,orgEvent:r}))return i.activeNode=null,void(null==s||s.setModified())}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,orgEvent:r})}s!==this&&(i.activeNode=this,null==s||s.setModified(),this.setModified()),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.navMode!==P.row&&i.setColumn(t.colIdx),this.scrollIntoView()}setModified(e=L.status){l(e===L.status),this.tree.setModified(L.row,this)}async setExpanded(e=!0,t){!e&&this.isExpanded()&&this.getLevel()<this.getOption("minExpandLevel")&&!C(t,"force")?this.logDebug("Ignored collapse request."):(e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e,this.tree.setModified(L.structure))}setIcon(){throw new Error("Not yet implemented")}setFocus(e=!0,t){const i=this.tree.focusNode;this.tree.focusNode=this,null==i||i.setModified(),this.setModified()}setSelected(e=!0,t){!!e!==this.selected&&this._callEvent("select",{flag:e}),this.selected=!!e,this.setModified()}setStatus(e,t,i){let s=this.tree,n=null;const r=e=>{let t=this.children,i=t?t[0]:null;return l(e.statusNodeType),l(!i||!i.isStatusNode()),n=this.addNode(e,"firstChild"),n.match=!0,s.setModified(L.structure),n};switch((()=>{let e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this.parent||r({statusNodeType:e,title:s.options.strings.loading+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!0,this._errorInfo=null;break;case"error":r({statusNodeType:e,title:s.options.strings.loadError+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo={message:t,details:i};break;case"noData":r({statusNodeType:e,title:t||s.options.strings.noData,checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo=null;break;default:a("invalid node status "+e)}return s.setModified(L.structure),n}setTitle(e){this.title=e,this.setModified()}triggerModifyChild(e,t,i){this.tree.options.modifyChild&&(t&&t.parent!==this&&a("child "+t+" is not a child of "+this),this._callEvent("modifyChild",m({operation:e,child:t},i)))}triggerModify(e,t){this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i,s,n=!0,r=this.children;if(!0===t&&(n=e(this),!1===n||"skip"===n))return n;if(r)for(i=0,s=r.length;i<s&&(n=r[i].visit(e,!0),!1!==n);i++);return n}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){let i,s,n,r=this.parent.children;for(i=0,s=r.length;i<s;i++)if(n=r[i],(t||n!==this)&&!1===e(n))return!1;return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}ne.sequence=0;
54
64
  /*!
55
65
  * Wunderbaum - ext-edit
56
66
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
57
- * v0.0.1-0, Thu, 31 Mar 2022 15:13:20 GMT (https://github.com/mar10/wunderbaum)
67
+ * v0.0.2, Tue, 12 Apr 2022 18:36:21 GMT (https://github.com/mar10/wunderbaum)
58
68
  */
59
- class ie extends q{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=$(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-dirty"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-dirty")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-dirty")})),n}_onChange(e){const t=se.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:se.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),_(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,s=v(t),n=this.tree,r=this.getPluginOption("trigger"),l=t.target&&t.target.closest("input,[contenteditable]");if(n.logDebug(`_preprocessKeyEvent: ${s}`),l){switch(s){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(n.navMode===P.row||0===n.activeColIdx){switch(s){case"Enter":if(r.indexOf("macEnter")>=0&&i)return this.startEditTitle(),!1;break;case"F2":if(r.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!s){s=`<input type=text class="wb-input-edit" value="${d(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){const i=document.activeElement;let s=i?u(i):null;const n=this.curEditNode,r=!!t.forceClose,l=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=n.getColElem(0);this._applyChange("edit.apply",n,e,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(l&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{}))}else this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(l(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:l(x(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.addClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
69
+ class re extends z{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=K(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-dirty"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-dirty")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-dirty")})),n}_onChange(e){const t=le.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:le.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),_(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,s=v(t),n=this.tree,r=this.getPluginOption("trigger"),l=t.target&&t.target.closest("input,[contenteditable]");if(n.logDebug(`_preprocessKeyEvent: ${s}`),l){switch(s){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(n.navMode===P.row||0===n.activeColIdx){switch(s){case"Enter":if(r.indexOf("macEnter")>=0&&i)return this.startEditTitle(),!1;break;case"F2":if(r.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!s){s=`<input type=text class="wb-input-edit" value="${d(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){const i=document.activeElement;let s=i?h(i):null;const n=this.curEditNode,r=!!t.forceClose,l=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=n.getColElem(0);this._applyChange("edit.apply",n,e,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(l&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{}))}else this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(l(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:l(E(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.addClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
60
70
  /*!
61
71
  * wunderbaum.ts
62
72
  *
@@ -65,7 +75,7 @@ class ie extends q{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxle
65
75
  * Copyright (c) 2021-2022, Martin Wendt (https://wwWendt.de).
66
76
  * Released under the MIT license.
67
77
  *
68
- * @version v0.0.1-0
69
- * @date Thu, 31 Mar 2022 15:13:20 GMT
70
- */class se{constructor(e){this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.viewNodes=new Set,this.activeNode=null,this.focusNode=null,this._disableUpdate=0,this._disableUpdateCount=0,this.types={},this.columns=[],this._columnsById={},this.changedSince=0,this.changes=new Set,this.changedNodes=new Set,this.filterMode=null,this.activeColIdx=0,this.navMode=P.row,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this._util=T,this.log=this.logDebug;let t=this.options=m({id:null,source:null,element:null,debugLevel:4,header:null,headerHeightPx:S,rowHeightPx:S,columns:null,types:null,escapeTitles:!0,showSpinner:!1,checkbox:!0,minExpandLevel:0,updateThrottleWait:200,skeleton:!1,navigationMode:O.startRow,quicksearch:!0,change:E,enhanceTitle:E,error:E,receive:E,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e);const i=new X;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){console.error("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++se.sequence,this.root=new te(this,null,{key:"__root__"}),this._registerExtension(new Y(this)),this._registerExtension(new ie(this)),this._registerExtension(new B(this)),this._registerExtension(new J(this)),this._registerExtension(new G(this)),this.columns=t.columns,delete t.columns,!this.columns){let e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}this.types=t.types||{},delete t.types;for(let e of Object.values(this.types))e.classes&&(e.classes=k(e.classes));1===this.columns.length&&(t.navigationMode=O.row),t.navigationMode!==O.cell&&t.navigationMode!==O.startCell||(this.navMode=P.cellNav),this._updateViewportThrottled=function(e,t=0,i={}){let s=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return j(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),$(e,t,{leading:s,trailing:n,maxWait:t})}((()=>{this._updateViewport()}),t.updateThrottleWait,{leading:!0,trailing:!0}),this.element=g(t.element),l(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){l(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||null,text:""+t.textContent})}else if(n){const e="<span class='wb-col'></span>".repeat(this.columns.length);this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`}else this.element.innerHTML="";this.element.innerHTML+='\n <div class="wb-scroll-container">\n <div class="wb-node-list"></div>\n </div>',this.scrollContainer=this.element.querySelector("div.wb-scroll-container"),this.nodeListElement=this.scrollContainer.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.columns.length>1&&this.element.classList.add("wb-grid"),this._initExtensions(),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),setTimeout((()=>{this.updateViewport()}),50),this.scrollContainer.addEventListener("scroll",(e=>{this.updateViewport()})),this.resizeObserver=new ResizeObserver((e=>{this.updateViewport(),console.log("ResizeObserver: Size changed",e)})),this.resizeObserver.observe(this.element),_(this.nodeListElement,"click","div.wb-row",(e=>{const t=se.getEventInfo(e),i=t.node;if(!1===this._callEvent("click",{event:e,node:i,info:t}))return this.lastClickTime=Date.now(),!1;if(i){const s=this.getOption("edit.trigger"),n=this.getOption("edit.slowClickDelay");s.indexOf("clickActive")>=0&&"title"===t.region&&i.isActive()&&(!n||Date.now()-this.lastClickTime<n)&&this._callMethod("edit.startEditTitle",i),t.colIdx>=0?i.setActive(!0,{colIdx:t.colIdx,event:e}):i.setActive(!0,{event:e}),t.region===I.expander?i.setExpanded(!i.isExpanded()):t.region===I.checkbox&&i.setSelected(!i.isSelected())}this.lastClickTime=Date.now()})),_(this.element,"keydown",(e=>{const t=se.getEventInfo(e),i=v(e);this._callHook("onKeyEvent",{event:e,node:t.node,info:t,eventName:i})})),_(this.element,"focusin focusout",(e=>{const t="focusin"===e.type;this._callEvent("focus",{flag:t,event:e}),t||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof se)return e;if(e instanceof te)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(let t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return l(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}static getNode(e){if(!e)return null;if(e instanceof te)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(let e of this.extensionList)e.init()}_registerNode(e){let t=e.key;l(null!=t&&!this.keyMap.has(t)),this.keyMap.set(t,e);let i=e.refKey;if(i){let t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,this.viewNodes.delete(e),e.removeMarkup()}_callHook(e,t={}){let i,s=m({},{tree:this,options:this.options,result:void 0},t);for(let t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,m({name:e,tree:this,util:this._util},t))}_firstNodeInView(e=!0){let t,i;return t=e?Math.ceil(this.scrollContainer.scrollTop/S):Math.floor(this.scrollContainer.scrollTop/S),this.visitRows((e=>{if(e._rowIdx===t)return i=e,!1})),i}_lastNodeInView(e=!0){let t,i;return t=e?Math.floor((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/S)-1:Math.ceil((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/S)-1,this.visitRows((e=>{if(e._rowIdx===t)return i=e,!1})),i}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof te?s=t:(s=this.getActiveNode(),l(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.viewNodes.clear(),this.activeNode=null,this.focusNode=null,this.changedSince=0,this.changes.clear(),this.changedNodes.clear(),this.updateViewport()}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(-1===e.indexOf("."))return void(this.options[e]=t);const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}hasFocus(){return this.element.contains(document.activeElement)}runWithoutUpdate(e,t=null){try{return this.enableUpdate(!1),e()}finally{this.enableUpdate(!0)}}async expandAll(e=!0){const t=this.logTime("expandAll("+e+")");try{this.enableUpdate(!1),await this.root.expandAll(e)}finally{this.enableUpdate(!0),this.logTimeEnd(t)}}count(e=!1){return e?this.viewNodes.size:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findNextNode(e,t){let i=null,s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null,n=Math.floor(this.scrollContainer.clientHeight/S);switch(t){case"parent":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((function(e){if(e.isVisible())return s=e,!1}));break;case"last":this.visit((function(e){e.isVisible()&&(s=e)}));break;case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":let i=this._lastNodeInView();s=this.focusNode!==i?i:this._getNextNodeInView(e,n);break;case"pageUp":if(this.focusNode&&0===this.focusNode._rowIdx)s=this.focusNode;else{let t=this._firstNodeInView();s=this.focusNode!==t?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){let t=e.target,i=t.classList,s=t.closest(".wb-col"),n=se.getNode(t),r={node:n,region:I.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))r.region=I.title;else if(i.contains("wb-expander"))r.region=!1===n.hasChildren()?I.prefix:I.expander;else if(i.contains("wb-checkbox"))r.region=I.checkbox;else if(i.contains("wb-icon"))r.region=I.icon;else if(i.contains("wb-node"))r.region=I.title;else{if(!s)return console.warn("getEventInfo(): not found",e,r),r;{r.region=I.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);r.colIdx=e}}return-1===r.colIdx&&(r.colIdx=0),r.colDef=n.tree.columns[r.colIdx],null!=r.colDef&&(r.colId=r.colDef.id),r}toString(){return"Wunderbaum<'"+this.id+"'>"}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){var e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}render(e){const t=this.logTime("render");let i=0,s=0;let n=!1,r=null==e?void 0:e.startIdx,o=null==e?void 0:e.endIdx;const a=this.viewNodes;this.viewNodes=new Set;let d=this.viewNodes;l(null!=r&&null!=o),r%2&&r--,this.visitRows((function(e){const t=e._rowIdx;d.add(e),a.delete(e),t!==i&&(e._rowIdx=i,n=!0),i<r||i>o?(e._callEvent("discard"),e.removeMarkup()):e.render({top:s}),i++,s+=22}));for(const e of a)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=s+"px",this.logTimeEnd(t),n}renderHeader(){if(!this.headerElement)return;const e=this.headerElement.querySelector(".wb-row");l(e),e.innerHTML="<span class='wb-col'></span>".repeat(this.columns.length);for(let t=0;t<this.columns.length;t++){let i=this.columns[t],s=e.children[t];s.style.left=i._ofsPx+"px",s.style.width=i._widthPx+"px",s.textContent=i.title||i.id}}scrollTo(e){const t=e.node||this.getActiveNode();l(null!=t._rowIdx);const i=this.scrollContainer.scrollTop,s=this.scrollContainer.clientHeight,n=t._rowIdx*S;let r;n>i?n+S<i+s||(r=n-s+S-1):n<i&&(r=n+1),this.log("scrollTo("+n+"): "+i+" => "+r,s),null!=r&&(this.scrollContainer.scrollTop=r,this.updateViewport())}setCellMode(e){if(e===this.navMode)return;const t=this.navMode,i=e!==P.row;this.navMode=e,i&&t===P.row&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",i),this.element.classList.toggle("wb-cell-edit-mode",e===P.cellEdit),this.setModified(L.row,this.activeNode)}setColumn(e){if(l(this.navMode!==P.row),l(0<=e&&e<this.columns.length),this.activeColIdx=e,this.setModified(L.row,this.activeNode),this.headerElement)for(let t of this.headerElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}for(let t of this.nodeListElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}}setFocus(e=!0){e?this.element.focus():this.element.blur()}setModified(e,t,i){this.changedSince||(this.changedSince=Date.now()),this.changes.add(e),e===L.structure?this.changedNodes.clear():t&&!this.changes.has(L.structure)&&(this.changedNodes.size<10?this.changedNodes.add(t):(this.changes.add(L.structure),this.changedNodes.clear()))}setStatus(e,t,i){return this.root.setStatus(e,t,i)}updateColumns(e){let t=!1,i=this.element.clientWidth,s=0,n=0;this._columnsById={};for(let e of this.columns){this._columnsById[e.id]=e;let i=e.width;if(i&&"*"!==i)if("number"==typeof i)e._weight=i,s+=i;else if("string"==typeof i&&i.endsWith("px")){e._weight=0;let s=parseFloat(i.slice(0,-2));e._widthPx!=s&&(t=!0,e._widthPx=s),n+=s}else a("Invalid column width: "+i);else e._weight=1,s+=1}let r=Math.max(0,i-n),l=0;for(let e of this.columns){if(e._weight){let i=Math.max(4,r*e._weight/s);e._widthPx!=i&&(t=!0,e._widthPx=i)}e._ofsPx=l,l+=e._widthPx}t&&(this.renderHeader(),!1!==e.render&&this.render())}updateViewport(e=!1){this._updateViewportThrottled(),e&&this._updateViewportThrottled.flush()}_updateViewport(){if(this._disableUpdate)return;let e=this.scrollContainer.clientHeight;const t=this.options.headerHeightPx;let i=this.element.clientHeight-t,s=this.scrollContainer.scrollTop;Math.abs(e-i)>1&&(this.scrollContainer.style.height=i+"px",e=i),this.updateColumns({render:!1}),this.render({startIdx:Math.max(0,s/S-5),endIdx:Math.max(0,(s+e)/S+5)}),this._callEvent("update")}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,o,a,d=0,c=!1===(t=t||{}).includeSelf,h=!!t.includeHidden,u=!h&&"hide"===this.filterMode,p=t.start||this.root.children[0];for(n=p.parent;n;){for(o=n.children,s=o.indexOf(p)+d,l(s>=0,"Could not find "+p+" in parent's children: "+n),i=s;i<o.length;i++){if(p=o[i],p===a)return!1;if(!u||p.statusNodeType||p.match||p.subMatchCount){if(!c&&!1===e(p))return!1;if(c=!1,p.children&&p.children.length&&(h||p.expanded)&&(r=p.visit((function(t){return t!==a&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")}),!1),!1===r))return!1}}p=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),l(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=!!t.includeHidden,l=t.start||this.root.children[0];if(!1!==t.includeSelf&&!1===e(l))return!1;for(;;){if(n=l.parent,i=n.children,i[0]===l){if(l=n,!l.parent)break;i=n.children}else for(s=i.indexOf(l),l=i[s-1];(r||l.expanded)&&l.children&&l.children.length;)i=l.children,n=l,l=i[i.length-1];if((r||l.isVisible())&&!1===e(l))return!1}return!0}load(e,t={}){this.clear();return(t.columns||e.columns)&&(this.columns=t.columns,this.renderHeader()),this.root.load(e)}enableUpdate(e){e?(l(this._disableUpdateCount>0),this._disableUpdateCount--,0===this._disableUpdateCount&&this.updateViewport()):this._disableUpdateCount++}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}se.version="v0.0.1-0",se.sequence=0,se.util=T,e.Wunderbaum=se,Object.defineProperty(e,"__esModule",{value:!0})}));
78
+ * @version v0.0.2
79
+ * @date Tue, 12 Apr 2022 18:36:21 GMT
80
+ */class le{constructor(e){this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.viewNodes=new Set,this.activeNode=null,this.focusNode=null,this._disableUpdate=0,this._disableUpdateCount=0,this.types={},this.columns=[],this._columnsById={},this.changedSince=0,this.changes=new Set,this.changedNodes=new Set,this.changeRedrawPending=!1,this.filterMode=null,this.activeColIdx=0,this.navMode=P.row,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this._util=T,this.log=this.logDebug;let t=this.options=m({id:null,source:null,element:null,debugLevel:4,header:null,headerHeightPx:M,rowHeightPx:M,columns:null,types:null,showSpinner:!1,checkbox:!0,minExpandLevel:0,updateThrottleWait:200,skeleton:!1,navigationMode:O.startRow,quicksearch:!0,change:x,enhanceTitle:x,error:x,receive:x,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e);const i=new te;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){console.error("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++le.sequence,this.root=new ne(this,null,{key:"__root__"}),this._registerExtension(new X(this)),this._registerExtension(new re(this)),this._registerExtension(new Y(this)),this._registerExtension(new J(this)),this._registerExtension(new ee(this)),this._registerExtension(new G(this)),this.columns=t.columns,delete t.columns,!this.columns){let e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}this.types=t.types||{},delete t.types;for(let e of Object.values(this.types))e.classes&&(e.classes=N(e.classes));1===this.columns.length&&(t.navigationMode=O.row),t.navigationMode!==O.cell&&t.navigationMode!==O.startCell||(this.navMode=P.cellNav),this._updateViewportThrottled=function(e,t=0,i={}){let s=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return j(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),K(e,t,{leading:s,trailing:n,maxWait:t})}((()=>{this._updateViewport()}),t.updateThrottleWait,{leading:!0,trailing:!0}),this.element=f(t.element),l(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){l(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||null,text:""+t.textContent})}else if(n){const e="<span class='wb-col'></span>".repeat(this.columns.length);this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`}else this.element.innerHTML="";this.element.innerHTML+='\n <div class="wb-scroll-container">\n <div class="wb-node-list"></div>\n </div>',this.scrollContainer=this.element.querySelector("div.wb-scroll-container"),this.nodeListElement=this.scrollContainer.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.columns.length>1&&this.element.classList.add("wb-grid"),this._initExtensions(),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),setTimeout((()=>{this.updateViewport()}),50),this.scrollContainer.addEventListener("scroll",(e=>{this.setModified(L.vscroll)})),this.resizeObserver=new ResizeObserver((e=>{this.setModified(L.vscroll),console.log("ResizeObserver: Size changed",e)})),this.resizeObserver.observe(this.element),_(this.nodeListElement,"click","div.wb-row",(e=>{const t=le.getEventInfo(e),i=t.node;if(!1===this._callEvent("click",{event:e,node:i,info:t}))return this.lastClickTime=Date.now(),!1;if(i){const s=this.getOption("edit.trigger"),n=this.getOption("edit.slowClickDelay");s.indexOf("clickActive")>=0&&"title"===t.region&&i.isActive()&&(!n||Date.now()-this.lastClickTime<n)&&this._callMethod("edit.startEditTitle",i),t.colIdx>=0?i.setActive(!0,{colIdx:t.colIdx,event:e}):i.setActive(!0,{event:e}),t.region===I.expander?i.setExpanded(!i.isExpanded()):t.region===I.checkbox&&i.setSelected(!i.isSelected())}this.lastClickTime=Date.now()})),_(this.element,"keydown",(e=>{const t=le.getEventInfo(e),i=v(e);this._callHook("onKeyEvent",{event:e,node:t.node,info:t,eventName:i})})),_(this.element,"focusin focusout",(e=>{const t="focusin"===e.type;this._callEvent("focus",{flag:t,event:e}),t||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof le)return e;if(e instanceof ne)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(let t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return l(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}static getNode(e){if(!e)return null;if(e instanceof ne)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(let e of this.extensionList)e.init()}_registerNode(e){let t=e.key;l(null!=t&&!this.keyMap.has(t)),this.keyMap.set(t,e);let i=e.refKey;if(i){let t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,this.viewNodes.delete(e),e.removeMarkup()}_callHook(e,t={}){let i,s=m({},{tree:this,options:this.options,result:void 0},t);for(let t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,m({name:e,tree:this,util:this._util},t))}_firstNodeInView(e=!0){let t,i;return t=e?Math.ceil(this.scrollContainer.scrollTop/M):Math.floor(this.scrollContainer.scrollTop/M),this.visitRows((e=>{if(e._rowIdx===t)return i=e,!1})),i}_lastNodeInView(e=!0){let t,i;return t=e?Math.floor((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/M)-1:Math.ceil((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/M)-1,this.visitRows((e=>{if(e._rowIdx===t)return i=e,!1})),i}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof ne?s=t:(s=this.getActiveNode(),l(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.viewNodes.clear(),this.activeNode=null,this.focusNode=null,this.changedSince=0,this.changes.clear(),this.changedNodes.clear(),this.setModified(L.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(-1===e.indexOf("."))return void(this.options[e]=t);const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}hasFocus(){return this.element.contains(document.activeElement)}runWithoutUpdate(e,t=null){try{return this.enableUpdate(!1),e()}finally{this.enableUpdate(!0)}}async expandAll(e=!0){const t=this.logTime("expandAll("+e+")");try{this.enableUpdate(!1),await this.root.expandAll(e)}finally{this.enableUpdate(!0),this.logTimeEnd(t)}}count(e=!1){return e?this.viewNodes.size:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findNextNode(e,t){let i=null,s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null,n=Math.floor(this.scrollContainer.clientHeight/M);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((function(e){if(e.isVisible())return s=e,!1}));break;case"last":this.visit((function(e){e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":let i=this._lastNodeInView();s=this.focusNode!==i?i:this._getNextNodeInView(e,n);break;case"pageUp":if(this.focusNode&&0===this.focusNode._rowIdx)s=this.focusNode;else{let t=this._firstNodeInView();s=this.focusNode!==t?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){let t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=le.getNode(t),r=n?n.tree:le.getTree(e),l={tree:r,node:n,region:I.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))l.region=I.title;else if(i.contains("wb-expander"))l.region=!1===n.hasChildren()?I.prefix:I.expander;else if(i.contains("wb-checkbox"))l.region=I.checkbox;else if(i.contains("wb-icon"))l.region=I.icon;else if(i.contains("wb-node"))l.region=I.title;else{if(!s)return"mousemove"!==e.type&&console.warn("getEventInfo(): not found",e,l),l;{l.region=I.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);l.colIdx=e}}return-1===l.colIdx&&(l.colIdx=0),l.colDef=null==r?void 0:r.columns[l.colIdx],null!=l.colDef&&(l.colId=l.colDef.id),l}toString(){return"Wunderbaum<'"+this.id+"'>"}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){var e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}render(e){const t=this.logTime("render");let i=0,s=0;let n=!1,r=null==e?void 0:e.startIdx,o=null==e?void 0:e.endIdx;const a=this.viewNodes,d=!!C(e,"newNodesOnly");this.viewNodes=new Set;let c=this.viewNodes;l(null!=r&&null!=o),r%2&&r--,this.visitRows((function(e){const t=e._rowIdx;c.add(e),a.delete(e),t!==i&&(e._rowIdx=i,n=!0),i<r||i>o?(e._callEvent("discard"),e.removeMarkup()):e._rowElem&&d||e.render({top:s}),i++,s+=22}));for(const e of a)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=s+"px",this.logTimeEnd(t),n}renderHeader(){if(!this.headerElement)return;const e=this.headerElement.querySelector(".wb-row");l(e),e.innerHTML="<span class='wb-col'></span>".repeat(this.columns.length);for(let t=0;t<this.columns.length;t++){const i=this.columns[t],s=e.children[t];s.style.left=i._ofsPx+"px",s.style.width=i._widthPx+"px";const n=d(i.title||i.id);s.innerHTML=`<span class="wb-col-title">${n}</span> <span class="wb-col-resizer"></span>`}}scrollTo(e){const t=e.node||this.getActiveNode();l(null!=t._rowIdx);const i=this.scrollContainer.scrollTop,s=this.scrollContainer.clientHeight,n=t._rowIdx*M;let r;n>i?n+M<i+s||(r=n-s+M-1):n<i&&(r=n+1),null!=r&&(this.log("scrollTo("+n+"): "+i+" => "+r,s),this.scrollContainer.scrollTop=r,this.setModified(L.vscroll))}setCellMode(e){if(e===this.navMode)return;const t=this.navMode,i=e!==P.row;this.navMode=e,i&&t===P.row&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",i),this.element.classList.toggle("wb-cell-edit-mode",e===P.cellEdit),this.setModified(L.row,this.activeNode)}setColumn(e){if(l(this.navMode!==P.row),l(0<=e&&e<this.columns.length),this.activeColIdx=e,this.setModified(L.row,this.activeNode),this.headerElement)for(let t of this.headerElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}for(let t of this.nodeListElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}}setFocus(e=!0){e?this.element.focus():this.element.blur()}setModified(e,t,i){if(t instanceof ne||(i=t),this._disableUpdate)return;const s=!!C(i,"immediate");switch(e){case L.any:case L.structure:case L.header:this.changeRedrawPending=!0,this.updateViewport(s);break;case L.vscroll:this.updateViewport(s);break;case L.row:case L.status:t._rowElem&&t.render();break;default:a(`Invalid change type ${e}`)}}setStatus(e,t,i){return this.root.setStatus(e,t,i)}updateColumns(e){let t=!1,i=this.element.clientWidth,s=0,n=0;this._columnsById={};for(let e of this.columns){this._columnsById[e.id]=e;let i=e.width;if(i&&"*"!==i)if("number"==typeof i)e._weight=i,s+=i;else if("string"==typeof i&&i.endsWith("px")){e._weight=0;let s=parseFloat(i.slice(0,-2));e._widthPx!=s&&(t=!0,e._widthPx=s),n+=s}else a("Invalid column width: "+i);else e._weight=1,s+=1}let r=Math.max(0,i-n),l=0;for(let e of this.columns){if(e._weight){let i=Math.max(4,r*e._weight/s);e._widthPx!=i&&(t=!0,e._widthPx=i)}e._ofsPx=l,l+=e._widthPx}t&&(this.renderHeader(),!1!==e.render&&this.render())}updateViewport(e=!1){this._updateViewportThrottled(),e&&this._updateViewportThrottled.flush()}_updateViewport(){if(this._disableUpdate)return;const e=!this.changeRedrawPending;this.changeRedrawPending=!1;let t=this.scrollContainer.clientHeight;const i=this.options.headerHeightPx,s=this.element.clientHeight-i,n=this.scrollContainer.scrollTop;Math.abs(t-s)>1&&(this.scrollContainer.style.height=s+"px",t=s),this.updateColumns({render:!1}),this.render({startIdx:Math.max(0,n/M-5),endIdx:Math.max(0,(n+t)/M+5),newNodesOnly:e}),this._callEvent("update")}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,o,a,d=0,c=!1===(t=t||{}).includeSelf,h=!!t.includeHidden,u=!h&&"hide"===this.filterMode,p=t.start||this.root.children[0];for(n=p.parent;n;){for(o=n.children,s=o.indexOf(p)+d,l(s>=0,"Could not find "+p+" in parent's children: "+n),i=s;i<o.length;i++){if(p=o[i],p===a)return!1;if(!u||p.statusNodeType||p.match||p.subMatchCount){if(!c&&!1===e(p))return!1;if(c=!1,p.children&&p.children.length&&(h||p.expanded)&&(r=p.visit((function(t){return t!==a&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")}),!1),!1===r))return!1}}p=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),l(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=!!t.includeHidden,l=t.start||this.root.children[0];if(!1!==t.includeSelf&&!1===e(l))return!1;for(;;){if(n=l.parent,i=n.children,i[0]===l){if(l=n,!l.parent)break;i=n.children}else for(s=i.indexOf(l),l=i[s-1];(r||l.expanded)&&l.children&&l.children.length;)i=l.children,n=l,l=i[i.length-1];if((r||l.isVisible())&&!1===e(l))return!1}return!0}load(e,t={}){this.clear();return(t.columns||e.columns)&&(this.columns=t.columns,this.renderHeader()),this.root.load(e)}enableUpdate(e){e?(l(this._disableUpdateCount>0),this._disableUpdateCount--,0===this._disableUpdateCount&&this.updateViewport()):this._disableUpdateCount++}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}le.version="v0.0.2",le.sequence=0,le.util=T,e.Wunderbaum=le,Object.defineProperty(e,"__esModule",{value:!0})}));
71
81
  //# sourceMappingURL=wunderbaum.umd.min.js.map