UNPKG

chonky

Version:

A File Browser component for React

1 lines 81.2 kB
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@material-ui/core/styles"),n=e(require("deepmerge")),r=require("react"),o=e(r),i=require("react-dnd"),a=require("react-dnd-html5-backend"),l=require("react-intl"),c=require("react-jss"),s=require("react-redux"),d=e(require("shortid")),u=require("@reduxjs/toolkit"),f=e(require("fast-sort")),p=e(require("fuzzy-search")),m=e(require("redux-watch")),g=e(require("filesize")),h=e(require("exact-trie")),b=e(require("@material-ui/core/useMediaQuery")),y=e(require("classnames")),v=e(require("@material-ui/core/Box")),x=e(require("@material-ui/core/ClickAwayListener")),C=e(require("hotkeys-js")),S=e(require("@material-ui/core/Breadcrumbs")),F=e(require("@material-ui/core/Button")),I=e(require("@material-ui/core/Menu")),k=e(require("@material-ui/core/ListItemIcon")),w=e(require("@material-ui/core/ListItemText")),E=e(require("@material-ui/core/MenuItem")),D=e(require("@material-ui/core/Typography")),M=e(require("@material-ui/core/InputAdornment")),N=e(require("@material-ui/core/TextField")),A=e(require("react-virtualized-auto-sizer")),O=require("react-window"),z=e(require("@material-ui/core/ListSubheader"));function T(){return(T=Object.assign||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}).apply(this,arguments)}function L(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 R(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 L(e,void 0);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)?L(e,void 0):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 _,j={},H=function(e){var t=r.useRef(j);return t.current===j&&(t.current=e()),t.current},P=function(e){var t=r.useRef(e);return r.useEffect((function(){t.current=e}),[t,e]),t},B=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}(),K=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.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){B.error("Could not convert provided string/number into a date: "+t.message+" ","Invalid value:",e)}return e instanceof Date&&!isNaN(e.getTime())?e:(B.warn("Unsupported date representation:",e),null)},e.getChildrenCount=function(e){return e&&"number"==typeof e.childrenCount?e.childrenCount:null},e}(),V=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 d='"'+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: "+d)}}else r.push('Expected "'+e+'" prop to be an array, got "'+typeof t+'" instead.');if(r.length>0){var u,f,p="\n- "+r.join("\n- ");"folderChain"===e?(u="folder chain",f="files"):"fileActions"===e?(u="file actions",f="file actions"):(u="files",f="files"),B.error("Errors were detected when sanitizing the "+u+" 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,U=function(e){return e.instanceId},Y=function(e){return e.externalFileActionHandler},X=function(e){return e.fileActionMap},Z=function(e){return e.fileActionIds},Q=function(e){return function(t){return X(t)[e]}},$=function(e){return e.toolbarItems},J=function(e){return e.contextMenuItems},ee=function(e){return e.folderChain},te=function(e){var t=ee(e);return t.length>0?t[t.length-1]:null},ne=function(e){var t=ee(e);return t.length>1?t[t.length-2]:null},re=function(e){return e.fileMap},oe=function(e){return e.cleanFileIds},ie=function(e){return function(t){return e?re(t)[e]:null}},ae=function(e){return e.hiddenFileIdMap},le=function(e){return Object.keys(ae(e)).length},ce=function(e){return e.focusSearchInput},se=function(e){return e.searchString},de=function(e){return e.selectionMap},ue=function(e){return Object.keys(de(e))},fe=function(e){return ue(e).length},pe=function(e){return function(t){return!!e&&!!de(t)[e]}},me=function(e){var t=re(e);return Object.keys(de(e)).map((function(e){return t[e]}))},ge=function(e){return function(t){var n=t.fileActionMap[e];if(n&&n.requiresSelection)return Xe(t,n.fileFilter)}},he=function(e){return function(t){var n;return null==(n=Ze(t,e))?void 0:n.length}},be=function(e){return e.disableSelection},ye=function(e){return e.fileViewConfig},ve=function(e){return e.sortActionId},xe=function(e){return e.sortOrder},Ce=function(e){return e.optionMap},Se=function(e){return function(t){return Ce(t)[e]}},Fe=function(e){return e.thumbnailGenerator},Ie=function(e){return e.doubleClickDelay},ke=function(e){return e.disableDragAndDrop},we=function(e){return e.clearSelectionOnOutsideClick},Ee=function(e){return e.contextMenuMounted},De=function(e){return e.contextMenuConfig},Me=function(e){var t,n=De(e);return n&&n.triggerFileId&&null!=(t=re(e)[n.triggerFileId])?t:null},Ne=function(e){return e.fileActionMap},Ae=function(e){return e.optionMap},Oe=function(e){return e.fileMap},ze=function(e){return e.fileIds},Te=function(e){return e.cleanFileIds},Le=function(e){return e.sortActionId},Re=function(e){return e.sortOrder},_e=function(e){return e.searchString},je=function(e){return e.lastClick},He=function(e){return u.createSelector([Ne,e],(function(e,t){return t&&e[t]?e[t]:null}))},Pe=function(e,t){return void 0===t&&(t=void 0),u.createSelector([Ae],(function(n){var r=n[e];return void 0===r?t:r}))},Be=function(e){return u.createSelector([Oe,e],(function(e,t){return t.map((function(t){return t&&e[t]?e[t]:null}))}))},Ke=u.createSelector([ze,Re,Be(ze),He(Le),Pe(q.ShowFoldersFirst,!1)],(function(e,t,n,r,o){if(!r)return e;var i,a=function(e){return function(t){return e(t)}},l=[];return o&&l.push({desc:a(K.isDirectory)}),r.sortKeySelector&&l.push(((i={})[t===_.ASC?"asc":"desc"]=a(r.sortKeySelector),i)),0===l.length?e:f([].concat(n)).by(l).map((function(e){return e?e.id:null}))})),Ve=u.createSelector([Be(Te)],(function(e){return new p(e,["name"],{caseSensitive:!1})})),qe=u.createSelector([Te,_e,Ve],(function(e,t,n){return t?n.search(t).map((function(e){return e.id})):e})),We=u.createSelector([qe,Be(Te),Pe(q.ShowHiddenFiles)],(function(e,t,n){var r=new Set(e),o={};return t.forEach((function(e){e&&(r.has(e.id)?!n&&K.isHidden(e)&&(o[e.id]=!0):o[e.id]=!0)})),o})),Ge={getFileActionMap:Ne,getOptionMap:Ae,getFileMap:Oe,getFileIds:ze,getCleanFileIds:Te,getSortActionId:Le,getSortOrder:Re,getSearchString:_e,_getLastClick:je,getSortedFileIds:Ke,getSearcher:Ve,getSearchFilteredFileIds:qe,getHiddenFileIdMap:We,getDisplayFileIds:u.createSelector([Ke,We],(function(e,t){return e.filter((function(e){return!e||!t[e]}))})),getLastClickIndex:u.createSelector([je,Ke],(function(e,t){return!e||e.index>t.length-1||e.fileId!=t[e.index]?null:e.index})),makeGetAction:He,makeGetOptionValue:Pe,makeGetFiles:Be},Ue=function(e,t){return t?re(e)[t]:null},Ye=function(e,t){return!!de(e)[t.id]},Xe=function(e){for(var t=e.fileMap,n=e.selectionMap,r=Object.keys(n).map((function(e){return t[e]})),o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];var l=i.reduce((function(e,t){return t?e.filter(t):e}),r);return l},Ze=function(e,t){return ge(t)(e)},Qe=function(e,t){return function(n){var r,o=V("fileActions",e),i=o.sanitizedArray,a=o.errorMessages;if(Array.isArray(t)){var l=new Set(t);r=pt.filter((function(e){return!l.has(e.id)}))}else r=t?[]:pt;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,ft,r),s={};c.map((function(e){return e.option?s[e.option.id]=e.option.defaultValue:null})),n(ht.setRawFileActions(e)),n(ht.setFileActionsErrorMessages(a)),n(ht.setFileActions(c)),n(ht.setOptionDefaults(s)),n($e(c))}},$e=function(e){return function(t){for(var n,r=new Set([ut.OpenParentFolder.id]),o=[],i={},a=[],l={},c=function(e,t,n){if(t[n])return t[n];var r={name:n,fileActionIds:[]};return e.push(r),t[n]=r,r},s=R(e);!(n=s()).done;){var d=n.value,u=d.button;u&&(u.toolbar&&!r.has(d.id)&&(u.group?c(o,i,u.group).fileActionIds.push(d.id):o.push(d.id)),u.contextMenu&&(u.group?c(a,l,u.group).fileActionIds.push(d.id):a.push(d.id)))}t(ht.updateFileActionMenuItems([o,a]))}},Je=function(e){return function(t,n){var r=n(),o=e?r.fileActionMap[e]:null;o&&o.fileViewConfig&&t(ht.setFileViewConfig(o.fileViewConfig))}},et=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(ht.setSort({actionId:e,order:i}))}}}},tt=function(e){return function(t,n){B.debug("FILE ACTION DISPATCH: ["+e.id+"]","data:",e);var r=n(),o=X(r)[e.id],i=Y(r);o?i&&Promise.resolve(i(e)).catch((function(e){return B.error("User-defined file action handler threw an error: "+e.message)})):B.warn('Internal components dispatched the "'+e.id+'" file action, but such action was not registered.')}},nt=function(e,t){return function(n,r){B.debug("FILE ACTION REQUEST: ["+e.id+"]","action:",e,"payload:",t);var o=r(),i=U(o);X(o)[e.id]||B.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=me(o),l=e.fileFilter?a.filter(e.fileFilter):a;if(!e.requiresSelection||0!==l.length){var c={instanceId:i,selectedFiles:a,selectedFilesForAction:l,contextMenuTriggerFile:Me(o)};e.sortKeySelector&&n(et(e.id));var s=e.fileViewConfig;s&&n(ht.setFileViewConfig(s));var d=e.option;d&&n(ht.toggleOption(d.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(ae(o))),l=r({prevSelection:i,fileIds:oe(o),fileMap:re(o),hiddenFileIds:a});l&&t(0===l.size?ht.clearSelection():ht.selectFiles({fileIds:Array.from(l),reset:!0}))}}}(e));var u=e.effect,f=void 0;if(u)try{f=u({action:e,payload:t,state:c,reduxDispatch:n,getReduxState:r})}catch(t){B.error("User-defined effect function for action "+e.id+" threw an error: "+t.message)}return Promise.resolve(f).then((function(r){rt(n,{id:e.id,action:e,payload:t,state:c},r)})).catch((function(r){B.error("User-defined effect function for action "+e.id+" returned a promise that was rejected: "+r.message),rt(n,{id:e.id,action:e,payload:t,state:c},void 0)}))}B.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.')}},rt=function(e,t,n){!0===n||e(tt(t))};(W=exports.FileViewMode||(exports.FileViewMode={})).List="list",W.Compact="compact",W.Grid="grid",(G=exports.ChonkyIconName||(exports.ChonkyIconName={})).loading="loading",G.dropdown="dropdown",G.placeholder="placeholder",G.dndDragging="dndDragging",G.dndCanDrop="dndCanDrop",G.dndCannotDrop="dndCannotDrop",G.openFiles="openFiles",G.openParentFolder="openParentFolder",G.copy="copy",G.paste="paste",G.share="share",G.search="search",G.selectAllFiles="selectAllFiles",G.clearSelection="clearSelection",G.sortAsc="sortAsc",G.sortDesc="sortDesc",G.toggleOn="toggleOn",G.toggleOff="toggleOff",G.list="list",G.compact="compact",G.smallThumbnail="smallThumbnail",G.largeThumbnail="largeThumbnail",G.folder="folder",G.folderCreate="folderCreate",G.folderOpen="folderOpen",G.folderChainSeparator="folderChainSeparator",G.download="download",G.upload="upload",G.trash="trash",G.fallbackIcon="fallbackIcon",G.symlink="symlink",G.hidden="hidden",G.file="file",G.license="license",G.code="code",G.config="config",G.model="model",G.database="database",G.text="text",G.archive="archive",G.image="image",G.video="video",G.info="info",G.key="key",G.lock="lock",G.music="music",G.terminal="terminal",G.users="users",G.linux="linux",G.ubuntu="ubuntu",G.windows="windows",G.rust="rust",G.python="python",G.nodejs="nodejs",G.php="php",G.git="git",G.adobe="adobe",G.pdf="pdf",G.excel="excel",G.word="word",G.flash="flash";var ot,it=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 B.error(n),new Error(n)}return e.effect=t,e},at=function e(t,n){return t?n(t)?t:t.parentElement?e(t.parentElement,n):null:t},lt=function(e,t,n){return n?typeof e===n?e:t:void 0!==e?e:t},ct={MouseClickFile:it({id:"mouse_click_file",__payloadType:{}},(function(e){var t,n=e.payload,r=e.reduxDispatch,o=e.getReduxState;if("double"===n.clickType)K.isOpenable(n.file)&&r(nt(ut.OpenFiles,{targetFile:n.file,files:[n.file]}));else{var i=be(o());if(K.isSelectable(n.file)&&!i)if(n.ctrlKey)r(ht.toggleSelection({fileId:n.file.id,exclusive:!1})),r(ht.setLastClickIndex({index:n.fileDisplayIndex,fileId:n.file.id}));else if(n.shiftKey){var a=Ge.getLastClickIndex(o());if("number"==typeof a){var l=a,c=n.fileDisplayIndex;if(l>c){var s=[c,l];l=s[0],c=s[1]}r((t={rangeStart:l,rangeEnd:c},function(e,n){var r=n();if(!r.disableSelection){var o=Ge.getDisplayFileIds(r).slice(t.rangeStart,t.rangeEnd+1).filter((function(e){return e&&K.isSelectable(r.fileMap[e])}));e(ht.selectFiles({fileIds:o,reset:!!t.reset}))}}))}else r(ht.toggleSelection({fileId:n.file.id,exclusive:!1})),r(ht.setLastClickIndex({index:n.fileDisplayIndex,fileId:n.file.id}))}else r(ht.toggleSelection({fileId:n.file.id,exclusive:!0})),r(ht.setLastClickIndex({index:n.fileDisplayIndex,fileId:n.file.id}));else n.ctrlKey||i||r(ht.clearSelection()),r(ht.setLastClickIndex({index:n.fileDisplayIndex,fileId:n.file.id}))}})),KeyboardClickFile:it({id:"keyboard_click_file",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch,r=e.getReduxState;n(ht.setLastClickIndex({index:t.fileDisplayIndex,fileId:t.file.id})),t.enterKey?0===fe(r())&&n(nt(ut.OpenFiles,{targetFile:t.file,files:[t.file]})):t.spaceKey&&K.isSelectable(t.file)&&n(ht.toggleSelection({fileId:t.file.id,exclusive:t.ctrlKey}))})),StartDragNDrop:it({id:"start_drag_n_drop",__payloadType:{}},(function(e){var t=e.reduxDispatch,n=e.payload.draggedFile;Ye((0,e.getReduxState)(),n)||K.isSelectable(n)&&t(ht.selectFiles({fileIds:[n.id],reset:!0}))})),EndDragNDrop:it({id:"end_drag_n_drop",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch;if(!Ye((0,e.getReduxState)(),t.destination)){var r=t.selectedFiles;n(nt(ut.MoveFiles,T({},t,{files:r.length>0?r:[t.draggedFile]})))}})),MoveFiles:it({id:"move_files",__payloadType:{}}),ChangeSelection:it({id:"change_selection",__payloadType:{}}),OpenFiles:it({id:"open_files",__payloadType:{}}),OpenParentFolder:it({id:"open_parent_folder",hotkeys:["backspace"],button:{name:"Go up a directory",toolbar:!0,contextMenu:!1,icon:exports.ChonkyIconName.openParentFolder,iconOnly:!0}},(function(e){var t=e.reduxDispatch,n=ne((0,e.getReduxState)());K.isOpenable(n)?t(nt(ut.OpenFiles,{targetFile:n,files:[n]})):B.warn("Open parent folder effect was triggered even though the parent folder is not openable. This indicates a bug in presentation components.")})),OpenFileContextMenu:it({id:"open_file_context_menu",__payloadType:{}},(function(e){var t=e.payload,n=e.reduxDispatch,r=e.getReduxState,o=Ue(r(),t.triggerFileId);o&&(Ye(r(),o)||(K.isSelectable(o)?n(ht.selectFiles({fileIds:[t.triggerFileId],reset:!0})):n(ht.clearSelection()))),n(ht.showContextMenu({triggerFileId:t.triggerFileId,mouseX:t.clientX-2,mouseY:t.clientY-4}))}))},st={OpenSelection:it({id:"open_selection",hotkeys:["enter"],requiresSelection:!0,fileFilter:K.isOpenable,button:{name:"Open selection",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.openFiles}},(function(e){(0,e.reduxDispatch)(nt(ct.OpenFiles,{files:e.state.selectedFilesForAction}))})),SelectAllFiles:it({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:it({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}}),EnableListView:it({id:"enable_list_view",fileViewConfig:{mode:exports.FileViewMode.List,entryHeight:30},button:{name:"Switch to List view",toolbar:!0,icon:exports.ChonkyIconName.list,iconOnly:!0}}),EnableCompactView:it({id:"enable_compact_view",fileViewConfig:{mode:exports.FileViewMode.Compact,entryHeight:40,entryWidth:220},button:{name:"Switch to Compact view",toolbar:!0,icon:exports.ChonkyIconName.compact,iconOnly:!0}}),EnableGridView:it({id:"enable_grid_view",fileViewConfig:{mode:exports.FileViewMode.Grid,entryWidth:165,entryHeight:130},button:{name:"Switch to Grid view",toolbar:!0,icon:exports.ChonkyIconName.smallThumbnail,iconOnly:!0}}),SortFilesByName:it({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:it({id:"sort_files_by_size",sortKeySelector:function(e){return e?e.size:void 0},button:{name:"Sort by size",toolbar:!0,group:"Options"}}),SortFilesByDate:it({id:"sort_files_by_date",sortKeySelector:function(e){return e?e.modDate:void 0},button:{name:"Sort by date",toolbar:!0,group:"Options"}}),ToggleHiddenFiles:it({id:"toggle_hidden_files",hotkeys:["ctrl+h"],option:{id:q.ShowHiddenFiles,defaultValue:!0},button:{name:"Show hidden files",toolbar:!0,group:"Options"}}),ToggleShowFoldersFirst:it({id:"toggle_show_folders_first",option:{id:q.ShowFoldersFirst,defaultValue:!0},button:{name:"Show folders first",toolbar:!0,group:"Options"}}),FocusSearchInput:it({id:"focus_search_input",hotkeys:["ctrl+f"]},(function(e){var t=ce((0,e.getReduxState)());t&&t()})),ToggleDarkMode:it({id:"enable_dark_mode",option:{id:q.DarkMode,defaultValue:!1},button:{name:"Enable dark mode",toolbar:!0,icon:exports.ChonkyIconName.list,iconOnly:!0}})},dt={CopyFiles:it({id:"copy_files",requiresSelection:!0,hotkeys:["ctrl+c"],button:{name:"Copy selection",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.copy}}),CreateFolder:it({id:"create_folder",button:{name:"Create folder",toolbar:!0,tooltip:"Create a folder",icon:exports.ChonkyIconName.folderCreate}}),UploadFiles:it({id:"upload_files",button:{name:"Upload files",toolbar:!0,tooltip:"Upload files",icon:exports.ChonkyIconName.upload}}),DownloadFiles:it({id:"download_files",requiresSelection:!0,button:{name:"Download files",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.download}}),DeleteFiles:it({id:"delete_files",requiresSelection:!0,hotkeys:["delete"],button:{name:"Delete files",toolbar:!0,contextMenu:!0,group:"Actions",icon:exports.ChonkyIconName.trash}})},ut=T({},ct,st,dt),ft=[ut.MouseClickFile,ut.KeyboardClickFile,ut.StartDragNDrop,ut.EndDragNDrop,ut.MoveFiles,ut.ChangeSelection,ut.OpenFiles,ut.OpenParentFolder,ut.OpenFileContextMenu],pt=[ut.OpenSelection,ut.SelectAllFiles,ut.ClearSelection,ut.EnableListView,ut.EnableGridView,ut.SortFilesByName,ut.SortFilesBySize,ut.SortFilesByDate,ut.ToggleHiddenFiles,ut.ToggleShowFoldersFirst,ut.FocusSearchInput],mt={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,searchString:"",searchMode:"currentFolder",selectionMap:{},disableSelection:!1,fileViewConfig:ut.EnableGridView.fileViewConfig,sortActionId:null,sortOrder:_.ASC,optionMap:{},thumbnailGenerator:null,doubleClickDelay:300,disableDragAndDrop:!1,clearSelectionOnOutsideClick:!0,lastClick:null,contextMenuMounted:!1,contextMenuConfig:null},gt=u.createSlice({name:"root",initialState:mt,reducers:{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=V("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=V("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,d=Object.keys(e.selectionMap);s<d.length;s++){var u=d[s];a[u]||delete e.selectionMap[u]}},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]}},setFocusSearchInput:function(e,t){e.focusSearchInput=t.payload},setSearchString:function(e,t){e.searchString=t.payload},selectAllFiles:function(e){e.fileIds.filter((function(t){return t&&K.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&&K.isSelectable(e.fileMap[t])})).map((function(t){return e.selectionMap[t]=!0})))},toggleSelection:function(e,t){if(!e.disableSelection){var n=!!e.selectionMap[t.payload.fileId];t.payload.exclusive&&(e.selectionMap={}),n?delete e.selectionMap[t.payload.fileId]:K.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={})},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]},setThumbnailGenerator:function(e,t){e.thumbnailGenerator=t.payload},setDoubleClickDelay:function(e,t){e.doubleClickDelay=t.payload},setDisableDragAndDrop:function(e,t){e.disableDragAndDrop=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)}}}),ht=gt.actions,bt=gt.reducer,yt=function(e){var t=H((function(){var t=T({},mt,{instanceId:e});return u.configureStore({preloadedState:t,reducer:bt,middleware:function(e){return e({serializableCheck:!1})},devTools:{name:"chonky_"+e}})}));return function(e){r.useEffect((function(){var t=m((function(){return de(e.getState())})),n=[e.subscribe(t((function(t,n){if(t!==n){var r=ue(e.getState()),o=new Set(r);e.dispatch(nt(ut.ChangeSelection,{selection:o}))}})))];return function(){for(var e,t=R(n);!(e=t()).done;)(0,e.value)()}}),[e])}(t),t},vt=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];var i=r.useCallback((function(t){return e.apply(void 0,n)(t)}),[e].concat(n));return s.useSelector(i)},xt=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];var i=s.useDispatch();r.useEffect((function(){i(e.apply(void 0,n))}),[i,e].concat(n))},Ct=function(e,t){var n=s.useDispatch();r.useEffect((function(){n(e(t))}),[n,e,t])},St=function(){return o.createElement("span",{title:"No icon component found. Please follow Chonky installation instructions to provide a pre-made icon component (or a custom icon)."},"⚠️")},Ft={fileActions:null,onFileAction:null,thumbnailGenerator:null,doubleClickDelay:300,disableSelection:!1,disableDefaultFileActions:!1,disableDragAndDrop:!1,disableDragAndDropProvider:!1,defaultSortActionId:ut.SortFilesByName.id,defaultFileViewActionId:ut.EnableGridView.id,clearSelectionOnOutsideClick:!0,iconComponent:St,darkMode:!1,i18n:{}};(ot=exports.I18nNamespace||(exports.I18nNamespace={})).Toolbar="toolbar",ot.FileList="fileList",ot.FileEntry="fileEntry",ot.FileContextMenu="contextMenu",ot.FileActions="actions",ot.FileActionGroups="actionGroups";var It=function(e,t){return"chonky."+e+"."+t},kt=function(e,t){return"chonky."+exports.I18nNamespace.FileActions+"."+e+"."+t},wt=function(e){var t=l.useIntl();return r.useMemo((function(){var n,r;if(!e)return{buttonName:"",buttonTooltip:void 0};var o,i=t.formatMessage({id:kt(e.id,"button.name"),defaultMessage:null==(n=e.button)?void 0:n.name}),a=void 0;return null!=(r=e.button)&&r.tooltip&&(a=t.formatMessage({id:kt(e.id,"button.tooltip"),defaultMessage:null==(o=e.button)?void 0:o.tooltip})),{buttonName:i,buttonTooltip:a}}),[e,t])},Et=function(e){var t=l.useIntl(),n=r.useContext(Mt);return r.useMemo((function(){return{fileModDateString:n.formatFileModDate(t,e),fileSizeString:n.formatFileSize(t,e)}}),[e,n,t])},Dt={formatFileModDate:function(e,t){var n=K.getModDate(t);return n?e.formatDate(n,{dateStyle:"medium",timeStyle:"short"}):null},formatFileSize:function(e,t){if(!t||"number"!=typeof t.size)return null;var n=g(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}},Mt=r.createContext(Dt),Nt=r.createContext(St),At=["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"],Ot=["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"],zt=["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"],Tt=["#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"],Lt=["#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"],Rt=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,Ot],[exports.ChonkyIconName.video,At],[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,zt],[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.adobe,["psd"]],[exports.ChonkyIconName.pdf,["pdf"]],[exports.ChonkyIconName.excel,["xls","xlsx"]],[exports.ChonkyIconName.word,["doc","docx","odt"]],[exports.ChonkyIconName.flash,["swf"]]],n=new h({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)%(Tt.length-1)+1},!0);return n}(),_t={colors:{debugRed:"#fabdbd",debugBlue:"#bdd8fa",debugGreen:"#d2fabd",debugPurple:"#d2bdfa",debugYellow:"#fae9bd",textActive:"#09f"},fontSizes:{rootPrimary:15},margins:{rootLayoutMargin:8},toolbar:{size:30,lineHeight:"30px",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,fileColorTint:"rgba(255, 255, 255, 0.4)",folderBackColorTint:"rgba(255, 255, 255, 0.1)",folderFrontColorTint:"rgba(255, 255, 255, 0.4)"},listFileEntry:{propertyFontSize:14,iconFontSize:"1.1em",iconBorderRadius:5,fontSize:14}},jt={gridFileEntry:{fileColorTint:"rgba(50, 50, 50, 0.4)",folderBackColorTint:"rgba(50, 50, 50, 0.4)",folderFrontColorTint:"rgba(50, 50, 50, 0.15)"}},Ht={fontSizes:{rootPrimary:13},margins:{rootLayoutMargin:4},toolbar:{size:28,lineHeight:"28px",fontSize:13},gridFileEntry:{fontSize:13},listFileEntry:{propertyFontSize:12,iconFontSize:"1em",fontSize:13}},Pt=function(){return b("(max-width:480px)")},Bt=function(e,t){return"repeating-linear-gradient(45deg,"+e+","+e+" 10px,"+t+" 0,"+t+" 20px)"},Kt=function(e){return c.createUseStyles(e)},Vt=function(e){var t={},n=c.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]})),T({},r,e)}},qt=function(e){return[e,"!important"]},Wt=y,Gt=o.memo(o.forwardRef((function(e,t){var n;return Ct(ht.setRawFiles,null!=(n=e.files)?n:mt.rawFiles),Ct(ht.setRawFolderChain,e.folderChain),xt(Qe,lt(e.fileActions,Ft.fileActions),lt(e.disableDefaultFileActions,Ft.disableDefaultFileActions)),xt(ht.setExternalFileActionHandler,lt(e.onFileAction,Ft.onFileAction)),xt(ht.setSelectionDisabled,lt(e.disableSelection,Ft.disableSelection,"boolean")),xt(et,lt(e.defaultSortActionId,Ft.defaultSortActionId)),xt(Je,lt(e.defaultFileViewActionId,Ft.defaultFileViewActionId,"string")),xt(ht.setThumbnailGenerator,lt(e.thumbnailGenerator,Ft.thumbnailGenerator)),xt(ht.setDoubleClickDelay,lt(e.doubleClickDelay,Ft.doubleClickDelay,"number")),xt(ht.setDisableDragAndDrop,lt(e.disableDragAndDrop,Ft.disableDragAndDrop,"boolean")),xt(ht.setClearSelectionOnOutsideClick,lt(e.clearSelectionOnOutsideClick,Ft.clearSelectionOnOutsideClick,"boolean")),function(e){var t=s.useStore(),n=s.useDispatch();r.useImperativeHandle(e,(function(){return{getFileSelection:function(){var e=de(t.getState());return new Set(Object.keys(e))},setFileSelection:function(e,t){void 0===t&&(t=!0);var r=Array.from(e);n(ht.selectFiles({fileIds:r,reset:t}))},requestFileAction:function(e,t){return Promise.resolve(n(nt(e,t))).then()}}}),[t,n])}(t),null})));Gt.displayName="ChonkyBusinessLogicInner";var Ut=o.memo(Gt);Ut.displayName="ChonkyBusinessLogic";var Yt=function(){return!!r.useContext(i.DndContext).dragDropManager},Xt={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},Zt=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}},Qt=function(){var e=$t(),t=i.useDragLayer((function(e){return{item:e.getItem(),itemType:e.getItemType(),initialCursorOffset:e.getInitialClientOffset(),initialFileOffset:e.getInitialSourceClientOffset(),currentFileOffset:e.getSourceClientOffset(),isDragging:e.isDragging()}})),n=t.item;if(!t.isDragging||"dnd-chonky-file-entry"!==t.itemType||!n.payload)return null;var r=n.payload.selectedFiles.length;return o.createElement("div",{style:Xt},o.createElement("div",{style:Zt(t.initialCursorOffset,t.initialFileOffset,t.currentFileOffset)},o.createElement("div",{className:e.fileDragPreview},o.createElement("b",null,n.payload.draggedFile.name),r>1&&o.createElement(o.Fragment,null," and ",o.createElement("strong",null,r-1," other file",r-1!=1?"s":"")))))},$t=Vt((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"}}})),Jt=o.memo((function(e){var t=e.fileActionId,n=s.useDispatch(),o=vt(Q,t);return r.useEffect((function(){if(o&&o.hotkeys&&0!==o.hotkeys.length){var e=o.hotkeys.join(","),t=function(e){e.preventDefault(),n(nt(o,void 0))};return C(e,t),function(){return C.unbind(e,t)}}}),[n,o]),null})),en=function(e){var t=e.children,n=s.useDispatch(),i=s.useSelector(Z),a=s.useSelector(ke),l=s.useSelector(we),c=r.useCallback((function(e){l&&!at(e.target,(function(e){return e.tagName&&"button"===e.tagName.toLowerCase()}))&&n(ht.clearSelection())}),[n,l]),d=r.useMemo((function(){return i.map((function(e){return o.createElement(Jt,{key:"file-action-listener-"+e,fileActionId:e})}))}),[i]),u=Yt(),f=function(){var e=s.useDispatch(),t=P(s.useSelector(Ee));return r.useCallback((function(n){if(t.current&&!n.altKey){n.preventDefault();var r,o=(r=at(n.target,(function(e){return e.tagName&&"div"===e.tagName.toLowerCase()&&e.dataset&&e.dataset.chonkyFileId})))?r.dataset.chonkyFileId:null;e(nt(ut.OpenFileContextMenu,{clientX:n.clientX,clientY:n.clientY,triggerFileId:o}))}}),[t,e])}(),p=tn();return o.createElement(x,{onClickAway:c},o.createElement(v,{className:p.chonkyRoot,onContextMenu:f},!a&&u&&o.createElement(Qt,null),d,t||null))},tn=Vt((function(e){return{chonkyRoot:{backgroundColor:e.palette.background.paper,border:"solid 1px "+e.palette.divider,padding:e.margins.rootLayoutMargin,fontSize:e.fontSizes.rootPrimary,color:e.palette.text.primary,touchAction:"manipulation",fontFamily:"sans-serif",flexDirection:"column",boxSizing:"border-box",textAlign:"left",borderRadius:4,display:"flex",height:"100%",webkitTouchCallout:"none",webkitUserSelect:"none",mozUserSelect:"none",msUserSelect:"none",userSelect:"none"}}})),nn=o.forwardRef((function(e,u){var f,p=e.instanceId,m=e.iconComponent,g=e.children,h=lt(e.disableDragAndDrop,Ft.disableDragAndDrop,"boolean"),b=lt(e.disableDragAndDropProvider,Ft.disableDragAndDropProvider,"boolean"),y=lt(e.darkMode,Ft.darkMode,"boolean"),v=lt(e.i18n,Ft.i18n),x=r.useMemo((function(){return T({},Dt,null==v?void 0:v.formatters)}),[v]),C=H((function(){return null!=p?p:d.generate()})),S=yt(C),F=Pt(),I=r.useMemo((function(){var e=t.createMuiTheme({palette:{type:y?"dark":"light"}}),r=n(e,n(_t,y?jt:{}));return F?n(r,Ht):r}),[y,F]),k=o.createElement(o.Fragment,null,o.createElement(Ut,Object.assign({ref:u},e)),o.createElement(en,null,g));return o.createElement(l.IntlProvider,Object.assign({locale:"en",defaultLocale:"en"},v),o.createElement(Mt.Provider,{value:x},o.createElement(s.Provider,{store:S},o.createElement(c.ThemeProvider,{theme:I},o.createElement(t.ThemeProvider,{theme:I},o.createElement(Nt.Provider,{value:null!=(f=null!=m?m:Ft.iconComponent)?f:St},h||b?k:o.createElement(i.DndProvider,{backend:a.HTML5Backend},k)))))))}));nn.displayName="FileBrowser";var rn,on=function(e){var t=e.file,n=e.forceDisableDrop,o=e.includeChildrenDrops,a=P(s.useSelector(ee)),l=function(){var e=Yt(),t=r.useCallback((function(){return[{},function(){return null}]}),[]),n=e?i.useDrop:t;return n.apply(void 0,arguments)}({accept:"dnd-chonky-file-entry",drop:r.useCallback((function(e,n){if(n.canDrop())return{dropTarget:t}}),[t]),canDrop:r.useCallback((function(e,r){if(n||!K.isDroppable(t)||!r.isOver({shallow:!0})&&!o)return!1;var i=e.payload,l=i.source,c=i.draggedFile,s=i.selectedFiles,d=new Set;d.add(t.id),a.current.map((function(e){e&&d.add(e.id)}));for(var u,f=R([c].concat(s));!(u=f()).done;)if(d.has(u.value.id))return!1;return t.id!==(null==l?void 0:l.id)}),[n,t,o,a]),collect:r.useCallback((function(e){return{isOver:e.isOver(),isOverCurrent:e.isOver({shallow:!0}),canDrop:e.canDrop()}}),[])}),c=l[0];return{dndIsOver:c.isOver,dndIsOverCurrent:c.isOverCurrent,dndCanDrop:c.canDrop,drop:l[1]}},an=function(e,t){var n=s.useDispatch(),o=P(s.useSelector(te));r.useEffect((function(){var r,i=null;return t.dndIsOver&&K.isDndOpenable(e)&&e.id!==(null==(r=o.current)?void 0:r.id)&&(i=setTimeout((function(){return n(nt(ct.OpenFiles,{targetFile:e,files:[e]}))}),1500)),function(){i&&clearTimeout(i)}}),[n,e,t.dndIsOver,o])},ln=o.memo((function(e){var t,n,r=(n=e.maxLength,(t=e.minLength)+Math.floor(Math.random()*Math.floor(n-t))),i="&nbsp;".repeat(r),a=cn();return o.createElement("span",{className:a.textPlaceholder,dangerouslySetInnerHTML:{__html:i}})})),cn=Kt((function(){return{"@keyframes loading-placeholder":{"0%":{opacity:.2},"50%":{opacity:.4},"100%":{opacity:.2}},textPlaceholder:{animationName:"$loading-placeholder",animationIterationCount:"infinite",animationTimingFunction:"linear",animationDuration:"1.5s",backgroundColor:"#ccc",whiteSpace:"nowrap",overflow:"hidden",borderRadius:4,maxWidth:"40%",minWidth:20}}})),sn=function(e){return r.useMemo((function(){return T({role:"listitem"},{"data-test-id":"file-entry","data-chonky-file-id":e?e.id:void 0})}),[e])},dn=function(e,t,n){var o=function(e){return r.useMemo((function(){return e?!0===e.isDir?{icon:exports.ChonkyIconName.folder,colorCode:0}:Rt.getWithCheckpoints(e.name,".",!0)||{icon:exports.ChonkyIconName.file,colorCode:32}:{icon:exports.ChonkyIconName.loading,colorCode:0}}),[e])}(e),i=fn(e),a=i.thumbnailUrl,l=i.thumbnailLoading;return r.useMemo((function(){var r=a?Lt[o.colorCode]:Tt[o.colorCode],i=l||!e,c=l?exports.ChonkyIconName.loading:o.icon;return{childrenCount:K.getChildrenCount(e),icon:e&&void 0!==e.icon?e.icon:c,iconSpin:i,thumbnailUrl:a,color:e&&void 0!==e.color?e.color:r,selected:t,focused:!!n}}),[e,n,o,t,l,a])},un=function(e){var t=null;return e.dndIsOver?t=e.dndCanDrop?exports.ChonkyIconName.dndCanDrop:exports.ChonkyIconName.dndCannotDrop:e.dndIsDragging&&(t=exports.ChonkyIconName.dndDragging),t},fn=function(e){var t=s.useSelector(Fe),n=r.useState(null),o=n[0],i=n[1],a=r.useState(!1),l=a[0],c=a[1],d=r.useRef(0);return r.useEffect((function(){var n=!1;return e&&(t?(0===d.current&&c(!0),d.current++,Promise.resolve().then((function(){return t(e)})).then((function(e){n||(c(!1),e&&"string"==typeof e&&i(e))})).catch((function(e){n||c(!1),B.error('User-defined "thumbnailGenerator" handler threw an error: '+e.message)}))):e.thumbnailUrl&&i(e.thumbnailUrl)),function(){n=!0}}),[e,i,c,t]),{thumbnailUrl:o,thumbnailLoading:l}};(rn=exports.CustomVisibilityState||(exports.CustomVisibilityState={}))[rn.Hidden=0]="Hidden",rn[rn.Disabled=1]="Disabled",rn[rn.Default=2]="Default",rn[rn.Active=3]="Active";var pn=function(e){var t=s.useDispatch(),n=vt(Q,e);return r.useCallback((function(){return t(nt(n,void 0))}),[t,n])},mn=function(e){var t,n=s.useSelector(ne),o=s.useSelector(ye),i=s.useSelector(ve),a=s.useSelector(xe),l=vt(Q,e),c=vt(Se,null==l||null==(t=l.option)?void 0:t.id),d=0===vt(he,e);return r.useMemo((function(){var e,t;if(!l)return{icon:null,active:!1,disabled:!0};var r=null!=(e=null==(t=l.button)?void 0:t.icon)?e:null;l.sortKeySelector?r=i===l.id?a===_.ASC?exports.ChonkyIconName.sortAsc:exports.ChonkyIconName.sortDesc:exports.ChonkyIconName.placeholder:l.option&&(r=c?exports.ChonkyIconName.toggleOn:exports.ChonkyIconName.toggleOff);var s=l.id===i,u=l.fileViewConfig===o,f=!!l.option&&!!c,p=!1,m=!1;void 0!==l.customVisibility&&(p=l.customVisibility()===exports.CustomVisibilityState.Disabled,m=l.customVisibility()===exports.CustomVisibilityState.Active);var g=s||u||f||m,h=!!l.requiresSelection&&d||p;return l.id===ut.OpenParentFolder.id&&(h=h||!K.isOpenable(n)),{icon:r,active:g,disabled:h}}),[n,o,i,a,l,c,d])},gn=o.memo((function(e){var t,n=e.className,i=e.text,a=e.tooltip,l=e.active,c=e.icon,s=e.iconOnly,d=e.onClick,u=e.disabled,f=e.dropdown,p=hn(),m=r.useContext(Nt),g=c||s?o.createElement("div",{className:s?"":p.iconWithText},o.createElement(m,{icon:c||exports.ChonkyIconName.fallbackIcon,fixedWidth:!0})):null,h=Wt(((t={})[null!=n?n:""]=!0,t[p.baseButton]=!0,t[p.iconOnlyButton]=s,t[p.activeButton]=!!l,t));return o.createElement(F,{className:h,onClick:d,title:a||i,disabled:u||!d},g,i&&!s&&o.createElement("span",null,i),f&&o.createElement("div",{className:p.iconDropdown},o.createElement(m,{icon:c||exports.ChonkyIconName.dropdown,fixedWidth:!0})))})),hn=Vt((function(e){return{baseButton:{fontSize:qt(e.toolbar.fontSize),textTransform:qt("none"),letterSpacing:qt(0),minWidth:qt("auto"),lineHeight:e.toolbar.lineHeight,height:e.toolbar.size,paddingBottom:qt(0),paddingTop:qt(0)},iconWithText:{marginRight:8},iconOnlyButton:{width:e.toolbar.size,textAlign:"center"},iconDropdown:{fontSize:"0.7em",marginLeft:2,marginTop:1},activeButton:{color:qt(e.colors.textActive)}}})),bn=o.memo((function(e){var t=e.fileActionId,n=vt(Q,t),r=pn(t),i=mn(t),a=i.icon,l=i.active,c=i.disabled,s=wt(n),d=s.buttonName,u=s.buttonTooltip;if(!n)return null;var f=n.button;return f?void 0!==n.customVisibility&&n.customVisibility()===exports.CustomVisibilityState.Hidden?null:o.createElement(gn,{text:d,tooltip:u,icon:a,iconOnly:f.iconOnly,active:l,onClick:r,disabled:c}):null})),yn=o.memo((function(e){var t,n=e.first,i=e.current,a=e.item,l=a.file,c=a.disabled,s=a.onClick,d=on({file:l,forceDisableDrop:!l||i}),u=d.dndIsOver,f=d.dndCanDrop,p=d.drop,m=r.useMemo((function(){return{dndIsOver:u,dndCanDrop:f,dndIsDragging:!1}}),[f,u]);an(l,m);var g=un(m),h=r.useContext(Nt),b=vn(m),y=Wt(((t={})[b.baseBreadcrumb]=!0,t[b.disabledBreadcrumb]=c,t[b.currentBreadcrumb]=i,t)),v=l?l.name:"Loading...",x=n&&void 0===(null==l?void 0:l.folderChainIcon)?exports.ChonkyIconName.folder:null==l?void 0:l.folderChainIcon;return o.createElement("div",{className:b.buttonContainer,ref:l?p:null},l&&g&&o.createElement("div",{className:b.dndIndicator},o.createElement(h,{icon:g,fixedWidth:!0})),o.createElement(gn,{icon:x,className:y,text:v,disabled:c,onClick:s}))})),vn=Kt((function(e){return{buttonContainer:{position:"relative"},baseBreadcrumb:{color:function(t){var n=e.palette.text.primary;return t.dndIsOver&&(n=t.dndCanDrop?e.dnd.canDropColor:e.dnd.cannotDropColor),qt(n)}},disabledBreadcrumb:{color:function(){return qt(e.palette.text.disabled)}},currentBreadcrumb:{textDecoration:qt("underline")},dndIndicator:{color:function(t){return t.dndCanDrop?e.dnd.canDropColor:e.dnd.cannotDropColor},backgroundColor:function(t){return t.dndCanDrop?e.dnd.canDropMask:e.dnd.cannotDropMask},lineHeight:"calc("+e.toolbar.lineHeight+" - 6px)",transform:"translateX(-50%) translateY(-50%)",borderRadius:e.toolbar.buttonRadius,height:e.toolbar.size-6,width:e.toolbar.size-6,boxSizing:"border-box",position:"absolute",textAlign:"center",left:"50%",top:"50%",zIndex:5}}})),xn=o.memo((function(){var e,t,n=Cn(),i=(e=s.useSelector(ee),t=s.useDispatch(),r.useMemo((function(){var n=[];if(!e)return n;for(var r=function(r){var o=e[r];n.push({file:o,disabled:!o,onClick:K.isOpenable(o)&&r!==e.length-1?function(){return t(nt(ut.OpenFiles,{targetFile:o,files:[o]}))}:void 0})},o=0;o<e.length;++o)r(o);return n}),[t,e])),a=r.useMemo((function(){for(var e=[],t=0;t<i.length;++t){var n=o.createElement(yn,{key:"folder-chain-"+t,first:0===t,current:t===i.length-1,item:i[t]});e.push(n)}return e}),[i]);return o.createElement(v,{className:n.navbarWrapper},o.createElement(v,{className:n.navbarContainer},o.createElement(bn,{fileActionId:ut.OpenParentFolder.id}),o.createElement(S,{className:n.navbarBreadcrumbs,classes:{separator:n.separator}},a)))})),Cn=Vt((function(e){return{navbarWrapper:{paddingBottom:e.margins.rootLayoutMargin},navbarContainer:{display:"flex"},upDirectoryButton:{fontSize:qt(e.toolbar.fontSize),height:e.toolbar.size,width:e.toolbar.size,padding:"0px !important"},navbarBreadcrumbs:{fontSize:qt(e.toolbar.fontSize),flexGrow:100},separator:{marginRight:qt(4),marginLeft:qt(4)}}})),Sn=o.forwardRef((function(e,t){var n,i=e.text,a=e.active,l=e.icon,c=e.onClick,s=e.disabled,d=Fn(),u=r.useContext(Nt),f=Wt(((n={})[d.baseButton]=!0,n[d.activeButton]=a,n));return o.createElement(E,{ref:t,className:f,onClick:c,disabled:s},l&&o.createElement(k,{className:d.icon},o.createElement(u,{icon:l,fixedWidth:!0})),o.createElement(w,{primaryTypographyProps:{className:d.text}},i))})),Fn=Vt((function(e){return{baseButton:{lineHeight:qt(e.toolbar.lineHeight),height:qt(e.toolbar.size),minHeight:qt("auto"),minWidth:qt("auto"),padding:qt(20)},icon:{fontSize:qt(e.toolbar.fontSize),minWidt