tree-processor 0.8.2 → 0.9.0

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.
@@ -1,100 +1,135 @@
1
1
  "use strict"
2
2
  Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})
3
3
  const r={children:"children",id:"id"}
4
- function e(e,n,t=r){const i=[]
5
- return function r(e){for(const o of e){i.push(n(o))
6
- const e=o[t.children]
7
- Array.isArray(e)&&e.length>0&&r(e)}}(e),i}function n(e,n,t=r){const i=[]
8
- return function r(e){e.forEach((e,o)=>{n(e,o)&&i.push(e)
9
- const u=e[t.children]
10
- Array.isArray(u)&&u.length>0&&r(u,o)})}(e),i}function t(e,n,i=r){for(const r of e){if(n(r))return r
11
- const e=r[i.children]
12
- if(Array.isArray(e)&&e.length>0){const r=t(e,n,i)
13
- if(r)return r}}return null}function i(e,n,t,i=r){return function r(e){for(const o of e){if(o[i.id]===n)return o[i.children]||(o[i.children]=[]),o[i.children].push(t),!0
14
- const e=o[i.children]
15
- if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function o(e,n,t,i=r){return function r(e){for(const o of e){if(o[i.id]===n)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(t),!0
16
- const e=o[i.children]
17
- if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function u(e,n,t=r){return function r(e){for(const i of e){if(i[t.id]===n){const r=i[t.children]
18
- return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const e=i[t.children]
19
- if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function s(e,n,t=r){return function r(e){for(const i of e){if(i[t.id]===n){const r=i[t.children]
20
- return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const e=i[t.children]
21
- if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function f(e,n,t=r){for(const r of e){if(n(r))return!0
22
- const e=r[t.children]
23
- if(Array.isArray(e)&&e.length>0&&f(e,n,t))return!0}return!1}function c(e,n,t=r){for(const r of e){if(!n(r))return!1
24
- const e=r[t.children]
25
- if(Array.isArray(e)&&e.length>0&&!c(e,n,t))return!1}return!0}function l(e,n,t,i=r){const o=function r(e){for(const t of e){if(t[i.id]===n)return t
26
- const e=t[i.children]
27
- if(Array.isArray(e)&&e.length>0){const n=r(e)
28
- if(n)return n}}return null}(e)
29
- if(!o)return null
30
- const u=o[i.children]
31
- if(!Array.isArray(u)||0===u.length)return null
32
- const s=t>=0?t:u.length+t
33
- return s>=0&&s<u.length?u[s]:null}function a(e,n,t=r){return function r(e,i=[]){for(let o=0;o<e.length;o++){const u=e[o],s=[...i,o]
34
- if(u[t.id]===n)return s
35
- const f=u[t.children]
36
- if(Array.isArray(f)&&f.length>0){const e=r(f,s)
37
- if(e)return e}}return null}(e)}function h(e,n,t=r){if(!Array.isArray(n)||0===n.length)return null
38
- let i=e
39
- for(let r=0;r<n.length;r++){const e=n[r]
40
- if(!Array.isArray(i)||e<0||e>=i.length)return null
41
- const o=i[e]
42
- if(r===n.length-1)return o
43
- const u=o[t.children]
44
- if(!Array.isArray(u))return null
45
- i=u}return null}function d(e,n=r){const t={}
46
- return function r(e,i=1){for(const o of e){t[o[n.id]]=i
47
- const e=o[n.children]
48
- Array.isArray(e)&&e.length>0&&r(e,i+1)}}(e),t}function y(e,n,t=r){return function r(e,i=1){for(const o of e){if(o[t.id]===n)return i
49
- const e=o[t.children]
50
- if(Array.isArray(e)&&e.length>0){const n=r(e,i+1)
51
- if(null!==n)return n}}return null}(e)}function A(e,n,t=r){const i=new Set
52
- return function r(e){const o=[]
53
- for(const u of e){const e=u[n]
54
- if(null!=e){if(i.has(e))continue
55
- i.add(e)}const s={...u},f=u[t.children]
56
- Array.isArray(f)&&f.length>0&&(s[t.children]=r(f)),o.push(s)}return o}(e)}function p(e,n,t=r){return function r(e){for(let i=0;i<e.length;i++){const o=e[i]
57
- if(o[t.id]===n)return e.splice(i,1),!0
58
- const u=o[t.children]
59
- if(Array.isArray(u)&&u.length>0&&r(u))return!0}return!1}(e)}function g(e,n,t=r){!function r(e){for(const i of e){n(i)
60
- const e=i[t.children]
61
- Array.isArray(e)&&e.length>0&&r(e)}}(e)}function T(r){return!Array.isArray(r)||0===r.length}function x(e,n=r){if(!v(e,n))return!0
62
- const t=e[n.children]
63
- return void 0===t||(!Array.isArray(t)||0===t.length)}function D(e,n,t=r){const i=function r(e){for(const i of e){if(i[t.id]===n)return i
64
- const e=i[t.children]
65
- if(Array.isArray(e)&&e.length>0){const n=r(e)
66
- if(null!==n)return n}}return null}(e)
67
- if(!i)return[]
68
- const o=i[t.children]
69
- return Array.isArray(o)?o:[]}function N(e,n,t=r){const i=function r(e,i=null){for(const o of e){if(o[t.id]===n)return{node:o,parent:i}
70
- const e=o[t.children]
71
- if(Array.isArray(e)&&e.length>0){const n=r(e,o)
72
- if(null!==n)return n}}return null}(e)
73
- if(!i)return[]
74
- if(null===i.parent)return e
75
- const o=i.parent[t.children]
76
- return Array.isArray(o)?o:[]}function S(e,n,t=r){return function r(e,i=null){for(const o of e){if(o[t.id]===n)return i
77
- const e=o[t.children]
78
- if(Array.isArray(e)&&e.length>0){const n=r(e,o)
79
- if(null!==n)return n}}return null}(e)}function m(e,n,t=r){for(const r of e){if(r[t.id]===n)return!0
80
- const e=r[t.children]
81
- if(Array.isArray(e)&&e.length>0&&m(e,n,t))return!0}return!1}function v(e,n=r){if(!e||"object"!=typeof e||Array.isArray(e))return!1
82
- const t=e[n.children]
4
+ function n(n,e,t=r){const o=[]
5
+ return function r(n){for(const i of n){o.push(e(i))
6
+ const n=i[t.children]
7
+ Array.isArray(n)&&n.length>0&&r(n)}}(n),o}function e(n,e,t=r){const o=[]
8
+ return function r(n){n.forEach((n,i)=>{e(n,i)&&o.push(n)
9
+ const c=n[t.children]
10
+ Array.isArray(c)&&c.length>0&&r(c)})}(n),o}function t(n,e,o=r){for(const r of n){if(e(r))return r
11
+ const n=r[o.children]
12
+ if(Array.isArray(n)&&n.length>0){const r=t(n,e,o)
13
+ if(r)return r}}return null}function o(n,e,t,o=r){return function r(n){for(const i of n){if(i[o.id]===e)return i[o.children]||(i[o.children]=[]),i[o.children].push(t),!0
14
+ const n=i[o.children]
15
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function i(n,e,t,o=r){return function r(n){for(const i of n){if(i[o.id]===e)return i[o.children]||(i[o.children]=[]),i[o.children].unshift(t),!0
16
+ const n=i[o.children]
17
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function c(n,e,t=r){return function r(n){for(const o of n){if(o[t.id]===e){const r=o[t.children]
18
+ return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=o[t.children]
19
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function s(n,e,t=r){return function r(n){for(const o of n){if(o[t.id]===e){const r=o[t.children]
20
+ return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const n=o[t.children]
21
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function f(n,e,t=r){for(const r of n){if(e(r))return!0
22
+ const n=r[t.children]
23
+ if(Array.isArray(n)&&n.length>0&&f(n,e,t))return!0}return!1}function u(n,e,t=r){for(const r of n){if(!e(r))return!1
24
+ const n=r[t.children]
25
+ if(Array.isArray(n)&&n.length>0&&!u(n,e,t))return!1}return!0}function l(n,e,t,o=r){const i=function r(n){for(const t of n){if(t[o.id]===e)return t
26
+ const n=t[o.children]
27
+ if(Array.isArray(n)&&n.length>0){const e=r(n)
28
+ if(e)return e}}return null}(n)
29
+ if(!i)return null
30
+ const c=i[o.children]
31
+ if(!Array.isArray(c)||0===c.length)return null
32
+ const s=t>=0?t:c.length+t
33
+ return s>=0&&s<c.length?c[s]:null}function a(n,e,t=r){return function r(n,o=[]){for(let i=0;i<n.length;i++){const c=n[i],s=[...o,i]
34
+ if(c[t.id]===e)return s
35
+ const f=c[t.children]
36
+ if(Array.isArray(f)&&f.length>0){const n=r(f,s)
37
+ if(n)return n}}return null}(n)}function h(n,e,t=r){if(!Array.isArray(e)||0===e.length)return null
38
+ let o=n
39
+ for(let r=0;r<e.length;r++){const n=e[r]
40
+ if(!Array.isArray(o)||n<0||n>=o.length)return null
41
+ const i=o[n]
42
+ if(r===e.length-1)return i
43
+ const c=i[t.children]
44
+ if(!Array.isArray(c))return null
45
+ o=c}return null}function d(n,e=r){const t={}
46
+ return function r(n,o=1){for(const i of n){t[i[e.id]]=o
47
+ const n=i[e.children]
48
+ Array.isArray(n)&&n.length>0&&r(n,o+1)}}(n),t}function y(n,e,t=r){return function r(n,o=1){for(const i of n){if(i[t.id]===e)return o
49
+ const n=i[t.children]
50
+ if(Array.isArray(n)&&n.length>0){const e=r(n,o+1)
51
+ if(null!==e)return e}}return null}(n)}function A(n,e,t=r){const o=new Set
52
+ return function r(n){const i=[]
53
+ for(const c of n){const n=c[e]
54
+ if(null!=n){if(o.has(n))continue
55
+ o.add(n)}const s={...c},f=c[t.children]
56
+ Array.isArray(f)&&f.length>0&&(s[t.children]=r(f)),i.push(s)}return i}(n)}function p(n,e,t=r){return function r(n){for(let o=0;o<n.length;o++){const i=n[o]
57
+ if(i[t.id]===e)return n.splice(o,1),!0
58
+ const c=i[t.children]
59
+ if(Array.isArray(c)&&c.length>0&&r(c))return!0}return!1}(n)}function T(n,e,t=r){!function r(n){for(const o of n){e(o)
60
+ const n=o[t.children]
61
+ Array.isArray(n)&&n.length>0&&r(n)}}(n)}function g(r){return!Array.isArray(r)||0===r.length}function x(n,e=r){if(!m(n,e))return!0
62
+ const t=n[e.children]
63
+ return void 0===t||!Array.isArray(t)||0===t.length}function v(n,e,t=r){const o=function r(n){for(const o of n){if(o[t.id]===e)return o
64
+ const n=o[t.children]
65
+ if(Array.isArray(n)&&n.length>0){const e=r(n)
66
+ if(null!==e)return e}}return null}(n)
67
+ if(!o)return[]
68
+ const i=o[t.children]
69
+ return Array.isArray(i)?i:[]}function D(n,e,t=r){const o=function r(n,o=null){for(const i of n){if(i[t.id]===e)return{node:i,parent:o}
70
+ const n=i[t.children]
71
+ if(Array.isArray(n)&&n.length>0){const e=r(n,i)
72
+ if(null!==e)return e}}return null}(n)
73
+ if(!o)return[]
74
+ if(null===o.parent)return n
75
+ const i=o.parent[t.children]
76
+ return Array.isArray(i)?i:[]}function b(n,e,t=r){return function r(n,o=null){for(const i of n){if(i[t.id]===e)return o
77
+ const n=i[t.children]
78
+ if(Array.isArray(n)&&n.length>0){const e=r(n,i)
79
+ if(null!==e)return e}}return null}(n)}function N(n,e,t=r){for(const r of n){if(r[t.id]===e)return!0
80
+ const n=r[t.children]
81
+ if(Array.isArray(n)&&n.length>0&&N(n,e,t))return!0}return!1}function m(n,e=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
82
+ const t=n[e.children]
83
83
  if(void 0!==t){if(null===t)return!1
84
84
  if(!Array.isArray(t))return!1
85
- for(const r of t)if(!v(r,n))return!1}return!0}function b(e,n=r){if(!Array.isArray(e))return!1
86
- for(const r of e)if(!v(r,n))return!1
87
- return!0}function E(e,n=r){if(!e||"object"!=typeof e||Array.isArray(e))return!1
88
- const t=e[n.children]
89
- return void 0===t||Array.isArray(t)}function C(e,n=r,t=new WeakSet){if(!e||"object"!=typeof e||Array.isArray(e))return!1
90
- if(t.has(e))return!1
91
- t.add(e)
92
- const i=e[n.children]
93
- if(void 0!==i){if(null===i)return!1
94
- if(!Array.isArray(i))return!1
95
- for(const r of i)if(!C(r,n,t))return!1}return!0}function O(e,n,t=r){if(n<=0)return!1
96
- return function r(e,i){if(i>n)return!1
97
- for(const n of e){const e=n[t.children]
98
- if(Array.isArray(e)&&e.length>0&&!r(e,i+1))return!1}return!0}(e,1)}function j(e,n=r){const t=e[n.children]
99
- return void 0===t||!Array.isArray(t)||0===t.length}function M(e,n,t=r){return!!m(e,n,t)&&null===S(e,n,t)}const k={mapTree:e,filterTree:n,findTree:t,pushTree:i,unshiftTree:o,popTree:u,shiftTree:s,someTree:f,everyTree:c,atTree:l,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:d,getNodeDepth:y,dedupTree:A,removeTree:p,forEachTree:g,isEmptyTreeData:T,isEmptySingleTreeData:x,getParentTree:S,getChildrenTree:D,getSiblingsTree:N,includesTree:m,isSingleTreeData:v,isTreeData:b,isValidTreeNode:E,isTreeNodeWithCircularCheck:C,isSafeTreeDepth:O,isLeafNode:j,isRootNode:M}
100
- exports.atIndexOfTree=h,exports.atTree=l,exports.dedupTree=A,exports.default=k,exports.everyTree=c,exports.filterTree=n,exports.findTree=t,exports.forEachTree=g,exports.getChildrenTree=D,exports.getNodeDepth=y,exports.getNodeDepthMap=d,exports.getParentTree=S,exports.getSiblingsTree=N,exports.includesTree=m,exports.indexOfTree=a,exports.isEmptySingleTreeData=x,exports.isEmptyTreeData=T,exports.isLeafNode=j,exports.isRootNode=M,exports.isSafeTreeDepth=O,exports.isSingleTreeData=v,exports.isTreeData=b,exports.isTreeNodeWithCircularCheck=C,exports.isValidTreeNode=E,exports.mapTree=e,exports.popTree=u,exports.pushTree=i,exports.removeTree=p,exports.shiftTree=s,exports.someTree=f,exports.unshiftTree=o
85
+ for(const r of t)if(!m(r,e))return!1}return!0}function S(n,e=r){if(!Array.isArray(n))return!1
86
+ for(const r of n)if(!m(r,e))return!1
87
+ return!0}function M(n,e=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
88
+ const t=n[e.children]
89
+ return void 0===t||Array.isArray(t)}function j(n,e=r,t=new WeakSet){if(!n||"object"!=typeof n||Array.isArray(n))return!1
90
+ if(t.has(n))return!1
91
+ t.add(n)
92
+ const o=n[e.children]
93
+ if(void 0!==o){if(null===o)return!1
94
+ if(!Array.isArray(o))return!1
95
+ for(const r of o)if(!j(r,e,t))return!1}return!0}function E(n,e,t=r){return!(e<=0)&&function r(n,o){if(o>e)return!1
96
+ for(const e of n){const n=e[t.children]
97
+ if(Array.isArray(n)&&n.length>0&&!r(n,o+1))return!1}return!0}(n,1)}function O(n,e=r){const t=n[e.children]
98
+ return void 0===t||!Array.isArray(t)||0===t.length}function k(n,e,t=r){return!!N(n,e,t)&&null===b(n,e,t)}function C(n,e=r){const t=[]
99
+ return function r(n){for(const o of n){const{[e.children]:n,...i}=o
100
+ t.push(i)
101
+ const c=o[e.children]
102
+ Array.isArray(c)&&c.length>0&&r(c)}}(n),t}function I(n,e={}){const{rootParentId:t=null,parentIdField:o="parentId",fieldNames:i=r}=e
103
+ if(Array.isArray(n)){if(0===n.length)return[]
104
+ const r=new Map
105
+ for(const e of n){const n=e[i.id]
106
+ if(null==n)continue
107
+ const t={...e,[i.children]:[]}
108
+ r.set(n,t)}const e=[]
109
+ for(const c of n){const n=c[i.id],s=c[o]
110
+ if(null==n)continue
111
+ const f=r.get(n)
112
+ if(f)if(s===t||null==s)e.push(f)
113
+ else{const n=r.get(s)
114
+ if(n){const r=n[i.children]
115
+ Array.isArray(r)?r.push(f):n[i.children]=[f]}else e.push(f)}}return e}if(n instanceof Map){if(0===n.size)return[]
116
+ const r=[]
117
+ return n.forEach((n,e)=>{r.push({...n,[i.id]:e})}),I(r,e)}if(n&&"object"==typeof n&&!Array.isArray(n)&&!(n instanceof Map)){const r=n[i.children]
118
+ if(Array.isArray(r))return[n]
119
+ const t=Object.keys(n)
120
+ if(t.length>0){let r=!0
121
+ for(const e of t){const t=n[e]
122
+ if(!t||"object"!=typeof t||Array.isArray(t)){r=!1
123
+ break}}if(r){const r=[]
124
+ for(const e of t){const t=n[e]
125
+ r.push({...t,[i.id]:e})}if(r.length>0)return I(r,e)}}return[{...n,[i.children]:[]}]}return[]}function w(n,e=r){const t=new Map
126
+ return function r(n){for(const o of n){const n=o[e.id]
127
+ if(null!=n){const{[e.children]:r,...i}=o
128
+ t.set(n,i)}const i=o[e.children]
129
+ Array.isArray(i)&&i.length>0&&r(i)}}(n),t}function L(n,e=r){const t=[]
130
+ return Array.isArray(n)&&0!==n.length?(function r(n,o=0){t[o]||(t[o]=[])
131
+ for(const i of n){const{[e.children]:n,...c}=i
132
+ t[o].push(c)
133
+ const s=i[e.children]
134
+ Array.isArray(s)&&s.length>0&&r(s,o+1)}}(n),t):[]}function P(r){return Array.isArray(r)&&0!==r.length&&1===r.length?r[0]:null}const W={mapTree:n,filterTree:e,findTree:t,pushTree:o,unshiftTree:i,popTree:c,shiftTree:s,someTree:f,everyTree:u,atTree:l,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:d,getNodeDepth:y,dedupTree:A,removeTree:p,forEachTree:T,isEmptyTreeData:g,isEmptySingleTreeData:x,getParentTree:b,getChildrenTree:v,getSiblingsTree:D,includesTree:N,isSingleTreeData:m,isTreeData:S,isValidTreeNode:M,isTreeNodeWithCircularCheck:j,isSafeTreeDepth:E,isLeafNode:O,isRootNode:k,convertToArrayTree:C,convertBackTree:I,convertToMapTree:w,convertToLevelArrayTree:L,convertToObjectTree:P}
135
+ exports.atIndexOfTree=h,exports.atTree=l,exports.convertBackTree=I,exports.convertToArrayTree=C,exports.convertToLevelArrayTree=L,exports.convertToMapTree=w,exports.convertToObjectTree=P,exports.dedupTree=A,exports.default=W,exports.everyTree=u,exports.filterTree=e,exports.findTree=t,exports.forEachTree=T,exports.getChildrenTree=v,exports.getNodeDepth=y,exports.getNodeDepthMap=d,exports.getParentTree=b,exports.getSiblingsTree=D,exports.includesTree=N,exports.indexOfTree=a,exports.isEmptySingleTreeData=x,exports.isEmptyTreeData=g,exports.isLeafNode=O,exports.isRootNode=k,exports.isSafeTreeDepth=E,exports.isSingleTreeData=m,exports.isTreeData=S,exports.isTreeNodeWithCircularCheck=j,exports.isValidTreeNode=M,exports.mapTree=n,exports.popTree=c,exports.pushTree=o,exports.removeTree=p,exports.shiftTree=s,exports.someTree=f,exports.unshiftTree=i
@@ -4,43 +4,43 @@ return function r(n){for(const o of n){i.push(t(o))
4
4
  const n=o[e.children]
5
5
  Array.isArray(n)&&n.length>0&&r(n)}}(n),i}function t(n,t,e=r){const i=[]
6
6
  return function r(n){n.forEach((n,o)=>{t(n,o)&&i.push(n)
7
- const u=n[e.children]
8
- Array.isArray(u)&&u.length>0&&r(u,o)})}(n),i}function e(n,t,i=r){for(const r of n){if(t(r))return r
7
+ const c=n[e.children]
8
+ Array.isArray(c)&&c.length>0&&r(c)})}(n),i}function e(n,t,i=r){for(const r of n){if(t(r))return r
9
9
  const n=r[i.children]
10
10
  if(Array.isArray(n)&&n.length>0){const r=e(n,t,i)
11
11
  if(r)return r}}return null}function i(n,t,e,i=r){return function r(n){for(const o of n){if(o[i.id]===t)return o[i.children]||(o[i.children]=[]),o[i.children].push(e),!0
12
12
  const n=o[i.children]
13
13
  if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function o(n,t,e,i=r){return function r(n){for(const o of n){if(o[i.id]===t)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(e),!0
14
14
  const n=o[i.children]
15
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function u(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
16
- return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[e.children]
17
15
  if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function c(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
16
+ return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[e.children]
17
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function f(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
18
18
  return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const n=i[e.children]
19
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function f(n,t,e=r){for(const r of n){if(t(r))return!0
19
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function u(n,t,e=r){for(const r of n){if(t(r))return!0
20
20
  const n=r[e.children]
21
- if(Array.isArray(n)&&n.length>0&&f(n,t,e))return!0}return!1}function l(n,t,e=r){for(const r of n){if(!t(r))return!1
21
+ if(Array.isArray(n)&&n.length>0&&u(n,t,e))return!0}return!1}function s(n,t,e=r){for(const r of n){if(!t(r))return!1
22
22
  const n=r[e.children]
23
- if(Array.isArray(n)&&n.length>0&&!l(n,t,e))return!1}return!0}function s(n,t,e,i=r){const o=function r(n){for(const e of n){if(e[i.id]===t)return e
23
+ if(Array.isArray(n)&&n.length>0&&!s(n,t,e))return!1}return!0}function l(n,t,e,i=r){const o=function r(n){for(const e of n){if(e[i.id]===t)return e
24
24
  const n=e[i.children]
25
25
  if(Array.isArray(n)&&n.length>0){const t=r(n)
26
26
  if(t)return t}}return null}(n)
27
27
  if(!o)return null
28
- const u=o[i.children]
29
- if(!Array.isArray(u)||0===u.length)return null
30
- const c=e>=0?e:u.length+e
31
- return c>=0&&c<u.length?u[c]:null}function a(n,t,e=r){return function r(n,i=[]){for(let o=0;o<n.length;o++){const u=n[o],c=[...i,o]
32
- if(u[e.id]===t)return c
33
- const f=u[e.children]
34
- if(Array.isArray(f)&&f.length>0){const n=r(f,c)
28
+ const c=o[i.children]
29
+ if(!Array.isArray(c)||0===c.length)return null
30
+ const f=e>=0?e:c.length+e
31
+ return f>=0&&f<c.length?c[f]:null}function a(n,t,e=r){return function r(n,i=[]){for(let o=0;o<n.length;o++){const c=n[o],f=[...i,o]
32
+ if(c[e.id]===t)return f
33
+ const u=c[e.children]
34
+ if(Array.isArray(u)&&u.length>0){const n=r(u,f)
35
35
  if(n)return n}}return null}(n)}function h(n,t,e=r){if(!Array.isArray(t)||0===t.length)return null
36
36
  let i=n
37
37
  for(let r=0;r<t.length;r++){const n=t[r]
38
38
  if(!Array.isArray(i)||n<0||n>=i.length)return null
39
39
  const o=i[n]
40
40
  if(r===t.length-1)return o
41
- const u=o[e.children]
42
- if(!Array.isArray(u))return null
43
- i=u}return null}function y(n,t=r){const e={}
41
+ const c=o[e.children]
42
+ if(!Array.isArray(c))return null
43
+ i=c}return null}function y(n,t=r){const e={}
44
44
  return function r(n,i=1){for(const o of n){e[o[t.id]]=i
45
45
  const n=o[t.children]
46
46
  Array.isArray(n)&&n.length>0&&r(n,i+1)}}(n),e}function d(n,t,e=r){return function r(n,i=1){for(const o of n){if(o[e.id]===t)return i
@@ -48,51 +48,86 @@ const n=o[e.children]
48
48
  if(Array.isArray(n)&&n.length>0){const t=r(n,i+1)
49
49
  if(null!==t)return t}}return null}(n)}function A(n,t,e=r){const i=new Set
50
50
  return function r(n){const o=[]
51
- for(const u of n){const n=u[t]
51
+ for(const c of n){const n=c[t]
52
52
  if(null!=n){if(i.has(n))continue
53
- i.add(n)}const c={...u},f=u[e.children]
54
- Array.isArray(f)&&f.length>0&&(c[e.children]=r(f)),o.push(c)}return o}(n)}function g(n,t,e=r){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
53
+ i.add(n)}const f={...c},u=c[e.children]
54
+ Array.isArray(u)&&u.length>0&&(f[e.children]=r(u)),o.push(f)}return o}(n)}function g(n,t,e=r){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
55
55
  if(o[e.id]===t)return n.splice(i,1),!0
56
- const u=o[e.children]
57
- if(Array.isArray(u)&&u.length>0&&r(u))return!0}return!1}(n)}function T(n,t,e=r){!function r(n){for(const i of n){t(i)
56
+ const c=o[e.children]
57
+ if(Array.isArray(c)&&c.length>0&&r(c))return!0}return!1}(n)}function p(n,t,e=r){!function r(n){for(const i of n){t(i)
58
58
  const n=i[e.children]
59
- Array.isArray(n)&&n.length>0&&r(n)}}(n)}function p(r){return!Array.isArray(r)||0===r.length}function v(n,t=r){if(!b(n,t))return!0
59
+ Array.isArray(n)&&n.length>0&&r(n)}}(n)}function T(r){return!Array.isArray(r)||0===r.length}function v(n,t=r){if(!m(n,t))return!0
60
60
  const e=n[t.children]
61
- return void 0===e||(!Array.isArray(e)||0===e.length)}function D(n,t,e=r){const i=function r(n){for(const i of n){if(i[e.id]===t)return i
61
+ return void 0===e||!Array.isArray(e)||0===e.length}function b(n,t,e=r){const i=function r(n){for(const i of n){if(i[e.id]===t)return i
62
62
  const n=i[e.children]
63
63
  if(Array.isArray(n)&&n.length>0){const t=r(n)
64
64
  if(null!==t)return t}}return null}(n)
65
65
  if(!i)return[]
66
66
  const o=i[e.children]
67
- return Array.isArray(o)?o:[]}function N(n,t,e=r){const i=function r(n,i=null){for(const o of n){if(o[e.id]===t)return{node:o,parent:i}
67
+ return Array.isArray(o)?o:[]}function j(n,t,e=r){const i=function r(n,i=null){for(const o of n){if(o[e.id]===t)return{node:o,parent:i}
68
68
  const n=o[e.children]
69
69
  if(Array.isArray(n)&&n.length>0){const t=r(n,o)
70
70
  if(null!==t)return t}}return null}(n)
71
71
  if(!i)return[]
72
72
  if(null===i.parent)return n
73
73
  const o=i.parent[e.children]
74
- return Array.isArray(o)?o:[]}function S(n,t,e=r){return function r(n,i=null){for(const o of n){if(o[e.id]===t)return i
74
+ return Array.isArray(o)?o:[]}function D(n,t,e=r){return function r(n,i=null){for(const o of n){if(o[e.id]===t)return i
75
75
  const n=o[e.children]
76
76
  if(Array.isArray(n)&&n.length>0){const t=r(n,o)
77
- if(null!==t)return t}}return null}(n)}function m(n,t,e=r){for(const r of n){if(r[e.id]===t)return!0
77
+ if(null!==t)return t}}return null}(n)}function N(n,t,e=r){for(const r of n){if(r[e.id]===t)return!0
78
78
  const n=r[e.children]
79
- if(Array.isArray(n)&&n.length>0&&m(n,t,e))return!0}return!1}function b(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
79
+ if(Array.isArray(n)&&n.length>0&&N(n,t,e))return!0}return!1}function m(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
80
80
  const e=n[t.children]
81
81
  if(void 0!==e){if(null===e)return!1
82
82
  if(!Array.isArray(e))return!1
83
- for(const r of e)if(!b(r,t))return!1}return!0}function E(n,t=r){if(!Array.isArray(n))return!1
84
- for(const r of n)if(!b(r,t))return!1
85
- return!0}function j(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
83
+ for(const r of e)if(!m(r,t))return!1}return!0}function M(n,t=r){if(!Array.isArray(n))return!1
84
+ for(const r of n)if(!m(r,t))return!1
85
+ return!0}function S(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
86
86
  const e=n[t.children]
87
- return void 0===e||Array.isArray(e)}function x(n,t=r,e=new WeakSet){if(!n||"object"!=typeof n||Array.isArray(n))return!1
87
+ return void 0===e||Array.isArray(e)}function k(n,t=r,e=new WeakSet){if(!n||"object"!=typeof n||Array.isArray(n))return!1
88
88
  if(e.has(n))return!1
89
89
  e.add(n)
90
90
  const i=n[t.children]
91
91
  if(void 0!==i){if(null===i)return!1
92
92
  if(!Array.isArray(i))return!1
93
- for(const r of i)if(!x(r,t,e))return!1}return!0}function C(n,t,e=r){if(t<=0)return!1
94
- return function r(n,i){if(i>t)return!1
93
+ for(const r of i)if(!k(r,t,e))return!1}return!0}function E(n,t,e=r){return!(t<=0)&&function r(n,i){if(i>t)return!1
95
94
  for(const t of n){const n=t[e.children]
96
- if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(n,1)}function k(n,t=r){const e=n[t.children]
97
- return void 0===e||!Array.isArray(e)||0===e.length}function w(n,t,e=r){return!!m(n,t,e)&&null===S(n,t,e)}const O={mapTree:n,filterTree:t,findTree:e,pushTree:i,unshiftTree:o,popTree:u,shiftTree:c,someTree:f,everyTree:l,atTree:s,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:y,getNodeDepth:d,dedupTree:A,removeTree:g,forEachTree:T,isEmptyTreeData:p,isEmptySingleTreeData:v,getParentTree:S,getChildrenTree:D,getSiblingsTree:N,includesTree:m,isSingleTreeData:b,isTreeData:E,isValidTreeNode:j,isTreeNodeWithCircularCheck:x,isSafeTreeDepth:C,isLeafNode:k,isRootNode:w}
98
- export{h as atIndexOfTree,s as atTree,A as dedupTree,O as default,l as everyTree,t as filterTree,e as findTree,T as forEachTree,D as getChildrenTree,d as getNodeDepth,y as getNodeDepthMap,S as getParentTree,N as getSiblingsTree,m as includesTree,a as indexOfTree,v as isEmptySingleTreeData,p as isEmptyTreeData,k as isLeafNode,w as isRootNode,C as isSafeTreeDepth,b as isSingleTreeData,E as isTreeData,x as isTreeNodeWithCircularCheck,j as isValidTreeNode,n as mapTree,u as popTree,i as pushTree,g as removeTree,c as shiftTree,f as someTree,o as unshiftTree}
95
+ if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(n,1)}function w(n,t=r){const e=n[t.children]
96
+ return void 0===e||!Array.isArray(e)||0===e.length}function I(n,t,e=r){return!!N(n,t,e)&&null===D(n,t,e)}function O(n,t=r){const e=[]
97
+ return function r(n){for(const i of n){const{[t.children]:n,...o}=i
98
+ e.push(o)
99
+ const c=i[t.children]
100
+ Array.isArray(c)&&c.length>0&&r(c)}}(n),e}function x(n,t={}){const{rootParentId:e=null,parentIdField:i="parentId",fieldNames:o=r}=t
101
+ if(Array.isArray(n)){if(0===n.length)return[]
102
+ const r=new Map
103
+ for(const t of n){const n=t[o.id]
104
+ if(null==n)continue
105
+ const e={...t,[o.children]:[]}
106
+ r.set(n,e)}const t=[]
107
+ for(const c of n){const n=c[o.id],f=c[i]
108
+ if(null==n)continue
109
+ const u=r.get(n)
110
+ if(u)if(f===e||null==f)t.push(u)
111
+ else{const n=r.get(f)
112
+ if(n){const r=n[o.children]
113
+ Array.isArray(r)?r.push(u):n[o.children]=[u]}else t.push(u)}}return t}if(n instanceof Map){if(0===n.size)return[]
114
+ const r=[]
115
+ return n.forEach((n,t)=>{r.push({...n,[o.id]:t})}),x(r,t)}if(n&&"object"==typeof n&&!Array.isArray(n)&&!(n instanceof Map)){const r=n[o.children]
116
+ if(Array.isArray(r))return[n]
117
+ const e=Object.keys(n)
118
+ if(e.length>0){let r=!0
119
+ for(const t of e){const e=n[t]
120
+ if(!e||"object"!=typeof e||Array.isArray(e)){r=!1
121
+ break}}if(r){const r=[]
122
+ for(const t of e){const e=n[t]
123
+ r.push({...e,[o.id]:t})}if(r.length>0)return x(r,t)}}return[{...n,[o.children]:[]}]}return[]}function C(n,t=r){const e=new Map
124
+ return function r(n){for(const i of n){const n=i[t.id]
125
+ if(null!=n){const{[t.children]:r,...o}=i
126
+ e.set(n,o)}const o=i[t.children]
127
+ Array.isArray(o)&&o.length>0&&r(o)}}(n),e}function L(n,t=r){const e=[]
128
+ return Array.isArray(n)&&0!==n.length?(function r(n,i=0){e[i]||(e[i]=[])
129
+ for(const o of n){const{[t.children]:n,...c}=o
130
+ e[i].push(c)
131
+ const f=o[t.children]
132
+ Array.isArray(f)&&f.length>0&&r(f,i+1)}}(n),e):[]}function P(r){return Array.isArray(r)&&0!==r.length&&1===r.length?r[0]:null}const W={mapTree:n,filterTree:t,findTree:e,pushTree:i,unshiftTree:o,popTree:c,shiftTree:f,someTree:u,everyTree:s,atTree:l,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:y,getNodeDepth:d,dedupTree:A,removeTree:g,forEachTree:p,isEmptyTreeData:T,isEmptySingleTreeData:v,getParentTree:D,getChildrenTree:b,getSiblingsTree:j,includesTree:N,isSingleTreeData:m,isTreeData:M,isValidTreeNode:S,isTreeNodeWithCircularCheck:k,isSafeTreeDepth:E,isLeafNode:w,isRootNode:I,convertToArrayTree:O,convertBackTree:x,convertToMapTree:C,convertToLevelArrayTree:L,convertToObjectTree:P}
133
+ export{h as atIndexOfTree,l as atTree,x as convertBackTree,O as convertToArrayTree,L as convertToLevelArrayTree,C as convertToMapTree,P as convertToObjectTree,A as dedupTree,W as default,s as everyTree,t as filterTree,e as findTree,p as forEachTree,b as getChildrenTree,d as getNodeDepth,y as getNodeDepthMap,D as getParentTree,j as getSiblingsTree,N as includesTree,a as indexOfTree,v as isEmptySingleTreeData,T as isEmptyTreeData,w as isLeafNode,I as isRootNode,E as isSafeTreeDepth,m as isSingleTreeData,M as isTreeData,k as isTreeNodeWithCircularCheck,S as isValidTreeNode,n as mapTree,c as popTree,i as pushTree,g as removeTree,f as shiftTree,u as someTree,o as unshiftTree}
@@ -5,17 +5,17 @@ return function r(n){for(const o of n){i.push(e(o))
5
5
  const n=o[t.children]
6
6
  Array.isArray(n)&&n.length>0&&r(n)}}(r),i}function t(r,e,t=n){const i=[]
7
7
  return function r(n){n.forEach((n,o)=>{e(n,o)&&i.push(n)
8
- const f=n[t.children]
9
- Array.isArray(f)&&f.length>0&&r(f,o)})}(r),i}function i(r,e,t=n){for(const n of r){if(e(n))return n
8
+ const c=n[t.children]
9
+ Array.isArray(c)&&c.length>0&&r(c)})}(r),i}function i(r,e,t=n){for(const n of r){if(e(n))return n
10
10
  const r=n[t.children]
11
11
  if(Array.isArray(r)&&r.length>0){const n=i(r,e,t)
12
12
  if(n)return n}}return null}function o(r,e,t,i=n){return function r(n){for(const o of n){if(o[i.id]===e)return o[i.children]||(o[i.children]=[]),o[i.children].push(t),!0
13
13
  const n=o[i.children]
14
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function f(r,e,t,i=n){return function r(n){for(const o of n){if(o[i.id]===e)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(t),!0
14
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function c(r,e,t,i=n){return function r(n){for(const o of n){if(o[i.id]===e)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(t),!0
15
15
  const n=o[i.children]
16
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function u(r,e,t=n){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
16
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function f(r,e,t=n){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
17
17
  return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[t.children]
18
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function c(r,e,t=n){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
18
+ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function u(r,e,t=n){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
19
19
  return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const n=i[t.children]
20
20
  if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function s(r,e,t=n){for(const n of r){if(e(n))return!0
21
21
  const r=n[t.children]
@@ -26,22 +26,22 @@ const n=t[i.children]
26
26
  if(Array.isArray(n)&&n.length>0){const e=r(n)
27
27
  if(e)return e}}return null}(r)
28
28
  if(!o)return null
29
- const f=o[i.children]
30
- if(!Array.isArray(f)||0===f.length)return null
31
- const u=t>=0?t:f.length+t
32
- return u>=0&&u<f.length?f[u]:null}function h(r,e,t=n){return function r(n,i=[]){for(let o=0;o<n.length;o++){const f=n[o],u=[...i,o]
33
- if(f[t.id]===e)return u
34
- const c=f[t.children]
35
- if(Array.isArray(c)&&c.length>0){const n=r(c,u)
29
+ const c=o[i.children]
30
+ if(!Array.isArray(c)||0===c.length)return null
31
+ const f=t>=0?t:c.length+t
32
+ return f>=0&&f<c.length?c[f]:null}function h(r,e,t=n){return function r(n,i=[]){for(let o=0;o<n.length;o++){const c=n[o],f=[...i,o]
33
+ if(c[t.id]===e)return f
34
+ const u=c[t.children]
35
+ if(Array.isArray(u)&&u.length>0){const n=r(u,f)
36
36
  if(n)return n}}return null}(r)}function d(r,e,t=n){if(!Array.isArray(e)||0===e.length)return null
37
37
  let i=r
38
38
  for(let r=0;r<e.length;r++){const n=e[r]
39
39
  if(!Array.isArray(i)||n<0||n>=i.length)return null
40
40
  const o=i[n]
41
41
  if(r===e.length-1)return o
42
- const f=o[t.children]
43
- if(!Array.isArray(f))return null
44
- i=f}return null}function y(r,e=n){const t={}
42
+ const c=o[t.children]
43
+ if(!Array.isArray(c))return null
44
+ i=c}return null}function y(r,e=n){const t={}
45
45
  return function r(n,i=1){for(const o of n){t[o[e.id]]=i
46
46
  const n=o[e.children]
47
47
  Array.isArray(n)&&n.length>0&&r(n,i+1)}}(r),t}function A(r,e,t=n){return function r(n,i=1){for(const o of n){if(o[t.id]===e)return i
@@ -49,51 +49,86 @@ const n=o[t.children]
49
49
  if(Array.isArray(n)&&n.length>0){const e=r(n,i+1)
50
50
  if(null!==e)return e}}return null}(r)}function T(r,e,t=n){const i=new Set
51
51
  return function r(n){const o=[]
52
- for(const f of n){const n=f[e]
52
+ for(const c of n){const n=c[e]
53
53
  if(null!=n){if(i.has(n))continue
54
- i.add(n)}const u={...f},c=f[t.children]
55
- Array.isArray(c)&&c.length>0&&(u[t.children]=r(c)),o.push(u)}return o}(r)}function g(r,e,t=n){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
54
+ i.add(n)}const f={...c},u=c[t.children]
55
+ Array.isArray(u)&&u.length>0&&(f[t.children]=r(u)),o.push(f)}return o}(r)}function g(r,e,t=n){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
56
56
  if(o[t.id]===e)return n.splice(i,1),!0
57
- const f=o[t.children]
58
- if(Array.isArray(f)&&f.length>0&&r(f))return!0}return!1}(r)}function p(r,e,t=n){!function r(n){for(const i of n){e(i)
57
+ const c=o[t.children]
58
+ if(Array.isArray(c)&&c.length>0&&r(c))return!0}return!1}(r)}function p(r,e,t=n){!function r(n){for(const i of n){e(i)
59
59
  const n=i[t.children]
60
- Array.isArray(n)&&n.length>0&&r(n)}}(r)}function D(r){return!Array.isArray(r)||0===r.length}function m(r,e=n){if(!x(r,e))return!0
60
+ Array.isArray(n)&&n.length>0&&r(n)}}(r)}function v(r){return!Array.isArray(r)||0===r.length}function b(r,e=n){if(!j(r,e))return!0
61
61
  const t=r[e.children]
62
- return void 0===t||(!Array.isArray(t)||0===t.length)}function N(r,e,t=n){const i=function r(n){for(const i of n){if(i[t.id]===e)return i
62
+ return void 0===t||!Array.isArray(t)||0===t.length}function m(r,e,t=n){const i=function r(n){for(const i of n){if(i[t.id]===e)return i
63
63
  const n=i[t.children]
64
64
  if(Array.isArray(n)&&n.length>0){const e=r(n)
65
65
  if(null!==e)return e}}return null}(r)
66
66
  if(!i)return[]
67
67
  const o=i[t.children]
68
- return Array.isArray(o)?o:[]}function S(r,e,t=n){const i=function r(n,i=null){for(const o of n){if(o[t.id]===e)return{node:o,parent:i}
68
+ return Array.isArray(o)?o:[]}function D(r,e,t=n){const i=function r(n,i=null){for(const o of n){if(o[t.id]===e)return{node:o,parent:i}
69
69
  const n=o[t.children]
70
70
  if(Array.isArray(n)&&n.length>0){const e=r(n,o)
71
71
  if(null!==e)return e}}return null}(r)
72
72
  if(!i)return[]
73
73
  if(null===i.parent)return r
74
74
  const o=i.parent[t.children]
75
- return Array.isArray(o)?o:[]}function v(r,e,t=n){return function r(n,i=null){for(const o of n){if(o[t.id]===e)return i
75
+ return Array.isArray(o)?o:[]}function N(r,e,t=n){return function r(n,i=null){for(const o of n){if(o[t.id]===e)return i
76
76
  const n=o[t.children]
77
77
  if(Array.isArray(n)&&n.length>0){const e=r(n,o)
78
- if(null!==e)return e}}return null}(r)}function b(r,e,t=n){for(const n of r){if(n[t.id]===e)return!0
78
+ if(null!==e)return e}}return null}(r)}function S(r,e,t=n){for(const n of r){if(n[t.id]===e)return!0
79
79
  const r=n[t.children]
80
- if(Array.isArray(r)&&r.length>0&&b(r,e,t))return!0}return!1}function x(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
80
+ if(Array.isArray(r)&&r.length>0&&S(r,e,t))return!0}return!1}function j(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
81
81
  const t=r[e.children]
82
82
  if(void 0!==t){if(null===t)return!1
83
83
  if(!Array.isArray(t))return!1
84
- for(const r of t)if(!x(r,e))return!1}return!0}function E(r,e=n){if(!Array.isArray(r))return!1
85
- for(const n of r)if(!x(n,e))return!1
86
- return!0}function C(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
84
+ for(const r of t)if(!j(r,e))return!1}return!0}function M(r,e=n){if(!Array.isArray(r))return!1
85
+ for(const n of r)if(!j(n,e))return!1
86
+ return!0}function E(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
87
87
  const t=r[e.children]
88
- return void 0===t||Array.isArray(t)}function j(r,e=n,t=new WeakSet){if(!r||"object"!=typeof r||Array.isArray(r))return!1
88
+ return void 0===t||Array.isArray(t)}function O(r,e=n,t=new WeakSet){if(!r||"object"!=typeof r||Array.isArray(r))return!1
89
89
  if(t.has(r))return!1
90
90
  t.add(r)
91
91
  const i=r[e.children]
92
92
  if(void 0!==i){if(null===i)return!1
93
93
  if(!Array.isArray(i))return!1
94
- for(const r of i)if(!j(r,e,t))return!1}return!0}function O(r,e,t=n){if(e<=0)return!1
95
- return function r(n,i){if(i>e)return!1
94
+ for(const r of i)if(!O(r,e,t))return!1}return!0}function k(r,e,t=n){return!(e<=0)&&function r(n,i){if(i>e)return!1
96
95
  for(const e of n){const n=e[t.children]
97
- if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(r,1)}function M(r,e=n){const t=r[e.children]
98
- return void 0===t||!Array.isArray(t)||0===t.length}function P(r,e,t=n){return!!b(r,e,t)&&null===v(r,e,t)}const k={mapTree:e,filterTree:t,findTree:i,pushTree:o,unshiftTree:f,popTree:u,shiftTree:c,someTree:s,everyTree:l,atTree:a,indexOfTree:h,atIndexOfTree:d,getNodeDepthMap:y,getNodeDepth:A,dedupTree:T,removeTree:g,forEachTree:p,isEmptyTreeData:D,isEmptySingleTreeData:m,getParentTree:v,getChildrenTree:N,getSiblingsTree:S,includesTree:b,isSingleTreeData:x,isTreeData:E,isValidTreeNode:C,isTreeNodeWithCircularCheck:j,isSafeTreeDepth:O,isLeafNode:M,isRootNode:P}
99
- r.atIndexOfTree=d,r.atTree=a,r.dedupTree=T,r.default=k,r.everyTree=l,r.filterTree=t,r.findTree=i,r.forEachTree=p,r.getChildrenTree=N,r.getNodeDepth=A,r.getNodeDepthMap=y,r.getParentTree=v,r.getSiblingsTree=S,r.includesTree=b,r.indexOfTree=h,r.isEmptySingleTreeData=m,r.isEmptyTreeData=D,r.isLeafNode=M,r.isRootNode=P,r.isSafeTreeDepth=O,r.isSingleTreeData=x,r.isTreeData=E,r.isTreeNodeWithCircularCheck=j,r.isValidTreeNode=C,r.mapTree=e,r.popTree=u,r.pushTree=o,r.removeTree=g,r.shiftTree=c,r.someTree=s,r.unshiftTree=f,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})
96
+ if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(r,1)}function x(r,e=n){const t=r[e.children]
97
+ return void 0===t||!Array.isArray(t)||0===t.length}function C(r,e,t=n){return!!S(r,e,t)&&null===N(r,e,t)}function I(r,e=n){const t=[]
98
+ return function r(n){for(const i of n){const{[e.children]:n,...o}=i
99
+ t.push(o)
100
+ const c=i[e.children]
101
+ Array.isArray(c)&&c.length>0&&r(c)}}(r),t}function P(r,e={}){const{rootParentId:t=null,parentIdField:i="parentId",fieldNames:o=n}=e
102
+ if(Array.isArray(r)){if(0===r.length)return[]
103
+ const n=new Map
104
+ for(const e of r){const r=e[o.id]
105
+ if(null==r)continue
106
+ const t={...e,[o.children]:[]}
107
+ n.set(r,t)}const e=[]
108
+ for(const c of r){const r=c[o.id],f=c[i]
109
+ if(null==r)continue
110
+ const u=n.get(r)
111
+ if(u)if(f===t||null==f)e.push(u)
112
+ else{const r=n.get(f)
113
+ if(r){const n=r[o.children]
114
+ Array.isArray(n)?n.push(u):r[o.children]=[u]}else e.push(u)}}return e}if(r instanceof Map){if(0===r.size)return[]
115
+ const n=[]
116
+ return r.forEach((r,e)=>{n.push({...r,[o.id]:e})}),P(n,e)}if(r&&"object"==typeof r&&!Array.isArray(r)&&!(r instanceof Map)){const n=r[o.children]
117
+ if(Array.isArray(n))return[r]
118
+ const t=Object.keys(r)
119
+ if(t.length>0){let n=!0
120
+ for(const e of t){const t=r[e]
121
+ if(!t||"object"!=typeof t||Array.isArray(t)){n=!1
122
+ break}}if(n){const n=[]
123
+ for(const e of t){const t=r[e]
124
+ n.push({...t,[o.id]:e})}if(n.length>0)return P(n,e)}}return[{...r,[o.children]:[]}]}return[]}function w(r,e=n){const t=new Map
125
+ return function r(n){for(const i of n){const n=i[e.id]
126
+ if(null!=n){const{[e.children]:r,...o}=i
127
+ t.set(n,o)}const o=i[e.children]
128
+ Array.isArray(o)&&o.length>0&&r(o)}}(r),t}function L(r,e=n){const t=[]
129
+ return Array.isArray(r)&&0!==r.length?(function r(n,i=0){t[i]||(t[i]=[])
130
+ for(const o of n){const{[e.children]:n,...c}=o
131
+ t[i].push(c)
132
+ const f=o[e.children]
133
+ Array.isArray(f)&&f.length>0&&r(f,i+1)}}(r),t):[]}function W(r){return Array.isArray(r)&&0!==r.length&&1===r.length?r[0]:null}const B={mapTree:e,filterTree:t,findTree:i,pushTree:o,unshiftTree:c,popTree:f,shiftTree:u,someTree:s,everyTree:l,atTree:a,indexOfTree:h,atIndexOfTree:d,getNodeDepthMap:y,getNodeDepth:A,dedupTree:T,removeTree:g,forEachTree:p,isEmptyTreeData:v,isEmptySingleTreeData:b,getParentTree:N,getChildrenTree:m,getSiblingsTree:D,includesTree:S,isSingleTreeData:j,isTreeData:M,isValidTreeNode:E,isTreeNodeWithCircularCheck:O,isSafeTreeDepth:k,isLeafNode:x,isRootNode:C,convertToArrayTree:I,convertBackTree:P,convertToMapTree:w,convertToLevelArrayTree:L,convertToObjectTree:W}
134
+ r.atIndexOfTree=d,r.atTree=a,r.convertBackTree=P,r.convertToArrayTree=I,r.convertToLevelArrayTree=L,r.convertToMapTree=w,r.convertToObjectTree=W,r.dedupTree=T,r.default=B,r.everyTree=l,r.filterTree=t,r.findTree=i,r.forEachTree=p,r.getChildrenTree=m,r.getNodeDepth=A,r.getNodeDepthMap=y,r.getParentTree=N,r.getSiblingsTree=D,r.includesTree=S,r.indexOfTree=h,r.isEmptySingleTreeData=b,r.isEmptyTreeData=v,r.isLeafNode=x,r.isRootNode=C,r.isSafeTreeDepth=k,r.isSingleTreeData=j,r.isTreeData=M,r.isTreeNodeWithCircularCheck=O,r.isValidTreeNode=E,r.mapTree=e,r.popTree=f,r.pushTree=o,r.removeTree=g,r.shiftTree=u,r.someTree=s,r.unshiftTree=c,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})