1import{ae as D,bx as x,j as e,r as l,v as g,T as s,a6 as f,cX as y,D as C,a4 as v,W as T,a5 as S,Q as c,$ as w,G as I,H as P,aa as E,b as A}from"./main-BEfQELxr.js";import{a as H}from"./admin-config-BaCrw7Kt.js";import{D as M}from"./settings-links-BagG4yO6.js";import{u as k,a as F,G as L,D as N,b as B,c as R}from"./use-datatable-query-DPUO64j4.js";import{D as Q}from"./data-table-export-csv-button-B0E1O6mX.js";import{D as $}from"./data-table-add-item-button-BdngBic4.js";import{a as q,D as O,b as W,c as G}from"./datatable-page-with-header-layout-DgFKm91D.js";import{T as z}from"./table-Bdp6S_DF.js";import{F as K}from"./formatted-date-B-08Y9yP.js";import{D as V}from"./Delete-C1DnnIWN.js";import{E as _}from"./Edit-gh_pXqg9.js";import{M as U}from"./MoreVert-Dq4kJhtz.js";import{C as X}from"./confirmation-dialog-CYwhNB58.js";import{T as J,a as Y,b as Z}from"./tabs-QG1LNIzu.js";import{t as ee}from"./team-DYmDDGxN.js";import"./Album-CXNrxcWI.js";import"./Comment-TqhRbk6J.js";import"./FileUpload-DPKPUe4e.js";import"./Mic-cPqrQSx8.js";import"./PlaylistPlay-jDnYmdDX.js";import"./QueueMusic-C8vaKlwp.js";import"./Sell-DvbBmLb2.js";import"./external-link-CT1zJoZ3.js";import"./FilterAlt-Cy68O-Jt.js";import"./form-normalized-model-chip-field-4XjViKi1.js";import"./use-normalized-models-ChKc2G_X.js";import"./form-chip-field-82C9gJw-.js";import"./input-BypPJ39K.js";import"./chip-list-CnaxlPJ9.js";import"./accordion-CpkAY-cS.js";import"./checkbox-C191zCCH.js";import"./CheckBoxOutlineBlank-B_WkUAPG.js";import"./ArrowRightAlt-CIybcFtZ.js";import"./DateRange-DXC1xWJJ.js";import"./use-base-date-picker-state-C8djIY4i.js";import"./use-date-formatter-BKDPf1lG.js";import"./DateFormatter-Dix9bfnP.js";import"./KeyboardArrowRight-BVstfQVU.js";import"./use-date-range-picker-state-CLLDtAYm.js";import"./list-C_muhLNE.js";import"./switch-kVp777pB.js";import"./dialog-footer-DZFPEWVp.js";import"./is-tablet-media-query-BWKVDwFI.js";import"./use-current-date-time-Bg8tRM7A.js";import"./select-DvPFHFsY.js";import"./combobox-end-adornment-B98K5MYg.js";import"./normalized-model-field-AJN-ee7u.js";import"./skeleton-IvCa_cqw.js";import"./FileDownload-ONH9vaCD.js";import"./download-file-from-url-BVaKcxRP.js";import"./Add-Cqjx6ezR.js";import"./dashboard-layout-context-Ors6hOMs.js";import"./use-toggle-dashboard-left-sidebar-BNAUqBUz.js";import"./ArrowDownward-i0hV0JR6.js";import"./useInteractOutside-Iqh6soAi.js";import"./useEffectEvent-TynbBUG3.js";import"./is-ctrl-or-shift-pressed-CMgU9cG9.js";import"./use-pointer-events-CdAPueCj.js";import"./useGlobalListeners-BF1tAQIT.js";const te=[{key:"name",allowsSorting:!0,visibleInMode:"all",header:()=>e.jsx(s,{message:"Role"}),body:t=>e.jsxs("div",{children:[e.jsx("div",{children:e.jsx(s,{message:t.name})}),e.jsx("div",{className:"overflow-x-hidden overflow-ellipsis text-xs text-muted",children:t.description?e.jsx(s,{message:t.description}):void 0})]})},{key:"updated_at",maxWidth:"max-w-100",allowsSorting:!0,header:()=>e.jsx(s,{message:"Last updated"}),body:t=>e.jsx(K,{date:t.updated_at})},{key:"actions",header:()=>e.jsx(s,{message:"Actions"}),hideHeader:!0,visibleInMode:"all",align:"end",width:"w-84 flex-shrink-0",body:t=>e.jsx(se,{role:t})}];function dt(){var p;const t=D(),{searchParams:o,sortDescriptor:i,mergeIntoSearchParams:n,setSearchQuery:u,isFiltering:h}=k(y),m=F(x.roles.index(o)),j=e.jsxs(l.Fragment,{children:[e.jsx(Q,{endpoint:"roles/csv/export"}),e.jsx($,{elementType:g,to:`new?type=${o.type??"users"}`,children:e.jsx(s,{message:"Add new role"})})]}),r=(p=l.useContext(f).roles)==null?void 0:p.types,b=o.type?r==null?void 0:r.findIndex(a=>a.type===o.type):0,d=r!=null&&r.length?e.jsx(J,{selectedTab:b,onTabChange:a=>{n({type:r[a].type})},children:e.jsx(Y,{className:"mx-24",children:r.map(a=>e.jsx(Z,{className:"min-w-100",children:e.jsx(s,{...a.label})},a.type))})}):null;return e.jsxs(q,{children:[e.jsx(L,{query:m}),e.jsx(O,{title:e.jsx(s,{message:"Roles"}),showSidebarToggleButton:!0,border:d?"border-none":void 0,rightContent:e.jsx(M,{variant:"button",link:H.pages.roles,size:"xs"})}),d,e.jsxs(W,{children:[e.jsx(N,{searchValue:o.query,onSearchChange:u,actions:j}),e.jsxs(G,{children:[e.jsx(z,{columns:te,data:m.items,sortDescriptor:i,onSortChange:n,enableSelection:!1,onAction:a=>t(`${a.id}/edit`),cellHeight:"h-64"}),m.isEmpty?e.jsx(B,{image:ee,isFiltering:h,title:e.jsx(s,{message:"No roles have been created yet"}),filteringTitle:e.jsx(s,{message:"No matching roles"})}):null,e.jsx(R,{query:m,onPageChange:a=>n({page:a}),onPerPageChange:a=>n({perPage:a})})]})]})]})}function se({role:t}){const[o,i]=l.useState(!1);return e.jsxs(l.Fragment,{children:[e.jsx(C,{type:"modal",isOpen:o,onOpenChange:i,children:e.jsx(ae,{roleId:t.id})}),e.jsxs(v,{children:[e.jsx(T,{size:"md",className:"text-muted",children:e.jsx(U,{})}),e.jsxs(S,{children:[e.jsx(c,{value:"edit",elementType:g,to:`${t.id}/edit`,startIcon:e.jsx(_,{}),children:e.jsx(s,{message:"Edit"})}),!t.internal&&e.jsx(c,{value:"delete",onSelected:()=>i(!0),startIcon:e.jsx(V,{}),children:e.jsx(s,{message:"Delete"})})]})]})]})}function ae({roleId:t}){const{close:o}=w(),i=I({mutationFn:()=>A.delete(`roles/${t}`),onSuccess:()=>{E.invalidateQueries({queryKey:x.roles.invalidateKey}),o()},onError:n=>P(n)});return e.jsx(X,{isDanger:!0,title:e.jsx(s,{message:"Delete role"}),body:e.jsx(s,{message:"Are you sure you want to delete this role?"}),confirm:e.jsx(s,{message:"Delete"}),isLoading:i.isPending,onConfirm:()=>{i.mutate()}})}
1export{dt as Component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.