@starasia/admin 8.23.0 → 8.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/FilterBar/types.d.ts +12 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +383 -383
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,lr){typeof exports=="object"&&typeof module<"u"?lr(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],lr):(g=typeof globalThis<"u"?globalThis:g||self,lr(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,lr,Ke,u,or,j,It,rr,We,kr,nr,pe,cr,$e,A,gr,ur,q,Ot,Ur,sr,Wt,ir,Be,qe,Jr,k,M,oe,At,zt,Ht,Vt,Pt,Ae,jt,e,h,ve,Yr,ho){"use strict";const fo={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},Xr=h.createContext(fo),Kr=()=>h.useContext(Xr),Nt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},_t=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),qt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(s=>{l(a=>typeof s=="function"?s(a):s)},[]),o=h.useCallback((s,a)=>{l(d=>{const y=typeof a=="function"?a(d[s]):a;return{...d,[s]:y}})},[]),c=h.useCallback(s=>{l(a=>{if(!(s in a))return a;const d={...a};return delete d[s],d})},[]),i=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(_t.Provider,{value:i,children:r})},Zt=()=>h.useContext(_t),Br=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},Gt=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:i})=>{const s=Nt({initialUserData:c}),{theme:a}=sr.useTheme();return e.jsx(Xr.Provider,{value:{logo:n,appName:o,menus:t,userData:s.userData,setUserData:s.setUserData,menuBottom:l},children:e.jsx(qt,{children:i?e.jsx(sr.ThemeProvider,{value:i,children:r}):a?e.jsx(sr.ThemeProvider,{value:a,children:r}):r})})},go=h.memo(Gt);function Qt({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const $r=h.createContext(null);function Ut({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,i]=h.useState(null),[s,a]=h.useState(0),d=h.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx($r.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:i,replaceCount:s,registerReplace:d},children:r})}function Jt({children:r}){const t=h.useContext($r);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:t.setPrependNode,style:{display:"contents"}}),t.replaceCount>0?e.jsx("div",{ref:t.setReplaceNode,style:{display:"contents"}}):r,e.jsx("div",{ref:t.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:r})}function uo({children:r,mode:t="append"}){const l=h.useContext($r);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?Yr.createPortal(r,n):null}const Rr=h.createContext(null);function Yt({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((a,d)=>{l(y=>y[a]===d?y:{...y,[a]:d})},[]),i=h.useCallback(a=>(o(d=>({...d,[a]:(d[a]??0)+1})),()=>o(d=>({...d,[a]:Math.max(0,(d[a]??0)-1)}))),[]),s=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:i}),[t,c,n,i]);return e.jsx(Rr.Provider,{value:s,children:r})}function Xt({slotKey:r,fallback:t}){const l=h.useContext(Rr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(i=>{var s;return(s=o.current)==null?void 0:s.call(o,r,i)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function yo({slotKey:r,children:t}){const l=h.useContext(Rr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?Yr.createPortal(t,o):null}const mr="moduleSwitcherGroupId",et="sa-module-switcher-change";function Kt(){if(typeof window>"u")return null;const r=window.localStorage.getItem(mr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function $t(r){typeof window>"u"||(r===null?window.localStorage.removeItem(mr):window.localStorage.setItem(mr,String(r)),window.dispatchEvent(new CustomEvent(et,{detail:r})))}function po(){$t(null)}function rt(){const[r,t]=h.useState(()=>Kt());return h.useEffect(()=>{const n=()=>{t(Kt())},o=c=>{c.key===mr&&n()};return window.addEventListener(et,n),window.addEventListener("storage",o),()=>{window.removeEventListener(et,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{$t(n),t(n)}}}let Fr=0,tr=!1,Rt=new Set;const el=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),rl={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function bo({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:i,sidebarHeaderContent:s,headerActions:a,profileRole:d,profileMenuButtons:y,profileMenuItems:b,logoutButton:p}){var Ve,Ue;const[x]=ve.useSearchParams(),T=x.get("embed")==="true",C=Kr(),{badges:I}=Zt(),F=ve.useNavigate(),O=ve.useLocation(),D=!pe.useMediaQuery("md"),[H,z]=h.useState(!1),[S,L]=h.useState(!1),[V,P]=h.useState(!1),[Z,Y]=h.useState(!1),[re,he]=h.useState(()=>new Set(Rt)),[fe,te]=h.useState(null),{selectedGroupId:Q,setSelectedGroupId:X}=rt();h.useEffect(()=>{Rt=re},[re]);const de=h.useRef(null),Se=h.useRef(null);h.useEffect(()=>{const m=de.current;if(!m)return;const G=()=>{tr||(Fr=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const se=()=>{const m=de.current;m&&Fr>0&&(tr=!0,m.scrollTop=Fr,requestAnimationFrame(()=>{tr=!1}))};h.useLayoutEffect(()=>{tr=!0,se();const m=setTimeout(()=>{tr=!1},300);return()=>clearTimeout(m)},[]),h.useLayoutEffect(()=>{C.menus.length>0&&(Fr>0?se():requestAnimationFrame(()=>{var G;const m=(G=de.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[C.menus]),h.useEffect(()=>{tr=!0,se();const m=setTimeout(se,0),G=setTimeout(se,50),$=setTimeout(se,100),W=setTimeout(se,200),U=setTimeout(()=>{tr=!1},300),_=setTimeout(()=>{const J=de.current,N=J==null?void 0:J.querySelector("[data-menu-active='true']");if(J&&N){const ge=J.getBoundingClientRect(),Fe=N.getBoundingClientRect();Fe.top>=ge.top&&Fe.bottom<=ge.bottom||N.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout($),clearTimeout(W),clearTimeout(U),clearTimeout(_)}},[O.pathname]),h.useEffect(()=>{Se.current&&(Se.current.scrollTop=0)},[O.pathname]),h.useEffect(()=>{D&&P(!1)},[O.pathname,D]),h.useEffect(()=>{D&&L(!0)},[D]);const Ce=()=>{z(!0)},Te=()=>{z(!1)},ke=()=>{z(!1),o()},He=m=>{const G=[m.to];return m.children&&G.push(...m.children.map($=>$.to)),G},Ie=[...C.menus.flatMap(m=>m.items.flatMap(He)),...((Ve=C.menuBottom)==null?void 0:Ve.flatMap(He))??[]],be=m=>{if(!O.pathname.startsWith(m))return!1;const G=Ie.filter($=>O.pathname.startsWith($)).sort(($,W)=>W.length-$.length)[0];return m===G};h.useEffect(()=>{var G;const m=$=>{var W;(W=$.children)!=null&&W.some(U=>O.pathname.startsWith(U.to))&&he(U=>{const _=new Set(U);return _.add($.id),_})};C.menus.forEach($=>{$.items.forEach(m)}),(G=C.menuBottom)==null||G.forEach(m)},[O.pathname,C.menus,C.menuBottom]);const Ze=m=>{he(G=>{const $=new Set(G);return $.has(m)?$.delete(m):$.add(m),$})};h.useEffect(()=>{C.menus.length!==0&&Q!==null&&!C.menus.some(m=>m.id===Q)&&X(null)},[C.menus,Q,X]);const xe=h.useMemo(()=>{if(Q!==null)return C.menus.filter($=>$.id===Q||$.parentGroupId===Q);const m=C.menus.filter($=>$.parentGroupId===void 0),G=C.menus.filter($=>$.parentGroupId!==void 0).flatMap($=>$.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[C.menus,Q]);if(T)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ve.Outlet,{})});const je=m=>{const G=m.children&&m.children.length>0,$=re.has(m.id),W=G?m.children.some(J=>be(J.to)):be(m.to),U=Br(m.badge,I[m.id]),_=!!U&&S&&!D;return e.jsxs("div",{"data-menu-active":W||void 0,children:[e.jsxs("button",{onClick:J=>{if(G)if(S&&!D){const N=J.currentTarget.getBoundingClientRect();te({item:m,top:N.top,left:N.right+8})}else Ze(m.id);else F(m.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:S&&!D?"center":void 0,gap:"0.5rem",paddingLeft:S&&!D?"0":"0.5rem",paddingRight:S&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:W?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:W?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:W?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:S&&!D?m.title:void 0,onMouseEnter:J=>{W||(J.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:J=>{W||(J.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),_&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!S||D)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:m.title}),U&&e.jsx(Ke.Badges,{text:String(U.value),variant:U.variant??"info",size:"xs",border:!0}),G&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:$?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),G&&(!S||D)&&(()=>{const J=m.children.findIndex(N=>be(N.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:$?`${m.children.length*36}px`:"0px",opacity:$?1:0,marginTop:$?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),J>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${J*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),m.children.map(N=>{const ge=Br(N.badge,I[N.id]);return e.jsxs("button",{onClick:()=>F(N.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:be(N.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:be(N.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:be(N.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:be(N.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{be(N.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{be(N.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(M.Icon,{name:N.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:N.title}),ge&&e.jsx(Ke.Badges,{text:String(ge.value),variant:ge.variant??"info",size:"xs",border:!0})]},N.id)})]})})()]},m.id)};return e.jsx(Yt,{children:e.jsxs(Ut,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":S?"4.375rem":"16.375rem","--app-footer-zindex":D&&V?"40":"998"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:V?.5:0,pointerEvents:V?"auto":"none",transition:"opacity 0.3s"},onClick:()=>P(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":S?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:V?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const m=!D&&S&&!V,G=m&&Z;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:m?1:void 0,justifyContent:m?"center":void 0,transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:C.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!S||V)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:C.appName})]}),!D&&!S&&e.jsx("button",{type:"button",onClick:()=>L(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(el,{})}),m&&e.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(el,{})})}),D&&e.jsx("button",{onClick:()=>P(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),s&&e.jsx(Qt,{collapsed:D?!1:S,children:s}),e.jsx("div",{ref:de,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:xe.map(m=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!S||D?m.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.name}):m.name&&e.jsx("div",{"aria-label":m.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:m.slotKey?e.jsx(Xt,{slotKey:m.slotKey,fallback:m.items.map(G=>je(G))}):m.items.map(G=>je(G))})]},m.id))}),C.menuBottom&&C.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:C.menuBottom.map(m=>je(m))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:D?"1rem":void 0},children:[D&&e.jsx("button",{onClick:()=>P(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(Jt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(A.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.email)||"unknown"}),d&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuButton,{children:e.jsxs("button",{type:"button",onClick:m.onClick,style:rl,onMouseEnter:$=>{$.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(M.Icon,{name:m.icon,size:"md"}),e.jsx("span",{children:m.label})]})},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Ce,style:{...rl,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(M.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:Se,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ve.Outlet,{})})]})]}),c&&i&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:i}),e.jsxs(We.Dialog,{isShow:H,onHide:Te,children:[e.jsx(We.DialogTitle,{children:"Confirmation Logout"}),e.jsx(We.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(We.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(oe.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Te,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:ke,children:"Yes, Sure"})})]})})})]}),fe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>te(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":fe.item.title,style:{position:"fixed",top:fe.top,left:fe.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:fe.item.title}),(Ue=fe.item.children)==null?void 0:Ue.map(m=>{const G=be(m.to),$=Br(m.badge,I[m.id]);return e.jsxs("button",{onClick:()=>{F(m.to),te(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:G?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:W=>{G||(W.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:W=>{G||(W.currentTarget.style.backgroundColor="transparent")},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:m.title}),$&&e.jsx(Ke.Badges,{text:String($.value),variant:$.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const yr=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),tl=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[i,s]=h.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",d=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",b=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:i?y:a,transition:"color 0.15s ease"}}),e.jsx(k.Text,{variant:"sub-h3",style:{color:i?b:d,transition:"color 0.15s ease"},children:r||"Back"})]})},vo=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,i]=h.useState(!1),s=n??"var(--sa-text-subtle, #8c8f97)",a=o??"var(--sa-text-subtle, #8c8f97)",d=r.length>1?r[0]:void 0,y=!!(d!=null&&d.to||d!=null&&d.onClick),b=e.jsx(M.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>i(!0):void 0,onMouseLeave:y?()=>i(!1):void 0,style:{color:y&&c?a:s,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),p=d!=null&&d.to?e.jsx(ve.Link,{to:d.to,replace:!0,style:{textDecoration:"none"},children:b}):d!=null&&d.onClick?e.jsx(yr,{onClick:d.onClick,children:b}):b;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(or.Breadcrumb,{separator:t,size:"md",children:r.map((x,T)=>{const C=T===r.length-1;return x.to&&!C?e.jsx(or.BreadcrumbItem,{children:e.jsx(ve.Link,{to:x.to,children:x.label})},T):e.jsx(or.BreadcrumbItem,{currentPage:C,children:e.jsx(or.BreadcrumbLink,{onClick:C?void 0:x.onClick,children:x.label})},T)})})]})},Co=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(vo,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ve.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(tl,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(yr,{onClick:n,children:e.jsx(tl,{...c})})})},tt=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function ll(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const ol={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},nl={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function cl({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,i]=h.useState(void 0),s=d=>{o(d),t()},a=tt[0];return e.jsx(We.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(We.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>s(null),onMouseEnter:()=>i("all"),onMouseLeave:()=>i(void 0),style:nl,children:[e.jsx("div",{style:ll(n===null,c==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:ol,children:"Semua"})]}),l.map((d,y)=>{var C;const b=n===d.id,p=c===d.id,x=((C=d.items[0])==null?void 0:C.icon)??"Grid",T=tt[(y+1)%tt.length];return e.jsxs("button",{onClick:()=>s(d.id),onMouseEnter:()=>i(d.id),onMouseLeave:()=>i(void 0),style:nl,children:[e.jsx("div",{style:ll(b,p,T),children:e.jsx("div",{style:{color:T.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:ol,children:d.name})]},d.id)})]})})})}function xo({onSelect:r,"aria-label":t="Pilih module"}={}){const l=Kr(),n=ve.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=rt(),[i,s]=h.useState(!1),a=d=>{var y;if(c(d),d!==null){const b=l.menus.find(x=>x.id===d),p=(y=b==null?void 0:b.items[0])==null?void 0:y.to;p&&n(p)}r==null||r(d)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>s(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":t,onMouseEnter:d=>{d.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),o!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(cl,{isShow:i,onHide:()=>s(!1),menus:l.menus.filter(d=>d.parentGroupId===void 0),selectedGroupId:o,onSelect:a})]})}const wo=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Do=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const i=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),s=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),a=()=>typeof t=="string"?e.jsx(k.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,d=()=>typeof r=="string"||typeof r=="number"?e.jsx(k.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(k.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(q.Tr,{children:[e.jsx(q.Td,{style:i,width:n,children:a()}),l?e.jsx(q.Td,{style:s,width:24,children:y()}):null,e.jsx(q.Td,{style:i,children:d()})]})}),So=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(q.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,o)=>e.jsx(Do,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),ko=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const i=h.useMemo(()=>wo(n,r),[n,r]),s=i.length>2,a=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(u.Box,{gap:s?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:s?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:i.map((d,y)=>e.jsx(u.Box,{direction:"column",flex:s?void 0:"1",width:s?a():void 0,marginBottom:s?"lg":void 0,children:e.jsx(So,{labelWidth:o,fields:d,separator:l})},y))})}),Bo=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",i=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(k.Text,{variant:"sub-h3",style:{color:t?i:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},mo=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:i=!1,subHeaders:s,action:a,titleTagProps:d,containerProps:y,headerProps:b})=>{const p=pe.useMediaQuery("md"),x=ve.useNavigate(),T=ve.useLocation(),C=r==null?void 0:r.show,I=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},F=()=>{if(!a)return null;if(h.isValidElement(a))return a;const S=a.filter(L=>L&&(L.title||L.icon));return S.length===0?null:p?e.jsx(u.Box,{direction:"row",gap:"md",children:S.map(({title:L,icon:V,buttonProps:P,onClick:Z},Y)=>e.jsx(j.Button,{iconLeft:V?e.jsx(M.Icon,{name:V,size:"md"}):void 0,onClick:Z,...P,children:L},`action-${Y}`))}):e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:200},children:S.map(({title:L,icon:V,buttonProps:P,onClick:Z},Y)=>{const re=(P==null?void 0:P.tone)==="error"||(P==null?void 0:P.danger)===!0;return e.jsx(A.MenuItem,{intent:re?"danger":void 0,disabled:P==null?void 0:P.disabled,startIcon:V?e.jsx(M.Icon,{name:V}):void 0,onClick:Z,children:L},`action-${Y}`)})})})]})},O=()=>{const S=e.jsx(Bo,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ve.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:S})}):e.jsx(u.Box,{direction:"row",children:e.jsx(yr,{onClick:I,children:S})})},B=()=>{const S=!!t,L=Array.isArray(a)&&a.length>0,V=h.isValidElement(a)?!0:L;if(!S&&!V&&!C)return null;const Z=p||!p&&L;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(b==null?void 0:b.paddingBlock)??"sm",paddingInline:(b==null?void 0:b.paddingInline)??"md",...b,style:{...i?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...b==null?void 0:b.style},children:[C&&O(),(S||V)&&e.jsxs(u.Box,{direction:Z?"row":"column",gap:"sm",justify:"space-between",align:Z?"center":"flex-start",children:[S?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(M.Icon,{name:l,size:"md",color:"primary"}),e.jsx(k.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ke.Badge,{border:!0,size:"lg",text:n,...d})]}):t:null,F()]})]})},D=()=>{if(!s||s.length===0)return null;const S=s.filter(P=>P.show!==!1);if(S.length===0)return null;let L=0,V=-1/0;return S.forEach((P,Z)=>{const Y=P.order??0;Y>=V&&(V=Y,L=Z)}),S.map(({content:P,order:Z,borderBottom:Y=!0,keepBottomPadding:re=!1},he)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:Y||re||he===L?"sm":"spacing-0",paddingInline:"md",style:{...Y?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...Z!==void 0?{order:Z}:{}},children:P},`sub-header-${he}`))},H=()=>{const S=c?B():null,L=D();return!S&&!L?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:L?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[S,L]})},z=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[H(),z()]},T.pathname)},Fo=h.memo(mo),Eo={icon:"Cross",title:""},Mo="calc(100vw - 16px)",sl=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${Mo})`,il=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Eo,width:i,minWidth:s="357px",maxWidth:a="357px"},d)=>{const y=sl(i??s),b=sl(i??a);return e.jsx(kr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:d,style:{minWidth:y,maxWidth:b,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(M.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(k.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),lt=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=pe.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),ot=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=pe.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Lo=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),To=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:i,containerProps:s,bodyProps:a,headerProps:d={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=pe.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(k.Text,{fontWeight:"medium",children:t}),e.jsx(Ke.Badges,{border:!0,text:l,variant:b})]}):e.jsx(k.Text,{fontWeight:"medium",children:t}),T=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...i,children:n??null})]}),C=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...s,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(s==null?void 0:s.style)??{}},children:[o!==null&&C?e.jsx(lt,{...d,children:T()}):null,e.jsx(Lo,{...a,children:r}),c?e.jsx(ot,{...y,children:c}):null]})}),ze={H1:r=>e.jsx(k.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(k.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(k.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(k.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(k.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(k.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(k.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(k.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(k.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(k.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(k.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(k.Text,{variant:"body-3",children:r.children,...r.props})},Ee=()=>{const[r,t]=ve.useSearchParams(),l=cr.searchParamsToObject(r.toString()),n=ve.useParams(),o=ve.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,b)=>r.has(y)&&r.get(y)===b,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},al=r=>JSON.stringify(r),dl=r=>JSON.stringify(r),hl=r=>JSON.stringify(r),fl=r=>JSON.stringify(r),Io=r=>r,Oo=r=>JSON.stringify(r),pr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:i,filterKey:s="filter",pageKey:a="page"})=>{if(n){let d;switch(l){case"search":d=Io(r);break;case"dropdown":case"dropdown-multiple":d=al(r);break;case"radio":d=dl(r);break;case"date-range":d=hl(r);break;case"advanced-date-range":d=Oo(r);break;case"date":d=fl(r);break;default:d=r;break}if(typeof d<"u"){const b={...c[s]&&typeof c[s]=="string"?JSON.parse(c[s]):void 0,[t]:d},p={...c};i&&typeof i=="string"&&delete p[i],delete p[a];const x={...p,[s]:JSON.stringify(b)},T=new URLSearchParams(c).toString(),C=new URLSearchParams(x).toString();if(T===C)return;o(x)}}},Er=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="label"&&i?JSON.parse(i)[0].label:n==="value"&&i?JSON.parse(i)[0].value:i},gl=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="label"&&i?JSON.parse(i).map(s=>s.label):n==="value"&&i?JSON.parse(i).map(s=>s.value):n==="array"&&i?JSON.parse(i):i},Wo=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="id"&&i?JSON.parse(i).id:n==="label"&&i?JSON.parse(i).label:n==="value"&&i?JSON.parse(i).value:i},Mr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},Ao=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},ul=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},zo=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,i=r.get(n)||void 0;return!!o||!!c||!!i},yl=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:i,searchQueries:s}=Ee(),[a,d]=h.useState({}),y=()=>{c.delete(l||"filter"),i(c)},b=(p,x)=>{switch(p.type){case"radio":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"dropdown":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"dropdown-multiple":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}default:return null}};return e.jsx(il,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(oe.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((p,x)=>b(p,x))]})})},pl=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:i=!0,filterKey:s="filter",pageKey:a="page",customWidthSearch:d,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:x="right",titleSearchLabel:T="Work Order",withTitleLabels:C=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[O,B]=h.useState(!1),[D,H]=h.useState(0),z=()=>{H(X=>X+1)},{searchParams:S,setSearchParams:L,getQueryParam:V}=Ee(),P=cr.searchParamsToObject(S.toString()),Z=Mr(r,S,s)||"",[Y,re]=h.useState(Z),he=V(s),te=!!(he&&!(()=>{if(he)try{const X=JSON.parse(he);return Object.keys(X).length===1&&X[r]===""}catch(X){console.error("Filter parameter is not a valid JSON:",X)}return!1})()),Q=pe.useMediaQuery("md");return h.useEffect(()=>{re(Z)},[Z]),h.useEffect(()=>{if(Y===Z)return;const X=window.setTimeout(()=>{pr({value:Y,name:r,type:"search",searchQueries:P,setSearchParams:L,filterKey:s,pageKey:a})},350);return()=>{window.clearTimeout(X)}},[Y,Z,r,P,L,s,a]),e.jsxs(oe.Flex,{gap:"md",style:{flexDirection:Q&&x==="left"?"row":Q&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[te&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const X=new URLSearchParams(S);X.delete(s),L(X),re(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(k.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:X,content:de,title:Se,onClickContainer:se},Ce)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:se,style:{minWidth:X},children:[Se&&e.jsx(ze.SubH3,{children:Se}),de]},`extended-filter-${Ce}-${D}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:te,secondary:!te,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:he?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!Q,onClick:()=>B(!0),children:F?"Filter":void 0}),i&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[C&&e.jsx(ze.SubH3,{children:"Status"}),e.jsx(nr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:Er({get:"value",name:t,searchParams:S,filterKey:s})?[{label:Er({get:"value",name:t,searchParams:S,filterKey:s})==="active"?"Active":"InActive",value:Er({get:"value",name:t,searchParams:S,filterKey:s})}]:[],onChange:X=>pr({value:X,name:t,type:"dropdown",searchQueries:P,setSearchParams:L,filterKey:s}),placeholder:C?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:d&&Q?d:Q?"310px":""},children:[C&&e.jsxs(ze.SubH3,{children:["Search for ",T]}),e.jsx($e.Input,{placeholder:l,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:X=>re(X.target.value),value:Y,fullWidth:!0},D+1+s)]}),e.jsx(yl,{isOpen:O,onClose:()=>B(!1),filterKey:s,filters:b,pageKey:a})]})},Ho=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function nt({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:i,searchQueries:s}=Ee(),a=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),d=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(z=>z.trim()).filter(Boolean);let H=[];try{const z=c.get(t);z&&(H=Object.keys(JSON.parse(z)).filter(S=>S!==o))}catch{}return r.map(z=>z.key).filter(z=>{const S=a[z];return(S==null?void 0:S.locked)||D.includes(z)||H.includes(z)})},[c,l,t,o,r,a]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),b=h.useCallback(D=>{const H={...s};D.length?H[l]=D.join(","):delete H[l],i(H)},[s,l,i]),p=h.useCallback(D=>{d.includes(D)||b([...d,D])},[d,b]),x=h.useCallback(D=>{var L;if((L=a[D])!=null&&L.locked)return;const H={...s},z=d.filter(V=>V!==D);z.length?H[l]=z.join(","):delete H[l];const S=y(H);D in S&&(delete S[D],Object.keys(S).length?H[t]=JSON.stringify(S):delete H[t]),delete H[n],i(H)},[s,d,l,t,n,y,i,a]),T=h.useCallback(D=>d.includes(D)?x(D):p(D),[d,p,x]),C=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return gl({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const H=ul({name:D.key,searchParams:c,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const z=y(Object.fromEntries(c.entries()))[D.key];return z&&typeof z=="object"?z:void 0}default:return}},[c,t,y]),I=h.useCallback((D,H)=>{if(D.type==="date-compact"){const z={...s},S=y(z);H==null?delete S[D.key]:S[D.key]=H,Object.keys(S).length?z[t]=JSON.stringify(S):delete z[t],delete z[n],i(z);return}pr({value:H,name:D.key,type:Ho(D.type),searchQueries:s,setSearchParams:i,filterKey:t,pageKey:n})},[s,i,t,n,y]),F=h.useCallback(D=>{const H={...s},z=y(H);D in z&&(delete z[D],Object.keys(z).length?H[t]=JSON.stringify(z):delete H[t]),delete H[n],i(H)},[s,t,n,y,i]),O=h.useCallback(()=>{const D={...s};delete D[t],delete D[l],delete D[n],i(D)},[s,t,l,n,i]),B=d.length>0;return{activeKeys:d,configByKey:a,hasActiveFilter:B,addFilter:p,removeFilter:x,toggleFilter:T,getValue:C,setValue:I,clearValue:F,clearAll:O}}const ct={get(r){return ur.storage.get(r)??null},set(r,t){ur.storage.save(r,t)},remove(r){ur.storage.delete(r)}},ar={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},Lr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function Vo({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(S=>S.key),hidden:[]}),[r]),i=t?ar.columns(t):void 0,s=(S,L)=>Lr({order:S.order??L,hidden:S.hidden??[]},r),[a,d]=h.useState(()=>{if(o&&(o.order||o.hidden))return s(o,r.map(S=>S.key));if(i){const S=l.get(i);if(S&&Array.isArray(S.order))return Lr(S,r)}return c}),y=r.map(S=>S.key).join("|");h.useEffect(()=>d(S=>Lr(S,r)),[y]);const b=h.useRef(a);b.current=a;const p=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(p);h.useEffect(()=>{if(p==null||x.current===p)return;x.current=p;const S=b.current,L=s(o,S.order);L.order.join("|")===S.order.join("|")&&L.hidden.join("|")===S.hidden.join("|")||(d(L),i&&l.set(i,L))},[p,y]);const T=h.useRef(!1);h.useEffect(()=>{T.current||(T.current=!0,n==null||n(a))},[]);const C=h.useCallback(S=>{d(S),i&&l.set(i,S),n==null||n(S)},[i,l,n]),I=h.useMemo(()=>{const S=new Map(r.map(L=>[L.key,L]));return a.order.filter(L=>S.has(L)).map(L=>({...S.get(L),visible:!a.hidden.includes(L)}))},[a,r]),F=h.useCallback(S=>{const L=a.hidden.includes(S)?a.hidden.filter(V=>V!==S):[...a.hidden,S];C({...a,hidden:L})},[a,C]),O=h.useCallback((S,L)=>{if(S===L)return;const V=[...a.order],[P]=V.splice(S,1);V.splice(L,0,P),C({...a,order:V})},[a,C]),B=h.useCallback(S=>{C({...a,hidden:S?r.filter(L=>!L.locked).map(L=>L.key):[]})},[a,r,C]),D=h.useCallback(()=>C(c),[C,c]),H=h.useCallback(S=>C(Lr(S,r)),[C,r]),z=a.hidden.length===0;return{state:a,orderedColumns:I,allVisible:z,toggleVisibility:F,reorder:O,setAllHidden:B,reset:D,applyState:H}}function Po({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:i,setSearchParams:s}=Ee(),a=r?ar.savedViews(r):void 0,[d,y]=h.useState(()=>a?t.get(a)||[]:[]),b=h.useCallback(C=>{y(C),a&&t.set(a,C)},[a]),p=h.useCallback(C=>{const I=C.trim();if(!I)return;const F={};l.forEach(B=>{const D=i.get(B);D!=null&&(F[B]=D)});const O={id:`${Date.now()}`,name:I,query:F,columns:o==null?void 0:o(),createdAt:Date.now()};b([...d,O])},[l,i,o,b,d]),x=h.useCallback(C=>b(d.filter(I=>I.id!==C)),[b,d]),T=h.useCallback(C=>{const I=Object.fromEntries(i.entries());l.forEach(F=>delete I[F]),Object.assign(I,C.query),delete I[n],s(I),C.columns&&(c==null||c(C.columns))},[i,l,n,s,c]);return{enabled:!!a,views:d,saveView:p,deleteView:x,applyView:T}}function jo({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=Ee(),c=r&&n?ar.lastState(r):void 0,i=h.useRef(c),s=h.useRef(!1);h.useEffect(()=>{if(!c){i.current=c;return}if(i.current!==c){i.current=c,s.current=!1;return}const y={};if(l.forEach(b=>{const p=o.get(b);p!=null&&(y[b]=p)}),Object.keys(y).length===0){s.current&&t.remove(c);return}s.current=!0,t.set(c,y)},[o,c,l,t]);const a=h.useCallback(()=>{if(!c)return null;const y=t.get(c);return y&&Object.keys(y).length>0?y:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:a,clear:d}}function No({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=Ee(),i=r&&o?ar.perPage(r):void 0,s=c.toString(),a=h.useRef(i);h.useEffect(()=>{if(!i){a.current=i;return}if(a.current!==i){a.current=i;return}const b=c.get(l);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(i,p)},[s,i,l,t]);const d=h.useCallback(()=>{if(!i)return null;const b=t.get(i);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[i,t,n]),y=h.useCallback(()=>{i&&t.remove(i)},[i,t]);return{enabled:!!i,read:d,clear:y}}let st={},it=!1,at=null;const _o=(r,t)=>{Object.assign(st,r),at=t,!it&&(it=!0,queueMicrotask(()=>{const l=st,n=at;st={},it=!1,at=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([i,s])=>c.set(i,s)),c})}))};function qo({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:i,location:s}=Ee(),a=h.useRef(null);h.useEffect(()=>{if(!r||a.current===s.pathname)return;a.current=s.pathname;const d={};if(!c.has(l)){const y=o();y&&(d[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(d,y)}Object.keys(d).length!==0&&_o(d,i)},[s.pathname,r])}const Zo=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(A.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,Tr=({onClear:r,onRemove:t})=>e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(M.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:180},children:[e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(A.MenuItem,{intent:"danger",startIcon:e.jsx(M.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),Go=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},bl=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},vl=r=>{const t=Go(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:bl(t,-l,r.period),to:t}:{from:t,to:bl(t,l,r.period)}},Cl=24,xl=r=>r.length>Cl?`${r.slice(0,Cl)}...`:r,Ir=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Or={is:"Is","is-before":"Is before","is-after":"Is after","is-on-or-before":"Is on or before","is-on-or-after":"Is on or after","is-between":"Is between","is-relative-to-today":"Is relative to today","is-empty":"Is empty","is-not-empty":"Is not empty"},Qo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],dt={past:"Past",next:"Next",this:"This"},Uo=["day","week","month","year"],Jo=["past","next","this"],Yo=r=>r.field.type==="date-compact"?e.jsx($o,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(Xo,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),Xo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?Ir(new Date(t)):null,i=!!c,s=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:xl(c)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:s})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():l(a),withPadding:!1})})})]})},Ko=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Or[r.op]} ${Ir(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${Ir(new Date(r.from))} - ${Ir(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${dt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return Or[r.op];default:return null}},$o=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=(t==null?void 0:t.op)??"is",i=t?Ko(t):null,s=!!i,a=s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:xl(i)})]}):r.label,d=y=>{if(y!==c){if(y==="is-empty"||y==="is-not-empty"){l({op:y});return}if(y==="is-relative-to-today"){l({op:y,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(y==="is-between"){l({op:y,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:y,date:t==null?void 0:t.date})}};return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:a})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Ro,{op:c,onChange:d})]}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsx(en,{value:t,op:c,onChange:l})}),c==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Ro=({op:r,onChange:t})=>e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Or[r]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:200},children:Qo.map(l=>e.jsx(A.MenuItem,{selected:r===l,onClick:()=>t(l),endIcon:r===l?e.jsx(M.Icon,{name:"Check"}):void 0,children:Or[l]},l))})})]}),en=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:i}=o;if(!c&&i&&(c=i,i=null),!c&&!i){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(rn,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},rn=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",i=vl({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:dt[l]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Jo.map(s=>e.jsx(A.MenuItem,{selected:l===s,endIcon:l===s?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(s==="this"?{direction:s,period:o}:{direction:s,count:n,period:o}),children:dt[s]},s))})})]}),c&&e.jsx($e.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:s=>{const a=Number(s.target.value);t({direction:l,count:Number.isFinite(a)&&a>0?a:1,period:o})},style:{width:72}}),e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Uo.map(s=>e.jsx(A.MenuItem,{selected:o===s,endIcon:o===s?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:s}:{direction:l,count:n,period:s}),children:s},s))})})]})]}),e.jsx(rr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:i,onChange:()=>{},withPadding:!1},"relative-preview")]})},wl=18,tn=r=>r.length>wl?`${r.slice(0,wl)}...`:r,ln=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",i=t.length,s=r.searchable!==!1,[a,d]=h.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(O=>O.label.toLowerCase().includes(F)):y})(),x=F=>t.some(O=>O.value===F.value),T=F=>{if(!c){l([{label:F.label,value:F.value}]),d("");return}l(x(F)?t.filter(O=>O.value!==F.value):[...t,{label:F.label,value:F.value}])},C=F=>{var O;d(F),(O=r.onSearch)==null||O.call(r,F)},I=i===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:i===1?tn(t[0].label):`${i} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:I})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[s&&e.jsx(nr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:a,onSearch:C,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!c,selected:x(F),startIcon:F.avatar,endIcon:x(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>T(F),children:F.label},F.value))})]})})})]})},Dl=18,on=r=>r.length>Dl?`${r.slice(0,Dl)}...`:r,Sl=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(qe.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),nn=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(p=>p.value)),i=t.length,s=r.options.length>0&&r.options.every(p=>c.has(p.value)),a=i>0&&!s,d=p=>{l(c.has(p.value)?t.filter(x=>x.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{l(s?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=i===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(k.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(k.Text,{as:"span",children:i===1?on(t[0].label):`${i} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s,onClick:y,startIcon:e.jsx(Sl,{checked:s||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:c.has(p.value),onClick:()=>d(p),startIcon:e.jsx(Sl,{checked:c.has(p.value)}),children:p.label},p.value))]})})]})},kl=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(i=>{const s=t[i];if(!s)return null;const a=l(s),d=s.locked?void 0:()=>c(i);return s.type==="date"||s.type==="date-compact"?e.jsx(Yo,{field:s,value:a,onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i):s.type==="checkbox-multiple"?e.jsx(nn,{field:s,value:a||[],onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i):e.jsx(ln,{field:s,value:a||[],onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i)})}),Bl=r=>`${r} Rows`,cn=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:i=!0,showPagination:s=!0})=>{var F;const{searchQueries:a,setSearchParams:d,searchParams:y}=Ee(),b=y.get(l),p=b?Number(b):o,x=O=>{d({...a,[t]:String(O)})},T=O=>{d({...a,[l]:O,[t]:"1"})},C=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),I=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${C}-${I} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),i&&e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:Bl(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(O=>e.jsx(A.MenuItem,{selected:O===p,onClick:()=>T(String(O)),children:Bl(O)},O))})})]}),s&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(gr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function sn(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var s;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,i=(s=c==null?void 0:c.tagName)==null?void 0:s.toLowerCase();i==="input"||i==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const an=240,ml=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:i,setSearchParams:s,searchQueries:a}=Ee(),d=Mr(r,i,t)||"",[y,b]=h.useState(!c||!!d),[p,x]=h.useState(c&&!d),[T,C]=h.useState(d),I=pe.useDebounce(T,350),F=h.useRef(null);h.useEffect(()=>{C(d),d&&b(!0)},[d]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{I!==d&&pr({value:I,name:r,type:"search",searchQueries:a,setSearchParams:s,filterKey:t,pageKey:l})},[I]);const O=h.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var z;return(z=F.current)==null?void 0:z.focus()})},[]);sn(o,O);const B=()=>{c&&!T&&b(!1)},D=z=>{var S;c&&z.key==="Escape"&&!T&&(b(!1),(S=F.current)==null||S.blur())},H=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:O}),e.jsxs(u.Box,{onTransitionEnd:H,style:{position:"relative",width:y?an:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx($e.Input,{ref:F,size:"sm",fullWidth:!0,value:T,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:z=>C(z.target.value),onKeyDown:D,onBlur:B,tabIndex:y?0:-1}),y&&!T&&e.jsx(u.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(k.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},Fl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,i]=h.useState(null),[s,a]=h.useState(null),d=()=>{c!==null&&s!==null&&c!==s&&n(c,s),i(null),a(null)},y=(b,p)=>{const x=b+p;x<0||x>=r.length||n(b,x)};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const x=!b.locked,T=s===p&&c!==null&&c!==p;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&i(p),onDragOver:C=>{C.preventDefault(),a(p)},onDrop:d,onDragEnd:d,style:{minHeight:32,boxShadow:T?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:C=>{x&&(C.key==="ArrowUp"?(C.preventDefault(),y(p,-1)):C.key==="ArrowDown"&&(C.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(ir.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>l(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},El=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),i=()=>{const s=o.trim();s&&(n(s),c(""))};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(M.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(A.MenuLists,{style:{width:"260px"},children:[e.jsx(A.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(k.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(s=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(s),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${s.name}`,onClick:a=>{a.stopPropagation(),l(s.id)}}),children:s.name},s.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx($e.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:s=>c(s.target.value),onKeyDown:s=>{s.key==="Enter"&&i()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:i,children:"Save"})]})})]})]})},dn=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:i,onReset:s,getValue:a,setValue:d,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(kr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(k.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(j.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(kl,{activeKeys:n,configByKey:o,getValue:a,setValue:d,clearValue:y,removeFilter:b})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const T=n.includes(x.key),C=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:C?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(k.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(ir.Toggle,{size:"sm",checked:T||C,disabled:C,onChange:()=>i(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:s,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},hn=r=>`${r} Rows`,fn=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:i,searchParams:s}=Ee(),a=s.get(r),d=a?Number(a):n,y=b=>{i({...c,[r]:b,[t]:"1"})};return o?e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(b=>e.jsx(A.MenuItem,{selected:b===d,endIcon:b===d?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:hn(b)},b))]})})]}):null},gn=r=>{var Ve;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:i,removeFilter:s,getValue:a,setValue:d,clearValue:y,onReset:b,searchable:p,searchKey:x,filterKey:T,pageKey:C,searchPlaceholder:I,searchShortcut:F,searchCollapsible:O,pagination:B,perPageKey:D,pageSizeOptions:H,defaultPerPage:z,showPagination:S,showResultCount:L,showPageSize:V,hasColumns:P,orderedColumns:Z,allVisible:Y,onToggleVisibility:re,onReorder:he,onSetAllHidden:fe,showSavedViews:te,savedViews:Q,onApplyView:X,onDeleteView:de,onSaveView:Se,leadingActions:se}=r,[Ce,Te]=h.useState(!1),{searchQueries:ke,setSearchParams:He}=Ee(),Ie=(B==null?void 0:B.rangeStart)??(((B==null?void 0:B.currentPage)||0)>1?(((B==null?void 0:B.currentPage)||0)-1)*((B==null?void 0:B.perPage)||0)+1:1),be=(B==null?void 0:B.rangeEnd)??((B==null?void 0:B.totalCurrentPage)!==(B==null?void 0:B.perPage)?B==null?void 0:B.totalData:((B==null?void 0:B.currentPage)||1)*((B==null?void 0:B.totalCurrentPage)||0)),Ze=Ue=>{He({...ke,[C]:String(Ue)})},xe=L||S&&!!(B!=null&&B.totalPage),je=()=>{b(),Te(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(ml,{searchKey:x,filterKey:T,pageKey:C,placeholder:I,shortcut:F,collapsible:O}),e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Te(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[se,te&&e.jsx(El,{views:Q,onApply:X,onDelete:de,onSave:Se}),P&&e.jsx(Fl,{columns:Z,allVisible:Y,onToggle:re,onReorder:he,onSetAllHidden:fe}),e.jsx(fn,{perPageKey:D,pageKey:C,pageSizeOptions:H,defaultPerPage:z,showPageSize:V})]})]}),xe&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[L?e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ie}-${be} of ${((Ve=B==null?void 0:B.totalData)==null?void 0:Ve.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),S&&!!(B!=null&&B.totalPage)&&e.jsx(gr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:B!=null&&B.currentPage?Number(B.currentPage):1,totalPages:Number(B.totalPage),onPageChange:Ze})]}),e.jsx(dn,{isOpen:Ce,onClose:()=>Te(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:i,onReset:je,getValue:a,setValue:d,clearValue:y,removeFilter:s})]})},un=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:i=[25,50,100],defaultPerPage:s,showPagination:a=!0,showResultCount:d=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:x="Search",searchShortcut:T="/",searchPosition:C="right",searchCollapsible:I=!0,pagination:F,columns:O=[],onColumnsChange:B,columnsState:D,scopeId:H,savedViews:z,persistLastState:S=!0,storage:L=ct,onReset:V,leadingActions:P})=>{const Z=H??(z==null?void 0:z.scopeId),{activeKeys:Y,configByKey:re,hasActiveFilter:he,toggleFilter:fe,removeFilter:te,getValue:Q,setValue:X,clearValue:de,clearAll:Se}=nt({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:p}),se=Vo({columns:O,scopeId:Z,storage:L,onColumnsChange:B,value:D}),Ce=Po({scopeId:Z,storage:L,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>se.state,applyColumns:se.applyState}),Te=jo({scopeId:Z,storage:L,snapshotKeys:[n,l,o],enabled:S}),ke=No({scopeId:Z,storage:L,perPageKey:c,pageSizeOptions:i,enabled:S});qo({enabled:S&&!!Z,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Te.read,readPerPage:ke.read});const He=s??i[0]??25,Ie=!!(z!=null&&z.enabled)&&Ce.enabled,be=()=>{Se(),Te.clear(),V==null||V()},Ze=pe.useMediaQuery("md"),xe=b?e.jsx(ml,{searchKey:p,filterKey:l,pageKey:o,placeholder:x,shortcut:T,collapsible:I}):null;return Ze?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Zo,{configs:t,activeKeys:Y,onToggle:fe,hasActiveFilter:he,onReset:be}),C==="left"&&xe,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(kl,{activeKeys:Y,configByKey:re,getValue:Q,setValue:X,clearValue:de,removeFilter:te}),he&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:be,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[P,e.jsx(cn,{pagination:F,pageKey:o,perPageKey:c,pageSizeOptions:i,defaultPerPage:He,showPagination:a,showResultCount:d,showPageSize:y}),C==="right"&&xe,Ie&&e.jsx(El,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),O.length>0&&e.jsx(Fl,{columns:se.orderedColumns,allVisible:se.allVisible,onToggle:se.toggleVisibility,onReorder:se.reorder,onSetAllHidden:se.setAllHidden})]})]}):e.jsx(gn,{withPadding:r,configs:t,activeKeys:Y,configByKey:re,hasActiveFilter:he,toggleFilter:fe,removeFilter:te,getValue:Q,setValue:X,clearValue:de,onReset:be,searchable:b,searchKey:p,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:T,searchCollapsible:I,pagination:F,perPageKey:c,pageSizeOptions:i,defaultPerPage:He,showPagination:a,showResultCount:d,showPageSize:y,hasColumns:O.length>0,orderedColumns:se.orderedColumns,allVisible:se.allVisible,onToggleVisibility:se.toggleVisibility,onReorder:se.reorder,onSetAllHidden:se.setAllHidden,showSavedViews:Ie,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:P})},yn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r[0];return(t==null?void 0:t.value)!=null?String(t.value):void 0},pn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},bn=(r,t)=>{switch(r.type){case"dropdown":case"radio":return yn(t);case"dropdown-multiple":case"checkbox-multiple":return pn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},Ml=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},vn=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:i="q",defaultPage:s=1,defaultPerPage:a=10,paramKeys:d,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:x,getValue:T}=nt({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:i}),{searchParams:C}=Ee(),I=C.toString();return h.useMemo(()=>{const O={},B={},D=Ml(C.get(o),s),H=Ml(C.get(c),a);O[(d==null?void 0:d.page)??"page"]=D,O[(d==null?void 0:d.perPage)??"perPage"]=H;const z=Mr(i,C,l)||"";z&&(O[(d==null?void 0:d.search)??"search"]=z);let S=!1;for(const L of b){const V=p[L];if(!V)continue;const P=T(V);B[L]=P;const Z=y==null?void 0:y[L],Y=Z?Z(P):bn(V,P);if(Y==null||Array.isArray(Y)&&Y.length===0)continue;const re=(d==null?void 0:d[L])??L;O[re]=Y,S=!0}return{params:O,raw:B,hasActiveFilter:x||!!z||S}},[I,b.join("|"),l,n,o,c,i,s,a,d,y,p])},Cn=["dropdown","dropdown-multiple","checkbox-multiple","radio"],xn=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:i,setValue:s,removeFilter:a,clearAll:d,hasActiveFilter:y}=nt({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),b=(F,O)=>{var D;const B=F.options;return((D=B==null?void 0:B.find(H=>H.value===O))==null?void 0:D.label)??O},p=h.useCallback(F=>{const O=c[F];if(!O)return[];const B=i(O);return Array.isArray(B)?B.map(D=>String(D.value)):[]},[c,i]),x=h.useCallback((F,O)=>{const B=c[F];if(!B||!Cn.includes(B.type))return;const D=Array.isArray(O)?O:[O];if(D.length===0){a(F);return}s(B,D.map(H=>({label:b(B,H),value:H})))},[c,s,a]),T=h.useCallback((F,O)=>{const B=p(F);x(F,B.includes(O)?B.filter(D=>D!==O):[...B,O])},[p,x]),C=h.useCallback((F,O)=>p(F).includes(O),[p]),I=h.useCallback(F=>a(F),[a]);return{set:x,toggle:T,clear:I,clearAll:d,isActive:C,values:p,hasActiveFilter:y}},wn=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:i,to:s}=vl(r.relative);return c[l]=i.toISOString(),c[n]=s.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},Ll=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const i=()=>{if(n.current){const s=n.current.getBoundingClientRect().top;c(`calc(100vh - ${s}px)`)}};return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},Tl=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const i=pe.useMediaQuery("md"),s=c?e.jsx(pl,{...o}):null,a=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:i?"row":"column",gap:"8px",width:i?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:d,icon:y,buttonProps:b,onClick:p},x)=>!d&&!y?null:e.jsx(j.Button,{fullWidth:!i,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:d},`action-${x}`))}):null;return e.jsx(u.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:i?"row":"column-reverse",gap:"16px"},children:n?n({filter:s}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[s,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},Dn=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(ze.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(ze.Body1,{children:r||0})]}),Il=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:i,setSearchParams:s,searchParams:a}=Ee(),d=a.get(l),y=T=>{s({...i,[t]:String(T)})},b=T=>{s({...i,[l]:T,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(k.Text,{children:"Rows Per Page: "}),e.jsx(nr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:T=>{b(T[0].value)},value:d?[{label:`${d} per row`,value:d}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:d?[{label:`${d} per row`,value:d}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(k.Text,{children:`${p}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(gr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(Dn,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},Ol=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),i=h.useRef(null),[s,a]=h.useState(""),[d,y]=h.useState({top:0,left:0}),b=r.selectedValues,p=h.useMemo(()=>s?r.options.filter(C=>C.label.toLowerCase().includes(s.toLowerCase())):r.options,[r.options,s]);h.useEffect(()=>{if(l&&c.current){const C=c.current.getBoundingClientRect(),I=280,F={top:C.bottom+8};r.position==="left"||C.left+I>window.innerWidth?F.right=window.innerWidth-C.right:F.left=C.left,y(F)}},[l,r.position]),h.useEffect(()=>{l&&i.current?setTimeout(()=>{var C;return(C=i.current)==null?void 0:C.focus()},50):a("")},[l]),h.useEffect(()=>{const C=I=>{o.current&&!o.current.contains(I.target)&&c.current&&!c.current.contains(I.target)&&n(!1)};return l&&document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[l]);const x=C=>{const I=b.includes(C)?b.filter(F=>F!==C):[...b,C];r.onFilterChange(I)},T=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:C=>{var I;C.stopPropagation(),l||(I=r.onOpen)==null||I.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.Box,{ref:o,style:{position:"fixed",top:`${d.top}px`,...d.left!==void 0?{left:`${d.left}px`}:{right:`${d.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(k.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(k.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:C=>{C.stopPropagation(),T()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx($e.Input,{ref:i,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:s,onChange:C=>a(C.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(k.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(C=>e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:b.includes(C.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:I=>{I.stopPropagation(),x(C.value)},onMouseEnter:I=>{b.includes(C.value)||(I.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),I.currentTarget.style.transform="translateX(2px)"},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=b.includes(C.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",I.currentTarget.style.transform="translateX(0)"},children:[e.jsx(qe.Checkbox,{checked:b.includes(C.value),onChange:()=>{}}),e.jsx(k.Text,{fontSize:"sm",fontWeight:b.includes(C.value)?"medium":"normal",color:b.includes(C.value)?"primary":"gray-700",children:C.label})]},C.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(k.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(u.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:b.length}),e.jsxs(k.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},Sn=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,i=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:c,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:i},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},kn=({frozen:r})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:r?"currentColor":"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:r?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),ht="var(--sa-background-primary, #ffffff)",Wl="var(--sa-background-primary-inverse, #f8f8f8)",Al=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:i,visibleHandleUpdate:s,visibleHandleDetail:a,showHeadBorder:d=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:x,actionsOrder:T=["detail","update","delete","custom"],customEmptyState:C,enableColumnResize:I=!1,defaultColumnWidths:F,onColumnWidthsChange:O,defaultMinColumnWidth:B=60,sort:D,defaultSort:H,onSortChange:z,showActionDivider:S=!1})=>{const L=D!==void 0,[V,P]=h.useState(H??null),Z=L?D??null:V,Y=W=>{if(W.sortKey)return W.sortKey;if(typeof W.accessor=="string")return W.accessor},re=W=>{const U=Y(W);if(!U)return;let _;!Z||Z.key!==U?_={key:U,direction:"asc"}:Z.direction==="asc"?_={key:U,direction:"desc"}:_=null,L||P(_),z==null||z(_)},fe=[l,n,o].filter(W=>W!==void 0).length,te=!!x,Q=!!l||!!n||!!o||te,X="var(--sa-border-subtle, #0b120e24)",de=`1px solid ${X}`,Se=`inset 1px 0 0 ${X}`,se=`inset -1px 0 0 ${X}`,Ce=fe===3?te?"178px":"140px":fe===2?te?"140px":"102px":fe===1?te?"112px":"74px":te?"74px":"",Te=(W,U)=>{if(!U)return W;if(typeof U=="function")return U(W);if(typeof U=="string")return W[U]},[ke,He]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const W=y.current;He(W.scrollHeight>W.clientHeight)},[t,y]);const Ie=h.useRef(null),[be,Ze]=h.useState([]),[xe,je]=h.useState(()=>F??{}),Ve=h.useRef(null);h.useLayoutEffect(()=>{if(!b||!Ie.current){Ze([]);return}const W=Array.from(Ie.current.querySelectorAll("thead tr th")),U=[];let _=0;W.forEach((J,N)=>{U[N]=_,N<b&&(_+=J.offsetWidth)}),Ze(U)},[b,r,t,xe]);const Ue=W=>{p&&p(W<b?W:W+1)},m=(W,U)=>{const _=xe[W];if(_!==void 0){const J=`${_}px`;return{width:J,minWidth:J,maxWidth:J}}return U?{width:U}:{}},G=W=>I&&(W.resizable??!0),$=(W,U)=>{W.preventDefault(),W.stopPropagation();const _=W.currentTarget.closest("th");if(!_)return;const J=Math.round(_.getBoundingClientRect().width);Ve.current={colIndex:U,startX:W.clientX,startWidth:J};const N=document.body.style.userSelect,ge=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=Ne=>{var Re;const Me=Ve.current;if(!Me)return;const Je=((Re=r[Me.colIndex])==null?void 0:Re.minWidth)??B,we=Math.max(Je,Me.startWidth+(Ne.clientX-Me.startX));je(er=>er[Me.colIndex]===we?er:{...er,[Me.colIndex]:we})},Ge=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ge),document.body.style.userSelect=N,document.body.style.cursor=ge,Ve.current=null,O&&je(Ne=>(O(Ne),Ne))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ge)};return e.jsx("div",{ref:Ie,children:e.jsxs(q.Table,{fullWidth:!0,children:[e.jsx(q.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(q.Tr,{children:[r.map((W,U)=>{var qr,hr;const _=b>0&&U<b,J=be[U]??0,N=G(W),Fe=U===r.length-1&&Q&&S,Ge=Y(W),Ne=!!W.sortable&&!!Ge,Me=Ne&&(Z==null?void 0:Z.key)===Ge?Z.direction:null,Je=W.title||((qr=W.accessor)==null?void 0:qr.toString())||"",we=(hr=W.headerTooltip)!=null&&hr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Re=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),er=Ne?e.jsxs("button",{type:"button",onClick:()=>re(W),title:Me==="asc"?"Sorted ascending — click to sort descending":Me==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left"},children:[Re,we,e.jsx(Sn,{direction:Me})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Re,we]});return e.jsxs(q.Th,{style:{position:"sticky",top:0,left:_?J:void 0,zIndex:_?4:2,paddingLeft:U===0?"12px":"",borderRight:d&&!Fe&&!_?de:void 0,borderBottom:d?de:void 0,boxShadow:d&&_?se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left",...m(U,W.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[W.headerTooltip?e.jsx(Be.Tooltip,{label:W.headerTooltip.content,position:"bottom",children:er}):er,W.filter&&e.jsx(Ol,{filter:W.filter,columnTitle:W.title}),p&&e.jsx("button",{onClick:()=>Ue(U),title:_?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:_?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:_?1:.45,transition:"opacity 0.15s"},children:e.jsx(kn,{frozen:_})})]}),N&&e.jsx("div",{onMouseDown:wr=>$(wr,U),onClick:wr=>wr.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${U}`)}),Q?e.jsx(q.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:d?de:void 0,boxShadow:d&&S?Se:void 0}}):null]})}),e.jsx(q.Tbody,{children:c?e.jsx(q.Tr,{children:e.jsx(q.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&C?e.jsx(q.Tr,{children:e.jsx(q.Td,{colSpan:r.length+1,children:C})}):t==null?void 0:t.map((W,U)=>e.jsxs(q.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:U===t.length-1&&ke?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:_=>{const J=_.currentTarget;J.style.backgroundColor=Wl,Array.from(J.querySelectorAll("td")).forEach(N=>{N.style.position==="sticky"&&(N.style.backgroundColor=Wl)})},onMouseLeave:_=>{const J=_.currentTarget;J.style.backgroundColor="",Array.from(J.querySelectorAll("td")).forEach(N=>{N.style.position==="sticky"&&(N.style.backgroundColor=ht)})},children:[r.map((_,J)=>{const N=_.render?_.render(W,U,t):Te(W,_.accessor),ge=b>0&&J<b,Fe=be[J]??0,Ge=xe[J]!==void 0,Ne=ge&&J===b-1;return e.jsx(q.Td,{style:{position:ge?"sticky":void 0,left:ge?Fe:void 0,zIndex:ge?1:void 0,backgroundColor:ge?ht:void 0,transition:ge?"background-color 0.3s ease":void 0,paddingLeft:J===0?"12px":"",whiteSpace:"nowrap",overflow:Ge?"hidden":void 0,borderLeft:_.showBorderLeft?de:void 0,borderRight:_.showBorderRight?de:void 0,boxShadow:Ne?se:void 0,textAlign:_.textAlign==="text-right"?"right":_.textAlign==="text-center"?"center":"left",...m(J,_.width)},children:typeof N=="string"?e.jsx(k.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:_.textAlign==="text-right"?"right":_.textAlign==="text-center"?"center":"left"},children:N}):N},`row-${U}-col-${J}`)}),Q?e.jsx(q.Td,{style:{width:Ce,position:"sticky",right:0,zIndex:1,backgroundColor:ht,boxShadow:S?Se:void 0,transition:"background-color 0.3s ease"},children:e.jsx(oe.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:T.map(_=>{const J=U===t.length-1?"top":"bottom";return _==="detail"&&l&&(a==null?void 0:a(W))!==!1?e.jsx(Be.Tooltip,{label:"Detail",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(W.id,W),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):_==="update"&&n&&(s==null?void 0:s(W))!==!1?e.jsx(Be.Tooltip,{label:"Update",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(W),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):_==="delete"&&o&&(i==null?void 0:i(W))!==!1?e.jsx(Be.Tooltip,{label:"Delete",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(W.id,W),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):_==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(W)},"custom"):null})})}):null]},`${W}${U}`))})]})})},Bn=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var b;const o=h.useRef(null),[c,i]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),s=(l==null?void 0:l.show)??!0,a=h.useRef(null),d=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof d=="number"&&(a.current=d);const y=(n==null?void 0:n.showFooter)??(d===void 0?a.current!==0:d!==0);return e.jsxs(Ll,{...r,children:[s&&e.jsx(Tl,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(Al,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?i:void 0}):null}),y&&e.jsx(Il,{pagination:t==null?void 0:t.pagination,pageKey:t==null?void 0:t.pageKey,perPageKey:t==null?void 0:t.perPageKey,defaultPerPage:t==null?void 0:t.defaultPerPage,showPagination:t==null?void 0:t.showPagination,totalData:n==null?void 0:n.totalData})]})};function mn(r){return h.memo(r)}const Fn=mn(Bn),zl=200,ft="1px solid var(--sa-border-subtle, #0b120e24)",En=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(M.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(M.Icon,{name:"ChevronSmallDown"}):t?e.jsx(M.Icon,{name:"LockOn",size:"xs"}):e.jsx(M.Icon,{name:"Filter",size:"xs"}),Wr=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"var(--sa-color-error-600, #c9184a)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:i=>{l||(i.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:i=>{i.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(k.Text,{as:"span",style:{color:c},children:t})]})},Hl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:i,onToggleFreeze:s,onHide:a})=>{const[d,y]=h.useState(!1),b=h.useRef(null),p=h.useRef(null),[x,T]=h.useState({top:0,left:0});h.useEffect(()=>{if(d&&b.current){const I=b.current.getBoundingClientRect(),F=I.left+zl>window.innerWidth;T({top:I.bottom+6,...F?{right:window.innerWidth-I.right}:{left:I.left}})}},[d]),h.useEffect(()=>{if(!d)return;const I=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[d]);const C=I=>{I(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||d?"true":"false",onClick:I=>{I.stopPropagation(),y(F=>!F)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:ft,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(En,{sortDir:n,frozen:o})}),d&&e.jsxs(u.Box,{ref:p,onClick:I=>I.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:zl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:ft,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Wr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>C(()=>n==="asc"?i():c("asc"))}),e.jsx(Wr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>C(()=>n==="desc"?i():c("desc"))}),e.jsx("div",{style:{borderTop:ft,margin:"4px 0"}})]}),e.jsx(Wr,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>C(s)}),l&&e.jsx(Wr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>C(a)})]})]})},br="1px solid var(--sa-border-subtle, #0b120e24)",Mn="var(--sa-text-subtle, #8c8f97)",dr="var(--sa-background-neutral, #f0f1f2)",Vl="2px 0 4px -2px rgba(0,0,0,0.15)",vr=40,gt="var(--sa-background-brand-subtlest)",Ar={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Pl="sa-table-layout-styles",Ln=()=>{if(typeof document>"u"||document.getElementById(Pl))return;const r=document.createElement("style");r.id=Pl,r.textContent=`
|
|
1
|
+
(function(g,lr){typeof exports=="object"&&typeof module<"u"?lr(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],lr):(g=typeof globalThis<"u"?globalThis:g||self,lr(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,lr,Ke,u,or,j,It,rr,We,kr,nr,pe,cr,$e,A,gr,ur,q,Ot,Ur,sr,Wt,ir,Be,qe,Jr,k,M,oe,At,zt,Ht,Vt,Pt,Ae,jt,e,h,ve,Yr,ho){"use strict";const fo={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},Xr=h.createContext(fo),Kr=()=>h.useContext(Xr),Nt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},_t=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),qt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(s=>{l(a=>typeof s=="function"?s(a):s)},[]),o=h.useCallback((s,a)=>{l(d=>{const y=typeof a=="function"?a(d[s]):a;return{...d,[s]:y}})},[]),c=h.useCallback(s=>{l(a=>{if(!(s in a))return a;const d={...a};return delete d[s],d})},[]),i=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(_t.Provider,{value:i,children:r})},Zt=()=>h.useContext(_t),Br=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},Gt=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:i})=>{const s=Nt({initialUserData:c}),{theme:a}=sr.useTheme();return e.jsx(Xr.Provider,{value:{logo:n,appName:o,menus:t,userData:s.userData,setUserData:s.setUserData,menuBottom:l},children:e.jsx(qt,{children:i?e.jsx(sr.ThemeProvider,{value:i,children:r}):a?e.jsx(sr.ThemeProvider,{value:a,children:r}):r})})},go=h.memo(Gt);function Qt({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const $r=h.createContext(null);function Ut({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,i]=h.useState(null),[s,a]=h.useState(0),d=h.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx($r.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:i,replaceCount:s,registerReplace:d},children:r})}function Jt({children:r}){const t=h.useContext($r);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:t.setPrependNode,style:{display:"contents"}}),t.replaceCount>0?e.jsx("div",{ref:t.setReplaceNode,style:{display:"contents"}}):r,e.jsx("div",{ref:t.setAppendNode,style:{display:"contents"}})]}):e.jsx(e.Fragment,{children:r})}function uo({children:r,mode:t="append"}){const l=h.useContext($r);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?Yr.createPortal(r,n):null}const Rr=h.createContext(null);function Yt({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((a,d)=>{l(y=>y[a]===d?y:{...y,[a]:d})},[]),i=h.useCallback(a=>(o(d=>({...d,[a]:(d[a]??0)+1})),()=>o(d=>({...d,[a]:Math.max(0,(d[a]??0)-1)}))),[]),s=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:i}),[t,c,n,i]);return e.jsx(Rr.Provider,{value:s,children:r})}function Xt({slotKey:r,fallback:t}){const l=h.useContext(Rr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(i=>{var s;return(s=o.current)==null?void 0:s.call(o,r,i)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function yo({slotKey:r,children:t}){const l=h.useContext(Rr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?Yr.createPortal(t,o):null}const mr="moduleSwitcherGroupId",et="sa-module-switcher-change";function Kt(){if(typeof window>"u")return null;const r=window.localStorage.getItem(mr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function $t(r){typeof window>"u"||(r===null?window.localStorage.removeItem(mr):window.localStorage.setItem(mr,String(r)),window.dispatchEvent(new CustomEvent(et,{detail:r})))}function po(){$t(null)}function rt(){const[r,t]=h.useState(()=>Kt());return h.useEffect(()=>{const n=()=>{t(Kt())},o=c=>{c.key===mr&&n()};return window.addEventListener(et,n),window.addEventListener("storage",o),()=>{window.removeEventListener(et,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{$t(n),t(n)}}}let Fr=0,tr=!1,Rt=new Set;const el=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),rl={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function bo({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:i,sidebarHeaderContent:s,headerActions:a,profileRole:d,profileMenuButtons:y,profileMenuItems:b,logoutButton:p}){var Ve,Ue;const[x]=ve.useSearchParams(),T=x.get("embed")==="true",C=Kr(),{badges:I}=Zt(),F=ve.useNavigate(),O=ve.useLocation(),D=!pe.useMediaQuery("md"),[H,z]=h.useState(!1),[S,L]=h.useState(!1),[V,P]=h.useState(!1),[Z,Y]=h.useState(!1),[re,he]=h.useState(()=>new Set(Rt)),[fe,te]=h.useState(null),{selectedGroupId:Q,setSelectedGroupId:X}=rt();h.useEffect(()=>{Rt=re},[re]);const de=h.useRef(null),Se=h.useRef(null);h.useEffect(()=>{const m=de.current;if(!m)return;const G=()=>{tr||(Fr=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const se=()=>{const m=de.current;m&&Fr>0&&(tr=!0,m.scrollTop=Fr,requestAnimationFrame(()=>{tr=!1}))};h.useLayoutEffect(()=>{tr=!0,se();const m=setTimeout(()=>{tr=!1},300);return()=>clearTimeout(m)},[]),h.useLayoutEffect(()=>{C.menus.length>0&&(Fr>0?se():requestAnimationFrame(()=>{var G;const m=(G=de.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[C.menus]),h.useEffect(()=>{tr=!0,se();const m=setTimeout(se,0),G=setTimeout(se,50),$=setTimeout(se,100),W=setTimeout(se,200),U=setTimeout(()=>{tr=!1},300),_=setTimeout(()=>{const J=de.current,N=J==null?void 0:J.querySelector("[data-menu-active='true']");if(J&&N){const ge=J.getBoundingClientRect(),Fe=N.getBoundingClientRect();Fe.top>=ge.top&&Fe.bottom<=ge.bottom||N.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout($),clearTimeout(W),clearTimeout(U),clearTimeout(_)}},[O.pathname]),h.useEffect(()=>{Se.current&&(Se.current.scrollTop=0)},[O.pathname]),h.useEffect(()=>{D&&P(!1)},[O.pathname,D]),h.useEffect(()=>{D&&L(!0)},[D]);const Ce=()=>{z(!0)},Te=()=>{z(!1)},ke=()=>{z(!1),o()},He=m=>{const G=[m.to];return m.children&&G.push(...m.children.map($=>$.to)),G},Ie=[...C.menus.flatMap(m=>m.items.flatMap(He)),...((Ve=C.menuBottom)==null?void 0:Ve.flatMap(He))??[]],be=m=>{if(!O.pathname.startsWith(m))return!1;const G=Ie.filter($=>O.pathname.startsWith($)).sort(($,W)=>W.length-$.length)[0];return m===G};h.useEffect(()=>{var G;const m=$=>{var W;(W=$.children)!=null&&W.some(U=>O.pathname.startsWith(U.to))&&he(U=>{const _=new Set(U);return _.add($.id),_})};C.menus.forEach($=>{$.items.forEach(m)}),(G=C.menuBottom)==null||G.forEach(m)},[O.pathname,C.menus,C.menuBottom]);const Ze=m=>{he(G=>{const $=new Set(G);return $.has(m)?$.delete(m):$.add(m),$})};h.useEffect(()=>{C.menus.length!==0&&Q!==null&&!C.menus.some(m=>m.id===Q)&&X(null)},[C.menus,Q,X]);const xe=h.useMemo(()=>{if(Q!==null)return C.menus.filter($=>$.id===Q||$.parentGroupId===Q);const m=C.menus.filter($=>$.parentGroupId===void 0),G=C.menus.filter($=>$.parentGroupId!==void 0).flatMap($=>$.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[C.menus,Q]);if(T)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ve.Outlet,{})});const je=m=>{const G=m.children&&m.children.length>0,$=re.has(m.id),W=G?m.children.some(J=>be(J.to)):be(m.to),U=Br(m.badge,I[m.id]),_=!!U&&S&&!D;return e.jsxs("div",{"data-menu-active":W||void 0,children:[e.jsxs("button",{onClick:J=>{if(G)if(S&&!D){const N=J.currentTarget.getBoundingClientRect();te({item:m,top:N.top,left:N.right+8})}else Ze(m.id);else F(m.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:S&&!D?"center":void 0,gap:"0.5rem",paddingLeft:S&&!D?"0":"0.5rem",paddingRight:S&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:W?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:W?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:W?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:S&&!D?m.title:void 0,onMouseEnter:J=>{W||(J.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:J=>{W||(J.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),_&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!S||D)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:m.title}),U&&e.jsx(Ke.Badges,{text:String(U.value),variant:U.variant??"info",size:"xs",border:!0}),G&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:$?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),G&&(!S||D)&&(()=>{const J=m.children.findIndex(N=>be(N.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:$?`${m.children.length*36}px`:"0px",opacity:$?1:0,marginTop:$?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),J>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${J*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),m.children.map(N=>{const ge=Br(N.badge,I[N.id]);return e.jsxs("button",{onClick:()=>F(N.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:be(N.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:be(N.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:be(N.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:be(N.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{be(N.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{be(N.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(M.Icon,{name:N.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:N.title}),ge&&e.jsx(Ke.Badges,{text:String(ge.value),variant:ge.variant??"info",size:"xs",border:!0})]},N.id)})]})})()]},m.id)};return e.jsx(Yt,{children:e.jsxs(Ut,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":S?"4.375rem":"16.375rem","--app-footer-zindex":D&&V?"40":"998"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:V?.5:0,pointerEvents:V?"auto":"none",transition:"opacity 0.3s"},onClick:()=>P(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":S?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:V?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const m=!D&&S&&!V,G=m&&Z;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:m?1:void 0,justifyContent:m?"center":void 0,transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:C.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!S||V)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:C.appName})]}),!D&&!S&&e.jsx("button",{type:"button",onClick:()=>L(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(el,{})}),m&&e.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(el,{})})}),D&&e.jsx("button",{onClick:()=>P(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),s&&e.jsx(Qt,{collapsed:D?!1:S,children:s}),e.jsx("div",{ref:de,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:xe.map(m=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!S||D?m.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.name}):m.name&&e.jsx("div",{"aria-label":m.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:m.slotKey?e.jsx(Xt,{slotKey:m.slotKey,fallback:m.items.map(G=>je(G))}):m.items.map(G=>je(G))})]},m.id))}),C.menuBottom&&C.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:C.menuBottom.map(m=>je(m))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:D?"1rem":void 0},children:[D&&e.jsx("button",{onClick:()=>P(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(Jt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(A.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.email)||"unknown"}),d&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuButton,{children:e.jsxs("button",{type:"button",onClick:m.onClick,style:rl,onMouseEnter:$=>{$.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(M.Icon,{name:m.icon,size:"md"}),e.jsx("span",{children:m.label})]})},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Ce,style:{...rl,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(M.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:Se,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ve.Outlet,{})})]})]}),c&&i&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:i}),e.jsxs(We.Dialog,{isShow:H,onHide:Te,children:[e.jsx(We.DialogTitle,{children:"Confirmation Logout"}),e.jsx(We.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(We.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(oe.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Te,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:ke,children:"Yes, Sure"})})]})})})]}),fe&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>te(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":fe.item.title,style:{position:"fixed",top:fe.top,left:fe.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:fe.item.title}),(Ue=fe.item.children)==null?void 0:Ue.map(m=>{const G=be(m.to),$=Br(m.badge,I[m.id]);return e.jsxs("button",{onClick:()=>{F(m.to),te(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:G?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:W=>{G||(W.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:W=>{G||(W.currentTarget.style.backgroundColor="transparent")},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:m.title}),$&&e.jsx(Ke.Badges,{text:String($.value),variant:$.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const yr=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),tl=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[i,s]=h.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",d=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",b=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:i?y:a,transition:"color 0.15s ease"}}),e.jsx(k.Text,{variant:"sub-h3",style:{color:i?b:d,transition:"color 0.15s ease"},children:r||"Back"})]})},vo=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,i]=h.useState(!1),s=n??"var(--sa-text-subtle, #8c8f97)",a=o??"var(--sa-text-subtle, #8c8f97)",d=r.length>1?r[0]:void 0,y=!!(d!=null&&d.to||d!=null&&d.onClick),b=e.jsx(M.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>i(!0):void 0,onMouseLeave:y?()=>i(!1):void 0,style:{color:y&&c?a:s,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),p=d!=null&&d.to?e.jsx(ve.Link,{to:d.to,replace:!0,style:{textDecoration:"none"},children:b}):d!=null&&d.onClick?e.jsx(yr,{onClick:d.onClick,children:b}):b;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(or.Breadcrumb,{separator:t,size:"md",children:r.map((x,T)=>{const C=T===r.length-1;return x.to&&!C?e.jsx(or.BreadcrumbItem,{children:e.jsx(ve.Link,{to:x.to,children:x.label})},T):e.jsx(or.BreadcrumbItem,{currentPage:C,children:e.jsx(or.BreadcrumbLink,{onClick:C?void 0:x.onClick,children:x.label})},T)})})]})},Co=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(vo,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ve.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(tl,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(yr,{onClick:n,children:e.jsx(tl,{...c})})})},tt=[{icon:"var(--sa-color-brand-400, #3366b7)",activeBg:"var(--sa-color-brand-50, #e6edf6)",activeBorder:"var(--sa-color-brand-300, #668cc9)",activeShadow:"rgba(51, 102, 183, 0.25)"},{icon:"var(--sa-color-warning-400, #ed9f30)",activeBg:"var(--sa-color-warning-50, #fef2e6)",activeBorder:"var(--sa-color-warning-300, #f1b259)",activeShadow:"rgba(237, 159, 48, 0.25)"},{icon:"var(--sa-color-secondary-300, #5468e1)",activeBg:"var(--sa-color-secondary-50, #e6e9fb)",activeBorder:"var(--sa-color-secondary-200, #8a98ea)",activeShadow:"rgba(84, 104, 225, 0.25)"},{icon:"var(--sa-color-info-500, #00abeb)",activeBg:"var(--sa-color-info-50, #effaff)",activeBorder:"var(--sa-color-info-300, #75dbff)",activeShadow:"rgba(0, 171, 235, 0.25)"},{icon:"var(--sa-color-success-500, #30ce84)",activeBg:"var(--sa-color-success-50, #ecfff6)",activeBorder:"var(--sa-color-success-300, #75dead)",activeShadow:"rgba(48, 206, 132, 0.25)"},{icon:"var(--sa-color-error-400, #ff758f)",activeBg:"var(--sa-color-error-50, #fff0f3)",activeBorder:"var(--sa-color-error-300, #ff8fa3)",activeShadow:"rgba(255, 117, 143, 0.25)"}];function ll(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const ol={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},nl={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function cl({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,i]=h.useState(void 0),s=d=>{o(d),t()},a=tt[0];return e.jsx(We.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(We.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>s(null),onMouseEnter:()=>i("all"),onMouseLeave:()=>i(void 0),style:nl,children:[e.jsx("div",{style:ll(n===null,c==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:ol,children:"Semua"})]}),l.map((d,y)=>{var C;const b=n===d.id,p=c===d.id,x=((C=d.items[0])==null?void 0:C.icon)??"Grid",T=tt[(y+1)%tt.length];return e.jsxs("button",{onClick:()=>s(d.id),onMouseEnter:()=>i(d.id),onMouseLeave:()=>i(void 0),style:nl,children:[e.jsx("div",{style:ll(b,p,T),children:e.jsx("div",{style:{color:T.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:ol,children:d.name})]},d.id)})]})})})}function xo({onSelect:r,"aria-label":t="Pilih module"}={}){const l=Kr(),n=ve.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=rt(),[i,s]=h.useState(!1),a=d=>{var y;if(c(d),d!==null){const b=l.menus.find(x=>x.id===d),p=(y=b==null?void 0:b.items[0])==null?void 0:y.to;p&&n(p)}r==null||r(d)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>s(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":t,onMouseEnter:d=>{d.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),o!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(cl,{isShow:i,onHide:()=>s(!1),menus:l.menus.filter(d=>d.parentGroupId===void 0),selectedGroupId:o,onSelect:a})]})}const wo=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Do=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const i=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),s=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),a=()=>typeof t=="string"?e.jsx(k.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,d=()=>typeof r=="string"||typeof r=="number"?e.jsx(k.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(k.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(q.Tr,{children:[e.jsx(q.Td,{style:i,width:n,children:a()}),l?e.jsx(q.Td,{style:s,width:24,children:y()}):null,e.jsx(q.Td,{style:i,children:d()})]})}),So=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(q.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,o)=>e.jsx(Do,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),ko=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const i=h.useMemo(()=>wo(n,r),[n,r]),s=i.length>2,a=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(u.Box,{gap:s?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:s?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:i.map((d,y)=>e.jsx(u.Box,{direction:"column",flex:s?void 0:"1",width:s?a():void 0,marginBottom:s?"lg":void 0,children:e.jsx(So,{labelWidth:o,fields:d,separator:l})},y))})}),Bo=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",i=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(k.Text,{variant:"sub-h3",style:{color:t?i:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},mo=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:i=!1,subHeaders:s,action:a,titleTagProps:d,containerProps:y,headerProps:b})=>{const p=pe.useMediaQuery("md"),x=ve.useNavigate(),T=ve.useLocation(),C=r==null?void 0:r.show,I=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},F=()=>{if(!a)return null;if(h.isValidElement(a))return a;const S=a.filter(L=>L&&(L.title||L.icon));return S.length===0?null:p?e.jsx(u.Box,{direction:"row",gap:"md",children:S.map(({title:L,icon:V,buttonProps:P,onClick:Z},Y)=>e.jsx(j.Button,{iconLeft:V?e.jsx(M.Icon,{name:V,size:"md"}):void 0,onClick:Z,...P,children:L},`action-${Y}`))}):e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:200},children:S.map(({title:L,icon:V,buttonProps:P,onClick:Z},Y)=>{const re=(P==null?void 0:P.tone)==="error"||(P==null?void 0:P.danger)===!0;return e.jsx(A.MenuItem,{intent:re?"danger":void 0,disabled:P==null?void 0:P.disabled,startIcon:V?e.jsx(M.Icon,{name:V}):void 0,onClick:Z,children:L},`action-${Y}`)})})})]})},O=()=>{const S=e.jsx(Bo,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ve.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:S})}):e.jsx(u.Box,{direction:"row",children:e.jsx(yr,{onClick:I,children:S})})},B=()=>{const S=!!t,L=Array.isArray(a)&&a.length>0,V=h.isValidElement(a)?!0:L;if(!S&&!V&&!C)return null;const Z=p||!p&&L;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(b==null?void 0:b.paddingBlock)??"sm",paddingInline:(b==null?void 0:b.paddingInline)??"md",...b,style:{...i?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...b==null?void 0:b.style},children:[C&&O(),(S||V)&&e.jsxs(u.Box,{direction:Z?"row":"column",gap:"sm",justify:"space-between",align:Z?"center":"flex-start",children:[S?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(M.Icon,{name:l,size:"md",color:"primary"}),e.jsx(k.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ke.Badge,{border:!0,size:"lg",text:n,...d})]}):t:null,F()]})]})},D=()=>{if(!s||s.length===0)return null;const S=s.filter(P=>P.show!==!1);if(S.length===0)return null;let L=0,V=-1/0;return S.forEach((P,Z)=>{const Y=P.order??0;Y>=V&&(V=Y,L=Z)}),S.map(({content:P,order:Z,borderBottom:Y=!0,keepBottomPadding:re=!1},he)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:Y||re||he===L?"sm":"spacing-0",paddingInline:"md",style:{...Y?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...Z!==void 0?{order:Z}:{}},children:P},`sub-header-${he}`))},H=()=>{const S=c?B():null,L=D();return!S&&!L?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:L?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[S,L]})},z=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[H(),z()]},T.pathname)},Fo=h.memo(mo),Eo={icon:"Cross",title:""},Mo="calc(100vw - 16px)",sl=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${Mo})`,il=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Eo,width:i,minWidth:s="357px",maxWidth:a="357px"},d)=>{const y=sl(i??s),b=sl(i??a);return e.jsx(kr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:d,style:{minWidth:y,maxWidth:b,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(M.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(k.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),lt=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=pe.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),ot=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=pe.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Lo=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),To=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:i,containerProps:s,bodyProps:a,headerProps:d={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=pe.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(k.Text,{fontWeight:"medium",children:t}),e.jsx(Ke.Badges,{border:!0,text:l,variant:b})]}):e.jsx(k.Text,{fontWeight:"medium",children:t}),T=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...i,children:n??null})]}),C=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...s,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(s==null?void 0:s.style)??{}},children:[o!==null&&C?e.jsx(lt,{...d,children:T()}):null,e.jsx(Lo,{...a,children:r}),c?e.jsx(ot,{...y,children:c}):null]})}),ze={H1:r=>e.jsx(k.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(k.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(k.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(k.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(k.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(k.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(k.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(k.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(k.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(k.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(k.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(k.Text,{variant:"body-3",children:r.children,...r.props})},Ee=()=>{const[r,t]=ve.useSearchParams(),l=cr.searchParamsToObject(r.toString()),n=ve.useParams(),o=ve.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,b)=>r.has(y)&&r.get(y)===b,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},al=r=>JSON.stringify(r),dl=r=>JSON.stringify(r),hl=r=>JSON.stringify(r),fl=r=>JSON.stringify(r),Io=r=>r,Oo=r=>JSON.stringify(r),pr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:i,filterKey:s="filter",pageKey:a="page"})=>{if(n){let d;switch(l){case"search":d=Io(r);break;case"dropdown":case"dropdown-multiple":d=al(r);break;case"radio":d=dl(r);break;case"date-range":d=hl(r);break;case"advanced-date-range":d=Oo(r);break;case"date":d=fl(r);break;default:d=r;break}if(typeof d<"u"){const b={...c[s]&&typeof c[s]=="string"?JSON.parse(c[s]):void 0,[t]:d},p={...c};i&&typeof i=="string"&&delete p[i],delete p[a];const x={...p,[s]:JSON.stringify(b)},T=new URLSearchParams(c).toString(),C=new URLSearchParams(x).toString();if(T===C)return;o(x)}}},Er=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="label"&&i?JSON.parse(i)[0].label:n==="value"&&i?JSON.parse(i)[0].value:i},gl=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="label"&&i?JSON.parse(i).map(s=>s.label):n==="value"&&i?JSON.parse(i).map(s=>s.value):n==="array"&&i?JSON.parse(i):i},Wo=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,i=c?c[r]:void 0;return n==="id"&&i?JSON.parse(i).id:n==="label"&&i?JSON.parse(i).label:n==="value"&&i?JSON.parse(i).value:i},Mr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},Ao=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},ul=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},zo=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,i=r.get(n)||void 0;return!!o||!!c||!!i},yl=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:i,searchQueries:s}=Ee(),[a,d]=h.useState({}),y=()=>{c.delete(l||"filter"),i(c)},b=(p,x)=>{switch(p.type){case"radio":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"dropdown":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"dropdown-multiple":{const{show:T=!0}=p;return T&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}default:return null}};return e.jsx(il,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(oe.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((p,x)=>b(p,x))]})})},pl=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:i=!0,filterKey:s="filter",pageKey:a="page",customWidthSearch:d,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:x="right",titleSearchLabel:T="Work Order",withTitleLabels:C=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[O,B]=h.useState(!1),[D,H]=h.useState(0),z=()=>{H(X=>X+1)},{searchParams:S,setSearchParams:L,getQueryParam:V}=Ee(),P=cr.searchParamsToObject(S.toString()),Z=Mr(r,S,s)||"",[Y,re]=h.useState(Z),he=V(s),te=!!(he&&!(()=>{if(he)try{const X=JSON.parse(he);return Object.keys(X).length===1&&X[r]===""}catch(X){console.error("Filter parameter is not a valid JSON:",X)}return!1})()),Q=pe.useMediaQuery("md");return h.useEffect(()=>{re(Z)},[Z]),h.useEffect(()=>{if(Y===Z)return;const X=window.setTimeout(()=>{pr({value:Y,name:r,type:"search",searchQueries:P,setSearchParams:L,filterKey:s,pageKey:a})},350);return()=>{window.clearTimeout(X)}},[Y,Z,r,P,L,s,a]),e.jsxs(oe.Flex,{gap:"md",style:{flexDirection:Q&&x==="left"?"row":Q&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[te&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const X=new URLSearchParams(S);X.delete(s),L(X),re(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(k.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:X,content:de,title:Se,onClickContainer:se},Ce)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:se,style:{minWidth:X},children:[Se&&e.jsx(ze.SubH3,{children:Se}),de]},`extended-filter-${Ce}-${D}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:te,secondary:!te,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:he?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!Q,onClick:()=>B(!0),children:F?"Filter":void 0}),i&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[C&&e.jsx(ze.SubH3,{children:"Status"}),e.jsx(nr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:Er({get:"value",name:t,searchParams:S,filterKey:s})?[{label:Er({get:"value",name:t,searchParams:S,filterKey:s})==="active"?"Active":"InActive",value:Er({get:"value",name:t,searchParams:S,filterKey:s})}]:[],onChange:X=>pr({value:X,name:t,type:"dropdown",searchQueries:P,setSearchParams:L,filterKey:s}),placeholder:C?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:d&&Q?d:Q?"310px":""},children:[C&&e.jsxs(ze.SubH3,{children:["Search for ",T]}),e.jsx($e.Input,{placeholder:l,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:X=>re(X.target.value),value:Y,fullWidth:!0},D+1+s)]}),e.jsx(yl,{isOpen:O,onClose:()=>B(!1),filterKey:s,filters:b,pageKey:a})]})},Ho=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function nt({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:i,searchQueries:s}=Ee(),a=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),d=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(z=>z.trim()).filter(Boolean);let H=[];try{const z=c.get(t);z&&(H=Object.keys(JSON.parse(z)).filter(S=>S!==o))}catch{}return r.map(z=>z.key).filter(z=>{const S=a[z];return(S==null?void 0:S.locked)||D.includes(z)||H.includes(z)})},[c,l,t,o,r,a]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),b=h.useCallback(D=>{const H={...s};D.length?H[l]=D.join(","):delete H[l],i(H)},[s,l,i]),p=h.useCallback(D=>{d.includes(D)||b([...d,D])},[d,b]),x=h.useCallback(D=>{var L;if((L=a[D])!=null&&L.locked)return;const H={...s},z=d.filter(V=>V!==D);z.length?H[l]=z.join(","):delete H[l];const S=y(H);D in S&&(delete S[D],Object.keys(S).length?H[t]=JSON.stringify(S):delete H[t]),delete H[n],i(H)},[s,d,l,t,n,y,i,a]),T=h.useCallback(D=>d.includes(D)?x(D):p(D),[d,p,x]),C=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return gl({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const H=ul({name:D.key,searchParams:c,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const z=y(Object.fromEntries(c.entries()))[D.key];return z&&typeof z=="object"?z:void 0}default:return}},[c,t,y]),I=h.useCallback((D,H)=>{if(D.type==="date-compact"){const z={...s},S=y(z);H==null?delete S[D.key]:S[D.key]=H,Object.keys(S).length?z[t]=JSON.stringify(S):delete z[t],delete z[n],i(z);return}pr({value:H,name:D.key,type:Ho(D.type),searchQueries:s,setSearchParams:i,filterKey:t,pageKey:n})},[s,i,t,n,y]),F=h.useCallback(D=>{const H={...s},z=y(H);D in z&&(delete z[D],Object.keys(z).length?H[t]=JSON.stringify(z):delete H[t]),delete H[n],i(H)},[s,t,n,y,i]),O=h.useCallback(()=>{const D={...s};delete D[t],delete D[l],delete D[n],i(D)},[s,t,l,n,i]),B=d.length>0;return{activeKeys:d,configByKey:a,hasActiveFilter:B,addFilter:p,removeFilter:x,toggleFilter:T,getValue:C,setValue:I,clearValue:F,clearAll:O}}const ct={get(r){return ur.storage.get(r)??null},set(r,t){ur.storage.save(r,t)},remove(r){ur.storage.delete(r)}},ar={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},Lr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function Vo({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(S=>S.key),hidden:[]}),[r]),i=t?ar.columns(t):void 0,s=(S,L)=>Lr({order:S.order??L,hidden:S.hidden??[]},r),[a,d]=h.useState(()=>{if(o&&(o.order||o.hidden))return s(o,r.map(S=>S.key));if(i){const S=l.get(i);if(S&&Array.isArray(S.order))return Lr(S,r)}return c}),y=r.map(S=>S.key).join("|");h.useEffect(()=>d(S=>Lr(S,r)),[y]);const b=h.useRef(a);b.current=a;const p=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(p);h.useEffect(()=>{if(p==null||x.current===p)return;x.current=p;const S=b.current,L=s(o,S.order);L.order.join("|")===S.order.join("|")&&L.hidden.join("|")===S.hidden.join("|")||(d(L),i&&l.set(i,L))},[p,y]);const T=h.useRef(!1);h.useEffect(()=>{T.current||(T.current=!0,n==null||n(a))},[]);const C=h.useCallback(S=>{d(S),i&&l.set(i,S),n==null||n(S)},[i,l,n]),I=h.useMemo(()=>{const S=new Map(r.map(L=>[L.key,L]));return a.order.filter(L=>S.has(L)).map(L=>({...S.get(L),visible:!a.hidden.includes(L)}))},[a,r]),F=h.useCallback(S=>{const L=a.hidden.includes(S)?a.hidden.filter(V=>V!==S):[...a.hidden,S];C({...a,hidden:L})},[a,C]),O=h.useCallback((S,L)=>{if(S===L)return;const V=[...a.order],[P]=V.splice(S,1);V.splice(L,0,P),C({...a,order:V})},[a,C]),B=h.useCallback(S=>{C({...a,hidden:S?r.filter(L=>!L.locked).map(L=>L.key):[]})},[a,r,C]),D=h.useCallback(()=>C(c),[C,c]),H=h.useCallback(S=>C(Lr(S,r)),[C,r]),z=a.hidden.length===0;return{state:a,orderedColumns:I,allVisible:z,toggleVisibility:F,reorder:O,setAllHidden:B,reset:D,applyState:H}}function Po({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:i,setSearchParams:s}=Ee(),a=r?ar.savedViews(r):void 0,[d,y]=h.useState(()=>a?t.get(a)||[]:[]),b=h.useCallback(C=>{y(C),a&&t.set(a,C)},[a]),p=h.useCallback(C=>{const I=C.trim();if(!I)return;const F={};l.forEach(B=>{const D=i.get(B);D!=null&&(F[B]=D)});const O={id:`${Date.now()}`,name:I,query:F,columns:o==null?void 0:o(),createdAt:Date.now()};b([...d,O])},[l,i,o,b,d]),x=h.useCallback(C=>b(d.filter(I=>I.id!==C)),[b,d]),T=h.useCallback(C=>{const I=Object.fromEntries(i.entries());l.forEach(F=>delete I[F]),Object.assign(I,C.query),delete I[n],s(I),C.columns&&(c==null||c(C.columns))},[i,l,n,s,c]);return{enabled:!!a,views:d,saveView:p,deleteView:x,applyView:T}}function jo({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=Ee(),c=r&&n?ar.lastState(r):void 0,i=h.useRef(c),s=h.useRef(!1);h.useEffect(()=>{if(!c){i.current=c;return}if(i.current!==c){i.current=c,s.current=!1;return}const y={};if(l.forEach(b=>{const p=o.get(b);p!=null&&(y[b]=p)}),Object.keys(y).length===0){s.current&&t.remove(c);return}s.current=!0,t.set(c,y)},[o,c,l,t]);const a=h.useCallback(()=>{if(!c)return null;const y=t.get(c);return y&&Object.keys(y).length>0?y:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:a,clear:d}}function No({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=Ee(),i=r&&o?ar.perPage(r):void 0,s=c.toString(),a=h.useRef(i);h.useEffect(()=>{if(!i){a.current=i;return}if(a.current!==i){a.current=i;return}const b=c.get(l);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(i,p)},[s,i,l,t]);const d=h.useCallback(()=>{if(!i)return null;const b=t.get(i);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[i,t,n]),y=h.useCallback(()=>{i&&t.remove(i)},[i,t]);return{enabled:!!i,read:d,clear:y}}let st={},it=!1,at=null;const _o=(r,t)=>{Object.assign(st,r),at=t,!it&&(it=!0,queueMicrotask(()=>{const l=st,n=at;st={},it=!1,at=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([i,s])=>c.set(i,s)),c})}))};function qo({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:i,location:s}=Ee(),a=h.useRef(null);h.useEffect(()=>{if(!r||a.current===s.pathname)return;a.current=s.pathname;const d={};if(!c.has(l)){const y=o();y&&(d[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(d,y)}Object.keys(d).length!==0&&_o(d,i)},[s.pathname,r])}const Zo=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(A.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,Tr=({onClear:r,onRemove:t})=>e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(M.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:180},children:[e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(A.MenuItem,{intent:"danger",startIcon:e.jsx(M.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),Go=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},bl=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},vl=r=>{const t=Go(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:bl(t,-l,r.period),to:t}:{from:t,to:bl(t,l,r.period)}},Cl=24,xl=r=>r.length>Cl?`${r.slice(0,Cl)}...`:r,Ir=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Or={is:"Is","is-before":"Is before","is-after":"Is after","is-on-or-before":"Is on or before","is-on-or-after":"Is on or after","is-between":"Is between","is-relative-to-today":"Is relative to today","is-empty":"Is empty","is-not-empty":"Is not empty"},Qo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],dt={past:"Past",next:"Next",this:"This"},Uo=["day","week","month","year"],Jo=["past","next","this"],Yo=r=>r.field.type==="date-compact"?e.jsx($o,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(Xo,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),Xo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?Ir(new Date(t)):null,i=!!c,s=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:xl(c)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:s})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():l(a),withPadding:!1})})})]})},Ko=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Or[r.op]} ${Ir(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${Ir(new Date(r.from))} - ${Ir(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${dt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return Or[r.op];default:return null}},$o=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.ops&&r.ops.length>0?r.ops:Qo,i=r.defaultOp&&c.includes(r.defaultOp)?r.defaultOp:c[0],s=(t==null?void 0:t.op)??i,a=t?Ko(t):null,d=!!a,y=d?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:xl(a)})]}):r.label,b=p=>{if(p!==s){if(p==="is-empty"||p==="is-not-empty"){l({op:p});return}if(p==="is-relative-to-today"){l({op:p,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(p==="is-between"){l({op:p,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:p,date:t==null?void 0:t.date})}};return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:d?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:d?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:y})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Ro,{op:s,ops:c,onChange:b})]}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsx(en,{value:t,op:s,onChange:l})}),s==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Ro=({op:r,ops:t,onChange:l})=>e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Or[r]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:200},children:t.map(n=>e.jsx(A.MenuItem,{selected:r===n,onClick:()=>l(n),endIcon:r===n?e.jsx(M.Icon,{name:"Check"}):void 0,children:Or[n]},n))})})]}),en=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:i}=o;if(!c&&i&&(c=i,i=null),!c&&!i){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(rn,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(rr.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},rn=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",i=vl({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:dt[l]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Jo.map(s=>e.jsx(A.MenuItem,{selected:l===s,endIcon:l===s?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(s==="this"?{direction:s,period:o}:{direction:s,count:n,period:o}),children:dt[s]},s))})})]}),c&&e.jsx($e.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:s=>{const a=Number(s.target.value);t({direction:l,count:Number.isFinite(a)&&a>0?a:1,period:o})},style:{width:72}}),e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Uo.map(s=>e.jsx(A.MenuItem,{selected:o===s,endIcon:o===s?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:s}:{direction:l,count:n,period:s}),children:s},s))})})]})]}),e.jsx(rr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:i,onChange:()=>{},withPadding:!1},"relative-preview")]})},wl=18,tn=r=>r.length>wl?`${r.slice(0,wl)}...`:r,ln=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",i=t.length,s=r.searchable!==!1,[a,d]=h.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(O=>O.label.toLowerCase().includes(F)):y})(),x=F=>t.some(O=>O.value===F.value),T=F=>{if(!c){l([{label:F.label,value:F.value}]),d("");return}l(x(F)?t.filter(O=>O.value!==F.value):[...t,{label:F.label,value:F.value}])},C=F=>{var O;d(F),(O=r.onSearch)==null||O.call(r,F)},I=i===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:i===1?tn(t[0].label):`${i} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:I})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[s&&e.jsx(nr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:a,onSearch:C,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(k.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!c,selected:x(F),startIcon:F.avatar,endIcon:x(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>T(F),children:F.label},F.value))})]})})})]})},Dl=18,on=r=>r.length>Dl?`${r.slice(0,Dl)}...`:r,Sl=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(qe.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),nn=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(p=>p.value)),i=t.length,s=r.options.length>0&&r.options.every(p=>c.has(p.value)),a=i>0&&!s,d=p=>{l(c.has(p.value)?t.filter(x=>x.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{l(s?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=i===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(k.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(k.Text,{as:"span",children:i===1?on(t[0].label):`${i} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:i>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Tr,{onClear:n,onRemove:o})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s,onClick:y,startIcon:e.jsx(Sl,{checked:s||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:c.has(p.value),onClick:()=>d(p),startIcon:e.jsx(Sl,{checked:c.has(p.value)}),children:p.label},p.value))]})})]})},kl=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(i=>{const s=t[i];if(!s)return null;const a=l(s),d=s.locked?void 0:()=>c(i);return s.type==="date"||s.type==="date-compact"?e.jsx(Yo,{field:s,value:a,onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i):s.type==="checkbox-multiple"?e.jsx(nn,{field:s,value:a||[],onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i):e.jsx(ln,{field:s,value:a||[],onChange:y=>n(s,y),onClear:()=>o(i),onRemove:d},i)})}),Bl=r=>`${r} Rows`,cn=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:i=!0,showPagination:s=!0})=>{var F;const{searchQueries:a,setSearchParams:d,searchParams:y}=Ee(),b=y.get(l),p=b?Number(b):o,x=O=>{d({...a,[t]:String(O)})},T=O=>{d({...a,[l]:O,[t]:"1"})},C=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),I=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${C}-${I} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),i&&e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:Bl(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(O=>e.jsx(A.MenuItem,{selected:O===p,onClick:()=>T(String(O)),children:Bl(O)},O))})})]}),s&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(gr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function sn(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var s;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,i=(s=c==null?void 0:c.tagName)==null?void 0:s.toLowerCase();i==="input"||i==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const an=240,ml=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:i,setSearchParams:s,searchQueries:a}=Ee(),d=Mr(r,i,t)||"",[y,b]=h.useState(!c||!!d),[p,x]=h.useState(c&&!d),[T,C]=h.useState(d),I=pe.useDebounce(T,350),F=h.useRef(null);h.useEffect(()=>{C(d),d&&b(!0)},[d]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{I!==d&&pr({value:I,name:r,type:"search",searchQueries:a,setSearchParams:s,filterKey:t,pageKey:l})},[I]);const O=h.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var z;return(z=F.current)==null?void 0:z.focus()})},[]);sn(o,O);const B=()=>{c&&!T&&b(!1)},D=z=>{var S;c&&z.key==="Escape"&&!T&&(b(!1),(S=F.current)==null||S.blur())},H=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:O}),e.jsxs(u.Box,{onTransitionEnd:H,style:{position:"relative",width:y?an:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx($e.Input,{ref:F,size:"sm",fullWidth:!0,value:T,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:z=>C(z.target.value),onKeyDown:D,onBlur:B,tabIndex:y?0:-1}),y&&!T&&e.jsx(u.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(k.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},Fl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,i]=h.useState(null),[s,a]=h.useState(null),d=()=>{c!==null&&s!==null&&c!==s&&n(c,s),i(null),a(null)},y=(b,p)=>{const x=b+p;x<0||x>=r.length||n(b,x)};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const x=!b.locked,T=s===p&&c!==null&&c!==p;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&i(p),onDragOver:C=>{C.preventDefault(),a(p)},onDrop:d,onDragEnd:d,style:{minHeight:32,boxShadow:T?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:C=>{x&&(C.key==="ArrowUp"?(C.preventDefault(),y(p,-1)):C.key==="ArrowDown"&&(C.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(ir.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>l(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},El=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),i=()=>{const s=o.trim();s&&(n(s),c(""))};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(M.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(A.MenuLists,{style:{width:"260px"},children:[e.jsx(A.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(k.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(s=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(s),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${s.name}`,onClick:a=>{a.stopPropagation(),l(s.id)}}),children:s.name},s.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx($e.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:s=>c(s.target.value),onKeyDown:s=>{s.key==="Enter"&&i()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:i,children:"Save"})]})})]})]})},dn=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:i,onReset:s,getValue:a,setValue:d,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(kr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(k.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(k.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(j.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(kl,{activeKeys:n,configByKey:o,getValue:a,setValue:d,clearValue:y,removeFilter:b})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const T=n.includes(x.key),C=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:C?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(k.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(ir.Toggle,{size:"sm",checked:T||C,disabled:C,onChange:()=>i(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:s,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},hn=r=>`${r} Rows`,fn=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:i,searchParams:s}=Ee(),a=s.get(r),d=a?Number(a):n,y=b=>{i({...c,[r]:b,[t]:"1"})};return o?e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(k.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(b=>e.jsx(A.MenuItem,{selected:b===d,endIcon:b===d?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:hn(b)},b))]})})]}):null},gn=r=>{var Ve;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:i,removeFilter:s,getValue:a,setValue:d,clearValue:y,onReset:b,searchable:p,searchKey:x,filterKey:T,pageKey:C,searchPlaceholder:I,searchShortcut:F,searchCollapsible:O,pagination:B,perPageKey:D,pageSizeOptions:H,defaultPerPage:z,showPagination:S,showResultCount:L,showPageSize:V,hasColumns:P,orderedColumns:Z,allVisible:Y,onToggleVisibility:re,onReorder:he,onSetAllHidden:fe,showSavedViews:te,savedViews:Q,onApplyView:X,onDeleteView:de,onSaveView:Se,leadingActions:se}=r,[Ce,Te]=h.useState(!1),{searchQueries:ke,setSearchParams:He}=Ee(),Ie=(B==null?void 0:B.rangeStart)??(((B==null?void 0:B.currentPage)||0)>1?(((B==null?void 0:B.currentPage)||0)-1)*((B==null?void 0:B.perPage)||0)+1:1),be=(B==null?void 0:B.rangeEnd)??((B==null?void 0:B.totalCurrentPage)!==(B==null?void 0:B.perPage)?B==null?void 0:B.totalData:((B==null?void 0:B.currentPage)||1)*((B==null?void 0:B.totalCurrentPage)||0)),Ze=Ue=>{He({...ke,[C]:String(Ue)})},xe=L||S&&!!(B!=null&&B.totalPage),je=()=>{b(),Te(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(ml,{searchKey:x,filterKey:T,pageKey:C,placeholder:I,shortcut:F,collapsible:O}),e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Te(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[se,te&&e.jsx(El,{views:Q,onApply:X,onDelete:de,onSave:Se}),P&&e.jsx(Fl,{columns:Z,allVisible:Y,onToggle:re,onReorder:he,onSetAllHidden:fe}),e.jsx(fn,{perPageKey:D,pageKey:C,pageSizeOptions:H,defaultPerPage:z,showPageSize:V})]})]}),xe&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[L?e.jsx(k.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ie}-${be} of ${((Ve=B==null?void 0:B.totalData)==null?void 0:Ve.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),S&&!!(B!=null&&B.totalPage)&&e.jsx(gr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:B!=null&&B.currentPage?Number(B.currentPage):1,totalPages:Number(B.totalPage),onPageChange:Ze})]}),e.jsx(dn,{isOpen:Ce,onClose:()=>Te(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:i,onReset:je,getValue:a,setValue:d,clearValue:y,removeFilter:s})]})},un=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:i=[25,50,100],defaultPerPage:s,showPagination:a=!0,showResultCount:d=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:x="Search",searchShortcut:T="/",searchPosition:C="right",searchCollapsible:I=!0,pagination:F,columns:O=[],onColumnsChange:B,columnsState:D,scopeId:H,savedViews:z,persistLastState:S=!0,storage:L=ct,onReset:V,leadingActions:P})=>{const Z=H??(z==null?void 0:z.scopeId),{activeKeys:Y,configByKey:re,hasActiveFilter:he,toggleFilter:fe,removeFilter:te,getValue:Q,setValue:X,clearValue:de,clearAll:Se}=nt({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:p}),se=Vo({columns:O,scopeId:Z,storage:L,onColumnsChange:B,value:D}),Ce=Po({scopeId:Z,storage:L,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>se.state,applyColumns:se.applyState}),Te=jo({scopeId:Z,storage:L,snapshotKeys:[n,l,o],enabled:S}),ke=No({scopeId:Z,storage:L,perPageKey:c,pageSizeOptions:i,enabled:S});qo({enabled:S&&!!Z,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Te.read,readPerPage:ke.read});const He=s??i[0]??25,Ie=!!(z!=null&&z.enabled)&&Ce.enabled,be=()=>{Se(),Te.clear(),V==null||V()},Ze=pe.useMediaQuery("md"),xe=b?e.jsx(ml,{searchKey:p,filterKey:l,pageKey:o,placeholder:x,shortcut:T,collapsible:I}):null;return Ze?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Zo,{configs:t,activeKeys:Y,onToggle:fe,hasActiveFilter:he,onReset:be}),C==="left"&&xe,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(kl,{activeKeys:Y,configByKey:re,getValue:Q,setValue:X,clearValue:de,removeFilter:te}),he&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:be,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[P,e.jsx(cn,{pagination:F,pageKey:o,perPageKey:c,pageSizeOptions:i,defaultPerPage:He,showPagination:a,showResultCount:d,showPageSize:y}),C==="right"&&xe,Ie&&e.jsx(El,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),O.length>0&&e.jsx(Fl,{columns:se.orderedColumns,allVisible:se.allVisible,onToggle:se.toggleVisibility,onReorder:se.reorder,onSetAllHidden:se.setAllHidden})]})]}):e.jsx(gn,{withPadding:r,configs:t,activeKeys:Y,configByKey:re,hasActiveFilter:he,toggleFilter:fe,removeFilter:te,getValue:Q,setValue:X,clearValue:de,onReset:be,searchable:b,searchKey:p,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:T,searchCollapsible:I,pagination:F,perPageKey:c,pageSizeOptions:i,defaultPerPage:He,showPagination:a,showResultCount:d,showPageSize:y,hasColumns:O.length>0,orderedColumns:se.orderedColumns,allVisible:se.allVisible,onToggleVisibility:se.toggleVisibility,onReorder:se.reorder,onSetAllHidden:se.setAllHidden,showSavedViews:Ie,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:P})},yn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r[0];return(t==null?void 0:t.value)!=null?String(t.value):void 0},pn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},bn=(r,t)=>{switch(r.type){case"dropdown":case"radio":return yn(t);case"dropdown-multiple":case"checkbox-multiple":return pn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},Ml=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},vn=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:i="q",defaultPage:s=1,defaultPerPage:a=10,paramKeys:d,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:x,getValue:T}=nt({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:i}),{searchParams:C}=Ee(),I=C.toString();return h.useMemo(()=>{const O={},B={},D=Ml(C.get(o),s),H=Ml(C.get(c),a);O[(d==null?void 0:d.page)??"page"]=D,O[(d==null?void 0:d.perPage)??"perPage"]=H;const z=Mr(i,C,l)||"";z&&(O[(d==null?void 0:d.search)??"search"]=z);let S=!1;for(const L of b){const V=p[L];if(!V)continue;const P=T(V);B[L]=P;const Z=y==null?void 0:y[L],Y=Z?Z(P):bn(V,P);if(Y==null||Array.isArray(Y)&&Y.length===0)continue;const re=(d==null?void 0:d[L])??L;O[re]=Y,S=!0}return{params:O,raw:B,hasActiveFilter:x||!!z||S}},[I,b.join("|"),l,n,o,c,i,s,a,d,y,p])},Cn=["dropdown","dropdown-multiple","checkbox-multiple","radio"],xn=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:i,setValue:s,removeFilter:a,clearAll:d,hasActiveFilter:y}=nt({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),b=(F,O)=>{var D;const B=F.options;return((D=B==null?void 0:B.find(H=>H.value===O))==null?void 0:D.label)??O},p=h.useCallback(F=>{const O=c[F];if(!O)return[];const B=i(O);return Array.isArray(B)?B.map(D=>String(D.value)):[]},[c,i]),x=h.useCallback((F,O)=>{const B=c[F];if(!B||!Cn.includes(B.type))return;const D=Array.isArray(O)?O:[O];if(D.length===0){a(F);return}s(B,D.map(H=>({label:b(B,H),value:H})))},[c,s,a]),T=h.useCallback((F,O)=>{const B=p(F);x(F,B.includes(O)?B.filter(D=>D!==O):[...B,O])},[p,x]),C=h.useCallback((F,O)=>p(F).includes(O),[p]),I=h.useCallback(F=>a(F),[a]);return{set:x,toggle:T,clear:I,clearAll:d,isActive:C,values:p,hasActiveFilter:y}},wn=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:i,to:s}=vl(r.relative);return c[l]=i.toISOString(),c[n]=s.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},Ll=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const i=()=>{if(n.current){const s=n.current.getBoundingClientRect().top;c(`calc(100vh - ${s}px)`)}};return i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},Tl=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const i=pe.useMediaQuery("md"),s=c?e.jsx(pl,{...o}):null,a=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:i?"row":"column",gap:"8px",width:i?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:d,icon:y,buttonProps:b,onClick:p},x)=>!d&&!y?null:e.jsx(j.Button,{fullWidth:!i,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:d},`action-${x}`))}):null;return e.jsx(u.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:i?"row":"column-reverse",gap:"16px"},children:n?n({filter:s}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[s,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},Dn=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(ze.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(ze.Body1,{children:r||0})]}),Il=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:i,setSearchParams:s,searchParams:a}=Ee(),d=a.get(l),y=T=>{s({...i,[t]:String(T)})},b=T=>{s({...i,[l]:T,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(k.Text,{children:"Rows Per Page: "}),e.jsx(nr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:T=>{b(T[0].value)},value:d?[{label:`${d} per row`,value:d}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:d?[{label:`${d} per row`,value:d}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(k.Text,{children:`${p}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(gr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(Dn,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},Ol=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),i=h.useRef(null),[s,a]=h.useState(""),[d,y]=h.useState({top:0,left:0}),b=r.selectedValues,p=h.useMemo(()=>s?r.options.filter(C=>C.label.toLowerCase().includes(s.toLowerCase())):r.options,[r.options,s]);h.useEffect(()=>{if(l&&c.current){const C=c.current.getBoundingClientRect(),I=280,F={top:C.bottom+8};r.position==="left"||C.left+I>window.innerWidth?F.right=window.innerWidth-C.right:F.left=C.left,y(F)}},[l,r.position]),h.useEffect(()=>{l&&i.current?setTimeout(()=>{var C;return(C=i.current)==null?void 0:C.focus()},50):a("")},[l]),h.useEffect(()=>{const C=I=>{o.current&&!o.current.contains(I.target)&&c.current&&!c.current.contains(I.target)&&n(!1)};return l&&document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[l]);const x=C=>{const I=b.includes(C)?b.filter(F=>F!==C):[...b,C];r.onFilterChange(I)},T=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:C=>{var I;C.stopPropagation(),l||(I=r.onOpen)==null||I.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.Box,{ref:o,style:{position:"fixed",top:`${d.top}px`,...d.left!==void 0?{left:`${d.left}px`}:{right:`${d.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(k.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(k.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:C=>{C.stopPropagation(),T()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx($e.Input,{ref:i,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:s,onChange:C=>a(C.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(k.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(C=>e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:b.includes(C.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:I=>{I.stopPropagation(),x(C.value)},onMouseEnter:I=>{b.includes(C.value)||(I.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),I.currentTarget.style.transform="translateX(2px)"},onMouseLeave:I=>{I.currentTarget.style.backgroundColor=b.includes(C.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",I.currentTarget.style.transform="translateX(0)"},children:[e.jsx(qe.Checkbox,{checked:b.includes(C.value),onChange:()=>{}}),e.jsx(k.Text,{fontSize:"sm",fontWeight:b.includes(C.value)?"medium":"normal",color:b.includes(C.value)?"primary":"gray-700",children:C.label})]},C.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(k.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(u.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:b.length}),e.jsxs(k.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},Sn=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,i=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:c,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:i},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},kn=({frozen:r})=>e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:r?"currentColor":"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:r?"M7 11V7a5 5 0 0 1 10 0v4":"M7 11V7a5 5 0 0 1 9.9-1"})]}),ht="var(--sa-background-primary, #ffffff)",Wl="var(--sa-background-primary-inverse, #f8f8f8)",Al=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:i,visibleHandleUpdate:s,visibleHandleDetail:a,showHeadBorder:d=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:x,actionsOrder:T=["detail","update","delete","custom"],customEmptyState:C,enableColumnResize:I=!1,defaultColumnWidths:F,onColumnWidthsChange:O,defaultMinColumnWidth:B=60,sort:D,defaultSort:H,onSortChange:z,showActionDivider:S=!1})=>{const L=D!==void 0,[V,P]=h.useState(H??null),Z=L?D??null:V,Y=W=>{if(W.sortKey)return W.sortKey;if(typeof W.accessor=="string")return W.accessor},re=W=>{const U=Y(W);if(!U)return;let _;!Z||Z.key!==U?_={key:U,direction:"asc"}:Z.direction==="asc"?_={key:U,direction:"desc"}:_=null,L||P(_),z==null||z(_)},fe=[l,n,o].filter(W=>W!==void 0).length,te=!!x,Q=!!l||!!n||!!o||te,X="var(--sa-border-subtle, #0b120e24)",de=`1px solid ${X}`,Se=`inset 1px 0 0 ${X}`,se=`inset -1px 0 0 ${X}`,Ce=fe===3?te?"178px":"140px":fe===2?te?"140px":"102px":fe===1?te?"112px":"74px":te?"74px":"",Te=(W,U)=>{if(!U)return W;if(typeof U=="function")return U(W);if(typeof U=="string")return W[U]},[ke,He]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const W=y.current;He(W.scrollHeight>W.clientHeight)},[t,y]);const Ie=h.useRef(null),[be,Ze]=h.useState([]),[xe,je]=h.useState(()=>F??{}),Ve=h.useRef(null);h.useLayoutEffect(()=>{if(!b||!Ie.current){Ze([]);return}const W=Array.from(Ie.current.querySelectorAll("thead tr th")),U=[];let _=0;W.forEach((J,N)=>{U[N]=_,N<b&&(_+=J.offsetWidth)}),Ze(U)},[b,r,t,xe]);const Ue=W=>{p&&p(W<b?W:W+1)},m=(W,U)=>{const _=xe[W];if(_!==void 0){const J=`${_}px`;return{width:J,minWidth:J,maxWidth:J}}return U?{width:U}:{}},G=W=>I&&(W.resizable??!0),$=(W,U)=>{W.preventDefault(),W.stopPropagation();const _=W.currentTarget.closest("th");if(!_)return;const J=Math.round(_.getBoundingClientRect().width);Ve.current={colIndex:U,startX:W.clientX,startWidth:J};const N=document.body.style.userSelect,ge=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=Ne=>{var Re;const Me=Ve.current;if(!Me)return;const Je=((Re=r[Me.colIndex])==null?void 0:Re.minWidth)??B,we=Math.max(Je,Me.startWidth+(Ne.clientX-Me.startX));je(er=>er[Me.colIndex]===we?er:{...er,[Me.colIndex]:we})},Ge=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ge),document.body.style.userSelect=N,document.body.style.cursor=ge,Ve.current=null,O&&je(Ne=>(O(Ne),Ne))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ge)};return e.jsx("div",{ref:Ie,children:e.jsxs(q.Table,{fullWidth:!0,children:[e.jsx(q.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(q.Tr,{children:[r.map((W,U)=>{var qr,hr;const _=b>0&&U<b,J=be[U]??0,N=G(W),Fe=U===r.length-1&&Q&&S,Ge=Y(W),Ne=!!W.sortable&&!!Ge,Me=Ne&&(Z==null?void 0:Z.key)===Ge?Z.direction:null,Je=W.title||((qr=W.accessor)==null?void 0:qr.toString())||"",we=(hr=W.headerTooltip)!=null&&hr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Re=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),er=Ne?e.jsxs("button",{type:"button",onClick:()=>re(W),title:Me==="asc"?"Sorted ascending — click to sort descending":Me==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left"},children:[Re,we,e.jsx(Sn,{direction:Me})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Re,we]});return e.jsxs(q.Th,{style:{position:"sticky",top:0,left:_?J:void 0,zIndex:_?4:2,paddingLeft:U===0?"12px":"",borderRight:d&&!Fe&&!_?de:void 0,borderBottom:d?de:void 0,boxShadow:d&&_?se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:W.textAlign==="text-right"?"right":W.textAlign==="text-center"?"center":"left",...m(U,W.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[W.headerTooltip?e.jsx(Be.Tooltip,{label:W.headerTooltip.content,position:"bottom",children:er}):er,W.filter&&e.jsx(Ol,{filter:W.filter,columnTitle:W.title}),p&&e.jsx("button",{onClick:()=>Ue(U),title:_?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:_?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:_?1:.45,transition:"opacity 0.15s"},children:e.jsx(kn,{frozen:_})})]}),N&&e.jsx("div",{onMouseDown:wr=>$(wr,U),onClick:wr=>wr.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${U}`)}),Q?e.jsx(q.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:d?de:void 0,boxShadow:d&&S?Se:void 0}}):null]})}),e.jsx(q.Tbody,{children:c?e.jsx(q.Tr,{children:e.jsx(q.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"}),e.jsx(Ae.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&C?e.jsx(q.Tr,{children:e.jsx(q.Td,{colSpan:r.length+1,children:C})}):t==null?void 0:t.map((W,U)=>e.jsxs(q.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:U===t.length-1&&ke?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:_=>{const J=_.currentTarget;J.style.backgroundColor=Wl,Array.from(J.querySelectorAll("td")).forEach(N=>{N.style.position==="sticky"&&(N.style.backgroundColor=Wl)})},onMouseLeave:_=>{const J=_.currentTarget;J.style.backgroundColor="",Array.from(J.querySelectorAll("td")).forEach(N=>{N.style.position==="sticky"&&(N.style.backgroundColor=ht)})},children:[r.map((_,J)=>{const N=_.render?_.render(W,U,t):Te(W,_.accessor),ge=b>0&&J<b,Fe=be[J]??0,Ge=xe[J]!==void 0,Ne=ge&&J===b-1;return e.jsx(q.Td,{style:{position:ge?"sticky":void 0,left:ge?Fe:void 0,zIndex:ge?1:void 0,backgroundColor:ge?ht:void 0,transition:ge?"background-color 0.3s ease":void 0,paddingLeft:J===0?"12px":"",whiteSpace:"nowrap",overflow:Ge?"hidden":void 0,borderLeft:_.showBorderLeft?de:void 0,borderRight:_.showBorderRight?de:void 0,boxShadow:Ne?se:void 0,textAlign:_.textAlign==="text-right"?"right":_.textAlign==="text-center"?"center":"left",...m(J,_.width)},children:typeof N=="string"?e.jsx(k.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:_.textAlign==="text-right"?"right":_.textAlign==="text-center"?"center":"left"},children:N}):N},`row-${U}-col-${J}`)}),Q?e.jsx(q.Td,{style:{width:Ce,position:"sticky",right:0,zIndex:1,backgroundColor:ht,boxShadow:S?Se:void 0,transition:"background-color 0.3s ease"},children:e.jsx(oe.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:T.map(_=>{const J=U===t.length-1?"top":"bottom";return _==="detail"&&l&&(a==null?void 0:a(W))!==!1?e.jsx(Be.Tooltip,{label:"Detail",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(W.id,W),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):_==="update"&&n&&(s==null?void 0:s(W))!==!1?e.jsx(Be.Tooltip,{label:"Update",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(W),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):_==="delete"&&o&&(i==null?void 0:i(W))!==!1?e.jsx(Be.Tooltip,{label:"Delete",position:J,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(W.id,W),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):_==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(W)},"custom"):null})})}):null]},`${W}${U}`))})]})})},Bn=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var b;const o=h.useRef(null),[c,i]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),s=(l==null?void 0:l.show)??!0,a=h.useRef(null),d=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof d=="number"&&(a.current=d);const y=(n==null?void 0:n.showFooter)??(d===void 0?a.current!==0:d!==0);return e.jsxs(Ll,{...r,children:[s&&e.jsx(Tl,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(Al,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?i:void 0}):null}),y&&e.jsx(Il,{pagination:t==null?void 0:t.pagination,pageKey:t==null?void 0:t.pageKey,perPageKey:t==null?void 0:t.perPageKey,defaultPerPage:t==null?void 0:t.defaultPerPage,showPagination:t==null?void 0:t.showPagination,totalData:n==null?void 0:n.totalData})]})};function mn(r){return h.memo(r)}const Fn=mn(Bn),zl=200,ft="1px solid var(--sa-border-subtle, #0b120e24)",En=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(M.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(M.Icon,{name:"ChevronSmallDown"}):t?e.jsx(M.Icon,{name:"LockOn",size:"xs"}):e.jsx(M.Icon,{name:"Filter",size:"xs"}),Wr=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"var(--sa-color-error-600, #c9184a)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:i=>{l||(i.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:i=>{i.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(k.Text,{as:"span",style:{color:c},children:t})]})},Hl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:i,onToggleFreeze:s,onHide:a})=>{const[d,y]=h.useState(!1),b=h.useRef(null),p=h.useRef(null),[x,T]=h.useState({top:0,left:0});h.useEffect(()=>{if(d&&b.current){const I=b.current.getBoundingClientRect(),F=I.left+zl>window.innerWidth;T({top:I.bottom+6,...F?{right:window.innerWidth-I.right}:{left:I.left}})}},[d]),h.useEffect(()=>{if(!d)return;const I=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[d]);const C=I=>{I(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||d?"true":"false",onClick:I=>{I.stopPropagation(),y(F=>!F)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:ft,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(En,{sortDir:n,frozen:o})}),d&&e.jsxs(u.Box,{ref:p,onClick:I=>I.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:zl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:ft,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Wr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>C(()=>n==="asc"?i():c("asc"))}),e.jsx(Wr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>C(()=>n==="desc"?i():c("desc"))}),e.jsx("div",{style:{borderTop:ft,margin:"4px 0"}})]}),e.jsx(Wr,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>C(s)}),l&&e.jsx(Wr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>C(a)})]})]})},br="1px solid var(--sa-border-subtle, #0b120e24)",Mn="var(--sa-text-subtle, #8c8f97)",dr="var(--sa-background-neutral, #f0f1f2)",Vl="2px 0 4px -2px rgba(0,0,0,0.15)",vr=40,gt="var(--sa-background-brand-subtlest)",Ar={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Pl="sa-table-layout-styles",Ln=()=>{if(typeof document>"u"||document.getElementById(Pl))return;const r=document.createElement("style");r.id=Pl,r.textContent=`
|
|
2
2
|
.sa-table-layout tbody td {
|
|
3
3
|
transition: background-color 0.15s ease;
|
|
4
4
|
background-color: var(--sa-tl-bg, transparent);
|