import e from"@babel/runtime/helpers/slicedToArray";import{useState as i}from"react";import r from"prop-types";import{Collapse as t,List as n}from"@material-ui/core";import o from"../FolderMenuItem/index.js";import"../EditableItem/EditableItem/index.js";import d from"../EditableItem/EditableItemWithBadge/index.js";import{jsxs as l,jsx as s}from"react/jsx-runtime";var u=function(r){var u=r.folderColor,a=r.id,m=r.isCreatable,c=r.isOpen,f=r.items,p=r.name,b=r.onAdd,C=r.onFolderClick,g=r.onItemClick,I=r.onSave,q=r.selectedItemId,R=i(c),E=e(R,2),k=E[0],v=E[1],h=function(e){return function(){return g(e)}},x=function(e){return function(i){return I({id:e,title:i})}};return l("div",{children:[s(o,{folderColor:u,isCreatable:m,isOpen:k,isSelected:q===a,name:p,onAdd:function(){return b(a)},onClick:function(){k||v(!0),q!==a&&C()},onToggle:function(){return v(!k)}}),s(t,{in:k,timeout:"auto",unmountOnExit:!0,children:s(n,{disablePadding:!0,children:f.map((function(e){return s(d,{isEditable:e.isEditable,isSelected:q===e.id,onClick:h(e),onSave:x(e.id),value:e.title},e.id)}))})})]})};u.propTypes={id:r.string.isRequired,isOpen:r.bool,selectedItemId:r.string.isRequired,items:r.arrayOf(r.shape({id:r.string.isRequired,title:r.string.isRequired,isEditable:r.bool,url:r.string.isRequired})),name:r.string.isRequired,onItemClick:r.func.isRequired,onFolderClick:r.func,folderColor:r.string.isRequired,isCreatable:r.bool,onSave:r.func.isRequired,onAdd:r.func.isRequired},u.defaultProps={isCreatable:!1,isOpen:!0,items:[],onFolderClick:function(){}};export{u as default};
