UNPKG

@animech-public/chonky

Version:

A File Browser component for React

1 lines 96.6 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("deepmerge"),t=require("react"),n=require("react-dnd"),r=require("react-dnd-html5-backend"),o=require("react-intl"),i=require("react-jss"),a=require("react-redux"),l=require("nanoid"),c=require("@mui/material/styles"),s=require("@reduxjs/toolkit"),u=require("fast-sort"),d=require("fuzzy-search"),f=require("redux-watch"),p=require("filesize"),m=require("exact-trie"),g=require("@mui/material/useMediaQuery"),h=require("classnames"),y=require("@mui/material/Box"),b=require("@mui/material/ClickAwayListener"),v=require("hotkeys-js"),x=require("@mui/material/Breadcrumbs"),C=require("@mui/material/Button"),S=require("@mui/material/Menu"),F=require("@mui/material/ListItemIcon"),I=require("@mui/material/ListItemText"),k=require("@mui/material/MenuItem"),w=require("@mui/material/Typography"),E=require("@mui/material/InputAdornment"),D=require("@mui/material/TextField"),M=require("react-virtualized-auto-sizer"),N=require("react-window"),A=require("@mui/material/ListSubheader");function O(){O=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var i=Object.create((t&&t.prototype instanceof y?t:y).prototype),a=new N(r||[]);return o(i,"_invoke",{value:w(e,n,a)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",p="suspendedYield",m="executing",g="completed",h={};function y(){}function b(){}function v(){}var x={};s(x,a,(function(){return this}));var C=Object.getPrototypeOf,S=C&&C(C(A([])));S&&S!==n&&r.call(S,a)&&(x=S);var F=v.prototype=y.prototype=Object.create(x);function I(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function n(o,i,a,l){var c=d(e[o],e,i);if("throw"!==c.type){var s=c.arg,u=s.value;return u&&"object"==typeof u&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(u).then((function(e){s.value=e,a(s)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function w(t,n,r){var o=f;return function(i,a){if(o===m)throw new Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var l=r.delegate;if(l){var c=E(l,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===f)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=m;var s=d(t,n,r);if("normal"===s.type){if(o=r.done?g:p,s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=g,r.method="throw",r.arg=s.arg)}}}function E(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=d(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,h;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,h):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=v,o(F,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:b,configurable:!0}),b.displayName=s(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,s(e,c,"GeneratorFunction")),e.prototype=Object.create(F),e},t.awrap=function(e){return{__await:e}},I(k.prototype),s(k.prototype,l,(function(){return this})),t.AsyncIterator=k,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new k(u(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(F),s(F,c,"Generator"),s(F,a,(function(){return this})),s(F,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=A,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return l.type="throw",l.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],l=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;M(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:A(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),h}},t}function T(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,o)}function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(this,arguments)}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function L(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var _,P={},j=function(e){var n=t.useRef(P);return n.current===P&&(n.current=e()),n.current},B=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[n,e]),n},H=function(){function e(){}return e.error=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=console).error.apply(e,["[Chonky runtime error]"].concat(n))},e.warn=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=console).warn.apply(e,["[Chonky runtime warning]"].concat(n))},e.debug=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];(e=console).debug.apply(e,["[Chonky runtime debug]"].concat(n))},e.formatBullets=function(e){return"\n- "+e.join("\n- ")},e}(),V=function(){function e(){}return e.isDirectory=function(e){return!!e&&!0===e.isDir},e.isHidden=function(e){return!!e&&!0===e.isHidden},e.isSymlink=function(e){return!!e&&!0===e.isSymlink},e.isEncrypted=function(e){return!!e&&!0===e.isEncrypted},e.isClickable=function(e){return!!e},e.isOpenable=function(e){return!!e&&!1!==e.openable},e.isSelectable=function(e){return!!e&&!1!==e.selectable},e.isRenamable=function(e){return!!e&&!1!==e.renamable},e.isDraggable=function(e){return!!e&&!1!==e.draggable},e.isDroppable=function(e){return!(!e||(!e.isDir||!1===e.droppable)&&!0!==e.droppable)},e.isDndOpenable=function(t){return!(!e.isOpenable(t)||(!t.isDir||!1===t.dndOpenable)&&!0!==t.dndOpenable)},e.getModDate=function(t){return t&&null!=t.modDate?e.parseDate(t.modDate):null},e.parseDate=function(e){if("string"==typeof e||"number"==typeof e)try{return new Date(e)}catch(t){H.error("Could not convert provided string/number into a date: "+t.message+" ","Invalid value:",e)}return e instanceof Date&&!isNaN(e.getTime())?e:(H.warn("Unsupported date representation:",e),null)},e.getChildrenCount=function(e){return e&&"number"==typeof e.childrenCount?e.childrenCount:null},e}(),K=function(e,t){var n=[],r=[];if("folderChain"!==e&&"fileActions"!==e||t)if(Array.isArray(t)){for(var o=0,i=0,a=new Set,l=new Set,c=0;c<t.length;++c){var s=t[c];s?"object"!=typeof s?o++:!s.id||"fileActions"!==e&&!s.name?i++:a.has(s.id)?l.add(s.id):(a.add(s.id),n.push(s)):"fileActions"===e?o++:n.push(null)}if(o&&r.push("Detected "+o+' file(s) of invalid type. Remember that "files" array should contain either objects or nulls.'),i&&r.push("Detected "+i+' file(s) that are missing the required fields. Remember that file object should define an "id" and a "name".'),l.size>0){var u='"'+Array.from(l).join('", "')+'"';r.push("Detected "+l.size+" file IDs that are used multiple times. Remember that each file should have a unique IDs. The following IDs were seen multiple times: "+u)}}else r.push('Expected "'+e+'" prop to be an array, got "'+typeof t+'" instead.');if(r.length>0){var d,f,p="\n- "+r.join("\n- ");"folderChain"===e?(d="folder chain",f="files"):"fileActions"===e?(d="file actions",f="file actions"):(d="files",f="files"),H.error("Errors were detected when sanitizing the "+d+" array. Offending "+f+" were removed from the array. Summary of validation errors: "+p)}return{sanitizedArray:n,errorMessages:r}},q={ShowHiddenFiles:"show_hidden_files",ShowFoldersFirst:"show_folders_first",DarkMode:"dark_mode"};!function(e){e.ASC="asc",e.DESC="desc"}(_||(_={}));var W,G=function(e){return e.instanceId},U=function(e){return e.externalFileActionHandler},Y=function(e){return e.fileActionMap},X=function(e){return e.fileActionIds},Z=function(e){return function(t){return Y(t)[e]}},Q=function(e){return e.toolbarItems},$=function(e){return e.contextMenuItems},J=function(e){return e.folderChain},ee=function(e){var t=J(e);return t.length>0?t[t.length-1]:null},te=function(e){var t=J(e);return t.length>1?t[t.length-2]:null},ne=function(e){return e.fileMap},re=function(e){return e.cleanFileIds},oe=function(e){return function(t){return e?ne(t)[e]:null}},ie=function(e){return e.hiddenFileIdMap},ae=function(e){return Object.keys(ie(e)).length},le=function(e){return e.focusSearchInput},ce=function(e){return e.searchString},se=function(e){return e.onSearchInput},ue=function(e){return e.onCancelSearch},de=function(e){return e.selectionMap},fe=function(e){return Object.keys(de(e))},pe=function(e){return fe(e).length},me=function(e){return function(t){return!!e&&!!de(t)[e]}},ge=function(e){var t=ne(e);return Object.keys(de(e)).map((function(e){return t[e]}))},he=function(e){return function(t){var n=t.fileActionMap[e];if(n&&n.requiresSelection)return nt(t,n.fileFilter)}},ye=function(e){return function(t){var n;return null==(n=rt(t,e))?void 0:n.length}},be=function(e){return e.disableSelection},ve=function(e){return e.disableSimpleDeselection},xe=function(e){return e.forceEnableOpenParent},Ce=function(e){return e.hideToolbarInfo},Se=function(e){return e.fileViewConfig},Fe=function(e){return e.sortActionId},Ie=function(e){return e.sortOrder},ke=function(e){return e.optionMap},we=function(e){return function(t){return ke(t)[e]}},Ee=function(e){return e.doubleClickDelay},De=function(e){return e.disableDragAndDrop},Me=function(e){return e.clearSelectionOnOutsideClick},Ne=function(e){return e.contextMenuMounted},Ae=function(e){return e.contextMenuConfig},Oe=function(e){var t,n=Ae(e);return n&&n.triggerFileId&&null!=(t=ne(e)[n.triggerFileId])?t:null},Te=function(e){return e.renamingFileId},ze=function(e){return function(t){return!!e&&Te(t)===e}},Re=function(e){return e.renamingSanitizer},Le=function(e){return e.fileActionMap},_e=function(e){return e.optionMap},Pe=function(e){return e.fileMap},je=function(e){return e.fileIds},Be=function(e){return e.cleanFileIds},He=function(e){return e.sortActionId},Ve=function(e){return e.sortOrder},Ke=function(e){return e.searchString},qe=function(e){return e.lastClick},We=function(e){return s.createSelector([Le,e],(function(e,t){return t&&e[t]?e[t]:null}))},Ge=function(e,t){return void 0===t&&(t=void 0),s.createSelector([_e],(function(n){var r=n[e];return void 0===r?t:r}))},Ue=function(e){return s.createSelector([Pe,e],(function(e,t){return t.map((function(t){return t&&e[t]?e[t]:null}))}))},Ye=s.createSelector([je,Ve,function(e){return e.sortCollator},Ue(je),We(He),Ge(q.ShowFoldersFirst,!1)],(function(e,t,n,r,o,i){if(!o)return e;var a,l=function(e){return function(t){return e(t)}},c=[];return i&&c.push({desc:l(V.isDirectory)}),o.sortKeySelector&&c.push(((a={})[t===_.ASC?"asc":"desc"]=l(o.sortKeySelector),a.comparer=null==n?void 0:n.compare,a)),0===c.length?e:u.sort([].concat(r)).by(c).map((function(e){return e?e.id:null}))})),Xe=s.createSelector([Ue(Be),function(e){return e.searchPredicate}],(function(e,t){var n=e;return t?{search:function(e){return n.filter((function(n){return t(e,n)}))}}:new d(n,["name"],{caseSensitive:!1})})),Ze=s.createSelector([Be,Ke,Xe],(function(e,t,n){return t?n.search(t).map((function(e){return e.id})):e})),Qe=s.createSelector([Ze,Ue(Be),Ge(q.ShowHiddenFiles)],(function(e,t,n){var r=new Set(e),o={};return t.forEach((function(e){e&&(r.has(e.id)?!n&&V.isHidden(e)&&(o[e.id]=!0):o[e.id]=!0)})),o})),$e=s.createSelector([Ye,Qe],(function(e,t){return e.filter((function(e){return!e||!t[e]}))})),Je={getFileActionMap:Le,getOptionMap:_e,getFileMap:Pe,getFileIds:je,getCleanFileIds:Be,getSortActionId:He,getSortOrder:Ve,getSearchString:Ke,_getLastClick:qe,getSortedFileIds:Ye,getSearcher:Xe,getSearchFilteredFileIds:Ze,getHiddenFileIdMap:Qe,getDisplayFileIds:$e,getLastClick:s.createSelector([qe,$e],(function(e,t){return!e||e.index>t.length-1||e.fileId!=t[e.index]?null:e})),makeGetAction:We,makeGetOptionValue:Ge,makeGetFiles:Ue},et=function(e,t){return t?ne(e)[t]:null},tt=function(e,t){return!!de(e)[t.id]},nt=function(e){for(var t=e.fileMap,n=Object.keys(e.selectionMap).map((function(e){return t[e]})),r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((function(e,t){return t?e.filter(t):e}),n)},rt=function(e,t){return he(t)(e)};exports.ChonkyIconName=void 0,(W=exports.ChonkyIconName||(exports.ChonkyIconName={})).loading="loading",W.dropdown="dropdown",W.placeholder="placeholder",W.dndDragging="dndDragging",W.dndCanDrop="dndCanDrop",W.dndCannotDrop="dndCannotDrop",W.openFiles="openFiles",W.openParentFolder="openParentFolder",W.copy="copy",W.paste="paste",W.share="share",W.search="search",W.selectAllFiles="selectAllFiles",W.clearSelection="clearSelection",W.sortAsc="sortAsc",W.sortDesc="sortDesc",W.toggleOn="toggleOn",W.toggleOff="toggleOff",W.list="list",W.compact="compact",W.smallThumbnail="smallThumbnail",W.largeThumbnail="largeThumbnail",W.folder="folder",W.folderCreate="folderCreate",W.folderOpen="folderOpen",W.folderChainSeparator="folderChainSeparator",W.download="download",W.upload="upload",W.trash="trash",W.fallbackIcon="fallbackIcon",W.symlink="symlink",W.hidden="hidden",W.file="file",W.license="license",W.code="code",W.config="config",W.model="model",W.database="database",W.text="text",W.archive="archive",W.image="image",W.video="video",W.info="info",W.key="key",W.lock="lock",W.music="music",W.terminal="terminal",W.users="users",W.linux="linux",W.ubuntu="ubuntu",W.windows="windows",W.rust="rust",W.python="python",W.nodejs="nodejs",W.php="php",W.git="git",W.pdf="pdf",W.excel="excel",W.word="word",W.flash="flash";var ot,it=function(e,t){return function(n){var r,o=K("fileActions",e),i=o.sanitizedArray,a=o.errorMessages;if(Array.isArray(t)){var l=new Set(t);r=Ct.filter((function(e){return!l.has(e.id)}))}else r=t?[]:Ct;var c=function(){for(var e,t=new Set,n=function(e){return!!t.add(e.id)},r=function(e){return!t.has(e.id)},o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var l=i.map((function(e){var t=e.filter(r);return t.map(n),t}));return(e=new Array).concat.apply(e,l)}(i,xt,r),s={};c.map((function(e){return e.option?s[e.option.id]=e.option.defaultValue:null})),n(kt.setRawFileActions(e)),n(kt.setFileActionsErrorMessages(a)),n(kt.setFileActions(c)),n(kt.setOptionDefaults(s)),n(at(c))}},at=function(e){return function(t){for(var n,r=new Set([vt.OpenParentFolder.id]),o={Actions:exports.ChonkyIconName.dropdown,Options:exports.ChonkyIconName.config},i={Options:0,Actions:1},a=[],l=[],c={},s=[],u={},d=function(e,t,n){if(t[n])return t[n];var r={name:n,icon:o[n]||null,sortOrder:i[n]||-1,fileActionIds:[]};return e.push(r),t[n]=r,r},f=L(e);!(n=f()).done;){var p=n.value,m=p.button;m&&(m.toolbar&&!r.has(p.id)&&(m.group?d(l,c,m.group).fileActionIds.push(p.id):a.push(p.id)),m.contextMenu&&(m.group?d(s,u,m.group).fileActionIds.push(p.id):s.push(p.id)))}l.sort((function(e,t){return e.sortOrder-t.sortOrder})),t(kt.updateFileActionMenuItems([[].concat(a,l),s]))}},lt=function(e){return function(t,n){var r=n(),o=e?r.fileActionMap[e]:null;o&&o.fileViewConfig&&t(kt.setFileViewConfig(o.fileViewConfig))}},ct=function(e){return function(t,n){if(e){var r=n(),o=r.fileActionMap[e];if(o&&o.sortKeySelector){var i=r.sortOrder===_.ASC?_.DESC:_.ASC;r.sortActionId!==e&&(i=_.ASC),t(kt.setSort({actionId:e,order:i}))}}}},st=function(e){return function(t,n){H.debug("FILE ACTION DISPATCH: ["+e.id+"]","data:",e);var r=n(),o=Y(r)[e.id],i=U(r);o?i&&Promise.resolve(i(e)).catch((function(e){return H.error("User-defined file action handler threw an error: "+e.message)})):H.warn('Internal components dispatched the "'+e.id+'" file action, but such action was not registered.')}},ut=function(e,t){return function(n,r){H.debug("FILE ACTION REQUEST: ["+e.id+"]","action:",e,"payload:",t);var o=r(),i=G(o);Y(o)[e.id]||H.warn('The action "'+e.id+'" was requested, but it is not registered. The action will still be dispatched, but this might indicate a bug in the code. Please register your actions by passing them to "fileActions" prop.');var a=ge(o),l=e.fileFilter?a.filter(e.fileFilter):a;if(!e.requiresSelection||0!==l.length){var c={instanceId:i,selectedFiles:a,selectedFilesForAction:l,contextMenuTriggerFile:Oe(o)};e.sortKeySelector&&n(ct(e.id));var s=e.fileViewConfig;s&&n(kt.setFileViewConfig(s));var u=e.option;u&&n(kt.toggleOption(u.id)),e.selectionTransform&&n(function(e){return function(t,n){var r=e.selectionTransform;if(r){var o=n(),i=new Set(Object.keys(de(o))),a=new Set(Object.keys(Je.getHiddenFileIdMap(o))),l=r({prevSelection:i,fileIds:re(o),fileMap:ne(o),hiddenFileIds:a});l&&t(0===l.size?kt.clearSelection():kt.selectFiles({fileIds:Array.from(l),reset:!0}))}}}(e));var d=e.effect,f=void 0;if(d)try{f=d({action:e,payload:t,state:c,reduxDispatch:n,getReduxState:r})}catch(t){H.error("User-defined effect function for action "+e.id+" threw an error: "+t.message)}return Promise.resolve(f).then((function(r){dt(n,{id:e.id,action:e,payload:t,state:c},r)})).catch((function(r){H.error("User-defined effect function for action "+e.id+" returned a promise that was rejected: "+r.message),dt(n,{id:e.id,action:e,payload:t,state:c},void 0)}))}H.warn('Internal components requested the "'+e.id+'" file action, but the selection for this action was empty. This might a bug in the code of the presentational components.')}},dt=function(e,t,n){!0===n||e(st(t))};exports.FileViewMode=void 0,(ot=exports.FileViewMode||(exports.FileViewMode={})).List="list",ot.Compact="compact",ot.Grid="grid";var ft,pt=function(e,t){if(void 0!==e.__payloadType&&(e.hotkeys||e.button)){var n='Invalid definition was provided for file action "'+e.id+'". Actions that specify hotkeys or buttons cannot define a payload type. If your application requires this functionality, define two actions and chain them using effects.';throw H.error(n),new Error(n)}return e.effect=t,e},mt=function e(t,n){return t?n(t)?t:t.parentElement?e(t.parentElement,n):null:t},gt=function(e,t,n){return n?typeof e===n?e:t:void 0!==e?e:t},ht={MouseClickFile:pt({id:"mouse_click_file",__payloadType:{}},(function(e){var t,n=e.payload,r=e.reduxDispatch,o=e.getReduxState,i=n.file,a=n.fileDisplayIndex,l=n.ctrlKey,c=n.shiftKey,s=n.targetElement,u=i.id;if("double"===n.clickType)V.isOpenable(i)&&r(ut(vt.OpenFiles,{targetFile:i,files:[i]}));else{var d=o(),f=ve(d),p=be(d),m=pe(d),g=tt(d,i),h=Je.getLastClick(d);if(!l&&!c&&V.isRenamable(i)&&s instanceof HTMLElement&&s.dataset.chonkyFileEntryName&&(p?(null==h?void 0:h.fileId)===u:g&&1===m))r(ut(ht.StartRenamingFile,{fileId:u}));else if(V.isSelectable(i)&&!p)if(l)r(kt.selectFile({fileId:u,exclusive:!1,toggle:!0})),r(kt.setLastClickIndex({index:a,fileId:u}));else if(c){var y=null==h?void 0:h.index;if("number"==typeof y){var b=y,v=a;if(b>v){var x=[v,b];b=x[0],v=x[1]}r((t={rangeStart:b,rangeEnd:v},function(e,n){var r=n();if(!r.disableSelection){var o=Je.getDisplayFileIds(r).slice(t.rangeStart,t.rangeEnd+1).filter((function(e){return e&&V.isSelectable(r.fileMap[e])}));e(kt.selectFiles({fileIds:o,reset:!!t.reset}))}})),r(kt.setLastClickIndex({index:a,fileId:u}))}else r(kt.selectFile({fileId:u,exclusive:!1,toggle:!f})),r(kt.setLastClickIndex({index:a,fileId:u}))}else r(kt.selectFile({fileId:u,exclusive:!0,toggle:!f})),r(kt.setLastClickIndex({index:a,fileId:u}));else l||p||r(kt.clearSelection()),r(kt.setLastClickIndex({index:a,fileId:u}))}})),KeyboardClickFile:pt({id:"keyboard_click_file",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch,r=e.getReduxState;n(kt.setLastClickIndex({index:t.fileDisplayIndex,fileId:t.file.id})),t.enterKey&&0===pe(r())&&n(ut(vt.OpenFiles,{targetFile:t.file,files:[t.file]}))})),StartDragNDrop:pt({id:"start_drag_n_drop",__payloadType:{}},(function(e){var t=e.reduxDispatch,n=e.payload.draggedFile;tt((0,e.getReduxState)(),n)||V.isSelectable(n)&&t(kt.selectFiles({fileIds:[n.id],reset:!0}))})),EndDragNDrop:pt({id:"end_drag_n_drop",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch;if(!tt((0,e.getReduxState)(),t.destination)){var r=t.selectedFiles;n(ut(vt.MoveFiles,z({},t,{files:r.length>0?r:[t.draggedFile]})))}})),MoveFiles:pt({id:"move_files",__payloadType:{}}),RenameFile:pt({id:"rename_file",__payloadType:{}}),StartRenamingFile:pt({id:"start_renaming_file",__payloadType:{}},(function(e){var t=e.reduxDispatch,n=e.payload.fileId,r=et((0,e.getReduxState)(),n);V.isRenamable(r)?t(kt.startRenaming(n)):H.warn("Start renaming file action was triggered for file that is not renamable. This may indicate a bug in internal components.")})),EndRenamingFile:pt({id:"end_renaming_file",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch,r=e.getReduxState,o=Te(r());if(o){var i=t.targetName;if(void 0!==i){var a=et(r(),o);V.isRenamable(a)&&a.name!==i&&n(ut(vt.RenameFile,{file:a,targetName:i}))}n(kt.endRenaming())}})),ChangeSelection:pt({id:"change_selection",__payloadType:{}}),OpenFiles:pt({id:"open_files",__payloadType:{}}),OpenParentFolder:pt({id:"open_parent_folder",button:{name:"Go up a directory",toolbar:!0,contextMenu:!1,icon:exports.ChonkyIconName.openParentFolder,iconOnly:!0}},(function(e){var t=e.reduxDispatch,n=(0,e.getReduxState)(),r=te(n);V.isOpenable(r)?t(ut(vt.OpenFiles,{targetFile:r,files:[r]})):n.forceEnableOpenParent||H.warn("Open parent folder effect was triggered even though the parent folder is not openable. This indicates a bug in presentation components.")})),OpenFileContextMenu:pt({id:"open_file_context_menu",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch,r=e.getReduxState,o=et(r(),t.triggerFileId);o?tt(r(),o)||(V.isSelectable(o)?n(kt.selectFiles({fileIds:[t.triggerFileId],reset:!0})):n(kt.clearSelection())):n(kt.clearSelection()),n(kt.showContextMenu({triggerFileId:t.triggerFileId,mouseX:t.clientX-2,mouseY:t.clientY-4}))}))},yt={OpenSelection:pt({id:"open_selection",hotkeys:["enter"],requiresSelection:!0,fileFilter:V.isOpenable,button:{name:"Open selection",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.openFiles}},(function(e){(0,e.reduxDispatch)(ut(ht.OpenFiles,{files:e.state.selectedFilesForAction}))})),SelectAllFiles:pt({id:"select_all_files",hotkeys:["ctrl+a"],button:{name:"Select all files",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.selectAllFiles},selectionTransform:function(e){var t=e.fileIds,n=e.hiddenFileIds,r=new Set;return t.map((function(e){n.has(e)||r.add(e)})),r}}),ClearSelection:pt({id:"clear_selection",hotkeys:["escape"],button:{name:"Clear selection",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.clearSelection},selectionTransform:function(e){return 0===e.prevSelection.size?null:new Set}}),StartRenamingSelection:pt({id:"start_renaming_selection",hotkeys:["f2"],requiresSelection:!0,fileFilter:V.isRenamable},(function(e){var t=e.state.selectedFilesForAction;t.length>=1&&(0,e.reduxDispatch)(ut(ht.StartRenamingFile,{fileId:t[t.length-1].id}))})),EnableListView:pt({id:"enable_list_view",fileViewConfig:{mode:exports.FileViewMode.List,entryHeight:30},button:{name:"Switch to List",toolbar:!0,icon:exports.ChonkyIconName.list,iconOnly:!0}}),EnableCompactView:pt({id:"enable_compact_view",fileViewConfig:{mode:exports.FileViewMode.Compact,entryHeight:40,entryWidth:220},button:{name:"Switch to Compact",toolbar:!0,icon:exports.ChonkyIconName.compact,iconOnly:!0}}),EnableGridView:pt({id:"enable_grid_view",fileViewConfig:{mode:exports.FileViewMode.Grid,entryWidth:100,entryHeight:100},button:{name:"Switch to Grid",toolbar:!0,icon:exports.ChonkyIconName.smallThumbnail,iconOnly:!0}}),SortFilesByName:pt({id:"sort_files_by_name",sortKeySelector:function(e){return e?e.name.toLowerCase():void 0},button:{name:"Sort by name",toolbar:!0,group:"Options"}}),SortFilesBySize:pt({id:"sort_files_by_size",sortKeySelector:function(e){return e?e.size:void 0},button:{name:"Sort by size",toolbar:!0,group:"Options"}}),SortFilesByDate:pt({id:"sort_files_by_date",sortKeySelector:function(e){return e?e.modDate:void 0},button:{name:"Sort by date",toolbar:!0,group:"Options"}}),ToggleHiddenFiles:pt({id:"toggle_hidden_files",hotkeys:["ctrl+h"],option:{id:q.ShowHiddenFiles,defaultValue:!0},button:{name:"Show hidden files",toolbar:!0,group:"Options"}}),ToggleShowFoldersFirst:pt({id:"toggle_show_folders_first",option:{id:q.ShowFoldersFirst,defaultValue:!0},button:{name:"Show folders first",toolbar:!0,group:"Options"}}),FocusSearchInput:pt({id:"focus_search_input",hotkeys:["ctrl+f"]},(function(e){var t=le((0,e.getReduxState)());t&&t()})),ToggleDarkMode:pt({id:"enable_dark_mode",option:{id:q.DarkMode,defaultValue:!1},button:{name:"Enable dark mode",toolbar:!0,icon:exports.ChonkyIconName.list,iconOnly:!0}})},bt={CopyFiles:pt({id:"copy_files",requiresSelection:!0,hotkeys:["ctrl+c"],button:{name:"Copy selection",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.copy}}),CreateFolder:pt({id:"create_folder",button:{name:"Create folder",toolbar:!0,tooltip:"Create a folder",icon:exports.ChonkyIconName.folderCreate}}),UploadFiles:pt({id:"upload_files",button:{name:"Upload files",toolbar:!0,tooltip:"Upload files",icon:exports.ChonkyIconName.upload}}),DownloadFiles:pt({id:"download_files",requiresSelection:!0,button:{name:"Download files",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.download}}),DeleteFiles:pt({id:"delete_files",requiresSelection:!0,hotkeys:["delete"],button:{name:"Delete files",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.trash}})},vt=z({},ht,yt,bt),xt=[vt.MouseClickFile,vt.KeyboardClickFile,vt.StartDragNDrop,vt.EndDragNDrop,vt.MoveFiles,vt.RenameFile,vt.StartRenamingFile,vt.EndRenamingFile,vt.ChangeSelection,vt.OpenFiles,vt.OpenParentFolder,vt.OpenFileContextMenu],Ct=[vt.OpenSelection,vt.SelectAllFiles,vt.ClearSelection,vt.StartRenamingSelection,vt.EnableListView,vt.EnableGridView,vt.SortFilesByName,vt.SortFilesBySize,vt.SortFilesByDate,vt.ToggleHiddenFiles,vt.ToggleShowFoldersFirst,vt.FocusSearchInput],St={instanceId:"CHONKY_INVALID_ID",externalFileActionHandler:null,rawFileActions:[],fileActionsErrorMessages:[],fileActionMap:{},fileActionIds:[],toolbarItems:[],contextMenuItems:[],rawFolderChain:null,folderChainErrorMessages:[],folderChain:[],rawFiles:[],filesErrorMessages:[],fileMap:{},fileIds:[],cleanFileIds:[],sortedFileIds:[],hiddenFileIdMap:{},focusSearchInput:null,onSearchInput:null,onCancelSearch:null,searchPredicate:null,searchString:"",searchMode:"currentFolder",selectionMap:{},disableSelection:!1,disableSimpleDeselection:!1,fileViewConfig:vt.EnableGridView.fileViewConfig,sortActionId:null,sortOrder:_.ASC,optionMap:{},sortCollator:null,doubleClickDelay:300,disableDragAndDrop:!1,clearSelectionOnOutsideClick:!0,forceEnableOpenParent:!1,hideToolbarInfo:!1,lastClick:null,contextMenuMounted:!1,contextMenuConfig:null,renamingFileId:null,renamingSanitizer:null,disableRenaming:!1},Ft={setExternalFileActionHandler:function(e,t){var n;e.externalFileActionHandler=null!=(n=t.payload)?n:null},setRawFileActions:function(e,t){e.rawFileActions=t.payload},setFileActionsErrorMessages:function(e,t){e.fileActionsErrorMessages=t.payload},setFileActions:function(e,t){var n={};t.payload.map((function(e){return n[e.id]=e}));var r=t.payload.map((function(e){return e.id}));e.fileActionMap=n,e.fileActionIds=r},updateFileActionMenuItems:function(e,t){var n=t.payload;e.toolbarItems=n[0],e.contextMenuItems=n[1]},setRawFolderChain:function(e,t){var n=t.payload,r=K("folderChain",n),o=r.sanitizedArray,i=r.errorMessages;e.rawFolderChain=n,e.folderChain=o,e.folderChainErrorMessages=i},setRawFiles:function(e,t){var n=t.payload,r=K("files",n),o=r.sanitizedArray,i=r.errorMessages;e.rawFiles=n,e.filesErrorMessages=i;var a={};o.forEach((function(e){e&&(a[e.id]=e)}));var l=o.map((function(e){return e?e.id:null})),c=l.filter((function(e){return!!e}));e.fileMap=a,e.fileIds=l,e.cleanFileIds=c;for(var s=0,u=Object.keys(e.selectionMap);s<u.length;s++){var d=u[s];a[d]||delete e.selectionMap[d]}},setSortedFileIds:function(e,t){e.sortedFileIds=t.payload},setHiddenFileIds:function(e,t){e.hiddenFileIdMap=t.payload;for(var n=0,r=Object.keys(e.selectionMap);n<r.length;n++){var o=r[n];e.hiddenFileIdMap[o]&&delete e.selectionMap[o]}},setSelectedFileIds:function(e,t){t.payload&&(e.selectionMap=t.payload.filter((function(t){return t&&V.isSelectable(e.fileMap[t])})).reduce((function(e,t){var n;return z({},e,((n={})[t]=!0,n))}),{}))},setFocusSearchInput:function(e,t){e.focusSearchInput=t.payload},setSearchString:function(e,t){e.searchString=t.payload},onSearchInput:function(e,t){e.onSearchInput=t.payload},onCancelSearch:function(e,t){e.onCancelSearch=t.payload},searchPredicate:function(e,t){e.searchPredicate=t.payload},selectAllFiles:function(e){e.fileIds.filter((function(t){return t&&V.isSelectable(e.fileMap[t])})).map((function(t){return t?e.selectionMap[t]=!0:null}))},selectFiles:function(e,t){e.disableSelection||(t.payload.reset&&(e.selectionMap={}),t.payload.fileIds.filter((function(t){return t&&V.isSelectable(e.fileMap[t])})).map((function(t){return e.selectionMap[t]=!0})))},selectFile:function(e,t){if(!e.disableSelection){var n=t.payload.toggle&&!!e.selectionMap[t.payload.fileId];t.payload.exclusive&&(e.selectionMap={}),n?delete e.selectionMap[t.payload.fileId]:V.isSelectable(e.fileMap[t.payload.fileId])&&(e.selectionMap[t.payload.fileId]=!0)}},clearSelection:function(e){e.disableSelection||0!==Object.keys(e.selectionMap).length&&(e.selectionMap={})},setSelectionDisabled:function(e,t){e.disableSelection=t.payload,0!==Object.keys(e.selectionMap).length&&(e.selectionMap={})},setSimpleDeselectionDisabled:function(e,t){e.disableSimpleDeselection=t.payload},setFileViewConfig:function(e,t){e.fileViewConfig=t.payload},setSort:function(e,t){e.sortActionId=t.payload.actionId,e.sortOrder=t.payload.order},setOptionDefaults:function(e,t){for(var n=0,r=Object.keys(t.payload);n<r.length;n++){var o=r[n];o in e.optionMap||(e.optionMap[o]=t.payload[o])}},toggleOption:function(e,t){e.optionMap[t.payload]=!e.optionMap[t.payload]},setSortCollator:function(e,t){e.sortCollator=t.payload},setDoubleClickDelay:function(e,t){e.doubleClickDelay=t.payload},setDisableDragAndDrop:function(e,t){e.disableDragAndDrop=t.payload},setForceEnableOpenParent:function(e,t){e.forceEnableOpenParent=t.payload},setHideToolbarInfo:function(e,t){e.hideToolbarInfo=t.payload},setClearSelectionOnOutsideClick:function(e,t){e.clearSelectionOnOutsideClick=t.payload},setLastClickIndex:function(e,t){e.lastClick=t.payload},setContextMenuMounted:function(e,t){e.contextMenuMounted=t.payload},showContextMenu:function(e,t){e.contextMenuConfig=t.payload},hideContextMenu:function(e){e.contextMenuConfig&&(e.contextMenuConfig=null)},startRenaming:function(e,t){if(!e.disableRenaming){var n=t.payload;V.isRenamable(e.fileMap[n])&&(e.renamingFileId=n)}},endRenaming:function(e){e.renamingFileId=null},renamingSanitizer:function(e,t){e.renamingSanitizer=t.payload},setRenamingDisabled:function(e,t){e.disableRenaming=t.payload,e.renamingFileId=null}},It=s.createSlice({name:"root",initialState:St,reducers:Ft}),kt=It.actions,wt=It.reducer,Et=function(e){var n=j((function(){var t=z({},St,{instanceId:e});return s.configureStore({preloadedState:t,reducer:wt,middleware:function(e){return e({serializableCheck:!1})},devTools:{name:"chonky_"+e}})}));return function(e){t.useEffect((function(){var t=f((function(){return de(e.getState())})),n=[e.subscribe(t((function(t,n){if(t!==n){var r=fe(e.getState()),o=new Set(r);e.dispatch(ut(vt.ChangeSelection,{selection:o}))}})))];return function(){for(var e=0,t=n;e<t.length;e++)(0,t[e])()}}),[e])}(n),n},Dt=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.useCallback((function(t){return e.apply(void 0,r)(t)}),[e].concat(r));return a.useSelector(i)},Mt=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=a.useDispatch();t.useEffect((function(){i(e.apply(void 0,r))}),[i,e].concat(r))},Nt=function(e,n){var r=a.useDispatch();t.useEffect((function(){r(e(n))}),[r,e,n])},At=function(){return t.createElement("span",{title:"No icon component found. Please follow Chonky installation instructions to provide a pre-made icon component (or a custom icon)."},"⚠️")},Ot={fileActions:null,onFileAction:null,onSearchInput:null,onCancelSearch:null,searchPredicate:null,doubleClickDelay:300,disableSelection:!1,disableSimpleDeselection:!1,disableDefaultFileActions:!1,forceEnableOpenParent:!1,hideToolbarInfo:!1,disableDragAndDrop:!1,disableDragAndDropProvider:!1,defaultSortActionId:vt.SortFilesByName.id,defaultFileViewActionId:vt.EnableGridView.id,clearSelectionOnOutsideClick:!0,iconComponent:At,darkMode:!1,i18n:{},renamingSanitizer:null,disableRenaming:!1,selectedFileIds:null};exports.I18nNamespace=void 0,(ft=exports.I18nNamespace||(exports.I18nNamespace={})).Toolbar="toolbar",ft.FileList="fileList",ft.FileEntry="fileEntry",ft.FileContextMenu="contextMenu",ft.FileActions="actions",ft.FileActionGroups="actionGroups";var Tt=function(e,t){return"chonky."+e+"."+t},zt=function(e,t){return"chonky."+exports.I18nNamespace.FileActions+"."+e+"."+t},Rt=function(e){var n=o.useIntl();return t.useMemo((function(){var t,r;if(!e)return{buttonName:"",buttonTooltip:void 0};var o,i=n.formatMessage({id:zt(e.id,"button.name"),defaultMessage:null==(t=e.button)?void 0:t.name}),a=void 0;return null!=(r=e.button)&&r.tooltip&&(a=n.formatMessage({id:zt(e.id,"button.tooltip"),defaultMessage:null==(o=e.button)?void 0:o.tooltip})),{buttonName:i,buttonTooltip:a}}),[e,n])},Lt=function(e){var n=o.useIntl(),r=t.useContext(Pt);return t.useMemo((function(){return{fileModDateString:r.formatFileModDate(n,e),fileSizeString:r.formatFileSize(n,e)}}),[e,r,n])},_t={formatFileModDate:function(e,t){var n=V.getModDate(t);return n?e.formatDate(n):null},formatFileSize:function(e,t){if(!t||"number"!=typeof t.size)return null;var n=p.filesize(t.size,{bits:!1,output:"object"});return"B"===n.symbol?Math.round(n.value/10)/100+" KB":"KB"===n.symbol?Math.round(n.value)+" "+n.symbol:n.value+" "+n.symbol}},Pt=t.createContext(_t),jt=t.createContext(At),Bt=["3g2","3gp","3gpp","asf","asx","avi","dvb","f4v","fli","flv","fvt","h261","h263","h264","jpgm","jpgv","jpm","m1v","m2v","m4u","m4v","mj2","mjp2","mk3d","mks","mkv","mng","mov","movie","mp4","mp4v","mpe","mpeg","mpg","mpg4","mxu","ogv","pyv","qt","smv","ts","uvh","uvm","uvp","uvs","uvu","uvv","uvvh","uvvm","uvvp","uvvs","uvvu","uvvv","viv","vob","webm","wm","wmv","wmx","wvx"],Ht=["3ds","apng","azv","bmp","bmp","btif","cgm","cmx","djv","djvu","drle","dwg","dxf","emf","exr","fbs","fh","fh4","fh5","fh7","fhc","fits","fpx","fst","g3","gif","heic","heics","heif","heifs","ico","ico","ief","jls","jng","jp2","jpe","jpeg","jpf","jpg","jpg2","jpm","jpx","jxr","ktx","mdi","mmr","npx","pbm","pct","pcx","pcx","pgm","pic","png","pnm","ppm","psd","pti","ras","rgb","rlc","sgi","sid","sub","svg","svgz","t38","tap","tfx","tga","tif","tiff","uvg","uvi","uvvg","uvvi","vtf","wbmp","wdp","webp","wmf","xbm","xif","xpm","xwd"],Vt=["3gpp","aac","adp","aif","aifc","aiff","au","caf","dra","dts","dtshd","ecelp4800","ecelp7470","ecelp9600","eol","flac","kar","lvp","m2a","m3a","m3u","m4a","m4a","mid","midi","mka","mp2","mp2a","mp3","mp3","mp4a","mpga","oga","ogg","pya","ra","ra","ram","rip","rmi","rmp","s3m","sil","snd","spx","uva","uvva","wav","wav","wav","wax","weba","wma","xm"],Kt=["#bbbbbb","#d65c5c","#d6665c","#d6705c","#d67a5c","#d6855c","#d68f5c","#d6995c","#d6a35c","#d6ad5c","#d6b85c","#d6c25c","#d6cc5c","#d6d65c","#ccd65c","#c2d65c","#b8d65c","#add65c","#a3d65c","#99d65c","#8fd65c","#85d65c","#7ad65c","#70d65c","#66d65c","#5cd65c","#5cd666","#5cd670","#5cd67a","#5cd685","#5cd68f","#5cd699","#5cd6a3","#5cd6ad","#5cd6b8","#5cd6c2","#5cd6cc","#5cd6d6","#5cccd6","#5cc2d6","#5cb8d6","#5cadd6","#5ca3d6","#5c99d6","#5c8fd6","#5c85d6","#5c7ad6","#5c70d6","#5c66d6","#5c5cd6","#665cd6","#705cd6","#7a5cd6","#855cd6","#8f5cd6","#995cd6","#a35cd6","#ad5cd6","#b85cd6","#c25cd6","#cc5cd6","#d65cd6","#d65ccc","#d65cc2","#d65cb8","#d65cad","#d65ca3","#d65c99","#d65c8f","#d65c85","#d65c7a","#d65c70","#d65c66"],qt=["#777","#8f3d3d","#8f443d","#8f4b3d","#8f523d","#8f583d","#8f5f3d","#8f663d","#8f6d3d","#8f743d","#8f7a3d","#8f813d","#8f883d","#8f8f3d","#888f3d","#818f3d","#7a8f3d","#748f3d","#6d8f3d","#668f3d","#5f8f3d","#588f3d","#528f3d","#4b8f3d","#448f3d","#3d8f3d","#3d8f44","#3d8f4b","#3d8f52","#3d8f58","#3d8f5f","#3d8f66","#3d8f6d","#3d8f74","#3d8f7a","#3d8f81","#3d8f88","#3d8f8f","#3d888f","#3d818f","#3d7a8f","#3d748f","#3d6d8f","#3d668f","#3d5f8f","#3d588f","#3d528f","#3d4b8f","#3d448f","#3d3d8f","#443d8f","#4b3d8f","#523d8f","#583d8f","#5f3d8f","#663d8f","#6d3d8f","#743d8f","#7a3d8f","#813d8f","#883d8f","#8f3d8f","#8f3d88","#8f3d81","#8f3d7a","#8f3d74","#8f3d6d","#8f3d66","#8f3d5f","#8f3d58","#8f3d52","#8f3d4b","#8f3d44"],Wt=function(){for(var e=0,t=[[exports.ChonkyIconName.license,["license"]],[exports.ChonkyIconName.config,["sfk","ini","yml","toml","iml"]],[exports.ChonkyIconName.model,["3ds","obj","ply","fbx"]],[exports.ChonkyIconName.database,["csv","json","sql","sqlite","sqlite3","npy","npz","rec","idx","hdf5"]],[exports.ChonkyIconName.text,["txt","md","mdx"]],[exports.ChonkyIconName.archive,["zip","rar","tar","tar.gz","7z"]],[exports.ChonkyIconName.image,Ht],[exports.ChonkyIconName.video,Bt],[exports.ChonkyIconName.code,["html","php","css","sass","scss","less","cpp","h","hpp","c","xml"]],[exports.ChonkyIconName.info,["bib","readme","nfo"]],[exports.ChonkyIconName.key,["pem","pub"]],[exports.ChonkyIconName.lock,["lock","lock.json","shrinkwrap.json"]],[exports.ChonkyIconName.music,Vt],[exports.ChonkyIconName.terminal,["run","sh"]],[exports.ChonkyIconName.trash,[".Trashes"]],[exports.ChonkyIconName.users,["authors","contributors"]],[exports.ChonkyIconName.linux,["AppImage"]],[exports.ChonkyIconName.ubuntu,["deb"]],[exports.ChonkyIconName.windows,["exe"]],[exports.ChonkyIconName.rust,["rs","rlib"]],[exports.ChonkyIconName.python,["py","ipynb"]],[exports.ChonkyIconName.nodejs,["js","jsx","ts","tsx","d.ts"]],[exports.ChonkyIconName.php,["php"]],[exports.ChonkyIconName.git,[".gitignore"]],[exports.ChonkyIconName.pdf,["pdf"]],[exports.ChonkyIconName.excel,["xls","xlsx"]],[exports.ChonkyIconName.word,["doc","docx","odt"]],[exports.ChonkyIconName.flash,["swf"]]],n=new m({ignoreCase:!0}),r=0,o=t;r<o.length;r++)for(var i=o[r],a=i[0],l=i[1],c=0;c<l.length;++c)n.put(l[c],{icon:a,colorCode:(e+=5)%(Kt.length-1)+1},!0);return n}(),Gt={colors:{debugRed:"#fabdbd",debugBlue:"#bdd8fa",debugGreen:"#d2fabd",debugPurple:"#d2bdfa",debugYellow:"#fae9bd",textActive:"#09f"},fontSizes:{rootPrimary:15},margins:{rootLayoutMargin:8},root:{borderRadius:4,borderStyle:"solid 1px",height:"100%"},toolbar:{size:30,lineHeight:"30px",buttonPadding:8,fontSize:15,buttonRadius:4},dnd:{canDropColor:"green",cannotDropColor:"red",canDropMask:"rgba(180, 235, 180, 0.75)",cannotDropMask:"rgba(235, 180, 180, 0.75)",fileListCanDropMaskOne:"rgba(180, 235, 180, 0.1)",fileListCanDropMaskTwo:"rgba(180, 235, 180, 0.2)",fileListCannotDropMaskOne:"rgba(235, 180, 180, 0.1)",fileListCannotDropMaskTwo:"rgba(235, 180, 180, 0.2)"},dragLayer:{border:"solid 2px #09f",padding:"7px 10px",borderRadius:2},fileList:{desktopGridGutter:8,mobileGridGutter:5},gridFileEntry:{childrenCountSize:"1.6em",iconColorFocused:"#000",iconSize:"2.4em",iconColor:"#fff",borderRadius:5,fontSize:14,textWrap:"wrap",fileColorTint:"rgba(255, 255, 255, 0.4)",fileFocusedBoxShadow:"inset rgba(0, 0, 0, 1) 0 0 0 3px",fileSelectedBoxShadow:"inset rgba(0,153,255, .65) 0 0 0 3px",folderBackColorTint:"rgba(255, 255, 255, 0.1)",folderBackFocusedColorTint:"rgba(0, 0, 0, 0.3)",folderBackSelectedColorTint:"rgba(0, 153, 255, .4)",folderFrontColorTint:"rgba(255, 255, 255, 0.4)",folderFrontFocusedBoxShadow:"inset rgba(0, 0, 0, 1) 0 0 0 3px",folderFrontSelectedBoxShadow:"inset rgba(0, 153, 255, .65) 0 0 0 3px"},listFileEntry:{propertyFontSize:14,iconColor:void 0,iconFontSize:"1.1em",iconBorderRadius:5,fontSize:14,headerFontSize:10},fileEntrySelectionIndicator:{background:"repeating-linear-gradient(45deg,rgba(0,153,255,.14),rgba(0,153,255,.14) 10px,rgba(0,153,255,.25) 0,rgba(0,153,255,.25) 20px)",backgroundColor:"rgba(0, 153, 255, .14)",position:"absolute",height:"100%",width:"100%",zIndex:10},fileEntryFocusIndicator:{boxShadow:"inset rgba(0, 0, 0, 1) 0 0 0 2px",position:"absolute",height:"100%",width:"100%",zIndex:11},fileRenamingInputField:{backgroundColor:"rgba(255, 255, 255, 0.25)",border:"solid 1px rgba(0, 0, 0, 0.25)",borderRadius:3}},Ut={gridFileEntry:{fileColorTint:"rgba(50, 50, 50, 0.4)",folderBackColorTint:"rgba(50, 50, 50, 0.4)",folderFrontColorTint:"rgba(50, 50, 50, 0.15)"},fileRenamingInputField:{backgroundColor:"rgba(0, 0, 0, 0.25)",border:"solid 1px rgba(255, 255, 255, 0.25)"}},Yt={fontSizes:{rootPrimary:13},margins:{rootLayoutMargin:4},toolbar:{size:28,lineHeight:"28px",fontSize:13},gridFileEntry:{fontSize:13},listFileEntry:{propertyFontSize:12,iconFontSize:"1em",fontSize:13}},Xt=function(){return g("(max-width:480px)")},Zt=function(e,t){return"repeating-linear-gradient(45deg,"+e+","+e+" 10px,"+t+" 0,"+t+" 20px)"},Qt=function(e){return i.createUseStyles(e)},$t=function(e){var t={},n=i.createUseStyles((function(n){var r=e(n),o={};return Object.keys(r).map((function(e){var n="chonky-"+e;o["@global ."+n]=r[e],t[e]=n})),o}));return function(){var e=n.apply(void 0,arguments),r={};return Object.keys(t).map((function(e){r[e]=t[e]})),z({},r,e)}},Jt=function(e){return[e,"!important"]},en=h,tn=t.memo(t.forwardRef((function(e,n){var r;return Nt(kt.setRawFiles,null!=(r=e.files)?r:St.rawFiles),Nt(kt.setRawFolderChain,e.folderChain),Mt(it,gt(e.fileActions,Ot.fileActions),gt(e.disableDefaultFileActions,Ot.disableDefaultFileActions)),Mt(kt.setExternalFileActionHandler,gt(e.onFileAction,Ot.onFileAction)),Mt(kt.setSelectedFileIds,gt(e.selectedFileIds,Ot.selectedFileIds)),Mt(kt.setSelectionDisabled,gt(e.disableSelection,Ot.disableSelection,"boolean")),Mt(kt.setSimpleDeselectionDisabled,gt(e.disableSimpleDeselection,Ot.disableSimpleDeselection,"boolean")),Mt(ct,gt(e.defaultSortActionId,Ot.defaultSortActionId)),Mt(lt,gt(e.defaultFileViewActionId,Ot.defaultFileViewActionId,"string")),Mt(kt.setSortCollator,gt(e.sortCollator,Ot.sortCollator)),Mt(kt.setDoubleClickDelay,gt(e.doubleClickDelay,Ot.doubleClickDelay,"number")),Mt(kt.setForceEnableOpenParent,gt(e.forceEnableOpenParent,Ot.forceEnableOpenParent,"boolean")),Mt(kt.setHideToolbarInfo,gt(e.hideToolbarInfo,Ot.hideToolbarInfo,"boolean")),Mt(kt.setDisableDragAndDrop,gt(e.disableDragAndDrop,Ot.disableDragAndDrop,"boolean")),Mt(kt.setClearSelectionOnOutsideClick,gt(e.clearSelectionOnOutsideClick,Ot.clearSelectionOnOutsideClick,"boolean")),Mt(kt.onSearchInput,gt(e.onSearchInput,Ot.onSearchInput)),Mt(kt.onCancelSearch,gt(e.onCancelSearch,Ot.onCancelSearch)),Mt(kt.searchPredicate,gt(e.searchPredicate,Ot.searchPredicate)),Mt(kt.renamingSanitizer,gt(e.renamingSanitizer,Ot.renamingSanitizer)),Mt(kt.setRenamingDisabled,gt(e.disableRenaming,Ot.disableRenaming,"boolean")),function(e){var n=a.useStore(),r=a.useDispatch();t.useImperativeHandle(e,(function(){return{getFileSelection:function(){var e=de(n.getState());return new Set(Object.keys(e))},setFileSelection:function(e,t){void 0===t&&(t=!0);var n=Array.from(e);r(kt.selectFiles({fileIds:n,reset:t}))},requestFileAction:function(e,t){return(n=O().mark((function n(){return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.resolve(r(ut(e,t))));case 1:case"end":return n.stop()}}),n)})),function(){var e=this,t=arguments;return new Promise((function(r,o){var i=n.apply(e,t);function a(e){T(i,r,o,a,l,"next",e)}function l(e){T(i,r,o,a,l,"throw",e)}a(void 0)}))})();var n}}}),[n,r])}(n),null})));tn.displayName="ChonkyBusinessLogicInner";var nn=t.memo(tn);nn.displayName="ChonkyBusinessLogic";var rn=function(){return!!t.useContext(n.DndContext).dragDropManager},on="dnd-chonky-file-entry",an={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},ln=function(e,t,n){if(!e||!t||!n)return{display:"none"};var r="translate("+(e.x+(n.x-t.x))+"px, "+(e.y+(n.y-t.y))+"px)";return{transform:r,WebkitTransform:r}},cn=function(){var e=sn(),r=n.useDragLayer((function(e){return{item:e.getItem(),itemType:e.getItemType(),initialCursorOffset:e.getInitialClientOffset(),initialFileOffset:e.getInitialSourceClientOffset(),currentFileOffset:e.getSourceClientOffset(),isDragging:e.isDragging()}})),o=r.item;if(!r.isDragging||r.itemType!==on||!o.payload)return null;var i=o.payload.selectedFiles.length;return t.createElement("div",{style:an},t.createElement("div",{style:ln(r.initialCursorOffset,r.initialFileOffset,r.currentFileOffset)},t.createElement("div",{className:e.fileDragPreview},t.createElement("b",null,o.payload.draggedFile.name),i>1&&t.createElement(t.Fragment,null," and ",t.createElement("strong",null,i-1," other file",i-1!=1?"s":"")))))},sn=$t((function(e){return{fileDragPreview:{boxShadow:"2px 2px 5px "+e.palette.divider,backgroundColor:e.palette.background.default,borderRadius:e.dragLayer.borderRadius,fontSize:e.fontSizes.rootPrimary,color:e.palette.text.primary,padding:e.dragLayer.padding,border:e.dragLayer.border,display:"inline-block"}}})),un=t.memo((function(e){var n=e.fileActionId,r=e.rootRef,o=a.useDispatch(),i=Dt(Z,n),l=r.current;return t.useEffect((function(){if(i&&i.hotkeys&&0!==i.hotkeys.length&&l){var e=i.hotkeys.join(","),t=function(e){e.preventDefault(),o(ut(i,void 0))};return v(e,{element:l},t),function(){v.unbind(e,t)}}}),[o,i,l]),null})),dn=function(e){var n=e.children,r=a.useDispatch(),o=t.useRef(null),i=a.useSel