UNPKG

@sensilla-cloud/react-file-tree

Version:

Virtualized tree for displaying hierarchy in a traditional file-tree format

25 lines (24 loc) 27.9 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react/jsx-runtime"),r={},o={get exports(){return r},set exports(e){r=e}},i={},s={get exports(){return i},set exports(e){i=e}},a={};var c,l,u,f,d,p,h,y,m,v,b,g,O,S,E={}; /** @license React v16.13.1 * react-is.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */function w(){return l||(l=1,t=s,"production"===process.env.NODE_ENV?t.exports=function(){if(e)return a;e=1;var t="function"==typeof Symbol&&Symbol.for,n=t?Symbol.for("react.element"):60103,r=t?Symbol.for("react.portal"):60106,o=t?Symbol.for("react.fragment"):60107,i=t?Symbol.for("react.strict_mode"):60108,s=t?Symbol.for("react.profiler"):60114,c=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,d=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,h=t?Symbol.for("react.suspense_list"):60120,y=t?Symbol.for("react.memo"):60115,m=t?Symbol.for("react.lazy"):60116,v=t?Symbol.for("react.block"):60121,b=t?Symbol.for("react.fundamental"):60117,g=t?Symbol.for("react.responder"):60118,O=t?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case u:case f:case o:case s:case i:case p:return e;default:switch(e=e&&e.$$typeof){case l:case d:case m:case y:case c:return e;default:return t}}case r:return t}}}function E(e){return S(e)===f}return a.AsyncMode=u,a.ConcurrentMode=f,a.ContextConsumer=l,a.ContextProvider=c,a.Element=n,a.ForwardRef=d,a.Fragment=o,a.Lazy=m,a.Memo=y,a.Portal=r,a.Profiler=s,a.StrictMode=i,a.Suspense=p,a.isAsyncMode=function(e){return E(e)||S(e)===u},a.isConcurrentMode=E,a.isContextConsumer=function(e){return S(e)===l},a.isContextProvider=function(e){return S(e)===c},a.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},a.isForwardRef=function(e){return S(e)===d},a.isFragment=function(e){return S(e)===o},a.isLazy=function(e){return S(e)===m},a.isMemo=function(e){return S(e)===y},a.isPortal=function(e){return S(e)===r},a.isProfiler=function(e){return S(e)===s},a.isStrictMode=function(e){return S(e)===i},a.isSuspense=function(e){return S(e)===p},a.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===f||e===s||e===i||e===p||e===h||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===y||e.$$typeof===c||e.$$typeof===l||e.$$typeof===d||e.$$typeof===b||e.$$typeof===g||e.$$typeof===O||e.$$typeof===v)},a.typeOf=S,a}():t.exports=(c||(c=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,d=e?Symbol.for("react.suspense_list"):60120,p=e?Symbol.for("react.memo"):60115,h=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,b=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var d=e.$$typeof;switch(d){case t:var y=e.type;switch(y){case c:case l:case r:case i:case o:case f:return y;default:var m=y&&y.$$typeof;switch(m){case a:case u:case h:case p:case s:return m;default:return d}}case n:return d}}}var O=c,S=l,w=a,x=s,_=t,j=u,T=r,N=h,$=p,C=n,R=i,I=o,M=f,k=!1;function A(e){return g(e)===l}E.AsyncMode=O,E.ConcurrentMode=S,E.ContextConsumer=w,E.ContextProvider=x,E.Element=_,E.ForwardRef=j,E.Fragment=T,E.Lazy=N,E.Memo=$,E.Portal=C,E.Profiler=R,E.StrictMode=I,E.Suspense=M,E.isAsyncMode=function(e){return k||(k=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),A(e)||g(e)===c},E.isConcurrentMode=A,E.isContextConsumer=function(e){return g(e)===a},E.isContextProvider=function(e){return g(e)===s},E.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},E.isForwardRef=function(e){return g(e)===u},E.isFragment=function(e){return g(e)===r},E.isLazy=function(e){return g(e)===h},E.isMemo=function(e){return g(e)===p},E.isPortal=function(e){return g(e)===n},E.isProfiler=function(e){return g(e)===i},E.isStrictMode=function(e){return g(e)===o},E.isSuspense=function(e){return g(e)===f},E.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===i||e===o||e===f||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===p||e.$$typeof===s||e.$$typeof===a||e.$$typeof===u||e.$$typeof===m||e.$$typeof===v||e.$$typeof===b||e.$$typeof===y)},E.typeOf=g}()),E)),i;var t} /* object-assign (c) Sindre Sorhus @license MIT */function x(){if(p)return d;p=1;return d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function _(){return y?h:(y=1,h=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var j=w();o.exports=function(){if(g)return b;g=1;var e=w(),t=function(){if(f)return u;f=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}return u=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map((function(e){return t[e]}));if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(o,i){for(var s,a,c=r(o),l=1;l<arguments.length;l++){for(var u in s=Object(arguments[l]))t.call(s,u)&&(c[u]=s[u]);if(e){a=e(s);for(var f=0;f<a.length;f++)n.call(s,a[f])&&(c[a[f]]=s[a[f]])}}return c},u}(),n=x(),r=_(),o=function(){if(v)return m;v=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=x(),n={},r=_();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,i,s,a,c){if("production"!==process.env.NODE_ENV)for(var l in o)if(r(o,l)){var u;try{if("function"!=typeof o[l]){var f=Error((a||"React class")+": "+s+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw f.name="Invariant Violation",f}u=o[l](i,l,a,s,null,t)}catch(e){u=e}if(!u||u instanceof Error||e((a||"React class")+": type specification of "+s+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),u instanceof Error&&!(u.message in n)){n[u.message]=!0;var d=c?c():"";e("Failed "+s+" type: "+u.message+(null!=d?d:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},m=o}(),i=function(){};function s(){return null}return"production"!==process.env.NODE_ENV&&(i=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),b=function(a,c){var l="function"==typeof Symbol&&Symbol.iterator,u="<<anonymous>>",f={array:y("array"),bigint:y("bigint"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:h(s),arrayOf:function(e){return h((function(t,r,o,i,s){if("function"!=typeof e)return new p("Property `"+s+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var a=t[r];if(!Array.isArray(a))return new p("Invalid "+i+" `"+s+"` of type `"+b(a)+"` supplied to `"+o+"`, expected an array.");for(var c=0;c<a.length;c++){var l=e(a,c,o,i,s+"["+c+"]",n);if(l instanceof Error)return l}return null}))},element:h((function(e,t,n,r,o){var i=e[t];return a(i)?null:new p("Invalid "+r+" `"+o+"` of type `"+b(i)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:h((function(t,n,r,o,i){var s=t[n];return e.isValidElementType(s)?null:new p("Invalid "+o+" `"+i+"` of type `"+b(s)+"` supplied to `"+r+"`, expected a single ReactElement type.")})),instanceOf:function(e){return h((function(t,n,r,o,i){if(!(t[n]instanceof e)){var s=e.name||u;return new p("Invalid "+o+" `"+i+"` of type `"+((a=t[n]).constructor&&a.constructor.name?a.constructor.name:u)+"` supplied to `"+r+"`, expected instance of `"+s+"`.")}var a;return null}))},node:h((function(e,t,n,r,o){return v(e[t])?null:new p("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return h((function(t,o,i,s,a){if("function"!=typeof e)return new p("Property `"+a+"` of component `"+i+"` has invalid PropType notation inside objectOf.");var c=t[o],l=b(c);if("object"!==l)return new p("Invalid "+s+" `"+a+"` of type `"+l+"` supplied to `"+i+"`, expected an object.");for(var u in c)if(r(c,u)){var f=e(c,u,i,s,a+"."+u,n);if(f instanceof Error)return f}return null}))},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&i(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),s;function t(t,n,r,o,i){for(var s=t[n],a=0;a<e.length;a++)if(d(s,e[a]))return null;var c=JSON.stringify(e,(function(e,t){return"symbol"===g(t)?String(t):t}));return new p("Invalid "+o+" `"+i+"` of value `"+String(s)+"` supplied to `"+r+"`, expected one of "+c+".")}return h(t)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&i("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+O(o)+" at index "+t+"."),s}return h((function(t,o,i,s,a){for(var c=[],l=0;l<e.length;l++){var u=(0,e[l])(t,o,i,s,a,n);if(null==u)return null;u.data&&r(u.data,"expectedType")&&c.push(u.data.expectedType)}return new p("Invalid "+s+" `"+a+"` supplied to `"+i+"`"+(c.length>0?", expected one of type ["+c.join(", ")+"]":"")+".")}))},shape:function(e){return h((function(t,r,o,i,s){var a=t[r],c=b(a);if("object"!==c)return new p("Invalid "+i+" `"+s+"` of type `"+c+"` supplied to `"+o+"`, expected `object`.");for(var l in e){var u=e[l];if("function"!=typeof u)return m(o,i,s,l,g(u));var f=u(a,l,o,i,s+"."+l,n);if(f)return f}return null}))},exact:function(e){return h((function(o,i,s,a,c){var l=o[i],u=b(l);if("object"!==u)return new p("Invalid "+a+" `"+c+"` of type `"+u+"` supplied to `"+s+"`, expected `object`.");var f=t({},o[i],e);for(var d in f){var h=e[d];if(r(e,d)&&"function"!=typeof h)return m(s,a,c,d,g(h));if(!h)return new p("Invalid "+a+" `"+c+"` key `"+d+"` supplied to `"+s+"`.\nBad object: "+JSON.stringify(o[i],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=h(l,d,s,a,c+"."+d,n);if(y)return y}return null}))}};function d(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function p(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function h(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,s,a,l,f,d,h){if(l=l||u,d=d||a,h!==n){if(c){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var m=l+":"+a;!t[m]&&r<3&&(i("You are manually calling a React.PropTypes validation function for the `"+d+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[m]=!0,r++)}}return null==s[a]?o?null===s[a]?new p("The "+f+" `"+d+"` is marked as required in `"+l+"`, but its value is `null`."):new p("The "+f+" `"+d+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(s,a,l,f,d)}var s=o.bind(null,!1);return s.isRequired=o.bind(null,!0),s}function y(e){return h((function(t,n,r,o,i,s){var a=t[n];return b(a)!==e?new p("Invalid "+o+" `"+i+"` of type `"+g(a)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null}))}function m(e,t,n,r,o){return new p((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function v(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(v);if(null===e||a(e))return!0;var t=function(e){var t=e&&(l&&e[l]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!v(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!v(o[1]))return!1}return!0;default:return!1}}function b(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function g(e){if(null==e)return""+e;var t=b(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function O(e){var t=g(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return p.prototype=Error.prototype,f.checkPropTypes=o,f.resetWarningCache=o.resetWarningCache,f.PropTypes=f,f},b}()(j.isElement,!0)}else o.exports=function(){if(S)return O;S=1;var e=x();function t(){}function n(){}return n.resetWarningCache=t,O=function(){function r(t,n,r,o,i,s){if(s!==e){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function o(){return r}r.isRequired=r;var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},O}()();var T,N={},$={get exports(){return N},set exports(e){N=e}},C={};var R,I,M={}; /** * @license React * use-sync-external-store-shim.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */I=$,"production"===process.env.NODE_ENV?I.exports=function(){if(T)return C;T=1;var e=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),c=r({inst:{value:n,getSnapshot:t}}),l=c[0].inst,u=c[1];return i((function(){l.value=n,l.getSnapshot=t,a(l)&&u({inst:l})}),[e,n,t]),o((function(){return a(l)&&u({inst:l}),e((function(){a(l)&&u({inst:l})}))}),[e]),s(n),n};return C.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:c,C}():I.exports=(R||(R=1,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];o("error",e,n)}function o(e,t,r){var o=n.ReactDebugCurrentFrame.getStackAddendum();""!==o&&(t+="%s",r=r.concat([o]));var i=r.map((function(e){return String(e)}));i.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,i)}var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=e.useState,a=e.useEffect,c=e.useLayoutEffect,l=e.useDebugValue,u=!1,f=!1;function d(e){var t=e.getSnapshot,n=e.value;try{var r=t();return!i(n,r)}catch(e){return!0}}var p="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t,n){return t()}:function(t,n,o){u||void 0!==e.startTransition&&(u=!0,r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=n();if(!f){var h=n();i(p,h)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var y=s({inst:{value:p,getSnapshot:n}}),m=y[0].inst,v=y[1];return c((function(){m.value=p,m.getSnapshot=n,d(m)&&v({inst:m})}),[t,p,n]),a((function(){return d(m)&&v({inst:m}),t((function(){d(m)&&v({inst:m})}))}),[t]),l(p),p},h=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:p;M.useSyncExternalStore=h,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),M);const k=(e,t,n)=>{const r=[];let{from:o,to:i}=e;if(n)for(let n=e.getOffset(o);i>o;)r.push(t(o,n)),n+=e.getSize(o++);else for(;i>o;)r.push(t(o++,0));return r},A=[0,1,2],L=class{observe(){}unobserve(){}disconnect(){}},P=e=>e(),D=(e,t)=>{const n=e.length+1,r=new t(n);r.set(e,1);for(let e,t=1;n>t;t++)e=t+(t&-t),n>e&&(r[e]+=r[t]);return r},V=(e,t,n,r)=>{for(;r>t;t+=t&-t)e[t]+=n},z=(e,t,n)=>{for(;n>t;t+=t&-t);return Math.min(t,e.length)},F=new Set,W={t:0,i(){this.t++},h(){0==--this.t&&(F.forEach(P),F.clear())},o:e=>F.add(e)},H=Uint32Array,q=new H(0);const B=e=>t.useRef().current||=new class{l(e){e&&(W.i(),this.u+=e,this.m-=e,this.scrollSize+=e,this.p(1),this.g(),W.h())}constructor(e){this.horizontal=!1,this.v="top",this.M="scrollTop",this._="offsetHeight",this.S=0,this.u=0,this.T=0,this.C=0,this.k=0,this.F=0,this.H=3,this.I=40,this.O=null,this.R=q,this.j=q,this.q=0,this.scrollSize=0,this.from=0,this.to=0,this.sizesHash=0,this.A=new Map,this.G=new Map,this.L=[null,null],this.U=[0,0],this.W=new L((e=>{let t=0,n=0,r=0;for(const{target:o}of e)t=this.L.indexOf(o),-1!==t&&(n=o[this._]-this.U[t],n&&(this.U[t]+=n,r+=n));this.l(r)})),this.$=new L((e=>{let t=0,n=0,r=0,o=!1,i=z(this.j,this.from+1,this.to);for(const{target:s}of e)t=this.A.get(s),i>t&&(n=s[this._]-this.R[t],n&&(o=!0,this.R[t]+=n,r+=n,V(this.j,t+1,n,i)));o&&(W.i(),0!==r&&(V(this.j,i,r,this.j.length),this.S+=r,this.scrollSize+=r,this.p(1),0>r&&this.g()),this.sizesHash=this.sizesHash+1&1023,this.p(2),W.h())})),this.B=A.map((()=>[])),this.D=()=>{const e=this.O[this._]-this.u;e!==this.m&&(this.m=e,this.g())},this.J=new L(this.D),this.setOuterNode=e=>{this.O&&(this.J.unobserve(this.O),this.O.removeEventListener("scroll",this)),(this.O=e)?(this.J.observe(e),e.addEventListener("scroll",this,{passive:!0})):(this.$.disconnect(),this.W.disconnect(),clearTimeout(this.k))},this.m=e.estimatedWidgetSize??200,this.set(e)}on(e,t){return t.forEach((t=>this.B[t].push(e))),()=>t.forEach((t=>this.B[t].splice(this.B[t].indexOf(e),1)))}p(e){this.B[e].forEach(0===W.t?P:W.o)}getIndex(e){let t=0;e=Math.min(e,this.S);for(let n=this.q,r=0;n>0;n>>=1)(r=t+n)<=this.T&&e>this.j[r]&&(t=r,e-=this.j[r]);return t}getOffset(e){if("production"!==process.env.NODE_ENV&&e>this.T)throw Error("index must not be > itemCount");let t=0;for(;e>0;e-=e&-e)t+=this.j[e];return t}getSize(e){if("production"!==process.env.NODE_ENV&&e>=this.R.length)throw Error("itemIndex must be < itemCount in getSize");return this.R[e]}get visibleFrom(){const e=this.getIndex(this.F);return e+(this.F-this.getOffset(e))/this.R[e]}handleEvent(e){const t=this.F,n=this.O[this.M];n!==t&&(this.F=n,this.C=e.timeStamp,n>t?this.g():this.K())}el(e,t){const n=this.G.get(e);n&&(this.G.delete(e),this.A.delete(n),this.$.unobserve(n)),t&&(this.A.set(t,e),this.G.set(e,t),this.$.observe(t))}N(e,t){const n=this.L[e];n&&(this.W.unobserve(n),this.l(-this.U[e]),this.L[e]=null,this.U[e]=0),t&&this.W.observe(this.L[e]=t)}setStickyHeader(e){this.N(0,e)}setStickyFooter(e){this.N(1,e)}g(){const e=1+this.getIndex(this.F+this.m);e>this.to&&(this.to=Math.min(this.T,e+this.H),this.from=this.getIndex(this.F),this.p(0))}K(){const e=this.getIndex(this.F);e<this.from&&(this.from=Math.max(0,e-this.H),this.to=this.T&&1+this.getIndex(this.F+this.m),this.p(0))}scrollTo(e,t,n){if(clearTimeout(this.k),this.O){const r=0|e,o=Math.min(this.scrollSize-this.m,this.getOffset(r)+Math.round(this.R[r]*(e-r)));o!==this.F&&(n||=5,t&&128>=performance.now()-this.C||(this.O.scroll({[this.v]:o,behavior:t?"smooth":"instant"}),n--),n&&(this.k=setTimeout((()=>this.scrollTo(e,t,n)),t?512:32)))}}set(e){let{overscanCount:t,horizontal:n,itemCount:r,estimatedItemSize:o}=e;if(W.i(),o&&(this.I=o),void 0!==t&&(this.H=t),void 0!==r&&this.T!==r){if(r>2147483647)throw Error(`itemCount must be <= 2147483647. Got: ${r}.`);this.q=(this.T=r)&&1<<31-Math.clz32(r);const e=this.R,t=e.length;r>t&&(this.R=new H(Math.min(r+32,2147483647)),this.R.set(e),this.j=D(this.R.fill(this.I||40,t),H)),this.scrollSize=(this.S=this.getOffset(r))+this.u,this.p(1),this.to>r&&(this.to=-1),this.g()}void 0!==n&&this.horizontal!==n&&(this.v=(this.horizontal=n)?"left":"top",this.M=n?"scrollLeft":"scrollTop",this._=n?"offsetWidth":"offsetHeight",this.O&&this.D(),this.scrollTo(0)),W.h()}}(e),U=t.useEffect,G=e=>(((e,n)=>{n||=A;const[r,o]=t.useMemo((()=>[t=>e.on(t,n),()=>n.reduce(((t,n)=>t+"_"+(0===n?e.to**2+e.from:1===n?e.scrollSize:e.sizesHash)),"")]),[n]);N.useSyncExternalStore(r,o,o)})(e.model,e.events),e.children()),K=new Map,J=e=>{const t=e.trim().replace(/(\s)+/g,"$1").replace(/\s?:\s?/,":");let n=K.get(t);return n||(n="af-styled_"+t.replace(/\W+/g,"_"),K.set(t,n)),n};function Y(e){let t=J(e);for(let e=1;e<arguments.length;e++)t+=" "+J(arguments[e]);return t}function Q(e){for(let t=1,n="";t<arguments.length;t++)n=arguments[t],n&&(e+=" "+n);return e}const X=Y("overflow: auto","position: relative"),Z=Y("visibility: hidden"),ee=Y("position: absolute"),te=Y("height: 1px"),ne=Y("width: 1px"),re=Q(X,Y("display: flex")),oe=Q(ee,Z,ne,Y("top: 0")),ie=Q(ee,Z,te,Y("left: 0")),se=Q(Z,ne),ae=Q(Z,te,Y("flex-shrink: 0")),ce=["height",X,oe,se],le=["width",re,ie,ae],ue=[0],fe=[1],de=e=>{let{model:t,children:r,className:o,itemData:i,header:s=null,footer:a=null,component:c="div",getKey:l=(e=>e),tabIndex:u=-1,...f}=e;const[d,p,h,y]=t.horizontal?le:ce;return n.jsxs(c,{className:Q(p,o),ref:t.setOuterNode,tabIndex:u,...f,children:[n.jsx(G,{model:t,events:fe,children:()=>n.jsx("div",{className:h,style:{[d]:t.scrollSize}})}),s,n.jsx(G,{model:t,events:ue,children:()=>n.jsxs(n.Fragment,{children:[n.jsx("div",{className:y,style:{[d]:t.getOffset(t.from)}}),k(t,((e,o)=>n.jsx(r,{i:e,data:i,offset:o,model:t},l(e,i))))]})}),a]})};"production"!==process.env.NODE_ENV&&(de.propTypes={model:r.object.isRequired,children:r.elementType.isRequired,getKey:r.func,component:r.elementType,header:r.element,footer:r.element,className:r.string,itemData:r.any,tabIndex:r.number});const pe={childClassName:"react-file-tree-child",expandTool:t.createElement("div",{className:"react-file-tree-child-button"},"+"),collapseTool:t.createElement("div",{className:"react-file-tree-child-button"},"-"),indentWidth:16},he={className:"react-file-tree",renderOptions:pe,filterFn:(e,t)=>e.name.toLowerCase().includes(t.toLowerCase())};exports.default=e=>{const n=Object.assign({},he,e);n.renderOptions=Object.assign({},pe,n.renderOptions);const[r,o]=t.useState(new Map),[i,s]=t.useState(new Map),[a,c]=t.useState([]),[l,u]=t.useState(),f={expand:e=>{n.onExpand&&n.onExpand(e),o(new Map(r.set(e.id,Object.assign(Object.assign({},r.get(e.id)),{expanded:!0}))))},collapse:e=>{n.onCollapse&&n.onCollapse(e),o(new Map(r.set(e.id,Object.assign(Object.assign({},r.get(e.id)),{expanded:!1}))))},select:e=>{if(n.selectable){n.onSelect&&n.onSelect(e);const t=new Map(r.set(e.id,Object.assign(Object.assign({},r.get(e.id)),{selected:!0})));n.multiSelect||(void 0!==l&&t.set(l,Object.assign(Object.assign({},t.get(l)),{selected:!1})),u(e.id)),o(t)}},deselect:e=>{n.selectable&&(n.onDeselect&&n.onDeselect(e),o(new Map(r.set(e.id,Object.assign(Object.assign({},r.get(e.id)),{selected:!1})))),n.multiSelect||u(void 0))}},d=t.useCallback(((t,o)=>void 0===t||n.filterable&&!a.includes(t.id)?[]:["function"==typeof e.childRenderer?e.childRenderer(t,o,n,f):h(t,o,n.renderOptions),...t.children&&o.expanded?Array.from(t.children.map((e=>d(e,r.get(e.id))))).flat(9999999):[]]),[r,n.renderOptions,e.childRenderer]),p=t.useCallback((({i:e,model:o})=>n.data[e]&&r.has(n.data[e].id)?t.createElement("div",{ref:t=>o.el(e,t),className:n.className+"-virtual-child-wrapper"},d(n.data[e],r.get(n.data[e].id))):null),[n.data,r,a]),h=(e,r,o)=>{var i,s;return t.createElement("div",{key:e.id,className:`${o.childClassName}${r.expanded?` ${o.childClassName}-expanded`:""}${r.selected?` ${o.childClassName}-selected`:""}${r.disabled?` ${o.childClassName}-disabled`:""}`},t.createElement("div",{className:o.childClassName+"-row"},t.createElement("div",{style:{width:o.indentWidth*r.depth}}),(null!==(s=null===(i=e.children)||void 0===i?void 0:i.length)&&void 0!==s?s:0)>0&&t.createElement("div",{className:o.childClassName+"-fold-button",onClick:()=>{if(n.disabled)return;const t=!r.expanded;t?f.expand(e):t||f.collapse(e)}},r.expanded?o.collapseTool:o.expandTool),t.createElement("div",{className:o.childClassName+"-label",style:{cursor:n.disabled?"not-allowed":n.selectable&&r.selectable?"pointer":"default"},onClick:()=>{if(n.selectable&&r.selectable&&!n.disabled){const t=!r.selected;t?f.select(e):t||f.deselect(e)}}},e.name)))};t.useEffect((()=>{const e=new Map,t=new Map,r=(n,o,i)=>{var s,a,c,l,u;e.set(n.id,{expanded:null!==(s=n.expanded)&&void 0!==s&&s,depth:o,selected:null!==(a=n.selected)&&void 0!==a&&a,disabled:null!==(c=n.disabled)&&void 0!==c&&c,selectable:null===(l=n.selectable)||void 0===l||l,parent:i}),t.set(n.id,n),null===(u=n.children)||void 0===u||u.forEach((e=>{r(e,o+1,n)}))};n.data.forEach((e=>{r(e,0,null)})),o(e),s(t)}),[e.data]),t.useEffect((()=>{if(n.filterable&&n.filter){const e=[],t=[];i.forEach((e=>{n.filterFn(e,n.filter||"")&&t.push(e)}));const o=t=>{var n,i;e.push(t.id),null!==(null===(n=r.get(t.id))||void 0===n?void 0:n.parent)&&o(null===(i=r.get(t.id))||void 0===i?void 0:i.parent)};t.forEach((e=>{o(e)})),c(e)}else n.filterable&&c([...i.keys()])}),[n.filter,n.filterable,i]);const y=(e=>{const t=B(e);return U((()=>t.set(e))),t})({itemCount:n.data.length});return t.createElement("div",{className:`${n.className}${n.disabled?` ${n.className}-disabled`:""}`},n.virtual?t.createElement(de,{className:n.className+"-virtual",model:y},p):n.data.map((e=>r.has(e.id)?d(e,r.get(e.id)):null)))}; //# sourceMappingURL=index.js.map