import{u as oe,K as J,h as I,N as ge,a3 as Ye}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{r as s}from"./index-NdkWRN8K.js";import{M as K}from"./Box-1mvP3NLW.js";import{M as ee}from"./MenuButton-B3T7c15t.js";import{M as Ze}from"./Callout-FZxPpigF.js";import{c as Le}from"./createUniqueId-ByTaVY63.js";import{u as Oe,a as en}from"./useScrollIndication-mYI-g6xa.js";import{M as nn}from"./EmptyState-CpBEzmap.js";import{u as sn,M as tn}from"./Pagination-CB1wBW8Q.js";import{M as an}from"./Typography-Cz6D417Y.js";import{M as on}from"./DataFilters-BnT_U3-o.js";import{M as we}from"./Button-BEA5U6Tg.js";import{j as n}from"./jsx-runtime-CnH95YSl.js";import{M as rn}from"./CircularProgress-DPxwxglU.js";import{M as ln}from"./Card-C0RGIer3.js";import{M as cn}from"./ChevronUp-CfT7Bz8X.js";import{C as ve}from"./Checkbox-vZwuXtzm.js";import{T as dn}from"./Tooltip-Cq2rQGbD.js";import{I as Ae}from"./IconButton-5qShmnSr.js";import{M as Q}from"./MenuItem-CmSG6PNu.js";import{M as mn,a as un,b as Be,c as gn,e as Ee,f as xn,d as bn}from"./List-UlX1tusJ.js";import{d as Fe,a as fn}from"./constants-CGUp4oSR.js";import{u as pn,a as hn}from"./index.esm-DTxqsiYY.js";import{M as Me}from"./More-DLQ2RjWn.js";import{M as Cn}from"./Show-BnmQFsN6.js";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const yn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({display:"flex",gap:e.Spacing2})),Sn=({data:e,menuItems:l,rowSelection:r,setRowSelection:a})=>{const m=oe(),{t}=J(),i=Object.values(r).filter(Boolean).length,o=s.useCallback(()=>{const h=Object.fromEntries(e.map(x=>[x.id,!0]));a(h)},[e,a]),g=s.useCallback(()=>{a({})},[a]);return n.jsxs(yn,{odysseyDesignTokens:m,children:[i>0&&n.jsx(ee,{ariaLabel:t("table.actions.arialabel"),buttonLabel:t("table.actions.selectsome",{selectedRowCount:i}),buttonVariant:"primary",endIcon:n.jsx(ge,{}),children:l==null?void 0:l(r)}),n.jsxs(K,{children:[n.jsx(we,{isDisabled:i===e.length,label:t("table.actions.selectall"),onClick:o,variant:"secondary"}),n.jsx(we,{isDisabled:i===0,label:t("table.actions.selectnone"),onClick:g,variant:"secondary"})]})]})},Ne=s.memo(Sn);Ne.displayName="BulkActionsMenu";const wn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({marginBlockStart:`-${e.Spacing1}`})),Mn=I(Ae)(()=>({visibility:"hidden"})),jn=({children:e,description:l,detailPanel:r,hasSelection:a,image:m,isSelected:t,onSelectionChange:i,overline:o,title:g,variant:h,menuButtonChildren:x})=>{const f=oe(),{t:b}=J(),C=s.useId(),[c,w]=s.useState(!1),D=s.useMemo(()=>n.jsx(wn,{odysseyDesignTokens:f,children:n.jsx(ve,{checked:t,inputProps:{"aria-labelledby":C},onChange:i})}),[t,f,i,C]),B=s.useMemo(()=>r?n.jsx(dn,{title:b(c?"table.rowexpansion.collapse":"table.rowexpansion.expand"),children:n.jsx(Ae,{"aria-label":b(c?"table.rowexpansion.collapse":"table.rowexpansion.expand"),children:c?n.jsx(cn,{}):n.jsx(ge,{}),onClick:()=>w(!c)})}):n.jsx(Mn,{disabled:!0,children:n.jsx(ge,{})}),[c,r,b]),u=s.useMemo(()=>n.jsxs(n.Fragment,{children:[a&&D,B]}),[B,D,a]);return n.jsx(ln,{__role:"listitem",accessory:u,children:e,description:l,detailPanel:c&&r,image:m,menuButtonChildren:x,overline:o,title:g,titleId:C,variant:h})},Ve=s.memo(jn);Ve.displayName="DataCard";/*!
 * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Tn=({isRowReorderingDisabled:e,row:l,rowActionMenuItems:r,rowIndex:a,totalRows:m,updateRowOrder:t})=>{const{t:i}=J(),o=l.original?l.original:l,g=s.useCallback(()=>{t&&t({rowId:o.id,newRowIndex:0})},[o.id,t]),h=s.useCallback(()=>{t&&t({rowId:o.id,newRowIndex:Math.max(0,a-1)})},[o.id,a,t]),x=s.useCallback(()=>{t&&t({rowId:o.id,newRowIndex:a+1})},[o.id,a,t]),f=s.useCallback(()=>{t&&t({rowId:o.id,newRowIndex:m?m-1:a})},[o.id,a,m,t]);return n.jsxs(n.Fragment,{children:[r&&r(o),r&&t&&n.jsx("hr",{}),t&&n.jsxs(n.Fragment,{children:[n.jsxs(Q,{isDisabled:a<=0||e,onClick:g,children:[n.jsx(mn,{})," ",i("table.reorder.tofront")]}),n.jsxs(Q,{isDisabled:a<=0||e,onClick:h,children:[n.jsx(un,{})," ",i("table.reorder.forward")]}),n.jsxs(Q,{isDisabled:(m?a>=m-1:!1)||e,onClick:x,children:[n.jsx(Be,{})," ",i("table.reorder.backward")]}),m&&n.jsxs(Q,{isDisabled:a>=m-1||e,onClick:f,children:[n.jsx(gn,{})," ",i("table.reorder.toback")]})]})]})},je=s.memo(Tn);je.displayName="RowActions";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const In=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"&&e!=="currentLayout"&&e!=="maxGridColumns"})(({odysseyDesignTokens:e,currentLayout:l,maxGridColumns:r})=>({display:l==="list"?"flex":"grid",flexDirection:"column",columnGap:e.Spacing5,...l==="grid"&&{"@media (max-width: 720px)":{gridTemplateColumns:"repeat(1, 1fr)"},"@media (min-width: 720px) and (max-width: 960px)":{gridTemplateColumns:"repeat(2, 1fr)"},"@media (min-width: 960px)":{gridTemplateColumns:`repeat(${r}, 1fr)`}}})),Dn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({display:"flex",alignItems:"center",justifyContent:"center",width:"100%",paddingBlock:e.Spacing5})),kn=({cardLayoutOptions:e,currentIndex:l,handleRowSelectionChange:r,hasRowReordering:a,hasRowSelection:m,isRowReorderingDisabled:t,onReorderRows:i,row:o,rowReorderingUtilities:g,rowSelection:h,totalRows:x})=>{const{overline:f,title:b,description:C,image:c,children:w,variant:D}=e.itemProps(o),B=s.useCallback(()=>r(o),[r,o]),u=s.useMemo(()=>{var z;return(z=e.renderDetailPanel)==null?void 0:z.call(e,{row:o})},[e,o]),p=s.useMemo(()=>e.rowActionMenuItems||a?n.jsx(je,{isRowReorderingDisabled:t,row:o,rowActionMenuItems:e.rowActionMenuItems,rowIndex:l,totalRows:x,updateRowOrder:a&&i?g.updateRowOrder:void 0}):null,[e.rowActionMenuItems,l,a,t,i,o,g,x]);return n.jsx(Ve,{children:w,description:C,detailPanel:u,hasSelection:m,image:c,isSelected:h[o.id]??!1,menuButtonChildren:p,onSelectionChange:B,overline:f,title:b,variant:D},o.id)},He=s.memo(kn);He.displayName="RowDataCard";const zn=({currentLayout:e,data:l,emptyState:r,hasRowReordering:a,hasRowSelection:m,isEmpty:t,isLoading:i,isNoResults:o,isRowReorderingDisabled:g,onReorderRows:h,pagination:x,rowReorderingUtilities:f,rowSelection:b,setRowSelection:C,cardLayoutOptions:c,totalRows:w})=>{const D=oe(),B=s.useCallback(u=>{C(p=>Object.fromEntries(u.id in p?Object.entries(p).filter(([z])=>z!==u.id):Object.entries(p).concat([[u.id,!0]])))},[C]);return n.jsx(K,{children:i?n.jsx(Dn,{odysseyDesignTokens:D,children:n.jsx(rn,{})}):n.jsx(n.Fragment,{children:!l||l.length===0||t||o?n.jsx(K,{children:r}):n.jsx(In,{currentLayout:e,maxGridColumns:c.maxGridColumns??3,odysseyDesignTokens:D,role:"list",children:l.map((u,p)=>{const z=p+(x.pageIndex-1)*x.pageSize;return n.jsx(He,{cardLayoutOptions:c,currentIndex:z,handleRowSelectionChange:B,hasRowReordering:a,hasRowSelection:m,isRowReorderingDisabled:g,onReorderRows:h,row:u,rowReorderingUtilities:f,rowSelection:b,totalRows:w},u.id)})})})})},We=s.memo(zn);We.displayName="CardLayoutContent";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const vn=async({dataQueryParams:e,errorMessageProp:l,getData:r,setData:a,setErrorMessage:m,setIsLoading:t})=>{t==null||t(!0),m(l);try{const i=await(r==null?void 0:r(e));a(i)}catch(i){m(typeof i=="string"?i:Ye("table.error"))}finally{t==null||t(!1)}};/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const An=({availableLayouts:e,currentLayout:l,setCurrentLayout:r})=>{const{t:a}=J(),m=s.useCallback(i=>{r(i)},[r]),t=s.useMemo(()=>e.map(i=>({value:i,onClick:()=>m(i),label:a(`dataview.layout.${i}`)})),[e,m,a]);return n.jsx(ee,{ariaLabel:a("dataview.layout.arialabel"),buttonLabel:a(`dataview.layout.${l}`),menuAlignment:"right",shouldCloseOnSelect:!1,children:t.map(({value:i,onClick:o,label:g})=>n.jsx(Q,{isSelected:l===i,onClick:o,children:g},i))})},Pe=s.memo(An);Pe.displayName="LayoutSwitcher";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Bn={enableColumnActions:!1,enableDensityToggle:!1,enableExpandAll:!1,enableFilters:!1,enableFullScreenToggle:!1,enableGlobalFilter:!1,enableHiding:!1,enablePagination:!1,layoutMode:"grid-no-grow",manualFiltering:!0,manualSorting:!0,muiTablePaperProps:{elevation:0,sx:{overflow:"visible"}},positionActionsColumn:"last",rowVirtualizerOptions:{overscan:4},selectAllMode:"all"},En={"mrt-row-drag":{header:"",muiTableBodyCellProps:{sx:{minWidth:0,width:"auto"},className:"ods-drag-handle"},muiTableHeadCellProps:{sx:{minWidth:0,width:"auto"},children:n.jsx(K,{sx:{marginInline:"-0.1rem"},children:n.jsx(Ee,{sx:{marginInline:1,opacity:0}})})}},"mrt-row-select":{muiTableHeadCellProps:{padding:"checkbox"},muiTableBodyCellProps:{padding:"checkbox"}},"mrt-row-expand":{header:"",muiTableBodyCellProps:{sx:{overflow:"visible"}}}},Fn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"&&e!=="isScrollableStart"&&e!=="isScrollableEnd"})(({odysseyDesignTokens:e,isScrollableStart:l,isScrollableEnd:r})=>({marginBlockEnd:e.Spacing4,position:"relative",borderInlineStartColor:l?e.HueNeutral200:"transparent",borderInlineStartStyle:"solid",borderInlineStartWidth:e.BorderWidthMain,"::before":{background:"linear-gradient(-90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.33) 50%, rgba(0, 0, 0, 1) 100%)",content:'""',opacity:l?"0.075":"0",pointerEvents:"none",position:"absolute",top:0,left:0,bottom:0,width:e.Spacing6,zIndex:100,transition:`opacity ${e.TransitionDurationMain} ${e.TransitionTimingMain}`},borderInlineEndColor:r?e.HueNeutral200:"transparent",borderInlineEndStyle:"solid",borderInlineEndWidth:e.BorderWidthMain,"::after":{background:"linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.33) 50%, rgba(0, 0, 0, 1) 100%)",content:'""',opacity:r?"0.075":"0",pointerEvents:"none",position:"absolute",top:0,right:0,bottom:0,width:e.Spacing6,transition:`opacity ${e.TransitionDurationMain} ${e.TransitionTimingMain}`}}));/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Nn=I("div")({whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"}),Vn=I("div")({display:"flex"}),Hn=({columns:e,data:l,draggingRow:r,emptyState:a,enableVirtualization:m,getRowId:t,hasRowReordering:i,hasRowSelection:o,isEmpty:g,isLoading:h,isNoResults:x,isRowReorderingDisabled:f,onReorderRows:b,pagination:C,rowReorderingUtilities:c,rowSelection:w,setRowSelection:D,setTableState:B,tableLayoutOptions:u,tableState:p,totalRows:z})=>{const[ne,U]=s.useState(!0),[se,xe]=s.useState(!0),[ie,R]=s.useState("100%"),X=s.useRef(!1),$=s.useRef(null),V=s.useRef(null),H=s.useRef(null);Oe({setIsTableContainerScrolledToEnd:xe,setIsTableContainerScrolledToStart:U,setTableInnerContainerWidth:R,tableInnerContainer:V.current,tableOuterContainer:$.current});const F=oe(),{t:M}=J(),Y=s.useMemo(()=>e.map(d=>d.accessorKey)??[],[e]),re=s.useMemo(()=>["mrt-row-drag","mrt-row-select","mrt-row-expand",...(Y==null?void 0:Y.filter(d=>typeof d=="string"))||[],"mrt-row-actions"],[Y]),j=s.useMemo(()=>p.rowDensity==="spacious"?"MuiTableBody-spacious":p.rowDensity==="compact"?"MuiTableBody-compact":"MuiTableBody-default",[p]),G=s.useCallback(({cell:d})=>{const y=d.getValue();return d.column.columnDef.hasTextWrapping||d.column.columnDef.enableWrapping?y:n.jsx(Nn,{children:y})},[]),{draggableTableBodyRowClassName:be,dragHandleStyles:fe,dragHandleText:Z,handleDragHandleKeyDown:_,handleDragHandleOnDragCapture:k,handleDragHandleOnDragEnd:E,resetDraggingAndHoveredRow:pe,updateRowOrder:v}=c,le=s.useCallback(({row:d})=>{var A;const y=d.index+(C.pageIndex-1)*C.pageSize;return n.jsxs(Vn,{children:[(A=u.rowActionButtons)==null?void 0:A.call(u,d.original),(u.rowActionMenuItems||i)&&n.jsx(ee,{ariaLabel:M("table.moreactions.arialabel"),buttonVariant:"floating",endIcon:n.jsx(Me,{}),menuAlignment:"right",size:"small",children:n.jsx(je,{isRowReorderingDisabled:f,row:d,rowActionMenuItems:u.rowActionMenuItems,rowIndex:y,totalRows:z,updateRowOrder:i&&b?v:void 0})})]})},[i,f,b,C.pageIndex,C.pageSize,M,u,z,v]),te=s.useMemo(()=>({width:ie}),[ie]),ce=s.useCallback(()=>n.jsx(K,{sx:te,children:a}),[te,a]);s.useEffect(()=>{m&&(X.current=!0)},[m,C]),s.useEffect(()=>{var d,y;X.current&&H.current&&typeof((d=V.current)==null?void 0:d.scrollTo)<"u"&&((y=V.current)==null||y.scrollTo(0,H.current.clientHeight),X.current=!1)},[l]);const W=s.useMemo(()=>!!(i===!0&&b||u.rowActionButtons||u.rowActionMenuItems),[i,b,u.rowActionButtons,u.rowActionMenuItems]),ae=e.some(d=>d.grow===!0),L=pn({data:!g&&!x?l:[],columns:e,getRowId:t,state:{sorting:p.columnSorting,columnVisibility:p.columnVisibility,isLoading:h,rowSelection:w,columnOrder:re},icons:{ArrowDownwardIcon:Be,DragHandleIcon:Ee,SyncAltIcon:xn,ExpandMoreIcon:ge},...Bn,displayColumnDefOptions:{...En,"mrt-row-actions":{header:"",grow:!ae,muiTableBodyCellProps:{align:"right",sx:{overflow:"visible",width:"unset"},className:"ods-actions-cell"},muiTableHeadCellProps:{align:"right",sx:{width:"unset"},className:"ods-actions-cell",children:n.jsxs(K,{sx:{display:"flex",visibility:"hidden"},children:[u.rowActionButtons&&u.rowActionButtons(),(i===!0&&b||u.rowActionMenuItems)&&n.jsx(K,{children:n.jsx(we,{ariaLabel:M("table.moreactions.arialabel"),endIcon:n.jsx(Me,{}),isDisabled:!0,size:"small",variant:"floating"})})]})}}},muiTableProps:{ref:H,className:!W&&u.hasColumnResizing?ae?"ods-hide-spacer-column":"ods-hide-spacer-column ods-column-grow":""},muiTableContainerProps:{ref:V},muiTableBodyProps:()=>({className:j,tabIndex:0,sx:g||x?{height:"unset"}:void 0}),enableColumnResizing:u.hasColumnResizing,defaultColumn:{Cell:G},enableRowActions:!!(i===!0&&b||u.rowActionButtons||u.rowActionMenuItems),renderRowActions:({row:d})=>le({row:d}),enableRowOrdering:i&&!!b,enableRowDragging:i&&!!b,muiDetailPanelProps:({row:d})=>({sx:{paddingBlock:d.getIsExpanded()?`${F.Spacing3} !important`:void 0}}),muiTableBodyRowProps:({table:d,row:y,isDetailPanel:A})=>{var P;return{className:be({currentRowId:y.id,draggingRowId:r==null?void 0:r.id,hoveredRowId:(P=d.getState().hoveredRow)==null?void 0:P.id}),sx:A?{paddingBlock:"0 !important",border:0,"&:hover":{backgroundColor:`${F.HueNeutralWhite} !important`}}:{}}},muiRowDragHandleProps:({table:d,row:y})=>({onKeyDown:A=>_({table:d,row:y,event:A}),onBlur:()=>pe(d),onDragEnd:()=>E(d),onDragCapture:()=>k(d),disabled:f,sx:fe,...Z}),renderDetailPanel:u.renderDetailPanel,enableRowVirtualization:m,muiTableHeadCellProps:({column:d})=>({className:p.columnSorting.find(y=>y.id===d.id)?"isSorted":"isUnsorted"}),muiTableBodyCellProps:({column:d})=>({className:d.getIsResizing()?"isResizing":""}),enableSorting:u.hasSorting===!0,onSortingChange:d=>{const y=typeof d=="function"?d(p.columnSorting):p.columnSorting;B(A=>({...A,columnSorting:y}))},enableRowSelection:o,onRowSelectionChange:D,renderEmptyRowsFallback:ce,localization:{collapse:M("table.rowexpansion.collapse"),collapseAll:M("table.rowexpansion.collapseall"),expand:M("table.rowexpansion.expand"),expandAll:M("table.rowexpansion.expandall")}});return n.jsx(Fn,{isScrollableEnd:!se,isScrollableStart:!ne,odysseyDesignTokens:F,ref:$,children:n.jsx(hn,{table:L})})},Ke=s.memo(Hn);Ke.displayName="TableLayoutContent";const Wn=({setTableState:e,tableLayoutOptions:l,tableState:r})=>{const{t:a}=J(),{hasChangeableDensity:m,hasColumnVisibility:t,columns:i}=l,{rowDensity:o,columnVisibility:g}=r,h=s.useCallback(c=>{e(w=>({...w,rowDensity:c}))},[e]),x=s.useCallback(c=>{e(w=>({...w,columnVisibility:{...w.columnVisibility,[c]:w.columnVisibility?w.columnVisibility[c]===!1:!1}}))},[e]),f=s.useMemo(()=>new Set(i.filter(c=>g?g[c.accessorKey]!==!1:!0).map(c=>c.accessorKey)),[i,g]),b=s.useMemo(()=>m&&n.jsx(ee,{ariaLabel:a("table.density.arialabel"),endIcon:n.jsx(bn,{}),menuAlignment:"right",shouldCloseOnSelect:!1,children:Fe.map(c=>n.jsx(Q,{isSelected:o===c,onClick:()=>h(c),children:a(`table.density.${c}`)},c))}),[m,a,o,h]),C=s.useMemo(()=>t&&n.jsx(ee,{ariaLabel:a("table.columnvisibility.arialabel"),endIcon:n.jsx(Cn,{}),menuAlignment:"right",shouldCloseOnSelect:!1,children:i.filter(c=>c.enableHiding!==!1).map(c=>n.jsxs(Q,{onClick:()=>x(c.id),children:[n.jsx(ve,{checked:f.has(c.id)}),c.header]},c.accessorKey))}),[t,a,i,x,f]);return n.jsxs(n.Fragment,{children:[b,C]})},Ue=s.memo(Wn);Ue.displayName="TableSettings";/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Pn=({columns:e,filters:l})=>{const r=s.useCallback(t=>t==null?void 0:t.map(i=>typeof i=="string"?{label:i,value:i}:{label:i.label??i.value,value:i.value??i.label}),[]),a=s.useCallback(t=>t.enableColumnFilter!==!1&&t.accessorKey?{id:t.accessorKey,label:t.header,variant:t.filterVariant,options:r(t.filterSelectOptions)}:null,[r]);return s.useMemo(()=>(l||e||[]).reduce((i,o)=>{if(typeof o=="string"){const g=e==null?void 0:e.find(x=>x.accessorKey===o),h=g&&a(g);return h?i.concat(h):i}if("accessorKey"in o){const g=a(o);return g?i.concat(g):i}return"label"in o?i.concat(o):i},[]),[e,a,l])};/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const Kn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({display:"flex",flexDirection:"column",gap:e.Spacing4})),Un=I("div")(()=>({display:"flex",justifyContent:"space-between"})),$n=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({display:"flex",justifyContent:"flex-end",gap:e.Spacing2})),Gn=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({display:"flex",alignItems:"center",gap:e.Spacing2})),_n=I("div",{shouldForwardProp:e=>e!=="odysseyDesignTokens"})(({odysseyDesignTokens:e})=>({marginInlineEnd:e.Spacing2})),qn=({additionalActionButton:e,additionalActionMenuItems:l,availableLayouts:r=fn,bulkActionMenuItems:a,currentPage:m=1,emptyPlaceholder:t,enableVirtualization:i,errorMessage:o,filters:g,getData:h,getRowId:x,hasFilters:f,hasPagination:b,hasPageInput:C,hasRowCountInput:c,hasRowCountLabel:w,hasSearch:D,hasSearchSubmitButton:B,hasRowReordering:u,hasRowSelection:p,initialLayout:z,isEmpty:ne,isLoading:U,isNoResults:se,isPaginationMoreDisabled:xe,isRowReorderingDisabled:ie,metaText:R,noResultsPlaceholder:X,onChangeRowSelection:$,onReorderRows:V,onRowSelectionChange:H,paginationType:F="paged",resultsPerPage:M=20,searchDelayTime:Y,cardLayoutOptions:re,tableLayoutOptions:j,totalRows:G,maxPages:be,maxResultsPerPage:fe,onPaginationChange:Z})=>{const _=oe(),{t:k}=J(),[E,pe]=s.useState(z??r[0]),[v,le]=s.useState([]),[te,ce]=s.useState(U??!0),[W,ae]=s.useState(ne??!0),[L,d]=s.useState(se??!1),[y,A]=s.useState(o),[P,$e]=s.useState(""),[de,Ge]=s.useState(g),[me,_e]=s.useState(g),[he,qe]=s.useState(),[q,Ce]=s.useState({});s.useEffect(()=>{$==null||$(q)},[q,$]),s.useEffect(()=>{H==null||H(q)},[q,H]);const[S,ye]=s.useState({pageIndex:m,pageSize:M}),[N,Te]=s.useState({columnSorting:[],columnVisibility:{},rowDensity:(j==null?void 0:j.initialDensity)??Fe[0]}),Se=D||f||e||l,O=Pn({filters:me,columns:j==null?void 0:j.columns});s.useEffect(()=>{!de&&O&&Ge(O)},[O,de]);const Ie=s.useMemo(()=>({page:S.pageIndex,resultsPerPage:S.pageSize,search:P,filters:O,sort:N==null?void 0:N.columnSorting}),[S.pageIndex,S.pageSize,P,O,N==null?void 0:N.columnSorting]),De=s.useCallback((T,Re,Xe)=>x?x(T,Re,Xe):T.id?T.id:Le(),[x]);s.useEffect(()=>{ye({pageIndex:m,pageSize:M})},[m,M]),s.useEffect(()=>{ye(T=>({pageIndex:1,pageSize:F=="loadMore"?M:T.pageSize}))},[me,F,M,P]),s.useEffect(()=>{Z==null||Z(S)},[Z,S]),s.useEffect(()=>{vn({dataQueryParams:Ie,errorMessageProp:o,getData:h,setData:le,setErrorMessage:A,setIsLoading:U?void 0:ce})},[Ie,o,h,U]),s.useEffect(()=>{ae(S.pageIndex===m&&S.pageSize===M&&P===""&&(!f||me===de)&&v.length===0)},[m,v,me,f,de,S,M,P]),s.useEffect(()=>{ce(T=>U??T)},[U]),s.useEffect(()=>{ae(T=>ne??T)},[ne]),s.useEffect(()=>{d(T=>se??T)},[se]);const ke=s.useMemo(()=>{const T=X||n.jsx(nn,{description:k("table.noresults.text"),heading:k("table.noresults.heading")});if(W)return t||T;if(L)return T},[X,k,W,L,t]),ue=s.useMemo(()=>(R||E==="table"&&j||r.length>1||e||l)&&n.jsxs(Gn,{odysseyDesignTokens:_,children:[R&&n.jsx(_n,{odysseyDesignTokens:_,children:n.jsx(an,{color:"textSecondary",children:R})}),E==="table"&&j&&n.jsx(Ue,{setTableState:Te,tableLayoutOptions:j,tableState:N}),r.length>1&&n.jsx(Pe,{availableLayouts:r,currentLayout:E,setCurrentLayout:pe}),e,l&&n.jsx(ee,{ariaLabel:k("table.moreactions.arialabel"),buttonVariant:"secondary",endIcon:n.jsx(Me,{}),menuAlignment:"right",children:l})]}),[e,l,r,E,R,_,j,N,k]),Qe=s.useMemo(()=>i??F==="loadMore",[i,F]),{lastRow:Je}=sn({currentRowsCount:v.length,pageIndex:S.pageIndex,pageSize:S.pageSize,totalRows:G}),ze=en({totalRows:G,onReorderRows:V,data:v,setData:le,draggingRow:he,setDraggingRow:qe,resultsPerPage:S.pageSize,page:S.pageIndex});return n.jsxs(Kn,{odysseyDesignTokens:_,children:[y&&n.jsx(K,{children:n.jsx(Ze,{severity:"error",text:y})}),Se&&n.jsx(on,{additionalActions:ue,filters:f?O:void 0,hasSearchSubmitButton:B,isDisabled:W,onChangeFilters:f?_e:void 0,onChangeSearch:D?$e:void 0,searchDelayTime:Y}),(a||p)&&n.jsxs(Un,{children:[n.jsx(Ne,{data:v,menuItems:a,rowSelection:q,setRowSelection:Ce}),!Se&&ue]}),!Se&&!a&&!p&&ue&&n.jsx($n,{odysseyDesignTokens:_,children:ue}),E==="table"&&j&&n.jsx(Ke,{columns:j.columns,data:v,draggingRow:he,emptyState:ke,enableVirtualization:Qe,getRowId:x||De,hasRowReordering:u,hasRowSelection:p,isEmpty:W,isLoading:te,isNoResults:L,isRowReorderingDisabled:ie,onReorderRows:V,pagination:S,rowReorderingUtilities:ze,rowSelection:q,setRowSelection:Ce,setTableState:Te,tableLayoutOptions:j,tableState:N,totalRows:G}),(E==="list"||E==="grid")&&re&&n.jsx(We,{cardLayoutOptions:re,currentLayout:E,data:v,draggingRow:he,emptyState:ke,getRowId:x||De,hasRowReordering:u,hasRowSelection:p,isEmpty:W,isLoading:te,isNoResults:L,isRowReorderingDisabled:ie,onReorderRows:V,pagination:S,rowReorderingUtilities:ze,rowSelection:q,setRowSelection:Ce,totalRows:G}),b&&n.jsx(tn,{currentPageLabel:k("pagination.page"),currentRowsCount:v.length,hasPageInput:C,hasRowCountInput:c,hasRowCountLabel:w,isDisabled:W,isMoreDisabled:xe,lastRow:Je,loadMoreLabel:k("pagination.loadmore"),maxPageIndex:be,maxPageSize:fe,nextLabel:k("pagination.next"),onPaginationChange:ye,pageIndex:S.pageIndex,pageSize:S.pageSize,previousLabel:k("pagination.previous"),rowsPerPageLabel:k("pagination.rowsperpage"),totalRows:G,variant:F})]})},Qn=s.memo(qn);Qn.displayName="DataView";export{Qn as M};
