@starasia/admin 14.0.4 → 15.0.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/adapters/tanstack.cjs.js +1 -1
- package/dist/adapters/tanstack.es.js +45 -30
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +15 -3
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(u,yr){typeof exports=="object"&&typeof module<"u"?yr(exports,require("@starasia/alert"),require("@starasia/avatar"),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-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/avatar","@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-dom","react-easy-crop"],yr):(u=typeof globalThis<"u"?globalThis:u||self,yr(u["@starasia/admin"]={},u.alert,u.avatar,u.badges,u.box,u.breadcrumb,u.button,u.card,u.date,u.dialog,u.drawer,u.dropdown,u.hooks,u.http,u.input,u.menu,u.pagination,u.storage,u.table,u.tabs,u.textarea,u.theme,u.toast,u.toggle,u.tooltip,u.checkbox,u.radio,u.text,u.icon,u.flex,u.grid,u.progress,u.stepper,u.accordion,u.storyRecord,u.skeleton,u.progressStepper,u.jsxRuntime,u.React,u.ReactDOM,u.ReactEasyCrop))})(this,function(u,yr,Hr,sr,f,pr,j,it,fr,Ve,Pr,br,De,vr,ar,A,kr,Er,U,Kt,at,Cr,Rt,xr,me,tr,dt,D,M,ie,eo,ro,to,oo,lo,$e,no,e,d,Vr,_l){"use strict";const ql={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},ht=d.createContext(ql),ft=()=>d.useContext(ht),so=r=>{const[t,o]=d.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:o}},co=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),io=({children:r})=>{const[t,o]=d.useState({}),n=d.useCallback(i=>{o(a=>typeof i=="function"?i(a):i)},[]),l=d.useCallback((i,a)=>{o(h=>{const y=typeof a=="function"?a(h[i]):a;return{...h,[i]:y}})},[]),s=d.useCallback(i=>{o(a=>{if(!(i in a))return a;const h={...a};return delete h[i],h})},[]),c=d.useMemo(()=>({badges:t,setBadge:l,setBadges:n,clearBadge:s}),[t,l,n,s]);return e.jsx(co.Provider,{value:c,children:r})},ao=()=>d.useContext(co),jr=(r,t)=>{const o=t!==void 0?t:r;return o==null?null:typeof o=="string"||typeof o=="number"?{value:o}:o},ut=240,gt=200,yt=480,Zl="sa-sidebar-width",pt=(r,t,o)=>Math.min(Math.max(r,t),o),Gl=(r,t,o,n)=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(r);if(!l)return t;const s=parseInt(l,10);return Number.isFinite(s)?pt(s,o,n):t}catch{return t}},ho=(r,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(r,String(t))}catch{}},fo=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:ut,setWidth:()=>{},resetWidth:()=>{},minWidth:gt,maxWidth:yt,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),uo=({children:r,defaultCollapsed:t=!1,defaultWidth:o=ut,minWidth:n=gt,maxWidth:l=yt,widthStorageKey:s=Zl})=>{const[c,i]=d.useState(t),[a,h]=d.useState(!1),[y,b]=d.useState(()=>Gl(s,o,n,l)),p=d.useCallback(B=>{i(W=>typeof B=="function"?B(W):B)},[]),C=d.useCallback(()=>i(B=>!B),[]),E=d.useCallback(()=>i(!0),[]),w=d.useCallback(()=>i(!1),[]),L=d.useCallback(B=>{b(W=>{const O=typeof B=="function"?B(W):B,Y=pt(Math.round(O),n,l);return ho(s,Y),Y})},[n,l,s]),F=d.useCallback(()=>{const B=pt(o,n,l);ho(s,B),b(B)},[o,n,l,s]),I=d.useCallback(B=>{h(W=>typeof B=="function"?B(W):B)},[]),S=d.useCallback(()=>h(!0),[]),k=d.useCallback(()=>h(!1),[]),H=d.useCallback(()=>h(B=>!B),[]),z=d.useMemo(()=>({collapsed:c,setCollapsed:p,toggle:C,collapse:E,expand:w,width:y,setWidth:L,resetWidth:F,minWidth:n,maxWidth:l,mobileOpen:a,setMobileOpen:I,openMobile:S,closeMobile:k,toggleMobile:H}),[c,p,C,E,w,y,L,F,n,l,a,I,S,k,H]);return e.jsx(fo.Provider,{value:z,children:r})},go=()=>d.useContext(fo),yo=d.createContext(null),po=({adapter:r,children:t})=>e.jsx(yo.Provider,{value:r,children:t}),or=()=>{const r=d.useContext(yo);if(!r)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return r},bo=({router:r,routerAdapter:t,menus:o=[],menuBottom:n,logo:l,appName:s="Workspace",initialUserData:c,theme:i})=>{const a=so({initialUserData:c}),{theme:h}=Cr.useTheme();return e.jsx(po,{adapter:t,children:e.jsx(ht.Provider,{value:{logo:l,appName:s,menus:o,userData:a.userData,setUserData:a.setUserData,menuBottom:n},children:e.jsx(io,{children:e.jsx(uo,{children:i?e.jsx(Cr.ThemeProvider,{value:i,children:r}):h?e.jsx(Cr.ThemeProvider,{value:h,children:r}):r})})})})},Ql=d.memo(bo);function vo({collapsed:r=!1,children:t}){if(!t)return null;const o=typeof t=="function",n=o?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:o?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const bt=d.createContext(null);function Co({children:r}){const[t,o]=d.useState(null),[n,l]=d.useState(null),[s,c]=d.useState(null),[i,a]=d.useState(0),h=d.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx(bt.Provider,{value:{prependNode:t,appendNode:n,replaceNode:s,setPrependNode:o,setAppendNode:l,setReplaceNode:c,replaceCount:i,registerReplace:h},children:r})}function xo({children:r}){const t=d.useContext(bt);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 Ul({children:r,mode:t="append"}){const o=d.useContext(bt);if(d.useEffect(()=>{if(!(t!=="replace"||!o))return o.registerReplace()},[t,o]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?o.prependNode:t==="replace"?o.replaceNode:o.appendNode;return n?Vr.createPortal(r,n):null}const vt=d.createContext(null);function wo({children:r}){const[t,o]=d.useState({}),[n,l]=d.useState({}),s=d.useCallback((a,h)=>{o(y=>y[a]===h?y:{...y,[a]:h})},[]),c=d.useCallback(a=>(l(h=>({...h,[a]:(h[a]??0)+1})),()=>l(h=>({...h,[a]:Math.max(0,(h[a]??0)-1)}))),[]),i=d.useMemo(()=>({outletNodes:t,setOutletNode:s,slotCounts:n,registerSlot:c}),[t,s,n,c]);return e.jsx(vt.Provider,{value:i,children:r})}function Do({slotKey:r,fallback:t}){const o=d.useContext(vt),n=o?(o.slotCounts[r]??0)>0:!1,l=d.useRef(o==null?void 0:o.setOutletNode);l.current=o==null?void 0:o.setOutletNode;const s=d.useCallback(c=>{var i;return(i=l.current)==null?void 0:i.call(l,r,c)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:s,style:{display:"contents"}}):t})}function Jl({slotKey:r,children:t}){const o=d.useContext(vt),n=d.useRef(o==null?void 0:o.registerSlot);if(n.current=o==null?void 0:o.registerSlot,d.useEffect(()=>{var s;return(s=n.current)==null?void 0:s.call(n,r)},[r]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const l=o.outletNodes[r];return l?Vr.createPortal(t,l):null}const Nr="moduleSwitcherGroupId",Ct="sa-module-switcher-change";function So(){if(typeof window>"u")return null;const r=window.localStorage.getItem(Nr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function Bo(r){typeof window>"u"||(r===null?window.localStorage.removeItem(Nr):window.localStorage.setItem(Nr,String(r)),window.dispatchEvent(new CustomEvent(Ct,{detail:r})))}function Yl(){Bo(null)}function xt(){const[r,t]=d.useState(()=>So());return d.useEffect(()=>{const n=()=>{t(So())},l=s=>{s.key===Nr&&n()};return window.addEventListener(Ct,n),window.addEventListener("storage",l),()=>{window.removeEventListener(Ct,n),window.removeEventListener("storage",l)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{Bo(n),t(n)}}}let _r=0,ur=!1,ko=new Set;function Xl(r){const[t,o]=d.useState(!1),n=d.useRef(null),l=d.useRef(null);return d.useLayoutEffect(()=>{const s=n.current;if(!s)return;let c=0;const i=()=>{c=0;const h=l.current;if(!h)return;const y=h.scrollWidth>s.clientWidth;o(b=>b===y?b:y)},a=new ResizeObserver(()=>{c||(c=requestAnimationFrame(i))});return a.observe(s),i(),()=>{c&&cancelAnimationFrame(c),a.disconnect()}},[r]),{containerRef:n,textRef:l,truncated:t}}function Eo({text:r,textStyle:t}){const{containerRef:o,textRef:n,truncated:l}=Xl(r),s=e.jsx(D.Text,{ref:n,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...t},children:r});return e.jsx(f.Box,{ref:o,display:"block",style:{flex:1,minWidth:0},children:l?e.jsx(me.Tooltip,{fluid:!0,label:r,position:"top",children:s}):s})}const $l=200,wt="var(--app-header-height, 4rem)",mo="44px",Dt=`calc((${wt} - 2rem) / 2)`,Fo=16;function Kl({children:r,headerLeftSlot:t,profile:o,isLoadingProfile:n,onLogout:l,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:i,headerActions:a,profileRole:h,profileMenuButtons:y,profileMenuItems:b,logoutButton:p,resizableSidebar:C=!0}){var hr,Sr;const{useSearchParams:E,useNavigate:w,useLocation:L,Outlet:F}=or(),[I]=E(),S=I.get("embed")==="true",k=ft(),{badges:H}=ao(),z=w(),B=L(),O=!De.useMediaQuery("md"),[Y,X]=d.useState(!1),{collapsed:q,setCollapsed:Z,width:K,setWidth:te,resetWidth:_,minWidth:V,maxWidth:N,mobileOpen:se,setMobileOpen:ve}=go(),[Ee,ue]=d.useState(!1),[Ce,xe]=d.useState(()=>new Set(ko)),[we,Ae]=d.useState(null),{selectedGroupId:Fe,setSelectedGroupId:Ne}=xt(),$=q&&!O;d.useEffect(()=>{ko=Ce},[Ce]);const ge=d.useRef(null),We=d.useRef(null),Ze=d.useRef(null),[de,Ge]=d.useState(!1),[lr,P]=d.useState(null),R=C&&!O&&!q,J=m=>Math.min(Math.max(m,V),N),he=lr??K,ce=m=>{var ke,Ie,_e;if(!R)return;m.preventDefault();const G=m.clientX,re=((ke=Ze.current)==null?void 0:ke.getBoundingClientRect().width)??K;(_e=(Ie=m.currentTarget).setPointerCapture)==null||_e.call(Ie,m.pointerId),Ge(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let Be=0,Oe=re;const Ye=Ar=>{Oe=re+(Ar.clientX-G),Be||(Be=requestAnimationFrame(()=>{Be=0,P(J(Oe))}))},He=()=>{Be&&cancelAnimationFrame(Be),window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",He),document.body.style.userSelect="",document.body.style.cursor="",P(null),Ge(!1),Oe<$l?Z(!0):te(J(Oe))};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",He)},Me=m=>{R&&(m.key==="ArrowLeft"?(m.preventDefault(),te(G=>G-Fo)):m.key==="ArrowRight"?(m.preventDefault(),te(G=>G+Fo)):m.key==="Home"?(m.preventDefault(),te(V)):m.key==="End"&&(m.preventDefault(),te(N)))};d.useEffect(()=>{const m=ge.current;if(!m)return;const G=()=>{ur||(_r=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const ze=()=>{const m=ge.current;m&&_r>0&&(ur=!0,m.scrollTop=_r,requestAnimationFrame(()=>{ur=!1}))};d.useLayoutEffect(()=>{ur=!0,ze();const m=setTimeout(()=>{ur=!1},300);return()=>clearTimeout(m)},[]),d.useLayoutEffect(()=>{k.menus.length>0&&(_r>0?ze():requestAnimationFrame(()=>{var G;const m=(G=ge.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[k.menus]),d.useEffect(()=>{ur=!0,ze();const m=setTimeout(ze,0),G=setTimeout(ze,50),re=setTimeout(ze,100),Be=setTimeout(ze,200),Oe=setTimeout(()=>{ur=!1},300),Ye=setTimeout(()=>{const He=ge.current,ke=He==null?void 0:He.querySelector("[data-menu-active='true']");if(He&&ke){const Ie=He.getBoundingClientRect(),_e=ke.getBoundingClientRect();_e.top>=Ie.top&&_e.bottom<=Ie.bottom||ke.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout(re),clearTimeout(Be),clearTimeout(Oe),clearTimeout(Ye)}},[B.pathname]),d.useEffect(()=>{We.current&&(We.current.scrollTop=0)},[B.pathname]),d.useEffect(()=>{O&&ve(!1)},[B.pathname,O]),d.useEffect(()=>{O&&Z(!0)},[O]),d.useEffect(()=>{const m=document.documentElement;return m.style.setProperty("--app-header-height",mo),()=>{m.style.removeProperty("--app-header-height")}},[]);const er=()=>{X(!0)},Qe=()=>{X(!1)},Le=()=>{X(!1),l()},Je=m=>{const G=[m.to];return m.children&&G.push(...m.children.map(re=>re.to)),G},Se=[...k.menus.flatMap(m=>m.items.flatMap(Je)),...((hr=k.menuBottom)==null?void 0:hr.flatMap(Je))??[]],Ue=m=>{if(!B.pathname.startsWith(m))return!1;const G=Se.filter(re=>B.pathname.startsWith(re)).sort((re,Be)=>Be.length-re.length)[0];return m===G};d.useEffect(()=>{var G;const m=re=>{var Be;(Be=re.children)!=null&&Be.some(Oe=>B.pathname.startsWith(Oe.to))&&xe(Oe=>{const Ye=new Set(Oe);return Ye.add(re.id),Ye})};k.menus.forEach(re=>{re.items.forEach(m)}),(G=k.menuBottom)==null||G.forEach(m)},[B.pathname,k.menus,k.menuBottom]);const nr=m=>{xe(G=>{const re=new Set(G);return re.has(m)?re.delete(m):re.add(m),re})};d.useEffect(()=>{k.menus.length!==0&&Fe!==null&&!k.menus.some(m=>m.id===Fe)&&Ne(null)},[k.menus,Fe,Ne]);const gr=d.useMemo(()=>{if(Fe!==null)return k.menus.filter(re=>re.id===Fe||re.parentGroupId===Fe);const m=k.menus.filter(re=>re.parentGroupId===void 0),G=k.menus.filter(re=>re.parentGroupId!==void 0).flatMap(re=>re.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[k.menus,Fe]);if(S)return e.jsx(f.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:r||e.jsx(F,{})});const dr=m=>{const G=m.children&&m.children.length>0,re=Ce.has(m.id),Be=G?m.children.some(He=>Ue(He.to)):Ue(m.to),Oe=jr(m.badge,H[m.id]),Ye=!!Oe&&q&&!O;return e.jsxs(f.Box,{display:"block","data-menu-active":Be||void 0,children:[e.jsxs(f.Box,{as:"button",onClick:He=>{if(G)if(q&&!O){const ke=He.currentTarget.getBoundingClientRect();Ae({item:m,top:ke.top,left:ke.right+8})}else nr(m.id);else z(m.to)},fullWidth:!0,direction:"row",align:"center",justify:q&&!O?"center":void 0,gap:"sm",paddingInline:q&&!O?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Be?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:Be?"white":void 0,hover:Be?void 0:{bg:"neutral"},title:q&&!O?m.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",borderColor:Be?"var(--sa-border-subtle, #0b120e24)":"transparent"},children:[e.jsxs(f.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),Ye&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(sr.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!q||O)&&e.jsxs(e.Fragment,{children:[e.jsx(Eo,{text:m.title,textStyle:{transition:"opacity 0.3s"}}),Oe&&e.jsx(sr.Badge,{text:String(Oe.value),variant:Oe.variant??"info",size:"xs",border:!0}),G&&e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:re?"rotate(180deg)":"rotate(0deg)"}})]})]}),G&&(!q||O)&&(()=>{const He=m.children.findIndex(ke=>Ue(ke.to));return e.jsxs(f.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:re?`${m.children.length*36}px`:"0px",opacity:re?1:0,marginTop:re?"0.25rem":"0px"},children:[e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),He>=0&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${He*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),m.children.map(ke=>{const Ie=jr(ke.badge,H[ke.id]),_e=Ue(ke.to);return e.jsxs(f.Box,{as:"button",onClick:()=>z(ke.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:_e?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:_e?"white":void 0,hover:_e?void 0:{bg:"neutral"},style:{textAlign:"left",color:_e?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",borderColor:_e?"var(--sa-border-subtle, #0b120e24)":"transparent"},children:[e.jsx(M.Icon,{name:ke.icon,size:"sm",style:{flexShrink:0}}),e.jsx(Eo,{text:ke.title}),Ie&&e.jsx(sr.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0})]},ke.id)})]})})()]},m.id)};return e.jsx(wo,{children:e.jsxs(Co,{children:[e.jsxs(f.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":mo,"--app-sidebar-width":O?"0px":q?wt:`${he}px`,"--app-footer-zindex":O&&se?"40":"998"},children:[O&&e.jsx(f.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ve(!1)}),e.jsxs(f.Box,{as:"aside",ref:Ze,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:O?void 0:"0",style:{width:O?"16.375rem":q?wt:`${he}px`,position:O?"fixed":"relative",...O&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:de?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(f.Box,{onMouseEnter:()=>ue(!0),onMouseLeave:()=>ue(!1),direction:"row",align:"center",justify:"space-between",paddingInline:$?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...$?{paddingInline:Dt}:null},children:(()=>{const m=!O&&q&&!se,G=m&&Ee;return e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flex:m?"1":void 0,justify:m?"center":void 0,style:{transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:k.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!q||se)&&e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:k.appName})]}),!O&&!q&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),m&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"Cross",size:"md"})})]})})()}),i&&e.jsx(vo,{collapsed:O?!1:q,children:i}),e.jsx(f.Box,{ref:ge,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:gr.map(m=>e.jsxs(f.Box,{marginBottom:"lg",children:[!q||O?m.name&&e.jsx(D.Text,{fontSize:"md",fontWeight:"normal",color:"subtlest",truncate:!0,style:{paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:m.name}):m.name&&e.jsx(f.Box,{"aria-label":m.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(f.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(f.Box,{paddingInline:$?void 0:"md",gap:"xs",style:$?{paddingInline:Dt}:void 0,children:m.slotKey?e.jsx(Do,{slotKey:m.slotKey,fallback:m.items.map(G=>dr(G))}):m.items.map(G=>dr(G))})]},m.id))}),k.menuBottom&&k.menuBottom.length>0&&e.jsx(f.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:$?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:$?{paddingInline:Dt}:void 0,children:k.menuBottom.map(m=>dr(m))}),R&&e.jsx(f.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":K,"aria-valuemin":V,"aria-valuemax":N,tabIndex:0,onPointerDown:ce,onKeyDown:Me,onDoubleClick:_,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:de?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:m=>{de||(m.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:m=>{de||(m.currentTarget.style.background="transparent")}})]}),e.jsxs(f.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(f.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:O?"lg":void 0,children:[O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(xo,{children:t})]}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(f.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:n?"Loading...":(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:n?"":(o==null?void 0:o.email)||"unknown"})]}),e.jsx(Hr.Avatar,{size:"sm",initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(M.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(A.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs(f.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(Hr.Avatar,{customSize:64,initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(D.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.email)||"unknown"}),h&&e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:h})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuItem,{onClick:m.onClick,startIcon:e.jsx(M.Icon,{name:m.icon,size:"md"}),children:m.label},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuItem,{intent:"danger",onClick:er,startIcon:e.jsx(M.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(f.Box,{as:"main",ref:We,flex:"1",overflow:"overflow-y-auto",children:r||e.jsx(F,{})})]})]}),s&&c&&e.jsx(f.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:c}),e.jsxs(Ve.Dialog,{isShow:Y,onHide:Qe,children:[e.jsx(Ve.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Ve.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Ve.DialogFooter,{children:e.jsx(f.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ie.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Qe,children:"Cancel"})}),e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:Le,children:"Yes, Sure"})})]})})})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{onClick:()=>Ae(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(f.Box,{role:"dialog","aria-label":we.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:we.top,left:we.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:we.item.title}),(Sr=we.item.children)==null?void 0:Sr.map(m=>{const G=Ue(m.to),re=jr(m.badge,H[m.id]);return e.jsxs(f.Box,{as:"button",onClick:()=>{z(m.to),Ae(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:G?"primary-inverse":void 0,hover:G?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:m.title}),re&&e.jsx(sr.Badge,{text:String(re.value),variant:re.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const mr=d.forwardRef(({children:r,...t},o)=>e.jsx(f.Box,{ref:o,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Mo=({title:r,iconName:t,textColor:o,iconColor:n,hoverTextColor:l,hoverIconColor:s})=>{const[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=o??"var(--sa-text-subtle, #8c8f97)",y=s??"var(--sa-text-subtle, #8c8f97)",b=l??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:c?y:a,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:c?b:h,transition:"color 0.15s ease"},children:r||"Back"})]})},Rl=({items:r,separator:t="/",iconName:o,iconColor:n,hoverIconColor:l})=>{const{Link:s}=or(),[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=l??"var(--sa-text-subtle, #8c8f97)",y=r.length>1?r[0]:void 0,b=!!(y!=null&&y.to||y!=null&&y.onClick),p=e.jsx(M.Icon,{name:o||"ChevronLeft",size:"xs",onMouseEnter:b?()=>i(!0):void 0,onMouseLeave:b?()=>i(!1):void 0,style:{color:b&&c?h:a,transition:"color 0.15s ease",cursor:b?"pointer":void 0}}),C=y!=null&&y.to?e.jsx(s,{to:y.to,replace:!0,style:{textDecoration:"none"},children:p}):y!=null&&y.onClick?e.jsx(mr,{onClick:y.onClick,children:p}):p;return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",children:[C,e.jsx(pr.Breadcrumb,{separator:t,size:"md",children:r.map((E,w)=>{const L=w===r.length-1;return E.to&&!L?e.jsx(pr.BreadcrumbItem,{children:e.jsx(s,{to:E.to,children:E.label})},w):e.jsx(pr.BreadcrumbItem,{currentPage:L,children:e.jsx(pr.BreadcrumbLink,{onClick:L?void 0:E.onClick,children:E.label})},w)})})]})},en=r=>{const{Link:t}=or(),{items:o,separator:n,onClick:l,navigateTo:s,...c}=r;return o&&o.length>0?e.jsx(Rl,{items:o,separator:n,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):s?e.jsx(f.Box,{direction:"row",children:e.jsx(t,{to:s,replace:!0,style:{textDecoration:"none"},children:e.jsx(Mo,{...c})})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:l,children:e.jsx(Mo,{...c})})})},St=[{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 Io(r,t,o){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${o.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?o.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${o.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${o.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 To={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Lo={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Oo({isShow:r,onHide:t,menus:o,selectedGroupId:n,onSelect:l}){const[s,c]=d.useState(void 0),i=h=>{l(h),t()},a=St[0];return e.jsx(Ve.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Ve.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:Lo,children:[e.jsx("div",{style:Io(n===null,s==="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:To,children:"Semua"})]}),o.map((h,y)=>{var w;const b=n===h.id,p=s===h.id,C=((w=h.items[0])==null?void 0:w.icon)??"Grid",E=St[(y+1)%St.length];return e.jsxs("button",{onClick:()=>i(h.id),onMouseEnter:()=>c(h.id),onMouseLeave:()=>c(void 0),style:Lo,children:[e.jsx("div",{style:Io(b,p,E),children:e.jsx("div",{style:{color:E.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:C,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:To,children:h.name})]},h.id)})]})})})}function rn({onSelect:r,"aria-label":t="Pilih module"}={}){const o=ft(),{useNavigate:n}=or(),l=n(),{selectedGroupId:s,setSelectedGroupId:c}=xt(),[i,a]=d.useState(!1),h=y=>{var b;if(c(y),y!==null){const p=o.menus.find(E=>E.id===y),C=(b=p==null?void 0:p.items[0])==null?void 0:b.to;C&&l(C)}r==null||r(y)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!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:y=>{y.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),s!==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(Oo,{isShow:i,onHide:()=>a(!1),menus:o.menus.filter(y=>y.parentGroupId===void 0),selectedGroupId:s,onSelect:h})]})}const tn=(r,t)=>{const o=[];if(t===0)return o.push(r),o;for(let n=0;n<r.length;n+=t){const l=r.slice(n,n+t);o.push(l)}return o},on=d.memo(({value:r,label:t,separator:o,labelWidth:n,lastIndex:l,labelAlign:s="top"})=>{const c=d.useMemo(()=>({padding:0,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),i=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),a=()=>typeof t=="string"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,h=()=>typeof r=="string"||typeof r=="number"?e.jsx(D.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof o=="string"||typeof o=="number"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:o}):o;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:n,children:a()}),o?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:c,children:h()})]})}),ln=d.memo(({fields:r,separator:t,labelWidth:o})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,l)=>e.jsx(on,{separator:t,labelWidth:o,lastIndex:l===r.length-1,...n},`field-group-field-${l}`))})),nn=d.memo(({maxRow:r=0,maxColumn:t=2,separator:o=":",fields:n=[],labelWidth:l=150,bordered:s=!1})=>{const c=d.useMemo(()=>tn(n,r),[n,r]),i=c.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(f.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((h,y)=>e.jsx(f.Box,{direction:"column",flex:i?void 0:"1",width:i?a():void 0,marginBottom:i?"lg":void 0,children:e.jsx(ln,{labelWidth:l,fields:h,separator:o})},y))})}),sn=({backButton:r})=>{const[t,o]=d.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",l=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?s:n,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:t?c:l,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},cn=({backButton:r,title:t,titleIcon:o,titleTag:n,children:l,header:s=!0,headerBorder:c=!1,disableAnimation:i=!1,scrollable:a=!1,stickyHeader:h=!1,subHeaders:y,action:b,titleTagProps:p,containerProps:C,headerProps:E})=>{const w=De.useMediaQuery("md"),{Link:L,useNavigate:F,useLocation:I}=or(),S=F(),k=I(),H=r==null?void 0:r.show,z=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}S(-1,{replace:!0})},B=()=>{if(!b)return null;if(d.isValidElement(b))return b;const Z=b.filter(K=>K&&(K.title||K.icon));return Z.length===0?null:w?e.jsx(f.Box,{direction:"row",gap:"md",children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>e.jsx(j.Button,{iconLeft:te?e.jsx(M.Icon,{name:te,size:"md"}):void 0,onClick:V,..._,children:K},`action-${N}`))}):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:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>{const se=(_==null?void 0:_.tone)==="error"||(_==null?void 0:_.danger)===!0;return e.jsx(A.MenuItem,{intent:se?"danger":void 0,disabled:_==null?void 0:_.disabled,startIcon:te?e.jsx(M.Icon,{name:te}):void 0,onClick:V,children:K},`action-${N}`)})})})]})},W=()=>{const Z=e.jsx(sn,{backButton:r});return r!=null&&r.navigateTo?e.jsx(f.Box,{direction:"row",children:e.jsx(L,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:Z})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:z,children:Z})})},O=()=>{const Z=!!t,K=Array.isArray(b)&&b.length>0,te=d.isValidElement(b)?!0:K;if(!Z&&!te&&!H)return null;const V=w||!w&&K;return e.jsxs(f.Box,{direction:"column",gap:"xs",paddingBlock:(E==null?void 0:E.paddingBlock)??"sm",paddingInline:(E==null?void 0:E.paddingInline)??"md",...E,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...E==null?void 0:E.style},children:[H&&W(),(Z||te)&&e.jsxs(f.Box,{direction:V?"row":"column",gap:"sm",justify:"space-between",align:V?"center":"flex-start",children:[Z?typeof t=="string"?e.jsxs(f.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[o&&e.jsx(M.Icon,{name:o,size:"md",color:"primary"}),e.jsx(D.Text,{variant:"h3",fontWeight:"semibold",children:t})]}),n&&e.jsx(sr.Badge,{border:!0,size:"lg",text:n,...p})]}):t:null,B()]})]})},Y=()=>{if(!y||y.length===0)return null;const Z=y.filter(_=>_.show!==!1);if(Z.length===0)return null;let K=0,te=-1/0;return Z.forEach((_,V)=>{const N=_.order??0;N>=te&&(te=N,K=V)}),Z.map(({content:_,order:V,borderBottom:N=!0,keepBottomPadding:se=!1,paddingInline:ve=!0,paddingBlock:Ee=!0},ue)=>e.jsx(f.Box,{direction:"column",paddingTop:Ee?"sm":"spacing-0",paddingBottom:Ee&&(N||se||ue===K)?"sm":"spacing-0",paddingInline:ve?"md":"spacing-0",style:{...N?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...V!==void 0?{order:V}:{}},children:_},`sub-header-${ue}`))},X=()=>{const Z=s?O():null,K=Y();return!Z&&!K?null:e.jsxs(f.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...h?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:K?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[Z,K]})},q=()=>l;return e.jsxs(f.Box,{direction:"column",as:"main",...C,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(C==null?void 0:C.style)??{},...i?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[X(),q()]},k.pathname)},an=d.memo(cn),dn={icon:"Cross",title:""},hn=320,Ao=16,Wo=4,fn=8,zo=d.forwardRef(({onHide:r,show:t,withBlur:o=!1,style:n,children:l,closeButton:s=dn,paddingHorizontal:c=!0,width:i,minWidth:a,maxWidth:h,hideBackdrop:y=!1,title:b,headerAction:p,header:C=!0,widthPresets:E,resizable:w=!0,resizeMin:L=hn,resizeMax:F,onWidthChange:I},S)=>{const H=!De.useMediaQuery("md"),z=i??h??a??"357px",B=E??[],W=B.length>1,[O,Y]=d.useState(()=>{const $=B.indexOf(z);return $>=0?$:0}),[X,q]=d.useState(null),[Z,K]=d.useState(!1),[te,_]=d.useState(!1),V=d.useRef(null),N=$=>{V.current=$,typeof S=="function"?S($):S&&(S.current=$)},se=W?B[O]:z,ve=X!=null?`${X}px`:se,Ee=w&&!H,ue=O===B.length-1,Ce=()=>{const $=(O+1)%B.length;q(null),Y($),I==null||I(B[$])},xe=d.useCallback($=>{const ge=F??window.innerWidth;return Math.min(Math.max($,L),ge)},[L,F]),we=d.useRef(null),Ae=$=>{if(!Ee)return;$.preventDefault();const ge=$.currentTarget;ge.setPointerCapture($.pointerId),K(!0);const We=document.body.style.cursor,Ze=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let de=null;const Ge=P=>{const R=xe(window.innerWidth-P.clientX);we.current=R,de==null&&(de=window.requestAnimationFrame(()=>{de=null,we.current!=null&&q(we.current)}))},lr=P=>{de!=null&&window.cancelAnimationFrame(de),we.current!=null&&q(we.current),ge.releasePointerCapture(P.pointerId),ge.removeEventListener("pointermove",Ge),ge.removeEventListener("pointerup",lr),ge.removeEventListener("pointercancel",lr),document.body.style.cursor=We,document.body.style.userSelect=Ze,K(!1),we.current!=null&&(I==null||I(`${we.current}px`))};ge.addEventListener("pointermove",Ge),ge.addEventListener("pointerup",lr),ge.addEventListener("pointercancel",lr)},Fe=$=>{var de;if(!Ee||$.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;$.preventDefault();const ge=$.key==="ArrowLeft"?Ao:-Ao,We=X??((de=V.current)==null?void 0:de.offsetWidth)??L,Ze=xe(We+ge);q(Ze),I==null||I(`${Ze}px`)},Ne=()=>{Ee&&(q(null),I==null||I(se))};return e.jsx(Pr.Drawer,{blur:o,isShow:t,position:"right",onHide:r,ref:N,size:ve,style:n,flush:!0,radius:"none",hideBackdrop:y,children:e.jsxs(f.Box,{direction:"column",height:"height-full",children:[Ee?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Ae,onKeyDown:Fe,onDoubleClick:Ne,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>_(!0),onPointerLeave:()=>_(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:fn,cursor:"col-resize",zIndex:1,background:Z||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Wo}px, transparent ${Wo}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,C?e.jsxs(f.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(f.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof b=="string"?e.jsx(D.Text,{fontSize:"md",fontWeight:"bold",children:b}):b}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[p,W?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:Ce,"aria-label":ue?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(M.Icon,{name:ue?"ChevronRight":"ChevronLeft"})}):null,s?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:r,"aria-label":s.title||"Tutup",iconRight:e.jsx(M.Icon,{name:s.icon}),children:s.title||void 0}):null]})]}):null,e.jsx(f.Box,{direction:"column",paddingBlock:"md",paddingInline:c?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:l})]})})}),Bt=d.memo(({children:r,borderBottom:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),kt=d.memo(({children:r,borderTop:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),un=d.memo(({children:r,...t})=>e.jsx(f.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),gn=d.memo(({children:r,title:t,titleTag:o,action:n,header:l,footer:s,actionContainer:c,containerProps:i,bodyProps:a,headerProps:h={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=De.useMediaQuery("lg"),C=()=>o?e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(D.Text,{fontWeight:"medium",children:t}),e.jsx(sr.Badges,{border:!0,text:o,variant:b})]}):e.jsx(D.Text,{fontWeight:"medium",children:t}),E=()=>l||e.jsxs(f.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(f.Box,{direction:"column",children:t?C():null}),e.jsx(f.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:n??null})]}),w=!!(l||t||n);return e.jsxs(f.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[l!==null&&w?e.jsx(Bt,{...h,children:E()}):null,e.jsx(un,{...a,children:r}),s?e.jsx(kt,{...y,children:s}):null]})}),Ke={H1:r=>e.jsx(D.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(D.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(D.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(D.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(D.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(D.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(D.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(D.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(D.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(D.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(D.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(D.Text,{variant:"body-3",children:r.children,...r.props})},je=()=>{const{useSearchParams:r,useParams:t,useLocation:o}=or(),[n,l]=r(),s=vr.searchParamsToObject(n.toString()),c=t(),i=o(),a=c.id;return{setSearchParams:l,searchParams:n,searchQueries:s,isHasQuery:(C,E)=>n.has(C)&&n.get(C)===E,getQueryParam:C=>n.get(C),getRouteParam:C=>c[C],params:c,location:i,id:a,hasId:!!a}},Ho=r=>JSON.stringify(r),Po=r=>JSON.stringify(r),Vo=r=>JSON.stringify(r),jo=r=>JSON.stringify(r),yn=r=>r,pn=r=>JSON.stringify(r),Fr=r=>{if(typeof r!="string"||r==="")return{};try{const t=JSON.parse(r);return!t||typeof t!="object"||Array.isArray(t)?{}:t}catch{return{}}},Mr=({value:r,name:t,type:o,withSearchParam:n=!0,setSearchParams:l,searchQueries:s,dropdownSearchKey:c,filterKey:i="filter",pageKey:a="page"})=>{if(n){let h;switch(o){case"search":h=yn(r);break;case"dropdown":case"dropdown-multiple":h=Ho(r);break;case"radio":h=Po(r);break;case"date-range":h=Vo(r);break;case"advanced-date-range":h=pn(r);break;case"date":h=jo(r);break;default:h=r;break}if(typeof h<"u"){const y={...Fr(s[i]),[t]:h},b={...s};c&&typeof c=="string"&&delete b[c],delete b[a];const p={...b,[i]:JSON.stringify(y)},C=new URLSearchParams(s).toString(),E=new URLSearchParams(p).toString();if(C===E)return;l(p)}}},qr=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c)[0].label:n==="value"&&c?JSON.parse(c)[0].value:c},No=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c).map(i=>i.label):n==="value"&&c?JSON.parse(c).map(i=>i.value):n==="array"&&c?JSON.parse(c):c},bn=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="id"&&c?JSON.parse(c).id:n==="label"&&c?JSON.parse(c).label:n==="value"&&c?JSON.parse(c).value:c},Zr=(r,t,o)=>{const n=t.get(o||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0;return l?l[r]:void 0},vn=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},_o=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return s?JSON.parse(s):void 0},Cn=(r,{filterKey:t="filter",perPageKey:o="perPage",pageKey:n="page"})=>{const l=r.get(t)||void 0,s=r.get(o)||void 0,c=r.get(n)||void 0;return!!l||!!s||!!c},qo=({isOpen:r,onClose:t,filterKey:o,pageKey:n,filters:l})=>{const{searchParams:s,setSearchParams:c,searchQueries:i}=je(),[a,h]=d.useState({}),y=()=>{s.delete(o||"filter"),c(s)},b=(p,C)=>{switch(p.type){case"radio":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"dropdown":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"date-range":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"date":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"dropdown-multiple":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}default:return null}};return e.jsx(zo,{onHide:t,show:r||!1,children:e.jsxs(f.Box,{direction:"column",gap:"md",children:[e.jsxs(ie.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(f.Box,{direction:"column",children:"Filter"}),e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),l==null?void 0:l.map((p,C)=>b(p,C))]})})},Zo=({searchKey:r="q",statusKey:t="status",searchPlaceholder:o="Search",searchHighlightPlaceholder:n,extendedFilter:l,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:i="filter",pageKey:a="page",customWidthSearch:h,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:C="right",titleSearchLabel:E="Work Order",withTitleLabels:w=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[I,S]=d.useState(!1),[k,H]=d.useState(0),z=()=>{H(N=>N+1)},{searchParams:B,setSearchParams:W,getQueryParam:O}=je(),Y=vr.searchParamsToObject(B.toString()),X=Zr(r,B,i)||"",[q,Z]=d.useState(X),K=O(i),_=!!(K&&!(()=>{if(K)try{const N=JSON.parse(K);return Object.keys(N).length===1&&N[r]===""}catch(N){console.error("Filter parameter is not a valid JSON:",N)}return!1})()),V=De.useMediaQuery("md");return d.useEffect(()=>{Z(X)},[X]),d.useEffect(()=>{if(q===X)return;const N=window.setTimeout(()=>{Mr({value:q,name:r,type:"search",searchQueries:Y,setSearchParams:W,filterKey:i,pageKey:a})},350);return()=>{window.clearTimeout(N)}},[q,X,r,Y,W,i,a]),e.jsxs(ie.Flex,{gap:"md",style:{flexDirection:V&&C==="left"?"row":V&&C==="right"?"row-reverse":"column"},align:"flex-end",children:[_&&e.jsx(f.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const N=new URLSearchParams(B);N.delete(i),W(N),Z(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(D.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),l==null?void 0:l.map(({minWidth:N,content:se,title:ve,onClickContainer:Ee},ue)=>e.jsxs(f.Box,{direction:"column",gap:"sm",onClick:Ee,style:{minWidth:N},children:[ve&&e.jsx(Ke.SubH3,{children:ve}),se]},`extended-filter-${ue}-${k}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:_,secondary:!_,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:K?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!V,onClick:()=>S(!0),children:F?"Filter":void 0}),c&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[w&&e.jsx(Ke.SubH3,{children:"Status"}),e.jsx(br.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:qr({get:"value",name:t,searchParams:B,filterKey:i})?[{label:qr({get:"value",name:t,searchParams:B,filterKey:i})==="active"?"Active":"InActive",value:qr({get:"value",name:t,searchParams:B,filterKey:i})}]:[],onChange:N=>Mr({value:N,name:t,type:"dropdown",searchQueries:Y,setSearchParams:W,filterKey:i}),placeholder:w?"All":"All Status"},k)]}),s&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{width:h&&V?h:V?"310px":""},children:[w&&e.jsxs(Ke.SubH3,{children:["Search for ",E]}),e.jsx(ar.Input,{placeholder:o,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:N=>Z(N.target.value),value:q,fullWidth:!0},k+1+i)]}),e.jsx(qo,{isOpen:I,onClose:()=>S(!1),filterKey:i,filters:b,pageKey:a})]})},xn=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function Et({configs:r,filterKey:t="filter",activeFilterKey:o="filters",pageKey:n="page",searchKey:l="q"}){const{searchParams:s,setSearchParams:c,searchQueries:i}=je(),a=d.useMemo(()=>Object.fromEntries(r.map(k=>[k.key,k])),[r]),h=d.useMemo(()=>{const k=(s.get(o)||"").split(",").map(z=>z.trim()).filter(Boolean),H=Object.keys(Fr(s.get(t))).filter(z=>z!==l);return r.map(z=>z.key).filter(z=>{const B=a[z];return(B==null?void 0:B.locked)||k.includes(z)||H.includes(z)})},[s,o,t,l,r,a]),y=d.useCallback(k=>Fr(k[t]),[t]),b=d.useCallback(k=>{const H={...i};k.length?H[o]=k.join(","):delete H[o],c(H)},[i,o,c]),p=d.useCallback(k=>{h.includes(k)||b([...h,k])},[h,b]),C=d.useCallback(k=>{var W;if((W=a[k])!=null&&W.locked)return;const H={...i},z=h.filter(O=>O!==k);z.length?H[o]=z.join(","):delete H[o];const B=y(H);k in B&&(delete B[k],Object.keys(B).length?H[t]=JSON.stringify(B):delete H[t]),delete H[n],c(H)},[i,h,o,t,n,y,c,a]),E=d.useCallback(k=>h.includes(k)?C(k):p(k),[h,p,C]),w=d.useCallback(k=>{switch(k.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return No({name:k.key,get:"array",searchParams:s,filterKey:t})||[];case"date":{const H=_o({name:k.key,searchParams:s,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const z=y(Object.fromEntries(s.entries()))[k.key];return z&&typeof z=="object"?z:void 0}default:return}},[s,t,y]),L=d.useCallback((k,H)=>{if(k.type==="date-compact"){const z={...i},B=y(z);H==null?delete B[k.key]:B[k.key]=H,Object.keys(B).length?z[t]=JSON.stringify(B):delete z[t],delete z[n],c(z);return}Mr({value:H,name:k.key,type:xn(k.type),searchQueries:i,setSearchParams:c,filterKey:t,pageKey:n})},[i,c,t,n,y]),F=d.useCallback(k=>{const H={...i},z=y(H);k in z&&(delete z[k],Object.keys(z).length?H[t]=JSON.stringify(z):delete H[t]),delete H[n],c(H)},[i,t,n,y,c]),I=d.useCallback(()=>{const k={...i};delete k[t],delete k[o],delete k[n],c(k)},[i,t,o,n,c]),S=h.length>0;return{activeKeys:h,configByKey:a,hasActiveFilter:S,addFilter:p,removeFilter:C,toggleFilter:E,getValue:w,setValue:L,clearValue:F,clearAll:I}}const mt={get(r){return Er.storage.get(r)??null},set(r,t){Er.storage.save(r,t)},remove(r){Er.storage.delete(r)}},wr={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}`},Gr=(r,t)=>{const o=new Set(t.map(s=>s.key)),n=r.order.filter(s=>o.has(s));for(const s of t)n.includes(s.key)||n.push(s.key);const l=r.hidden.filter(s=>o.has(s));return{order:n,hidden:l}};function wn({columns:r,scopeId:t,storage:o,onColumnsChange:n,value:l}){const s=d.useMemo(()=>({order:r.map(B=>B.key),hidden:[]}),[r]),c=t?wr.columns(t):void 0,i=(B,W)=>Gr({order:B.order??W,hidden:B.hidden??[]},r),[a,h]=d.useState(()=>{if(l&&(l.order||l.hidden))return i(l,r.map(B=>B.key));if(c){const B=o.get(c);if(B&&Array.isArray(B.order))return Gr(B,r)}return s}),y=r.map(B=>B.key).join("|");d.useEffect(()=>h(B=>Gr(B,r)),[y]);const b=d.useRef(a);b.current=a;const p=l?`${(l.order??[]).join("|")}~${(l.hidden??[]).join("|")}`:null,C=d.useRef(p);d.useEffect(()=>{if(p==null||C.current===p)return;C.current=p;const B=b.current,W=i(l,B.order);W.order.join("|")===B.order.join("|")&&W.hidden.join("|")===B.hidden.join("|")||(h(W),c&&o.set(c,W))},[p,y]);const E=d.useRef(!1);d.useEffect(()=>{E.current||(E.current=!0,n==null||n(a))},[]);const w=d.useCallback(B=>{h(B),c&&o.set(c,B),n==null||n(B)},[c,o,n]),L=d.useMemo(()=>{const B=new Map(r.map(W=>[W.key,W]));return a.order.filter(W=>B.has(W)).map(W=>({...B.get(W),visible:!a.hidden.includes(W)}))},[a,r]),F=d.useCallback(B=>{const W=a.hidden.includes(B)?a.hidden.filter(O=>O!==B):[...a.hidden,B];w({...a,hidden:W})},[a,w]),I=d.useCallback((B,W)=>{if(B===W)return;const O=[...a.order],[Y]=O.splice(B,1);O.splice(W,0,Y),w({...a,order:O})},[a,w]),S=d.useCallback(B=>{w({...a,hidden:B?r.filter(W=>!W.locked).map(W=>W.key):[]})},[a,r,w]),k=d.useCallback(()=>w(s),[w,s]),H=d.useCallback(B=>w(Gr(B,r)),[w,r]),z=a.hidden.length===0;return{state:a,orderedColumns:L,allVisible:z,toggleVisibility:F,reorder:I,setAllHidden:S,reset:k,applyState:H}}function Dn({scopeId:r,storage:t,snapshotKeys:o,pageKey:n="page",getColumns:l,applyColumns:s}){const{searchParams:c,setSearchParams:i}=je(),a=r?wr.savedViews(r):void 0,[h,y]=d.useState(()=>a?t.get(a)||[]:[]),b=d.useCallback(w=>{y(w),a&&t.set(a,w)},[a]),p=d.useCallback(w=>{const L=w.trim();if(!L)return;const F={};o.forEach(S=>{const k=c.get(S);k!=null&&(F[S]=k)});const I={id:`${Date.now()}`,name:L,query:F,columns:l==null?void 0:l(),createdAt:Date.now()};b([...h,I])},[o,c,l,b,h]),C=d.useCallback(w=>b(h.filter(L=>L.id!==w)),[b,h]),E=d.useCallback(w=>{const L=Object.fromEntries(c.entries());o.forEach(F=>delete L[F]),Object.assign(L,w.query),delete L[n],i(L),w.columns&&(s==null||s(w.columns))},[c,o,n,i,s]);return{enabled:!!a,views:h,saveView:p,deleteView:C,applyView:E}}function Sn(r,t){const o=Fr(r);return delete o[t],Object.keys(o).length>0?JSON.stringify(o):void 0}function Go(r,t,o){const n=r[t];if(n==null)return;const l=Sn(n,o);l===void 0?delete r[t]:r[t]=l}function Bn({scopeId:r,storage:t,snapshotKeys:o,enabled:n=!0,filterKey:l="filter",searchKey:s="q",persistSearch:c=!0}){const{searchParams:i}=je(),a=r&&n?wr.lastState(r):void 0,h=d.useRef(a),y=d.useRef(!1);d.useEffect(()=>{if(!a){h.current=a;return}if(h.current!==a){h.current=a,y.current=!1;return}const C={};if(o.forEach(E=>{const w=i.get(E);w!=null&&(C[E]=w)}),c||Go(C,l,s),Object.keys(C).length===0){y.current&&t.remove(a);return}y.current=!0,t.set(a,C)},[i,a,o,t,c,l,s]);const b=d.useCallback(()=>{if(!a)return null;const C=t.get(a);if(!C||typeof C!="object"||Array.isArray(C)||Object.keys(C).length===0)return null;const E=C[l];return E!=null&&Object.keys(Fr(E)).length===0&&delete C[l],c||Go(C,l,s),Object.keys(C).length>0?C:null},[a,t,c,l,s]),p=d.useCallback(()=>{a&&t.remove(a)},[a,t]);return{enabled:!!a,read:b,clear:p}}function kn({scopeId:r,storage:t,perPageKey:o,pageSizeOptions:n,enabled:l=!0}){const{searchParams:s}=je(),c=r&&l?wr.perPage(r):void 0,i=s.toString(),a=d.useRef(c);d.useEffect(()=>{if(!c){a.current=c;return}if(a.current!==c){a.current=c;return}const b=s.get(o);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(c,p)},[i,c,o,t]);const h=d.useCallback(()=>{if(!c)return null;const b=t.get(c);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[c,t,n]),y=d.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:h,clear:y}}let Ft={},Mt=!1,It=null;const En=(r,t)=>{Object.assign(Ft,r),It=t,!Mt&&(Mt=!0,queueMicrotask(()=>{const o=Ft,n=It;Ft={},Mt=!1,It=null,!(!n||Object.keys(o).length===0)&&n(l=>{const s=new URLSearchParams(l);return Object.entries(o).forEach(([c,i])=>s.set(c,i)),s},{replace:!0})}))};function mn({enabled:r,snapshotKeys:t,perPageKey:o,readSnapshot:n,readPerPage:l}){const{searchParams:s,setSearchParams:c,location:i}=je(),a=d.useRef(null);d.useEffect(()=>{if(!r||a.current===i.pathname)return;a.current=i.pathname;const h={};if(!s.has(o)){const y=l();y&&(h[o]=y)}if(!t.some(y=>s.has(y))){const y=n();y&&Object.assign(h,y)}Object.keys(h).length!==0&&En(h,c)},[i.pathname,r])}const Fn=({configs:r,activeKeys:t,onToggle:o,hasActiveFilter:n,onReset:l})=>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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&l&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:l,children:"Reset"})]}),children:r.map(s=>e.jsx(A.MenuItem,{selected:s.locked||t.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||o(s.key)},children:s.label},s.key))})})]}):null,Qr=({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"})]})})]}),Mn=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},Qo=(r,t,o)=>{const n=new Date(r);return o==="day"?n.setDate(n.getDate()+t):o==="week"?n.setDate(n.getDate()+t*7):o==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Uo=r=>{const t=Mn(new Date);if(r.direction==="this"){const n=new Date(t),l=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),l.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),l.setMonth(l.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),l.setMonth(11,31)),{from:n,to:l}}const o=r.count??1;return r.direction==="past"?{from:Qo(t,-o,r.period),to:t}:{from:t,to:Qo(t,o,r.period)}},Jo=24,Yo=r=>r.length>Jo?`${r.slice(0,Jo)}...`:r,Xo=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Tt=(r,t="days")=>t==="months"?r.toLocaleDateString(void 0,{month:"short",year:"numeric"}):t==="years"?String(r.getFullYear()):Xo(r),Ur={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"},In=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],Lt={past:"Past",next:"Next",this:"This"},Tn=["day","week","month","year"],Ln=["past","next","this"],On=r=>r.field.type==="date-compact"?e.jsx(zn,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(An,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),An=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=t?Xo(new Date(t)):null,c=!!s,i=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Yo(s)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(M.Icon,{name:"Calendar",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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():o(a),withPadding:!1})})})]})},Wn=(r,t="days")=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Ur[r.op]} ${Tt(new Date(r.date),t)}`:null;case"is-between":return r.from&&r.to?`${Tt(new Date(r.from),t)} - ${Tt(new Date(r.to),t)}`:null;case"is-relative-to-today":{const o=r.relative;if(!o)return null;if(o.direction==="this")return`This ${o.period}`;const n=o.count??1,l=n===1?o.period:`${o.period}s`;return`${Lt[o.direction]} ${n} ${l}`}case"is-empty":case"is-not-empty":return Ur[r.op];default:return null}},zn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.ops&&r.ops.length>0?r.ops:In,c=r.defaultOp&&s.includes(r.defaultOp)?r.defaultOp:s[0],i=r.mode??"days",a=(t==null?void 0:t.op)??c,h=t?Wn(t,i):null,y=!!h,b=y?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Yo(h)})]}):r.label,p=C=>{if(C!==a){if(C==="is-empty"||C==="is-not-empty"){o({op:C});return}if(C==="is-relative-to-today"){o({op:C,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(C==="is-between"){o({op:C,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}o({op:C,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:y?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:y?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Hn,{op:a,ops:s,onChange:p})]}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsx(Pn,{value:t,op:a,mode:i,onChange:o})}),a==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Hn=({op:r,ops:t,onChange:o})=>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:Ur[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:()=>o(n),endIcon:r===n?e.jsx(M.Icon,{name:"Check"}):void 0,children:Ur[n]},n))})})]}),Pn=({value:r,op:t,mode:o="days",onChange:n})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const l=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(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:o,value:l,onChange:s=>{if(s==null){n({op:t});return}if(typeof s=="object"&&s!==null&&"from"in s&&"to"in s){let{from:c,to:i}=s;if(!c&&i&&(c=i,i=null),!c&&!i){n({op:t});return}n({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},`range-${o}`)}return t==="is-relative-to-today"?e.jsx(Vn,{value:r==null?void 0:r.relative,onChange:l=>n({op:t,relative:l})}):e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:o,value:r!=null&&r.date?new Date(r.date):void 0,onChange:l=>{if(l==null){n({op:t});return}l instanceof Date&&n({op:t,date:l.toISOString()})},withPadding:!1},`single-${o}`)},Vn=({value:r,onChange:t})=>{const o=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,l=(r==null?void 0:r.period)??"week",s=o!=="this",c=Uo({direction:o,count:n,period:l});return e.jsxs(f.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(f.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:Lt[o]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Ln.map(i=>e.jsx(A.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:l}:{direction:i,count:n,period:l}),children:Lt[i]},i))})})]}),s&&e.jsx(ar.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const a=Number(i.target.value);t({direction:o,count:Number.isFinite(a)&&a>0?a:1,period:l})},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:l})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Tn.map(i=>e.jsx(A.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(o==="this"?{direction:o,period:i}:{direction:o,count:n,period:i}),children:i},i))})})]})]}),e.jsx(fr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},$o=18,jn=r=>r.length>$o?`${r.slice(0,$o)}...`:r,Nn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.type==="dropdown-multiple",c=t.length,i=r.searchable!==!1,[a,h]=d.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(I=>I.label.toLowerCase().includes(F)):y})(),C=F=>t.some(I=>I.value===F.value),E=F=>{if(!s){o([{label:F.label,value:F.value}]),h("");return}o(C(F)?t.filter(I=>I.value!==F.value):[...t,{label:F.label,value:F.value}])},w=F=>{var I;h(F),(I=r.onSearch)==null||I.call(r,F)},L=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?jn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:L})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsxs(f.Box,{direction:"column",gap:"sm",children:[i&&e.jsx(br.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:a,onSearch:w,value:t,onChange:o,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!s,selected:C(F),startIcon:F.avatar,endIcon:C(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>E(F),children:F.label},F.value))})]})})})]})},Ko=18,_n=r=>r.length>Ko?`${r.slice(0,Ko)}...`:r,Ro=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(tr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),qn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=new Set(t.map(p=>p.value)),c=t.length,i=r.options.length>0&&r.options.every(p=>s.has(p.value)),a=c>0&&!i,h=p=>{o(s.has(p.value)?t.filter(C=>C.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{o(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(D.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(D.Text,{as:"span",children:c===1?_n(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(Ro,{checked:i||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s.has(p.value),onClick:()=>h(p),startIcon:e.jsx(Ro,{checked:s.has(p.value)}),children:p.label},p.value))]})})]})},el=({activeKeys:r,configByKey:t,getValue:o,setValue:n,clearValue:l,removeFilter:s})=>e.jsx(e.Fragment,{children:r.map(c=>{const i=t[c];if(!i)return null;const a=o(i),h=i.locked?void 0:()=>s(c);return i.type==="date"||i.type==="date-compact"?e.jsx(On,{field:i,value:a,onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):i.type==="checkbox-multiple"?e.jsx(qn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):e.jsx(Nn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c)})}),rl=r=>`${r} Rows`,Zn=({pagination:r,pageKey:t="page",perPageKey:o="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:l=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:i=!0})=>{var F;const{searchQueries:a,setSearchParams:h,searchParams:y}=je(),b=y.get(o),p=b?Number(b):l,C=I=>{h({...a,[t]:String(I)})},E=I=>{h({...a,[o]:I,[t]:"1"})},w=(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),L=(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:[s&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${w}-${L} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),c&&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:rl(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(I=>e.jsx(A.MenuItem,{selected:I===p,onClick:()=>E(String(I)),children:rl(I)},I))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(f.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(kr.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:C})})]})};function Gn(r,t,o=!0){d.useEffect(()=>{if(!o)return;const n=l=>{var i;if(l.metaKey||l.ctrlKey||l.altKey||l.key!==r||Ve.isOverlayOpen())return;const s=l.target,c=(i=s==null?void 0:s.tagName)==null?void 0:i.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(l.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,o])}const Qn=240,tl=({searchKey:r="q",filterKey:t="filter",pageKey:o="page",placeholder:n="Search",shortcut:l="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:i,searchQueries:a}=je(),h=Zr(r,c,t)||"",[y,b]=d.useState(!s||!!h),[p,C]=d.useState(s&&!h),[E,w]=d.useState(h),L=De.useDebounce(E,350),F=d.useRef(null);d.useEffect(()=>{w(h),h&&b(!0)},[h]),d.useEffect(()=>{y&&C(!1)},[y]),d.useEffect(()=>{L!==h&&Mr({value:L,name:r,type:"search",searchQueries:a,setSearchParams:i,filterKey:t,pageKey:o})},[L]);const I=d.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var z;return(z=F.current)==null?void 0:z.focus()})},[]);Gn(l,I);const S=()=>{s&&!E&&b(!1)},k=z=>{var B;s&&z.key==="Escape"&&!E&&(b(!1),(B=F.current)==null||B.blur())},H=()=>{y||C(!0)};return e.jsxs(f.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:I}),e.jsxs(f.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Qn:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(ar.Input,{ref:F,size:"sm",fullWidth:!0,value:E,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:z=>w(z.target.value),onKeyDown:k,onBlur:S,tabIndex:y?0:-1}),y&&!E&&e.jsx(f.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(D.Text,{fontSize:"xs",color:"subtle",children:l})})]})]})},ol=({columns:r,allVisible:t,onToggle:o,onReorder:n,onSetAllHidden:l})=>{const[s,c]=d.useState(null),[i,a]=d.useState(null),h=()=>{s!==null&&i!==null&&s!==i&&n(s,i),c(null),a(null)},y=(b,p)=>{const C=b+p;C<0||C>=r.length||n(b,C)};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(f.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>l(t),children:t?"Hide All":"Show All"})]}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const C=!b.locked,E=i===p&&s!==null&&s!==p;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:C,onDragStart:()=>C&&c(p),onDragOver:w=>{w.preventDefault(),a(p)},onDrop:h,onDragEnd:h,style:{minHeight:32,boxShadow:E?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(f.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:C?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!C||void 0,color:"icon-subtlest",onKeyDown:w=>{C&&(w.key==="ArrowUp"?(w.preventDefault(),y(p,-1)):w.key==="ArrowDown"&&(w.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:C?"grab":"default",opacity:C?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(f.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(xr.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>o(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},ll=({views:r,onApply:t,onDelete:o,onSave:n})=>{const[l,s]=d.useState(""),c=()=>{const i=l.trim();i&&(n(i),s(""))};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(f.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(f.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(D.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:a=>{a.stopPropagation(),o(i.id)}}),children:i.name},i.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(f.Box,{direction:"row",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(ar.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:l,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&c()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!l.trim(),onClick:c,children:"Save"})]})})]})]})},Un=({isOpen:r,onClose:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:i,getValue:a,setValue:h,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(Pr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(f.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(D.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(f.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(f.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(el,{activeKeys:n,configByKey:l,getValue:a,setValue:h,clearValue:y,removeFilter:b})})]}),o.length>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(f.Box,{direction:"column",children:o.map(C=>{const E=n.includes(C.key),w=!!C.locked;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:w?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[C.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(D.Text,{fontSize:"sm",color:"primary",truncate:!0,children:C.label})]}),e.jsx(xr.Toggle,{size:"sm",checked:E||w,disabled:w,onChange:()=>c(C.key),"aria-label":`Toggle ${C.label}`})]},C.key)})})]})]}),e.jsxs(f.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(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:i,children:"Reset"})}),e.jsx(f.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"})})]})]})})},Jn=r=>`${r} Rows`,Yn=({perPageKey:r,pageKey:t,pageSizeOptions:o,defaultPerPage:n=10,showPageSize:l})=>{const{searchQueries:s,setSearchParams:c,searchParams:i}=je(),a=i.get(r),h=a?Number(a):n,y=b=>{c({...s,[r]:b,[t]:"1"})};return l?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(f.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),o.map(b=>e.jsx(A.MenuItem,{selected:b===h,endIcon:b===h?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:Jn(b)},b))]})})]}):null},Xn=r=>{var We;const{withPadding:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,toggleFilter:c,removeFilter:i,getValue:a,setValue:h,clearValue:y,onReset:b,searchable:p,searchKey:C,filterKey:E,pageKey:w,searchPlaceholder:L,searchShortcut:F,searchCollapsible:I,pagination:S,perPageKey:k,pageSizeOptions:H,defaultPerPage:z,showPagination:B,showResultCount:W,showPageSize:O,hasColumns:Y,orderedColumns:X,allVisible:q,onToggleVisibility:Z,onReorder:K,onSetAllHidden:te,showSavedViews:_,savedViews:V,onApplyView:N,onDeleteView:se,onSaveView:ve,leadingActions:Ee}=r,[ue,Ce]=d.useState(!1),{searchQueries:xe,setSearchParams:we}=je(),Ae=(S==null?void 0:S.rangeStart)??(((S==null?void 0:S.currentPage)||0)>1?(((S==null?void 0:S.currentPage)||0)-1)*((S==null?void 0:S.perPage)||0)+1:1),Fe=(S==null?void 0:S.rangeEnd)??((S==null?void 0:S.totalCurrentPage)!==(S==null?void 0:S.perPage)?S==null?void 0:S.totalData:((S==null?void 0:S.currentPage)||1)*((S==null?void 0:S.totalCurrentPage)||0)),Ne=Ze=>{we({...xe,[w]:String(Ze)})},$=W||B&&!!(S!=null&&S.totalPage),ge=()=>{b(),Ce(!1)};return e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(tl,{searchKey:C,filterKey:E,pageKey:w,placeholder:L,shortcut:F,collapsible:I}),e.jsx(j.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Ce(!0),"aria-label":"Open filters",children:s?`Filter: ${n.length}`:null}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Ee,_&&e.jsx(ll,{views:V,onApply:N,onDelete:se,onSave:ve}),Y&&e.jsx(ol,{columns:X,allVisible:q,onToggle:Z,onReorder:K,onSetAllHidden:te}),e.jsx(Yn,{perPageKey:k,pageKey:w,pageSizeOptions:H,defaultPerPage:z,showPageSize:O})]})]}),$&&e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[W?e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ae}-${Fe} of ${((We=S==null?void 0:S.totalData)==null?void 0:We.toLocaleString())||0}`}):e.jsx(f.Box,{direction:"column"}),B&&!!(S!=null&&S.totalPage)&&e.jsx(kr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:S!=null&&S.currentPage?Number(S.currentPage):1,totalPages:Number(S.totalPage),onPageChange:Ne})]}),e.jsx(Un,{isOpen:ue,onClose:()=>Ce(!1),configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:ge,getValue:a,setValue:h,clearValue:y,removeFilter:i})]})},$n=({withPadding:r=!1,filterConfigs:t=[],filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:i,showPagination:a=!0,showResultCount:h=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:C="Search",searchShortcut:E="/",searchPosition:w="right",searchCollapsible:L=!0,pagination:F,columns:I=[],onColumnsChange:S,columnsState:k,scopeId:H,savedViews:z,persistLastState:B=!0,persistSearch:W=!0,storage:O=mt,onReset:Y,leadingActions:X})=>{const q=H??(z==null?void 0:z.scopeId),{activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,clearAll:Ee}=Et({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:p}),ue=wn({columns:I,scopeId:q,storage:O,onColumnsChange:S,value:k}),Ce=Dn({scopeId:q,storage:O,snapshotKeys:[n,o,s],pageKey:l,getColumns:()=>ue.state,applyColumns:ue.applyState}),xe=Bn({scopeId:q,storage:O,snapshotKeys:[n,o,l],enabled:B,filterKey:o,searchKey:p,persistSearch:W}),we=kn({scopeId:q,storage:O,perPageKey:s,pageSizeOptions:c,enabled:B});mn({enabled:B&&!!q,snapshotKeys:[n,o,l],perPageKey:s,readSnapshot:xe.read,readPerPage:we.read});const Ae=i??c[0]??25,Fe=!!(z!=null&&z.enabled)&&Ce.enabled,Ne=()=>{Ee(),xe.clear(),Y==null||Y()},$=De.useMediaQuery("md"),ge=b?e.jsx(tl,{searchKey:p,filterKey:o,pageKey:l,placeholder:C,shortcut:E,collapsible:L}):null;return $?e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Fn,{configs:t,activeKeys:Z,onToggle:_,hasActiveFilter:te,onReset:Ne}),w==="left"&&ge,e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(el,{activeKeys:Z,configByKey:K,getValue:N,setValue:se,clearValue:ve,removeFilter:V}),te&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:Ne,children:"Reset"})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[X,e.jsx(Zn,{pagination:F,pageKey:l,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y}),w==="right"&&ge,Fe&&e.jsx(ll,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),I.length>0&&e.jsx(ol,{columns:ue.orderedColumns,allVisible:ue.allVisible,onToggle:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden})]})]}):e.jsx(Xn,{withPadding:r,configs:t,activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,onReset:Ne,searchable:b,searchKey:p,filterKey:o,pageKey:l,searchPlaceholder:C,searchShortcut:E,searchCollapsible:L,pagination:F,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y,hasColumns:I.length>0,orderedColumns:ue.orderedColumns,allVisible:ue.allVisible,onToggleVisibility:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden,showSavedViews:Fe,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:X})},Kn=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},Rn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(o=>(o==null?void 0:o.value)!=null?String(o.value):null).filter(o=>o!=null);return t.length?t:void 0},es=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Kn(t);case"dropdown-multiple":case"checkbox-multiple":return Rn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},nl=(r,t)=>{if(r==null||r==="")return t;const o=Number(r);return Number.isFinite(o)&&o>0?o:t},rs=r=>{const{filterConfigs:t,filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:i=1,defaultPerPage:a=10,paramKeys:h,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:C,getValue:E}=Et({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:c}),{searchParams:w}=je(),L=w.toString();return d.useMemo(()=>{const I={},S={},k=nl(w.get(l),i),H=nl(w.get(s),a);I[(h==null?void 0:h.page)??"page"]=k,I[(h==null?void 0:h.perPage)??"perPage"]=H;const z=Zr(c,w,o)||"";z&&(I[(h==null?void 0:h.search)??"search"]=z);let B=!1;for(const W of b){const O=p[W];if(!O)continue;const Y=E(O);S[W]=Y;const X=y==null?void 0:y[W],q=X?X(Y):es(O,Y);if(q==null||Array.isArray(q)&&q.length===0)continue;const Z=(h==null?void 0:h[W])??W;I[Z]=q,B=!0}return{params:I,raw:S,hasActiveFilter:C||!!z||B}},[L,b.join("|"),o,n,l,s,c,i,a,h,y,p])},ts=["dropdown","dropdown-multiple","checkbox-multiple","radio"],os=({filterConfigs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l})=>{const{configByKey:s,getValue:c,setValue:i,removeFilter:a,clearAll:h,hasActiveFilter:y}=Et({configs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l}),b=(F,I)=>{var k;const S=F.options;return((k=S==null?void 0:S.find(H=>H.value===I))==null?void 0:k.label)??I},p=d.useCallback(F=>{const I=s[F];if(!I)return[];const S=c(I);return Array.isArray(S)?S.map(k=>String(k.value)):[]},[s,c]),C=d.useCallback((F,I)=>{const S=s[F];if(!S||!ts.includes(S.type))return;const k=Array.isArray(I)?I:[I];if(k.length===0){a(F);return}i(S,k.map(H=>({label:b(S,H),value:H})))},[s,i,a]),E=d.useCallback((F,I)=>{const S=p(F);C(F,S.includes(I)?S.filter(k=>k!==I):[...S,I])},[p,C]),w=d.useCallback((F,I)=>p(F).includes(I),[p]),L=d.useCallback(F=>a(F),[a]);return{set:C,toggle:E,clear:L,clearAll:h,isActive:w,values:p,hasActiveFilter:y}},ls=(r,t)=>{if(!r)return{};const{fromKey:o,toKey:n,opKey:l}=t,s={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(s[o]=new Date(r.date).toISOString()),l&&(s[l]=r.op),s;case"is-between":return r.from&&(s[o]=new Date(r.from).toISOString()),r.to&&(s[n]=new Date(r.to).toISOString()),s;case"is-relative-to-today":{if(!r.relative)return s;const{from:c,to:i}=Uo(r.relative);return s[o]=c.toISOString(),s[n]=i.toISOString(),s}case"is-empty":case"is-not-empty":return l&&(s[l]=r.op==="is-empty"?"empty":"not-empty"),s;default:return s}},sl=({children:r,borderRadius:t,height:o})=>{const n=d.useRef(null),[l,s]=d.useState("100vh");return d.useEffect(()=>{if(o)return;const c=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;s(`calc(100vh - ${i}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[o]),e.jsx(f.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:o??l,display:"flex",flexDirection:"column"},children:r})},cl=({action:r,rightContent:t,leftContent:o,headerSlot:n,advanceFilter:l,showFilter:s=!0})=>{const c=De.useMediaQuery("md"),i=s?e.jsx(Zo,{...l}):null,a=()=>r?d.isValidElement(r)?r:e.jsx(f.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:h,icon:y,buttonProps:b,onClick:p},C)=>!h&&!y?null:e.jsx(j.Button,{fullWidth:!c,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:h},`action-${C}`))}):null;return e.jsx(f.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:c?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,o]}),e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},ns=({totalData:r,withMarginBottom:t=!0,withMarginTop:o=!0})=>e.jsxs(f.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:o?"16px":void 0},children:[e.jsxs(Ke.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ke.Body1,{children:r||0})]}),il=({pagination:r,pageKey:t="page",perPageKey:o="perPage",defaultPerPage:n=10,showPagination:l=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:i,searchParams:a}=je(),h=a.get(o),y=E=>{i({...c,[t]:String(E)})},b=E=>{i({...c,[o]:E,[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),C=(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(f.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:l?e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(D.Text,{children:"Rows Per Page: "}),e.jsx(br.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:E=>{b(E[0].value)},value:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(D.Text,{children:`${p}-${C} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(kr.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(ns,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},al=({filter:r,columnTitle:t})=>{const[o,n]=d.useState(!1),l=d.useRef(null),s=d.useRef(null),c=d.useRef(null),[i,a]=d.useState(""),[h,y]=d.useState({top:0,left:0}),b=r.selectedValues,p=d.useMemo(()=>i?r.options.filter(w=>w.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);d.useEffect(()=>{if(o&&s.current){const w=s.current.getBoundingClientRect(),L=280,F={top:w.bottom+8};r.position==="left"||w.left+L>window.innerWidth?F.right=window.innerWidth-w.right:F.left=w.left,y(F)}},[o,r.position]),d.useEffect(()=>{o&&c.current?setTimeout(()=>{var w;return(w=c.current)==null?void 0:w.focus()},50):a("")},[o]),d.useEffect(()=>{const w=L=>{l.current&&!l.current.contains(L.target)&&s.current&&!s.current.contains(L.target)&&n(!1)};return o&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[o]);const C=w=>{const L=b.includes(w)?b.filter(F=>F!==w):[...b,w];r.onFilterChange(L)},E=()=>r.onFilterChange([]);return e.jsxs(f.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(f.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:w=>{var L;w.stopPropagation(),o||(L=r.onOpen)==null||L.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:o?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),o&&e.jsxs(f.Box,{ref:l,style:{position:"fixed",top:`${h.top}px`,...h.left!==void 0?{left:`${h.left}px`}:{right:`${h.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(f.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(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(D.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:w=>{w.stopPropagation(),E()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(f.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(ar.Input,{ref:c,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:i,onChange:w=>a(w.target.value),style:{fontSize:"14px"}})}),e.jsx(f.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(f.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(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(f.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(w=>e.jsxs(f.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(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:L=>{L.stopPropagation(),C(w.value)},onMouseEnter:L=>{b.includes(w.value)||(L.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),L.currentTarget.style.transform="translateX(2px)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor=b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",L.currentTarget.style.transform="translateX(0)"},children:[e.jsx(tr.Checkbox,{checked:b.includes(w.value),onChange:()=>{}}),e.jsx(D.Text,{fontSize:"sm",fontWeight:b.includes(w.value)?"medium":"normal",color:b.includes(w.value)?"primary":"gray-700",children:w.label})]},w.value))}):e.jsxs(f.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(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(f.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(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(f.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(D.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},ss=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",o="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:o,l=r==="desc"?t:o,s=r==="asc"?1:.45,c=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:s,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:l,opacity:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},cs=({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"})]}),Ot="var(--sa-background-primary, #ffffff)",dl="var(--sa-background-primary-inverse, #f8f8f8)",hl=({columns:r,records:t,handleDetail:o,handleUpdate:n,handleDelete:l,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:i,visibleHandleDetail:a,showHeadBorder:h=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:C,actionsOrder:E=["detail","update","delete","custom"],customEmptyState:w,enableColumnResize:L=!1,defaultColumnWidths:F,onColumnWidthsChange:I,defaultMinColumnWidth:S=60,sort:k,defaultSort:H,onSortChange:z,showActionDivider:B=!1})=>{const W=k!==void 0,[O,Y]=d.useState(H??null),X=W?k??null:O,q=P=>{if(P.sortKey)return P.sortKey;if(typeof P.accessor=="string")return P.accessor},Z=P=>{const R=q(P);if(!R)return;let J;!X||X.key!==R?J={key:R,direction:"asc"}:X.direction==="asc"?J={key:R,direction:"desc"}:J=null,W||Y(J),z==null||z(J)},te=[o,n,l].filter(P=>P!==void 0).length,_=!!C,V=!!o||!!n||!!l||_,N="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${N}`,ve=`inset 1px 0 0 ${N}`,Ee=`inset -1px 0 0 ${N}`,ue=te===3?_?"178px":"140px":te===2?_?"140px":"102px":te===1?_?"112px":"74px":_?"74px":"",Ce=(P,R)=>{if(!R)return P;if(typeof R=="function")return R(P);if(typeof R=="string")return P[R]},[xe,we]=d.useState(!1);d.useEffect(()=>{if(!(y!=null&&y.current))return;const P=y.current;we(P.scrollHeight>P.clientHeight)},[t,y]);const Ae=d.useRef(null),[Fe,Ne]=d.useState([]),[$,ge]=d.useState(()=>F??{}),We=d.useRef(null);d.useLayoutEffect(()=>{if(!b||!Ae.current){Ne([]);return}const P=Array.from(Ae.current.querySelectorAll("thead tr th")),R=[];let J=0;P.forEach((he,ce)=>{R[ce]=J,ce<b&&(J+=he.offsetWidth)}),Ne(R)},[b,r,t,$]);const Ze=P=>{p&&p(P<b?P:P+1)},de=(P,R)=>{const J=$[P];if(J!==void 0){const he=`${J}px`;return{width:he,minWidth:he,maxWidth:he}}return R?{width:R}:{}},Ge=P=>L&&(P.resizable??!0),lr=(P,R)=>{P.preventDefault(),P.stopPropagation();const J=P.currentTarget.closest("th");if(!J)return;const he=Math.round(J.getBoundingClientRect().width);We.current={colIndex:R,startX:P.clientX,startWidth:he};const ce=document.body.style.userSelect,Me=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ze=Qe=>{var Ue;const Le=We.current;if(!Le)return;const Je=((Ue=r[Le.colIndex])==null?void 0:Ue.minWidth)??S,Se=Math.max(Je,Le.startWidth+(Qe.clientX-Le.startX));ge(nr=>nr[Le.colIndex]===Se?nr:{...nr,[Le.colIndex]:Se})},er=()=>{document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",er),document.body.style.userSelect=ce,document.body.style.cursor=Me,We.current=null,I&&ge(Qe=>(I(Qe),Qe))};document.addEventListener("mousemove",ze),document.addEventListener("mouseup",er)};return e.jsx("div",{ref:Ae,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((P,R)=>{var gr,dr;const J=b>0&&R<b,he=Fe[R]??0,ce=Ge(P),ze=R===r.length-1&&V&&B,er=q(P),Qe=!!P.sortable&&!!er,Le=Qe&&(X==null?void 0:X.key)===er?X.direction:null,Je=P.title||((gr=P.accessor)==null?void 0:gr.toString())||"",Se=(dr=P.headerTooltip)!=null&&dr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ue=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),nr=Qe?e.jsxs("button",{type:"button",onClick:()=>Z(P),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="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:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left"},children:[Ue,Se,e.jsx(ss,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ue,Se]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:J?he:void 0,zIndex:J?4:2,paddingLeft:R===0?"12px":"",borderRight:h&&!ze&&!J?se:void 0,borderBottom:h?se:void 0,boxShadow:h&&J?Ee:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left",...de(R,P.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[P.headerTooltip?e.jsx(me.Tooltip,{label:P.headerTooltip.content,position:"bottom",children:nr}):nr,P.filter&&e.jsx(al,{filter:P.filter,columnTitle:P.title}),p&&e.jsx("button",{onClick:()=>Ze(R),title:J?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:J?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:J?1:.45,transition:"opacity 0.15s"},children:e.jsx(cs,{frozen:J})})]}),ce&&e.jsx("div",{onMouseDown:hr=>lr(hr,R),onClick:hr=>hr.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-${R}`)}),V?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:h?se:void 0,boxShadow:h&&B?ve:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(f.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&w?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:w})}):t==null?void 0:t.map((P,R)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:R===t.length-1&&xe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:J=>{const he=J.currentTarget;he.style.backgroundColor=dl,Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=dl)})},onMouseLeave:J=>{const he=J.currentTarget;he.style.backgroundColor="",Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=Ot)})},children:[r.map((J,he)=>{const ce=J.render?J.render(P,R,t):Ce(P,J.accessor),Me=b>0&&he<b,ze=Fe[he]??0,er=$[he]!==void 0,Qe=Me&&he===b-1;return e.jsx(U.Td,{style:{position:Me?"sticky":void 0,left:Me?ze:void 0,zIndex:Me?1:void 0,backgroundColor:Me?Ot:void 0,transition:Me?"background-color 0.3s ease":void 0,paddingLeft:he===0?"12px":"",whiteSpace:"nowrap",overflow:er?"hidden":void 0,borderLeft:J.showBorderLeft?se:void 0,borderRight:J.showBorderRight?se:void 0,boxShadow:Qe?Ee:void 0,textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left",...de(he,J.width)},children:typeof ce=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left"},children:ce}):ce},`row-${R}-col-${he}`)}),V?e.jsx(U.Td,{style:{width:ue,position:"sticky",right:0,zIndex:1,backgroundColor:Ot,boxShadow:B?ve:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ie.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:E.map(J=>{const he=R===t.length-1?"top":"bottom";return J==="detail"&&o&&(a==null?void 0:a(P))!==!1?e.jsx(me.Tooltip,{label:"Detail",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(P.id,P),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):J==="update"&&n&&(i==null?void 0:i(P))!==!1?e.jsx(me.Tooltip,{label:"Update",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(P),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):J==="delete"&&l&&(c==null?void 0:c(P))!==!1?e.jsx(me.Tooltip,{label:"Delete",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(P.id,P),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):J==="custom"?e.jsx(d.Fragment,{children:C==null?void 0:C(P)},"custom"):null})})}):null]},`${P}${R}`))})]})})};let fl=!1;const is=({wrapperProps:r,dataTableProps:t,headerProps:o,footerProps:n})=>{var b;process.env.NODE_ENV!=="production"&&!fl&&(fl=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const l=d.useRef(null),[s,c]=d.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(o==null?void 0:o.show)??!0,a=d.useRef(null),h=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof h=="number"&&(a.current=h);const y=(n==null?void 0:n.showFooter)??(h===void 0?a.current!==0:h!==0);return e.jsxs(sl,{...r,children:[i&&e.jsx(cl,{...o}),e.jsx(f.Box,{direction:"column",ref:l,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(hl,{...t,scrollParentRef:l,frozenCount:t!=null&&t.enableFreezeColumns?s:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?c: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 as(r){return d.memo(r)}const ds=as(is),ul=200,At="1px solid var(--sa-border-subtle, #0b120e24)",hs=({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"}),Jr=({icon:r,label:t,active:o,danger:n,onClick:l})=>{const s=n?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:l,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:o?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:s,textAlign:"left"},onMouseEnter:c=>{o||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=o?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(D.Text,{as:"span",style:{color:s},children:t})]})},gl=({active:r,canSort:t,canHide:o,sortDir:n,frozen:l,onSort:s,onClearSort:c,onToggleFreeze:i,onHide:a})=>{const[h,y]=d.useState(!1),b=d.useRef(null),p=d.useRef(null),[C,E]=d.useState({top:0,left:0});d.useEffect(()=>{if(h&&b.current){const L=b.current.getBoundingClientRect(),F=L.left+ul>window.innerWidth;E({top:L.bottom+6,...F?{right:window.innerWidth-L.right}:{left:L.left}})}},[h]),d.useEffect(()=>{if(!h)return;const L=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[h]);const w=L=>{L(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||h?"true":"false",onClick:L=>{L.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:At,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(hs,{sortDir:n,frozen:l})}),h&&e.jsxs(f.Box,{ref:p,onClick:L=>L.stopPropagation(),style:{position:"fixed",top:`${C.top}px`,...C.left!==void 0?{left:`${C.left}px`}:{right:`${C.right}px`},minWidth:ul,backgroundColor:"var(--sa-background-primary, #ffffff)",border:At,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Jr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>w(()=>n==="asc"?c():s("asc"))}),e.jsx(Jr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>w(()=>n==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:At,margin:"4px 0"}})]}),e.jsx(Jr,{icon:"Pin1",label:l?"Unfreeze":"Freeze",active:l,onClick:()=>w(i)}),o&&e.jsx(Jr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>w(a)})]})]})},Ir="1px solid var(--sa-border-subtle, #0b120e24)",fs="var(--sa-text-subtle, #8c8f97)",Dr="var(--sa-background-neutral, #f0f1f2)",yl="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Tr=40,Wt="var(--sa-background-brand-subtlest)",Yr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},pl="sa-table-layout-styles",us=()=>{if(typeof document>"u"||document.getElementById(pl))return;const r=document.createElement("style");r.id=pl,r.textContent=`
|
|
1
|
+
(function(u,yr){typeof exports=="object"&&typeof module<"u"?yr(exports,require("@starasia/alert"),require("@starasia/avatar"),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-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/avatar","@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-dom","react-easy-crop"],yr):(u=typeof globalThis<"u"?globalThis:u||self,yr(u["@starasia/admin"]={},u.alert,u.avatar,u.badges,u.box,u.breadcrumb,u.button,u.card,u.date,u.dialog,u.drawer,u.dropdown,u.hooks,u.http,u.input,u.menu,u.pagination,u.storage,u.table,u.tabs,u.textarea,u.theme,u.toast,u.toggle,u.tooltip,u.checkbox,u.radio,u.text,u.icon,u.flex,u.grid,u.progress,u.stepper,u.accordion,u.storyRecord,u.skeleton,u.progressStepper,u.jsxRuntime,u.React,u.ReactDOM,u.ReactEasyCrop))})(this,function(u,yr,Hr,sr,f,pr,j,it,fr,Ve,Pr,br,De,vr,ar,A,kr,Er,U,Kt,at,Cr,Rt,xr,me,tr,dt,D,M,ie,eo,ro,to,oo,lo,$e,no,e,d,Vr,_l){"use strict";const ql={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},ht=d.createContext(ql),ft=()=>d.useContext(ht),so=r=>{const[t,o]=d.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:o}},co=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),io=({children:r})=>{const[t,o]=d.useState({}),n=d.useCallback(i=>{o(a=>typeof i=="function"?i(a):i)},[]),l=d.useCallback((i,a)=>{o(h=>{const y=typeof a=="function"?a(h[i]):a;return{...h,[i]:y}})},[]),s=d.useCallback(i=>{o(a=>{if(!(i in a))return a;const h={...a};return delete h[i],h})},[]),c=d.useMemo(()=>({badges:t,setBadge:l,setBadges:n,clearBadge:s}),[t,l,n,s]);return e.jsx(co.Provider,{value:c,children:r})},ao=()=>d.useContext(co),jr=(r,t)=>{const o=t!==void 0?t:r;return o==null?null:typeof o=="string"||typeof o=="number"?{value:o}:o},ut=240,gt=200,yt=480,Zl="sa-sidebar-width",pt=(r,t,o)=>Math.min(Math.max(r,t),o),Gl=(r,t,o,n)=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(r);if(!l)return t;const s=parseInt(l,10);return Number.isFinite(s)?pt(s,o,n):t}catch{return t}},ho=(r,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(r,String(t))}catch{}},fo=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:ut,setWidth:()=>{},resetWidth:()=>{},minWidth:gt,maxWidth:yt,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),uo=({children:r,defaultCollapsed:t=!1,defaultWidth:o=ut,minWidth:n=gt,maxWidth:l=yt,widthStorageKey:s=Zl})=>{const[c,i]=d.useState(t),[a,h]=d.useState(!1),[y,b]=d.useState(()=>Gl(s,o,n,l)),p=d.useCallback(B=>{i(W=>typeof B=="function"?B(W):B)},[]),C=d.useCallback(()=>i(B=>!B),[]),E=d.useCallback(()=>i(!0),[]),w=d.useCallback(()=>i(!1),[]),L=d.useCallback(B=>{b(W=>{const O=typeof B=="function"?B(W):B,Y=pt(Math.round(O),n,l);return ho(s,Y),Y})},[n,l,s]),F=d.useCallback(()=>{const B=pt(o,n,l);ho(s,B),b(B)},[o,n,l,s]),I=d.useCallback(B=>{h(W=>typeof B=="function"?B(W):B)},[]),S=d.useCallback(()=>h(!0),[]),k=d.useCallback(()=>h(!1),[]),H=d.useCallback(()=>h(B=>!B),[]),z=d.useMemo(()=>({collapsed:c,setCollapsed:p,toggle:C,collapse:E,expand:w,width:y,setWidth:L,resetWidth:F,minWidth:n,maxWidth:l,mobileOpen:a,setMobileOpen:I,openMobile:S,closeMobile:k,toggleMobile:H}),[c,p,C,E,w,y,L,F,n,l,a,I,S,k,H]);return e.jsx(fo.Provider,{value:z,children:r})},go=()=>d.useContext(fo),yo=d.createContext(null),po=({adapter:r,children:t})=>e.jsx(yo.Provider,{value:r,children:t}),or=()=>{const r=d.useContext(yo);if(!r)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return r},bo=({router:r,routerAdapter:t,menus:o=[],menuBottom:n,logo:l,appName:s="Workspace",initialUserData:c,theme:i})=>{const a=so({initialUserData:c}),{theme:h}=Cr.useTheme();return e.jsx(po,{adapter:t,children:e.jsx(ht.Provider,{value:{logo:l,appName:s,menus:o,userData:a.userData,setUserData:a.setUserData,menuBottom:n},children:e.jsx(io,{children:e.jsx(uo,{children:i?e.jsx(Cr.ThemeProvider,{value:i,children:r}):h?e.jsx(Cr.ThemeProvider,{value:h,children:r}):r})})})})},Ql=d.memo(bo);function vo({collapsed:r=!1,children:t}){if(!t)return null;const o=typeof t=="function",n=o?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:o?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const bt=d.createContext(null);function Co({children:r}){const[t,o]=d.useState(null),[n,l]=d.useState(null),[s,c]=d.useState(null),[i,a]=d.useState(0),h=d.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx(bt.Provider,{value:{prependNode:t,appendNode:n,replaceNode:s,setPrependNode:o,setAppendNode:l,setReplaceNode:c,replaceCount:i,registerReplace:h},children:r})}function xo({children:r}){const t=d.useContext(bt);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 Ul({children:r,mode:t="append"}){const o=d.useContext(bt);if(d.useEffect(()=>{if(!(t!=="replace"||!o))return o.registerReplace()},[t,o]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?o.prependNode:t==="replace"?o.replaceNode:o.appendNode;return n?Vr.createPortal(r,n):null}const vt=d.createContext(null);function wo({children:r}){const[t,o]=d.useState({}),[n,l]=d.useState({}),s=d.useCallback((a,h)=>{o(y=>y[a]===h?y:{...y,[a]:h})},[]),c=d.useCallback(a=>(l(h=>({...h,[a]:(h[a]??0)+1})),()=>l(h=>({...h,[a]:Math.max(0,(h[a]??0)-1)}))),[]),i=d.useMemo(()=>({outletNodes:t,setOutletNode:s,slotCounts:n,registerSlot:c}),[t,s,n,c]);return e.jsx(vt.Provider,{value:i,children:r})}function Do({slotKey:r,fallback:t}){const o=d.useContext(vt),n=o?(o.slotCounts[r]??0)>0:!1,l=d.useRef(o==null?void 0:o.setOutletNode);l.current=o==null?void 0:o.setOutletNode;const s=d.useCallback(c=>{var i;return(i=l.current)==null?void 0:i.call(l,r,c)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:s,style:{display:"contents"}}):t})}function Jl({slotKey:r,children:t}){const o=d.useContext(vt),n=d.useRef(o==null?void 0:o.registerSlot);if(n.current=o==null?void 0:o.registerSlot,d.useEffect(()=>{var s;return(s=n.current)==null?void 0:s.call(n,r)},[r]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const l=o.outletNodes[r];return l?Vr.createPortal(t,l):null}const Nr="moduleSwitcherGroupId",Ct="sa-module-switcher-change";function So(){if(typeof window>"u")return null;const r=window.localStorage.getItem(Nr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function Bo(r){typeof window>"u"||(r===null?window.localStorage.removeItem(Nr):window.localStorage.setItem(Nr,String(r)),window.dispatchEvent(new CustomEvent(Ct,{detail:r})))}function Yl(){Bo(null)}function xt(){const[r,t]=d.useState(()=>So());return d.useEffect(()=>{const n=()=>{t(So())},l=s=>{s.key===Nr&&n()};return window.addEventListener(Ct,n),window.addEventListener("storage",l),()=>{window.removeEventListener(Ct,n),window.removeEventListener("storage",l)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{Bo(n),t(n)}}}let _r=0,ur=!1,ko=new Set;function Xl(r){const[t,o]=d.useState(!1),n=d.useRef(null),l=d.useRef(null);return d.useLayoutEffect(()=>{const s=n.current;if(!s)return;let c=0;const i=()=>{c=0;const h=l.current;if(!h)return;const y=h.scrollWidth>s.clientWidth;o(b=>b===y?b:y)},a=new ResizeObserver(()=>{c||(c=requestAnimationFrame(i))});return a.observe(s),i(),()=>{c&&cancelAnimationFrame(c),a.disconnect()}},[r]),{containerRef:n,textRef:l,truncated:t}}function Eo({text:r,textStyle:t}){const{containerRef:o,textRef:n,truncated:l}=Xl(r),s=e.jsx(D.Text,{ref:n,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...t},children:r});return e.jsx(f.Box,{ref:o,display:"block",style:{flex:1,minWidth:0},children:l?e.jsx(me.Tooltip,{fluid:!0,label:r,position:"top",children:s}):s})}const $l=200,wt="var(--app-header-height, 4rem)",mo="44px",Dt=`calc((${wt} - 2rem) / 2)`,Fo=16;function Kl({children:r,headerLeftSlot:t,profile:o,isLoadingProfile:n,onLogout:l,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:i,headerActions:a,profileRole:h,profileMenuButtons:y,profileMenuItems:b,logoutButton:p,resizableSidebar:C=!0}){var hr,Sr;const{useSearchParams:E,useNavigate:w,useLocation:L,Outlet:F}=or(),[I]=E(),S=I.get("embed")==="true",k=ft(),{badges:H}=ao(),z=w(),B=L(),O=!De.useMediaQuery("md"),[Y,X]=d.useState(!1),{collapsed:q,setCollapsed:Z,width:K,setWidth:te,resetWidth:_,minWidth:V,maxWidth:N,mobileOpen:se,setMobileOpen:ve}=go(),[Ee,ue]=d.useState(!1),[Ce,xe]=d.useState(()=>new Set(ko)),[we,Ae]=d.useState(null),{selectedGroupId:Fe,setSelectedGroupId:Ne}=xt(),$=q&&!O;d.useEffect(()=>{ko=Ce},[Ce]);const ge=d.useRef(null),We=d.useRef(null),Ze=d.useRef(null),[de,Ge]=d.useState(!1),[lr,P]=d.useState(null),R=C&&!O&&!q,J=m=>Math.min(Math.max(m,V),N),he=lr??K,ce=m=>{var ke,Ie,_e;if(!R)return;m.preventDefault();const G=m.clientX,re=((ke=Ze.current)==null?void 0:ke.getBoundingClientRect().width)??K;(_e=(Ie=m.currentTarget).setPointerCapture)==null||_e.call(Ie,m.pointerId),Ge(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let Be=0,Oe=re;const Ye=Ar=>{Oe=re+(Ar.clientX-G),Be||(Be=requestAnimationFrame(()=>{Be=0,P(J(Oe))}))},He=()=>{Be&&cancelAnimationFrame(Be),window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",He),document.body.style.userSelect="",document.body.style.cursor="",P(null),Ge(!1),Oe<$l?Z(!0):te(J(Oe))};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",He)},Me=m=>{R&&(m.key==="ArrowLeft"?(m.preventDefault(),te(G=>G-Fo)):m.key==="ArrowRight"?(m.preventDefault(),te(G=>G+Fo)):m.key==="Home"?(m.preventDefault(),te(V)):m.key==="End"&&(m.preventDefault(),te(N)))};d.useEffect(()=>{const m=ge.current;if(!m)return;const G=()=>{ur||(_r=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const ze=()=>{const m=ge.current;m&&_r>0&&(ur=!0,m.scrollTop=_r,requestAnimationFrame(()=>{ur=!1}))};d.useLayoutEffect(()=>{ur=!0,ze();const m=setTimeout(()=>{ur=!1},300);return()=>clearTimeout(m)},[]),d.useLayoutEffect(()=>{k.menus.length>0&&(_r>0?ze():requestAnimationFrame(()=>{var G;const m=(G=ge.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[k.menus]),d.useEffect(()=>{ur=!0,ze();const m=setTimeout(ze,0),G=setTimeout(ze,50),re=setTimeout(ze,100),Be=setTimeout(ze,200),Oe=setTimeout(()=>{ur=!1},300),Ye=setTimeout(()=>{const He=ge.current,ke=He==null?void 0:He.querySelector("[data-menu-active='true']");if(He&&ke){const Ie=He.getBoundingClientRect(),_e=ke.getBoundingClientRect();_e.top>=Ie.top&&_e.bottom<=Ie.bottom||ke.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout(re),clearTimeout(Be),clearTimeout(Oe),clearTimeout(Ye)}},[B.pathname]),d.useEffect(()=>{We.current&&(We.current.scrollTop=0)},[B.pathname]),d.useEffect(()=>{O&&ve(!1)},[B.pathname,O]),d.useEffect(()=>{O&&Z(!0)},[O]),d.useEffect(()=>{const m=document.documentElement;return m.style.setProperty("--app-header-height",mo),()=>{m.style.removeProperty("--app-header-height")}},[]);const er=()=>{X(!0)},Qe=()=>{X(!1)},Le=()=>{X(!1),l()},Je=m=>{const G=[m.to];return m.children&&G.push(...m.children.map(re=>re.to)),G},Se=[...k.menus.flatMap(m=>m.items.flatMap(Je)),...((hr=k.menuBottom)==null?void 0:hr.flatMap(Je))??[]],Ue=m=>{if(!B.pathname.startsWith(m))return!1;const G=Se.filter(re=>B.pathname.startsWith(re)).sort((re,Be)=>Be.length-re.length)[0];return m===G};d.useEffect(()=>{var G;const m=re=>{var Be;(Be=re.children)!=null&&Be.some(Oe=>B.pathname.startsWith(Oe.to))&&xe(Oe=>{const Ye=new Set(Oe);return Ye.add(re.id),Ye})};k.menus.forEach(re=>{re.items.forEach(m)}),(G=k.menuBottom)==null||G.forEach(m)},[B.pathname,k.menus,k.menuBottom]);const nr=m=>{xe(G=>{const re=new Set(G);return re.has(m)?re.delete(m):re.add(m),re})};d.useEffect(()=>{k.menus.length!==0&&Fe!==null&&!k.menus.some(m=>m.id===Fe)&&Ne(null)},[k.menus,Fe,Ne]);const gr=d.useMemo(()=>{if(Fe!==null)return k.menus.filter(re=>re.id===Fe||re.parentGroupId===Fe);const m=k.menus.filter(re=>re.parentGroupId===void 0),G=k.menus.filter(re=>re.parentGroupId!==void 0).flatMap(re=>re.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[k.menus,Fe]);if(S)return e.jsx(f.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:r||e.jsx(F,{})});const dr=m=>{const G=m.children&&m.children.length>0,re=Ce.has(m.id),Be=G?m.children.some(He=>Ue(He.to)):Ue(m.to),Oe=jr(m.badge,H[m.id]),Ye=!!Oe&&q&&!O;return e.jsxs(f.Box,{display:"block","data-menu-active":Be||void 0,children:[e.jsxs(f.Box,{as:"button",onClick:He=>{if(G)if(q&&!O){const ke=He.currentTarget.getBoundingClientRect();Ae({item:m,top:ke.top,left:ke.right+8})}else nr(m.id);else z(m.to)},fullWidth:!0,direction:"row",align:"center",justify:q&&!O?"center":void 0,gap:"sm",paddingInline:q&&!O?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Be?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:Be?"white":void 0,hover:Be?void 0:{bg:"neutral"},title:q&&!O?m.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",borderColor:Be?"var(--sa-border-subtle, #0b120e24)":"transparent"},children:[e.jsxs(f.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),Ye&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(sr.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!q||O)&&e.jsxs(e.Fragment,{children:[e.jsx(Eo,{text:m.title,textStyle:{transition:"opacity 0.3s"}}),Oe&&e.jsx(sr.Badge,{text:String(Oe.value),variant:Oe.variant??"info",size:"xs",border:!0}),G&&e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:re?"rotate(180deg)":"rotate(0deg)"}})]})]}),G&&(!q||O)&&(()=>{const He=m.children.findIndex(ke=>Ue(ke.to));return e.jsxs(f.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:re?`${m.children.length*36}px`:"0px",opacity:re?1:0,marginTop:re?"0.25rem":"0px"},children:[e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),He>=0&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${He*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),m.children.map(ke=>{const Ie=jr(ke.badge,H[ke.id]),_e=Ue(ke.to);return e.jsxs(f.Box,{as:"button",onClick:()=>z(ke.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:_e?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:_e?"white":void 0,hover:_e?void 0:{bg:"neutral"},style:{textAlign:"left",color:_e?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",borderColor:_e?"var(--sa-border-subtle, #0b120e24)":"transparent"},children:[e.jsx(M.Icon,{name:ke.icon,size:"sm",style:{flexShrink:0}}),e.jsx(Eo,{text:ke.title}),Ie&&e.jsx(sr.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0})]},ke.id)})]})})()]},m.id)};return e.jsx(wo,{children:e.jsxs(Co,{children:[e.jsxs(f.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":mo,"--app-sidebar-width":O?"0px":q?wt:`${he}px`,"--app-footer-zindex":O&&se?"40":"998"},children:[O&&e.jsx(f.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ve(!1)}),e.jsxs(f.Box,{as:"aside",ref:Ze,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:O?void 0:"0",style:{width:O?"16.375rem":q?wt:`${he}px`,position:O?"fixed":"relative",...O&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:de?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(f.Box,{onMouseEnter:()=>ue(!0),onMouseLeave:()=>ue(!1),direction:"row",align:"center",justify:"space-between",paddingInline:$?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...$?{paddingInline:Dt}:null},children:(()=>{const m=!O&&q&&!se,G=m&&Ee;return e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flex:m?"1":void 0,justify:m?"center":void 0,style:{transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:k.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!q||se)&&e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:k.appName})]}),!O&&!q&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),m&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"Cross",size:"md"})})]})})()}),i&&e.jsx(vo,{collapsed:O?!1:q,children:i}),e.jsx(f.Box,{ref:ge,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:gr.map(m=>e.jsxs(f.Box,{marginBottom:"lg",children:[!q||O?m.name&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"subtlest",textTransform:"uppercase",truncate:!0,style:{letterSpacing:"0.06em",paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:m.name}):m.name&&e.jsx(f.Box,{"aria-label":m.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(f.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(f.Box,{paddingInline:$?void 0:"md",gap:"xs",style:$?{paddingInline:Dt}:void 0,children:m.slotKey?e.jsx(Do,{slotKey:m.slotKey,fallback:m.items.map(G=>dr(G))}):m.items.map(G=>dr(G))})]},m.id))}),k.menuBottom&&k.menuBottom.length>0&&e.jsx(f.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:$?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:$?{paddingInline:Dt}:void 0,children:k.menuBottom.map(m=>dr(m))}),R&&e.jsx(f.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":K,"aria-valuemin":V,"aria-valuemax":N,tabIndex:0,onPointerDown:ce,onKeyDown:Me,onDoubleClick:_,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:de?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:m=>{de||(m.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:m=>{de||(m.currentTarget.style.background="transparent")}})]}),e.jsxs(f.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(f.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:O?"lg":void 0,children:[O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(xo,{children:t})]}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(f.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:n?"Loading...":(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:n?"":(o==null?void 0:o.email)||"unknown"})]}),e.jsx(Hr.Avatar,{size:"sm",initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(M.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(A.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs(f.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(Hr.Avatar,{customSize:64,initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(D.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.email)||"unknown"}),h&&e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:h})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuItem,{onClick:m.onClick,startIcon:e.jsx(M.Icon,{name:m.icon,size:"md"}),children:m.label},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuItem,{intent:"danger",onClick:er,startIcon:e.jsx(M.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(f.Box,{as:"main",ref:We,flex:"1",overflow:"overflow-y-auto",children:r||e.jsx(F,{})})]})]}),s&&c&&e.jsx(f.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:c}),e.jsxs(Ve.Dialog,{isShow:Y,onHide:Qe,children:[e.jsx(Ve.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Ve.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Ve.DialogFooter,{children:e.jsx(f.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ie.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Qe,children:"Cancel"})}),e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:Le,children:"Yes, Sure"})})]})})})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{onClick:()=>Ae(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(f.Box,{role:"dialog","aria-label":we.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:we.top,left:we.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:we.item.title}),(Sr=we.item.children)==null?void 0:Sr.map(m=>{const G=Ue(m.to),re=jr(m.badge,H[m.id]);return e.jsxs(f.Box,{as:"button",onClick:()=>{z(m.to),Ae(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:G?"primary-inverse":void 0,hover:G?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:m.title}),re&&e.jsx(sr.Badge,{text:String(re.value),variant:re.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const mr=d.forwardRef(({children:r,...t},o)=>e.jsx(f.Box,{ref:o,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Mo=({title:r,iconName:t,textColor:o,iconColor:n,hoverTextColor:l,hoverIconColor:s})=>{const[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=o??"var(--sa-text-subtle, #8c8f97)",y=s??"var(--sa-text-subtle, #8c8f97)",b=l??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:c?y:a,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:c?b:h,transition:"color 0.15s ease"},children:r||"Back"})]})},Rl=({items:r,separator:t="/",iconName:o,iconColor:n,hoverIconColor:l})=>{const{Link:s}=or(),[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=l??"var(--sa-text-subtle, #8c8f97)",y=r.length>1?r[0]:void 0,b=!!(y!=null&&y.to||y!=null&&y.onClick),p=e.jsx(M.Icon,{name:o||"ChevronLeft",size:"xs",onMouseEnter:b?()=>i(!0):void 0,onMouseLeave:b?()=>i(!1):void 0,style:{color:b&&c?h:a,transition:"color 0.15s ease",cursor:b?"pointer":void 0}}),C=y!=null&&y.to?e.jsx(s,{to:y.to,replace:!0,style:{textDecoration:"none"},children:p}):y!=null&&y.onClick?e.jsx(mr,{onClick:y.onClick,children:p}):p;return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",children:[C,e.jsx(pr.Breadcrumb,{separator:t,size:"md",children:r.map((E,w)=>{const L=w===r.length-1;return E.to&&!L?e.jsx(pr.BreadcrumbItem,{children:e.jsx(s,{to:E.to,children:E.label})},w):e.jsx(pr.BreadcrumbItem,{currentPage:L,children:e.jsx(pr.BreadcrumbLink,{onClick:L?void 0:E.onClick,children:E.label})},w)})})]})},en=r=>{const{Link:t}=or(),{items:o,separator:n,onClick:l,navigateTo:s,...c}=r;return o&&o.length>0?e.jsx(Rl,{items:o,separator:n,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):s?e.jsx(f.Box,{direction:"row",children:e.jsx(t,{to:s,replace:!0,style:{textDecoration:"none"},children:e.jsx(Mo,{...c})})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:l,children:e.jsx(Mo,{...c})})})},St=[{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 Io(r,t,o){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${o.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?o.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${o.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${o.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 To={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},Lo={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Oo({isShow:r,onHide:t,menus:o,selectedGroupId:n,onSelect:l}){const[s,c]=d.useState(void 0),i=h=>{l(h),t()},a=St[0];return e.jsx(Ve.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Ve.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:Lo,children:[e.jsx("div",{style:Io(n===null,s==="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:To,children:"Semua"})]}),o.map((h,y)=>{var w;const b=n===h.id,p=s===h.id,C=((w=h.items[0])==null?void 0:w.icon)??"Grid",E=St[(y+1)%St.length];return e.jsxs("button",{onClick:()=>i(h.id),onMouseEnter:()=>c(h.id),onMouseLeave:()=>c(void 0),style:Lo,children:[e.jsx("div",{style:Io(b,p,E),children:e.jsx("div",{style:{color:E.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:C,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:To,children:h.name})]},h.id)})]})})})}function rn({onSelect:r,"aria-label":t="Pilih module"}={}){const o=ft(),{useNavigate:n}=or(),l=n(),{selectedGroupId:s,setSelectedGroupId:c}=xt(),[i,a]=d.useState(!1),h=y=>{var b;if(c(y),y!==null){const p=o.menus.find(E=>E.id===y),C=(b=p==null?void 0:p.items[0])==null?void 0:b.to;C&&l(C)}r==null||r(y)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!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:y=>{y.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),s!==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(Oo,{isShow:i,onHide:()=>a(!1),menus:o.menus.filter(y=>y.parentGroupId===void 0),selectedGroupId:s,onSelect:h})]})}const tn=(r,t)=>{const o=[];if(t===0)return o.push(r),o;for(let n=0;n<r.length;n+=t){const l=r.slice(n,n+t);o.push(l)}return o},on=d.memo(({value:r,label:t,separator:o,labelWidth:n,lastIndex:l,labelAlign:s="top"})=>{const c=d.useMemo(()=>({padding:0,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),i=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),a=()=>typeof t=="string"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,h=()=>typeof r=="string"||typeof r=="number"?e.jsx(D.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof o=="string"||typeof o=="number"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:o}):o;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:n,children:a()}),o?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:c,children:h()})]})}),ln=d.memo(({fields:r,separator:t,labelWidth:o})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,l)=>e.jsx(on,{separator:t,labelWidth:o,lastIndex:l===r.length-1,...n},`field-group-field-${l}`))})),nn=d.memo(({maxRow:r=0,maxColumn:t=2,separator:o=":",fields:n=[],labelWidth:l=150,bordered:s=!1})=>{const c=d.useMemo(()=>tn(n,r),[n,r]),i=c.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(f.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((h,y)=>e.jsx(f.Box,{direction:"column",flex:i?void 0:"1",width:i?a():void 0,marginBottom:i?"lg":void 0,children:e.jsx(ln,{labelWidth:l,fields:h,separator:o})},y))})}),sn=({backButton:r})=>{const[t,o]=d.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",l=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?s:n,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:t?c:l,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},cn=({backButton:r,title:t,titleIcon:o,titleTag:n,children:l,header:s=!0,headerBorder:c=!1,disableAnimation:i=!1,scrollable:a=!1,stickyHeader:h=!1,subHeaders:y,action:b,titleTagProps:p,containerProps:C,headerProps:E})=>{const w=De.useMediaQuery("md"),{Link:L,useNavigate:F,useLocation:I}=or(),S=F(),k=I(),H=r==null?void 0:r.show,z=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}S(-1,{replace:!0})},B=()=>{if(!b)return null;if(d.isValidElement(b))return b;const Z=b.filter(K=>K&&(K.title||K.icon));return Z.length===0?null:w?e.jsx(f.Box,{direction:"row",gap:"md",children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>e.jsx(j.Button,{iconLeft:te?e.jsx(M.Icon,{name:te,size:"md"}):void 0,onClick:V,..._,children:K},`action-${N}`))}):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:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>{const se=(_==null?void 0:_.tone)==="error"||(_==null?void 0:_.danger)===!0;return e.jsx(A.MenuItem,{intent:se?"danger":void 0,disabled:_==null?void 0:_.disabled,startIcon:te?e.jsx(M.Icon,{name:te}):void 0,onClick:V,children:K},`action-${N}`)})})})]})},W=()=>{const Z=e.jsx(sn,{backButton:r});return r!=null&&r.navigateTo?e.jsx(f.Box,{direction:"row",children:e.jsx(L,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:Z})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:z,children:Z})})},O=()=>{const Z=!!t,K=Array.isArray(b)&&b.length>0,te=d.isValidElement(b)?!0:K;if(!Z&&!te&&!H)return null;const V=w||!w&&K;return e.jsxs(f.Box,{direction:"column",gap:"xs",paddingBlock:(E==null?void 0:E.paddingBlock)??"sm",paddingInline:(E==null?void 0:E.paddingInline)??"md",...E,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...E==null?void 0:E.style},children:[H&&W(),(Z||te)&&e.jsxs(f.Box,{direction:V?"row":"column",gap:"sm",justify:"space-between",align:V?"center":"flex-start",children:[Z?typeof t=="string"?e.jsxs(f.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[o&&e.jsx(M.Icon,{name:o,size:"md",color:"primary"}),e.jsx(D.Text,{variant:"h3",fontWeight:"semibold",children:t})]}),n&&e.jsx(sr.Badge,{border:!0,size:"lg",text:n,...p})]}):t:null,B()]})]})},Y=()=>{if(!y||y.length===0)return null;const Z=y.filter(_=>_.show!==!1);if(Z.length===0)return null;let K=0,te=-1/0;return Z.forEach((_,V)=>{const N=_.order??0;N>=te&&(te=N,K=V)}),Z.map(({content:_,order:V,borderBottom:N=!0,keepBottomPadding:se=!1,paddingInline:ve=!0,paddingBlock:Ee=!0},ue)=>e.jsx(f.Box,{direction:"column",paddingTop:Ee?"sm":"spacing-0",paddingBottom:Ee&&(N||se||ue===K)?"sm":"spacing-0",paddingInline:ve?"md":"spacing-0",style:{...N?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...V!==void 0?{order:V}:{}},children:_},`sub-header-${ue}`))},X=()=>{const Z=s?O():null,K=Y();return!Z&&!K?null:e.jsxs(f.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...h?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:K?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[Z,K]})},q=()=>l;return e.jsxs(f.Box,{direction:"column",as:"main",...C,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(C==null?void 0:C.style)??{},...i?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[X(),q()]},k.pathname)},an=d.memo(cn),dn={icon:"Cross",title:""},hn=320,Ao=16,Wo=4,fn=8,zo=d.forwardRef(({onHide:r,show:t,withBlur:o=!1,style:n,children:l,closeButton:s=dn,paddingHorizontal:c=!0,width:i,minWidth:a,maxWidth:h,hideBackdrop:y=!1,title:b,headerAction:p,header:C=!0,widthPresets:E,resizable:w=!0,resizeMin:L=hn,resizeMax:F,onWidthChange:I},S)=>{const H=!De.useMediaQuery("md"),z=i??h??a??"357px",B=E??[],W=B.length>1,[O,Y]=d.useState(()=>{const $=B.indexOf(z);return $>=0?$:0}),[X,q]=d.useState(null),[Z,K]=d.useState(!1),[te,_]=d.useState(!1),V=d.useRef(null),N=$=>{V.current=$,typeof S=="function"?S($):S&&(S.current=$)},se=W?B[O]:z,ve=X!=null?`${X}px`:se,Ee=w&&!H,ue=O===B.length-1,Ce=()=>{const $=(O+1)%B.length;q(null),Y($),I==null||I(B[$])},xe=d.useCallback($=>{const ge=F??window.innerWidth;return Math.min(Math.max($,L),ge)},[L,F]),we=d.useRef(null),Ae=$=>{if(!Ee)return;$.preventDefault();const ge=$.currentTarget;ge.setPointerCapture($.pointerId),K(!0);const We=document.body.style.cursor,Ze=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let de=null;const Ge=P=>{const R=xe(window.innerWidth-P.clientX);we.current=R,de==null&&(de=window.requestAnimationFrame(()=>{de=null,we.current!=null&&q(we.current)}))},lr=P=>{de!=null&&window.cancelAnimationFrame(de),we.current!=null&&q(we.current),ge.releasePointerCapture(P.pointerId),ge.removeEventListener("pointermove",Ge),ge.removeEventListener("pointerup",lr),ge.removeEventListener("pointercancel",lr),document.body.style.cursor=We,document.body.style.userSelect=Ze,K(!1),we.current!=null&&(I==null||I(`${we.current}px`))};ge.addEventListener("pointermove",Ge),ge.addEventListener("pointerup",lr),ge.addEventListener("pointercancel",lr)},Fe=$=>{var de;if(!Ee||$.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;$.preventDefault();const ge=$.key==="ArrowLeft"?Ao:-Ao,We=X??((de=V.current)==null?void 0:de.offsetWidth)??L,Ze=xe(We+ge);q(Ze),I==null||I(`${Ze}px`)},Ne=()=>{Ee&&(q(null),I==null||I(se))};return e.jsx(Pr.Drawer,{blur:o,isShow:t,position:"right",onHide:r,ref:N,size:ve,style:n,flush:!0,radius:"none",hideBackdrop:y,children:e.jsxs(f.Box,{direction:"column",height:"height-full",children:[Ee?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Ae,onKeyDown:Fe,onDoubleClick:Ne,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>_(!0),onPointerLeave:()=>_(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:fn,cursor:"col-resize",zIndex:1,background:Z||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Wo}px, transparent ${Wo}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,C?e.jsxs(f.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(f.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof b=="string"?e.jsx(D.Text,{fontSize:"md",fontWeight:"bold",children:b}):b}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[p,W?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:Ce,"aria-label":ue?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(M.Icon,{name:ue?"ChevronRight":"ChevronLeft"})}):null,s?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:r,"aria-label":s.title||"Tutup",iconRight:e.jsx(M.Icon,{name:s.icon}),children:s.title||void 0}):null]})]}):null,e.jsx(f.Box,{direction:"column",paddingBlock:"md",paddingInline:c?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:l})]})})}),Bt=d.memo(({children:r,borderBottom:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),kt=d.memo(({children:r,borderTop:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),un=d.memo(({children:r,...t})=>e.jsx(f.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),gn=d.memo(({children:r,title:t,titleTag:o,action:n,header:l,footer:s,actionContainer:c,containerProps:i,bodyProps:a,headerProps:h={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=De.useMediaQuery("lg"),C=()=>o?e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(D.Text,{fontWeight:"medium",children:t}),e.jsx(sr.Badges,{border:!0,text:o,variant:b})]}):e.jsx(D.Text,{fontWeight:"medium",children:t}),E=()=>l||e.jsxs(f.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(f.Box,{direction:"column",children:t?C():null}),e.jsx(f.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:n??null})]}),w=!!(l||t||n);return e.jsxs(f.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[l!==null&&w?e.jsx(Bt,{...h,children:E()}):null,e.jsx(un,{...a,children:r}),s?e.jsx(kt,{...y,children:s}):null]})}),Ke={H1:r=>e.jsx(D.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(D.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(D.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(D.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(D.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(D.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(D.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(D.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(D.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(D.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(D.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(D.Text,{variant:"body-3",children:r.children,...r.props})},je=()=>{const{useSearchParams:r,useParams:t,useLocation:o}=or(),[n,l]=r(),s=vr.searchParamsToObject(n.toString()),c=t(),i=o(),a=c.id;return{setSearchParams:l,searchParams:n,searchQueries:s,isHasQuery:(C,E)=>n.has(C)&&n.get(C)===E,getQueryParam:C=>n.get(C),getRouteParam:C=>c[C],params:c,location:i,id:a,hasId:!!a}},Ho=r=>JSON.stringify(r),Po=r=>JSON.stringify(r),Vo=r=>JSON.stringify(r),jo=r=>JSON.stringify(r),yn=r=>r,pn=r=>JSON.stringify(r),Fr=r=>{if(typeof r!="string"||r==="")return{};try{const t=JSON.parse(r);return!t||typeof t!="object"||Array.isArray(t)?{}:t}catch{return{}}},Mr=({value:r,name:t,type:o,withSearchParam:n=!0,setSearchParams:l,searchQueries:s,dropdownSearchKey:c,filterKey:i="filter",pageKey:a="page"})=>{if(n){let h;switch(o){case"search":h=yn(r);break;case"dropdown":case"dropdown-multiple":h=Ho(r);break;case"radio":h=Po(r);break;case"date-range":h=Vo(r);break;case"advanced-date-range":h=pn(r);break;case"date":h=jo(r);break;default:h=r;break}if(typeof h<"u"){const y={...Fr(s[i]),[t]:h},b={...s};c&&typeof c=="string"&&delete b[c],delete b[a];const p={...b,[i]:JSON.stringify(y)},C=new URLSearchParams(s).toString(),E=new URLSearchParams(p).toString();if(C===E)return;l(p)}}},qr=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c)[0].label:n==="value"&&c?JSON.parse(c)[0].value:c},No=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c).map(i=>i.label):n==="value"&&c?JSON.parse(c).map(i=>i.value):n==="array"&&c?JSON.parse(c):c},bn=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="id"&&c?JSON.parse(c).id:n==="label"&&c?JSON.parse(c).label:n==="value"&&c?JSON.parse(c).value:c},Zr=(r,t,o)=>{const n=t.get(o||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0;return l?l[r]:void 0},vn=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},_o=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return s?JSON.parse(s):void 0},Cn=(r,{filterKey:t="filter",perPageKey:o="perPage",pageKey:n="page"})=>{const l=r.get(t)||void 0,s=r.get(o)||void 0,c=r.get(n)||void 0;return!!l||!!s||!!c},qo=({isOpen:r,onClose:t,filterKey:o,pageKey:n,filters:l})=>{const{searchParams:s,setSearchParams:c,searchQueries:i}=je(),[a,h]=d.useState({}),y=()=>{s.delete(o||"filter"),c(s)},b=(p,C)=>{switch(p.type){case"radio":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"dropdown":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"date-range":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"date":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"dropdown-multiple":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}default:return null}};return e.jsx(zo,{onHide:t,show:r||!1,children:e.jsxs(f.Box,{direction:"column",gap:"md",children:[e.jsxs(ie.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(f.Box,{direction:"column",children:"Filter"}),e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),l==null?void 0:l.map((p,C)=>b(p,C))]})})},Zo=({searchKey:r="q",statusKey:t="status",searchPlaceholder:o="Search",searchHighlightPlaceholder:n,extendedFilter:l,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:i="filter",pageKey:a="page",customWidthSearch:h,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:C="right",titleSearchLabel:E="Work Order",withTitleLabels:w=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[I,S]=d.useState(!1),[k,H]=d.useState(0),z=()=>{H(N=>N+1)},{searchParams:B,setSearchParams:W,getQueryParam:O}=je(),Y=vr.searchParamsToObject(B.toString()),X=Zr(r,B,i)||"",[q,Z]=d.useState(X),K=O(i),_=!!(K&&!(()=>{if(K)try{const N=JSON.parse(K);return Object.keys(N).length===1&&N[r]===""}catch(N){console.error("Filter parameter is not a valid JSON:",N)}return!1})()),V=De.useMediaQuery("md");return d.useEffect(()=>{Z(X)},[X]),d.useEffect(()=>{if(q===X)return;const N=window.setTimeout(()=>{Mr({value:q,name:r,type:"search",searchQueries:Y,setSearchParams:W,filterKey:i,pageKey:a})},350);return()=>{window.clearTimeout(N)}},[q,X,r,Y,W,i,a]),e.jsxs(ie.Flex,{gap:"md",style:{flexDirection:V&&C==="left"?"row":V&&C==="right"?"row-reverse":"column"},align:"flex-end",children:[_&&e.jsx(f.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const N=new URLSearchParams(B);N.delete(i),W(N),Z(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(D.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),l==null?void 0:l.map(({minWidth:N,content:se,title:ve,onClickContainer:Ee},ue)=>e.jsxs(f.Box,{direction:"column",gap:"sm",onClick:Ee,style:{minWidth:N},children:[ve&&e.jsx(Ke.SubH3,{children:ve}),se]},`extended-filter-${ue}-${k}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:_,secondary:!_,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:K?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!V,onClick:()=>S(!0),children:F?"Filter":void 0}),c&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[w&&e.jsx(Ke.SubH3,{children:"Status"}),e.jsx(br.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:qr({get:"value",name:t,searchParams:B,filterKey:i})?[{label:qr({get:"value",name:t,searchParams:B,filterKey:i})==="active"?"Active":"InActive",value:qr({get:"value",name:t,searchParams:B,filterKey:i})}]:[],onChange:N=>Mr({value:N,name:t,type:"dropdown",searchQueries:Y,setSearchParams:W,filterKey:i}),placeholder:w?"All":"All Status"},k)]}),s&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{width:h&&V?h:V?"310px":""},children:[w&&e.jsxs(Ke.SubH3,{children:["Search for ",E]}),e.jsx(ar.Input,{placeholder:o,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:N=>Z(N.target.value),value:q,fullWidth:!0},k+1+i)]}),e.jsx(qo,{isOpen:I,onClose:()=>S(!1),filterKey:i,filters:b,pageKey:a})]})},xn=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function Et({configs:r,filterKey:t="filter",activeFilterKey:o="filters",pageKey:n="page",searchKey:l="q"}){const{searchParams:s,setSearchParams:c,searchQueries:i}=je(),a=d.useMemo(()=>Object.fromEntries(r.map(k=>[k.key,k])),[r]),h=d.useMemo(()=>{const k=(s.get(o)||"").split(",").map(z=>z.trim()).filter(Boolean),H=Object.keys(Fr(s.get(t))).filter(z=>z!==l);return r.map(z=>z.key).filter(z=>{const B=a[z];return(B==null?void 0:B.locked)||k.includes(z)||H.includes(z)})},[s,o,t,l,r,a]),y=d.useCallback(k=>Fr(k[t]),[t]),b=d.useCallback(k=>{const H={...i};k.length?H[o]=k.join(","):delete H[o],c(H)},[i,o,c]),p=d.useCallback(k=>{h.includes(k)||b([...h,k])},[h,b]),C=d.useCallback(k=>{var W;if((W=a[k])!=null&&W.locked)return;const H={...i},z=h.filter(O=>O!==k);z.length?H[o]=z.join(","):delete H[o];const B=y(H);k in B&&(delete B[k],Object.keys(B).length?H[t]=JSON.stringify(B):delete H[t]),delete H[n],c(H)},[i,h,o,t,n,y,c,a]),E=d.useCallback(k=>h.includes(k)?C(k):p(k),[h,p,C]),w=d.useCallback(k=>{switch(k.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return No({name:k.key,get:"array",searchParams:s,filterKey:t})||[];case"date":{const H=_o({name:k.key,searchParams:s,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const z=y(Object.fromEntries(s.entries()))[k.key];return z&&typeof z=="object"?z:void 0}default:return}},[s,t,y]),L=d.useCallback((k,H)=>{if(k.type==="date-compact"){const z={...i},B=y(z);H==null?delete B[k.key]:B[k.key]=H,Object.keys(B).length?z[t]=JSON.stringify(B):delete z[t],delete z[n],c(z);return}Mr({value:H,name:k.key,type:xn(k.type),searchQueries:i,setSearchParams:c,filterKey:t,pageKey:n})},[i,c,t,n,y]),F=d.useCallback(k=>{const H={...i},z=y(H);k in z&&(delete z[k],Object.keys(z).length?H[t]=JSON.stringify(z):delete H[t]),delete H[n],c(H)},[i,t,n,y,c]),I=d.useCallback(()=>{const k={...i};delete k[t],delete k[o],delete k[n],c(k)},[i,t,o,n,c]),S=h.length>0;return{activeKeys:h,configByKey:a,hasActiveFilter:S,addFilter:p,removeFilter:C,toggleFilter:E,getValue:w,setValue:L,clearValue:F,clearAll:I}}const mt={get(r){return Er.storage.get(r)??null},set(r,t){Er.storage.save(r,t)},remove(r){Er.storage.delete(r)}},wr={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}`},Gr=(r,t)=>{const o=new Set(t.map(s=>s.key)),n=r.order.filter(s=>o.has(s));for(const s of t)n.includes(s.key)||n.push(s.key);const l=r.hidden.filter(s=>o.has(s));return{order:n,hidden:l}};function wn({columns:r,scopeId:t,storage:o,onColumnsChange:n,value:l}){const s=d.useMemo(()=>({order:r.map(B=>B.key),hidden:[]}),[r]),c=t?wr.columns(t):void 0,i=(B,W)=>Gr({order:B.order??W,hidden:B.hidden??[]},r),[a,h]=d.useState(()=>{if(l&&(l.order||l.hidden))return i(l,r.map(B=>B.key));if(c){const B=o.get(c);if(B&&Array.isArray(B.order))return Gr(B,r)}return s}),y=r.map(B=>B.key).join("|");d.useEffect(()=>h(B=>Gr(B,r)),[y]);const b=d.useRef(a);b.current=a;const p=l?`${(l.order??[]).join("|")}~${(l.hidden??[]).join("|")}`:null,C=d.useRef(p);d.useEffect(()=>{if(p==null||C.current===p)return;C.current=p;const B=b.current,W=i(l,B.order);W.order.join("|")===B.order.join("|")&&W.hidden.join("|")===B.hidden.join("|")||(h(W),c&&o.set(c,W))},[p,y]);const E=d.useRef(!1);d.useEffect(()=>{E.current||(E.current=!0,n==null||n(a))},[]);const w=d.useCallback(B=>{h(B),c&&o.set(c,B),n==null||n(B)},[c,o,n]),L=d.useMemo(()=>{const B=new Map(r.map(W=>[W.key,W]));return a.order.filter(W=>B.has(W)).map(W=>({...B.get(W),visible:!a.hidden.includes(W)}))},[a,r]),F=d.useCallback(B=>{const W=a.hidden.includes(B)?a.hidden.filter(O=>O!==B):[...a.hidden,B];w({...a,hidden:W})},[a,w]),I=d.useCallback((B,W)=>{if(B===W)return;const O=[...a.order],[Y]=O.splice(B,1);O.splice(W,0,Y),w({...a,order:O})},[a,w]),S=d.useCallback(B=>{w({...a,hidden:B?r.filter(W=>!W.locked).map(W=>W.key):[]})},[a,r,w]),k=d.useCallback(()=>w(s),[w,s]),H=d.useCallback(B=>w(Gr(B,r)),[w,r]),z=a.hidden.length===0;return{state:a,orderedColumns:L,allVisible:z,toggleVisibility:F,reorder:I,setAllHidden:S,reset:k,applyState:H}}function Dn({scopeId:r,storage:t,snapshotKeys:o,pageKey:n="page",getColumns:l,applyColumns:s}){const{searchParams:c,setSearchParams:i}=je(),a=r?wr.savedViews(r):void 0,[h,y]=d.useState(()=>a?t.get(a)||[]:[]),b=d.useCallback(w=>{y(w),a&&t.set(a,w)},[a]),p=d.useCallback(w=>{const L=w.trim();if(!L)return;const F={};o.forEach(S=>{const k=c.get(S);k!=null&&(F[S]=k)});const I={id:`${Date.now()}`,name:L,query:F,columns:l==null?void 0:l(),createdAt:Date.now()};b([...h,I])},[o,c,l,b,h]),C=d.useCallback(w=>b(h.filter(L=>L.id!==w)),[b,h]),E=d.useCallback(w=>{const L=Object.fromEntries(c.entries());o.forEach(F=>delete L[F]),Object.assign(L,w.query),delete L[n],i(L),w.columns&&(s==null||s(w.columns))},[c,o,n,i,s]);return{enabled:!!a,views:h,saveView:p,deleteView:C,applyView:E}}function Sn(r,t){const o=Fr(r);return delete o[t],Object.keys(o).length>0?JSON.stringify(o):void 0}function Go(r,t,o){const n=r[t];if(n==null)return;const l=Sn(n,o);l===void 0?delete r[t]:r[t]=l}function Bn({scopeId:r,storage:t,snapshotKeys:o,enabled:n=!0,filterKey:l="filter",searchKey:s="q",persistSearch:c=!0}){const{searchParams:i}=je(),a=r&&n?wr.lastState(r):void 0,h=d.useRef(a),y=d.useRef(!1);d.useEffect(()=>{if(!a){h.current=a;return}if(h.current!==a){h.current=a,y.current=!1;return}const C={};if(o.forEach(E=>{const w=i.get(E);w!=null&&(C[E]=w)}),c||Go(C,l,s),Object.keys(C).length===0){y.current&&t.remove(a);return}y.current=!0,t.set(a,C)},[i,a,o,t,c,l,s]);const b=d.useCallback(()=>{if(!a)return null;const C=t.get(a);if(!C||typeof C!="object"||Array.isArray(C)||Object.keys(C).length===0)return null;const E=C[l];return E!=null&&Object.keys(Fr(E)).length===0&&delete C[l],c||Go(C,l,s),Object.keys(C).length>0?C:null},[a,t,c,l,s]),p=d.useCallback(()=>{a&&t.remove(a)},[a,t]);return{enabled:!!a,read:b,clear:p}}function kn({scopeId:r,storage:t,perPageKey:o,pageSizeOptions:n,enabled:l=!0}){const{searchParams:s}=je(),c=r&&l?wr.perPage(r):void 0,i=s.toString(),a=d.useRef(c);d.useEffect(()=>{if(!c){a.current=c;return}if(a.current!==c){a.current=c;return}const b=s.get(o);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(c,p)},[i,c,o,t]);const h=d.useCallback(()=>{if(!c)return null;const b=t.get(c);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[c,t,n]),y=d.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:h,clear:y}}let Ft={},Mt=!1,It=null;const En=(r,t)=>{Object.assign(Ft,r),It=t,!Mt&&(Mt=!0,queueMicrotask(()=>{const o=Ft,n=It;Ft={},Mt=!1,It=null,!(!n||Object.keys(o).length===0)&&n(l=>{const s=new URLSearchParams(l);return Object.entries(o).forEach(([c,i])=>s.set(c,i)),s},{replace:!0})}))};function mn({enabled:r,snapshotKeys:t,perPageKey:o,readSnapshot:n,readPerPage:l}){const{searchParams:s,setSearchParams:c,location:i}=je(),a=d.useRef(null);d.useEffect(()=>{if(!r||a.current===i.pathname)return;a.current=i.pathname;const h={};if(!s.has(o)){const y=l();y&&(h[o]=y)}if(!t.some(y=>s.has(y))){const y=n();y&&Object.assign(h,y)}Object.keys(h).length!==0&&En(h,c)},[i.pathname,r])}const Fn=({configs:r,activeKeys:t,onToggle:o,hasActiveFilter:n,onReset:l})=>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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&l&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:l,children:"Reset"})]}),children:r.map(s=>e.jsx(A.MenuItem,{selected:s.locked||t.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||o(s.key)},children:s.label},s.key))})})]}):null,Qr=({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"})]})})]}),Mn=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},Qo=(r,t,o)=>{const n=new Date(r);return o==="day"?n.setDate(n.getDate()+t):o==="week"?n.setDate(n.getDate()+t*7):o==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Uo=r=>{const t=Mn(new Date);if(r.direction==="this"){const n=new Date(t),l=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),l.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),l.setMonth(l.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),l.setMonth(11,31)),{from:n,to:l}}const o=r.count??1;return r.direction==="past"?{from:Qo(t,-o,r.period),to:t}:{from:t,to:Qo(t,o,r.period)}},Jo=24,Yo=r=>r.length>Jo?`${r.slice(0,Jo)}...`:r,Xo=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),Tt=(r,t="days")=>t==="months"?r.toLocaleDateString(void 0,{month:"short",year:"numeric"}):t==="years"?String(r.getFullYear()):Xo(r),Ur={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"},In=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],Lt={past:"Past",next:"Next",this:"This"},Tn=["day","week","month","year"],Ln=["past","next","this"],On=r=>r.field.type==="date-compact"?e.jsx(zn,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(An,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),An=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=t?Xo(new Date(t)):null,c=!!s,i=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Yo(s)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(M.Icon,{name:"Calendar",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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():o(a),withPadding:!1})})})]})},Wn=(r,t="days")=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Ur[r.op]} ${Tt(new Date(r.date),t)}`:null;case"is-between":return r.from&&r.to?`${Tt(new Date(r.from),t)} - ${Tt(new Date(r.to),t)}`:null;case"is-relative-to-today":{const o=r.relative;if(!o)return null;if(o.direction==="this")return`This ${o.period}`;const n=o.count??1,l=n===1?o.period:`${o.period}s`;return`${Lt[o.direction]} ${n} ${l}`}case"is-empty":case"is-not-empty":return Ur[r.op];default:return null}},zn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.ops&&r.ops.length>0?r.ops:In,c=r.defaultOp&&s.includes(r.defaultOp)?r.defaultOp:s[0],i=r.mode??"days",a=(t==null?void 0:t.op)??c,h=t?Wn(t,i):null,y=!!h,b=y?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Yo(h)})]}):r.label,p=C=>{if(C!==a){if(C==="is-empty"||C==="is-not-empty"){o({op:C});return}if(C==="is-relative-to-today"){o({op:C,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(C==="is-between"){o({op:C,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}o({op:C,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:y?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:y?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Hn,{op:a,ops:s,onChange:p})]}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsx(Pn,{value:t,op:a,mode:i,onChange:o})}),a==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},Hn=({op:r,ops:t,onChange:o})=>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:Ur[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:()=>o(n),endIcon:r===n?e.jsx(M.Icon,{name:"Check"}):void 0,children:Ur[n]},n))})})]}),Pn=({value:r,op:t,mode:o="days",onChange:n})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const l=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(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:o,value:l,onChange:s=>{if(s==null){n({op:t});return}if(typeof s=="object"&&s!==null&&"from"in s&&"to"in s){let{from:c,to:i}=s;if(!c&&i&&(c=i,i=null),!c&&!i){n({op:t});return}n({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},`range-${o}`)}return t==="is-relative-to-today"?e.jsx(Vn,{value:r==null?void 0:r.relative,onChange:l=>n({op:t,relative:l})}):e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:o,value:r!=null&&r.date?new Date(r.date):void 0,onChange:l=>{if(l==null){n({op:t});return}l instanceof Date&&n({op:t,date:l.toISOString()})},withPadding:!1},`single-${o}`)},Vn=({value:r,onChange:t})=>{const o=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,l=(r==null?void 0:r.period)??"week",s=o!=="this",c=Uo({direction:o,count:n,period:l});return e.jsxs(f.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(f.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:Lt[o]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Ln.map(i=>e.jsx(A.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:l}:{direction:i,count:n,period:l}),children:Lt[i]},i))})})]}),s&&e.jsx(ar.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const a=Number(i.target.value);t({direction:o,count:Number.isFinite(a)&&a>0?a:1,period:l})},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:l})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Tn.map(i=>e.jsx(A.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(o==="this"?{direction:o,period:i}:{direction:o,count:n,period:i}),children:i},i))})})]})]}),e.jsx(fr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},$o=18,jn=r=>r.length>$o?`${r.slice(0,$o)}...`:r,Nn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.type==="dropdown-multiple",c=t.length,i=r.searchable!==!1,[a,h]=d.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(I=>I.label.toLowerCase().includes(F)):y})(),C=F=>t.some(I=>I.value===F.value),E=F=>{if(!s){o([{label:F.label,value:F.value}]),h("");return}o(C(F)?t.filter(I=>I.value!==F.value):[...t,{label:F.label,value:F.value}])},w=F=>{var I;h(F),(I=r.onSearch)==null||I.call(r,F)},L=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?jn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:L})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:e.jsxs(f.Box,{direction:"column",gap:"sm",children:[i&&e.jsx(br.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:a,onSearch:w,value:t,onChange:o,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!s,selected:C(F),startIcon:F.avatar,endIcon:C(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>E(F),children:F.label},F.value))})]})})})]})},Ko=18,_n=r=>r.length>Ko?`${r.slice(0,Ko)}...`:r,Ro=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(tr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),qn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=new Set(t.map(p=>p.value)),c=t.length,i=r.options.length>0&&r.options.every(p=>s.has(p.value)),a=c>0&&!i,h=p=>{o(s.has(p.value)?t.filter(C=>C.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{o(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(D.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(D.Text,{as:"span",children:c===1?_n(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>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(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Qr,{onClear:n,onRemove:l})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(Ro,{checked:i||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s.has(p.value),onClick:()=>h(p),startIcon:e.jsx(Ro,{checked:s.has(p.value)}),children:p.label},p.value))]})})]})},el=({activeKeys:r,configByKey:t,getValue:o,setValue:n,clearValue:l,removeFilter:s})=>e.jsx(e.Fragment,{children:r.map(c=>{const i=t[c];if(!i)return null;const a=o(i),h=i.locked?void 0:()=>s(c);return i.type==="date"||i.type==="date-compact"?e.jsx(On,{field:i,value:a,onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):i.type==="checkbox-multiple"?e.jsx(qn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):e.jsx(Nn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c)})}),rl=r=>`${r} Rows`,Zn=({pagination:r,pageKey:t="page",perPageKey:o="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:l=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:i=!0})=>{var F;const{searchQueries:a,setSearchParams:h,searchParams:y}=je(),b=y.get(o),p=b?Number(b):l,C=I=>{h({...a,[t]:String(I)})},E=I=>{h({...a,[o]:I,[t]:"1"})},w=(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),L=(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:[s&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${w}-${L} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),c&&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:rl(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(I=>e.jsx(A.MenuItem,{selected:I===p,onClick:()=>E(String(I)),children:rl(I)},I))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(f.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(kr.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:C})})]})};function Gn(r,t,o=!0){d.useEffect(()=>{if(!o)return;const n=l=>{var i;if(l.metaKey||l.ctrlKey||l.altKey||l.key!==r||Ve.isOverlayOpen())return;const s=l.target,c=(i=s==null?void 0:s.tagName)==null?void 0:i.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(l.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,o])}const Qn=240,tl=({searchKey:r="q",filterKey:t="filter",pageKey:o="page",placeholder:n="Search",shortcut:l="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:i,searchQueries:a}=je(),h=Zr(r,c,t)||"",[y,b]=d.useState(!s||!!h),[p,C]=d.useState(s&&!h),[E,w]=d.useState(h),L=De.useDebounce(E,350),F=d.useRef(null);d.useEffect(()=>{w(h),h&&b(!0)},[h]),d.useEffect(()=>{y&&C(!1)},[y]),d.useEffect(()=>{L!==h&&Mr({value:L,name:r,type:"search",searchQueries:a,setSearchParams:i,filterKey:t,pageKey:o})},[L]);const I=d.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var z;return(z=F.current)==null?void 0:z.focus()})},[]);Gn(l,I);const S=()=>{s&&!E&&b(!1)},k=z=>{var B;s&&z.key==="Escape"&&!E&&(b(!1),(B=F.current)==null||B.blur())},H=()=>{y||C(!0)};return e.jsxs(f.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:I}),e.jsxs(f.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Qn:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(ar.Input,{ref:F,size:"sm",fullWidth:!0,value:E,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:z=>w(z.target.value),onKeyDown:k,onBlur:S,tabIndex:y?0:-1}),y&&!E&&e.jsx(f.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(D.Text,{fontSize:"xs",color:"subtle",children:l})})]})]})},ol=({columns:r,allVisible:t,onToggle:o,onReorder:n,onSetAllHidden:l})=>{const[s,c]=d.useState(null),[i,a]=d.useState(null),h=()=>{s!==null&&i!==null&&s!==i&&n(s,i),c(null),a(null)},y=(b,p)=>{const C=b+p;C<0||C>=r.length||n(b,C)};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(f.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>l(t),children:t?"Hide All":"Show All"})]}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const C=!b.locked,E=i===p&&s!==null&&s!==p;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:C,onDragStart:()=>C&&c(p),onDragOver:w=>{w.preventDefault(),a(p)},onDrop:h,onDragEnd:h,style:{minHeight:32,boxShadow:E?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(f.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:C?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!C||void 0,color:"icon-subtlest",onKeyDown:w=>{C&&(w.key==="ArrowUp"?(w.preventDefault(),y(p,-1)):w.key==="ArrowDown"&&(w.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:C?"grab":"default",opacity:C?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(f.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(xr.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>o(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},ll=({views:r,onApply:t,onDelete:o,onSave:n})=>{const[l,s]=d.useState(""),c=()=>{const i=l.trim();i&&(n(i),s(""))};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(f.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(f.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(D.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:a=>{a.stopPropagation(),o(i.id)}}),children:i.name},i.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(f.Box,{direction:"row",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(ar.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:l,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&c()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!l.trim(),onClick:c,children:"Save"})]})})]})]})},Un=({isOpen:r,onClose:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:i,getValue:a,setValue:h,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(Pr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(f.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(D.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(f.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(f.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(el,{activeKeys:n,configByKey:l,getValue:a,setValue:h,clearValue:y,removeFilter:b})})]}),o.length>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(f.Box,{direction:"column",children:o.map(C=>{const E=n.includes(C.key),w=!!C.locked;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:w?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[C.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(D.Text,{fontSize:"sm",color:"primary",truncate:!0,children:C.label})]}),e.jsx(xr.Toggle,{size:"sm",checked:E||w,disabled:w,onChange:()=>c(C.key),"aria-label":`Toggle ${C.label}`})]},C.key)})})]})]}),e.jsxs(f.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(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:i,children:"Reset"})}),e.jsx(f.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"})})]})]})})},Jn=r=>`${r} Rows`,Yn=({perPageKey:r,pageKey:t,pageSizeOptions:o,defaultPerPage:n=10,showPageSize:l})=>{const{searchQueries:s,setSearchParams:c,searchParams:i}=je(),a=i.get(r),h=a?Number(a):n,y=b=>{c({...s,[r]:b,[t]:"1"})};return l?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(f.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),o.map(b=>e.jsx(A.MenuItem,{selected:b===h,endIcon:b===h?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:Jn(b)},b))]})})]}):null},Xn=r=>{var We;const{withPadding:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,toggleFilter:c,removeFilter:i,getValue:a,setValue:h,clearValue:y,onReset:b,searchable:p,searchKey:C,filterKey:E,pageKey:w,searchPlaceholder:L,searchShortcut:F,searchCollapsible:I,pagination:S,perPageKey:k,pageSizeOptions:H,defaultPerPage:z,showPagination:B,showResultCount:W,showPageSize:O,hasColumns:Y,orderedColumns:X,allVisible:q,onToggleVisibility:Z,onReorder:K,onSetAllHidden:te,showSavedViews:_,savedViews:V,onApplyView:N,onDeleteView:se,onSaveView:ve,leadingActions:Ee}=r,[ue,Ce]=d.useState(!1),{searchQueries:xe,setSearchParams:we}=je(),Ae=(S==null?void 0:S.rangeStart)??(((S==null?void 0:S.currentPage)||0)>1?(((S==null?void 0:S.currentPage)||0)-1)*((S==null?void 0:S.perPage)||0)+1:1),Fe=(S==null?void 0:S.rangeEnd)??((S==null?void 0:S.totalCurrentPage)!==(S==null?void 0:S.perPage)?S==null?void 0:S.totalData:((S==null?void 0:S.currentPage)||1)*((S==null?void 0:S.totalCurrentPage)||0)),Ne=Ze=>{we({...xe,[w]:String(Ze)})},$=W||B&&!!(S!=null&&S.totalPage),ge=()=>{b(),Ce(!1)};return e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(tl,{searchKey:C,filterKey:E,pageKey:w,placeholder:L,shortcut:F,collapsible:I}),e.jsx(j.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Ce(!0),"aria-label":"Open filters",children:s?`Filter: ${n.length}`:null}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Ee,_&&e.jsx(ll,{views:V,onApply:N,onDelete:se,onSave:ve}),Y&&e.jsx(ol,{columns:X,allVisible:q,onToggle:Z,onReorder:K,onSetAllHidden:te}),e.jsx(Yn,{perPageKey:k,pageKey:w,pageSizeOptions:H,defaultPerPage:z,showPageSize:O})]})]}),$&&e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[W?e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ae}-${Fe} of ${((We=S==null?void 0:S.totalData)==null?void 0:We.toLocaleString())||0}`}):e.jsx(f.Box,{direction:"column"}),B&&!!(S!=null&&S.totalPage)&&e.jsx(kr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:S!=null&&S.currentPage?Number(S.currentPage):1,totalPages:Number(S.totalPage),onPageChange:Ne})]}),e.jsx(Un,{isOpen:ue,onClose:()=>Ce(!1),configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:ge,getValue:a,setValue:h,clearValue:y,removeFilter:i})]})},$n=({withPadding:r=!1,filterConfigs:t=[],filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:i,showPagination:a=!0,showResultCount:h=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:C="Search",searchShortcut:E="/",searchPosition:w="right",searchCollapsible:L=!0,pagination:F,columns:I=[],onColumnsChange:S,columnsState:k,scopeId:H,savedViews:z,persistLastState:B=!0,persistSearch:W=!0,storage:O=mt,onReset:Y,leadingActions:X})=>{const q=H??(z==null?void 0:z.scopeId),{activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,clearAll:Ee}=Et({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:p}),ue=wn({columns:I,scopeId:q,storage:O,onColumnsChange:S,value:k}),Ce=Dn({scopeId:q,storage:O,snapshotKeys:[n,o,s],pageKey:l,getColumns:()=>ue.state,applyColumns:ue.applyState}),xe=Bn({scopeId:q,storage:O,snapshotKeys:[n,o,l],enabled:B,filterKey:o,searchKey:p,persistSearch:W}),we=kn({scopeId:q,storage:O,perPageKey:s,pageSizeOptions:c,enabled:B});mn({enabled:B&&!!q,snapshotKeys:[n,o,l],perPageKey:s,readSnapshot:xe.read,readPerPage:we.read});const Ae=i??c[0]??25,Fe=!!(z!=null&&z.enabled)&&Ce.enabled,Ne=()=>{Ee(),xe.clear(),Y==null||Y()},$=De.useMediaQuery("md"),ge=b?e.jsx(tl,{searchKey:p,filterKey:o,pageKey:l,placeholder:C,shortcut:E,collapsible:L}):null;return $?e.jsxs(f.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(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Fn,{configs:t,activeKeys:Z,onToggle:_,hasActiveFilter:te,onReset:Ne}),w==="left"&&ge,e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(el,{activeKeys:Z,configByKey:K,getValue:N,setValue:se,clearValue:ve,removeFilter:V}),te&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:Ne,children:"Reset"})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[X,e.jsx(Zn,{pagination:F,pageKey:l,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y}),w==="right"&&ge,Fe&&e.jsx(ll,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),I.length>0&&e.jsx(ol,{columns:ue.orderedColumns,allVisible:ue.allVisible,onToggle:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden})]})]}):e.jsx(Xn,{withPadding:r,configs:t,activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,onReset:Ne,searchable:b,searchKey:p,filterKey:o,pageKey:l,searchPlaceholder:C,searchShortcut:E,searchCollapsible:L,pagination:F,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y,hasColumns:I.length>0,orderedColumns:ue.orderedColumns,allVisible:ue.allVisible,onToggleVisibility:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden,showSavedViews:Fe,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:X})},Kn=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},Rn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(o=>(o==null?void 0:o.value)!=null?String(o.value):null).filter(o=>o!=null);return t.length?t:void 0},es=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Kn(t);case"dropdown-multiple":case"checkbox-multiple":return Rn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},nl=(r,t)=>{if(r==null||r==="")return t;const o=Number(r);return Number.isFinite(o)&&o>0?o:t},rs=r=>{const{filterConfigs:t,filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:i=1,defaultPerPage:a=10,paramKeys:h,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:C,getValue:E}=Et({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:c}),{searchParams:w}=je(),L=w.toString();return d.useMemo(()=>{const I={},S={},k=nl(w.get(l),i),H=nl(w.get(s),a);I[(h==null?void 0:h.page)??"page"]=k,I[(h==null?void 0:h.perPage)??"perPage"]=H;const z=Zr(c,w,o)||"";z&&(I[(h==null?void 0:h.search)??"search"]=z);let B=!1;for(const W of b){const O=p[W];if(!O)continue;const Y=E(O);S[W]=Y;const X=y==null?void 0:y[W],q=X?X(Y):es(O,Y);if(q==null||Array.isArray(q)&&q.length===0)continue;const Z=(h==null?void 0:h[W])??W;I[Z]=q,B=!0}return{params:I,raw:S,hasActiveFilter:C||!!z||B}},[L,b.join("|"),o,n,l,s,c,i,a,h,y,p])},ts=["dropdown","dropdown-multiple","checkbox-multiple","radio"],os=({filterConfigs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l})=>{const{configByKey:s,getValue:c,setValue:i,removeFilter:a,clearAll:h,hasActiveFilter:y}=Et({configs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l}),b=(F,I)=>{var k;const S=F.options;return((k=S==null?void 0:S.find(H=>H.value===I))==null?void 0:k.label)??I},p=d.useCallback(F=>{const I=s[F];if(!I)return[];const S=c(I);return Array.isArray(S)?S.map(k=>String(k.value)):[]},[s,c]),C=d.useCallback((F,I)=>{const S=s[F];if(!S||!ts.includes(S.type))return;const k=Array.isArray(I)?I:[I];if(k.length===0){a(F);return}i(S,k.map(H=>({label:b(S,H),value:H})))},[s,i,a]),E=d.useCallback((F,I)=>{const S=p(F);C(F,S.includes(I)?S.filter(k=>k!==I):[...S,I])},[p,C]),w=d.useCallback((F,I)=>p(F).includes(I),[p]),L=d.useCallback(F=>a(F),[a]);return{set:C,toggle:E,clear:L,clearAll:h,isActive:w,values:p,hasActiveFilter:y}},ls=(r,t)=>{if(!r)return{};const{fromKey:o,toKey:n,opKey:l}=t,s={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(s[o]=new Date(r.date).toISOString()),l&&(s[l]=r.op),s;case"is-between":return r.from&&(s[o]=new Date(r.from).toISOString()),r.to&&(s[n]=new Date(r.to).toISOString()),s;case"is-relative-to-today":{if(!r.relative)return s;const{from:c,to:i}=Uo(r.relative);return s[o]=c.toISOString(),s[n]=i.toISOString(),s}case"is-empty":case"is-not-empty":return l&&(s[l]=r.op==="is-empty"?"empty":"not-empty"),s;default:return s}},sl=({children:r,borderRadius:t,height:o})=>{const n=d.useRef(null),[l,s]=d.useState("100vh");return d.useEffect(()=>{if(o)return;const c=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;s(`calc(100vh - ${i}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[o]),e.jsx(f.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:o??l,display:"flex",flexDirection:"column"},children:r})},cl=({action:r,rightContent:t,leftContent:o,headerSlot:n,advanceFilter:l,showFilter:s=!0})=>{const c=De.useMediaQuery("md"),i=s?e.jsx(Zo,{...l}):null,a=()=>r?d.isValidElement(r)?r:e.jsx(f.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:h,icon:y,buttonProps:b,onClick:p},C)=>!h&&!y?null:e.jsx(j.Button,{fullWidth:!c,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:h},`action-${C}`))}):null;return e.jsx(f.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:c?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,o]}),e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},ns=({totalData:r,withMarginBottom:t=!0,withMarginTop:o=!0})=>e.jsxs(f.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:o?"16px":void 0},children:[e.jsxs(Ke.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ke.Body1,{children:r||0})]}),il=({pagination:r,pageKey:t="page",perPageKey:o="perPage",defaultPerPage:n=10,showPagination:l=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:i,searchParams:a}=je(),h=a.get(o),y=E=>{i({...c,[t]:String(E)})},b=E=>{i({...c,[o]:E,[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),C=(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(f.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:l?e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(D.Text,{children:"Rows Per Page: "}),e.jsx(br.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:E=>{b(E[0].value)},value:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(D.Text,{children:`${p}-${C} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(kr.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(ns,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},al=({filter:r,columnTitle:t})=>{const[o,n]=d.useState(!1),l=d.useRef(null),s=d.useRef(null),c=d.useRef(null),[i,a]=d.useState(""),[h,y]=d.useState({top:0,left:0}),b=r.selectedValues,p=d.useMemo(()=>i?r.options.filter(w=>w.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);d.useEffect(()=>{if(o&&s.current){const w=s.current.getBoundingClientRect(),L=280,F={top:w.bottom+8};r.position==="left"||w.left+L>window.innerWidth?F.right=window.innerWidth-w.right:F.left=w.left,y(F)}},[o,r.position]),d.useEffect(()=>{o&&c.current?setTimeout(()=>{var w;return(w=c.current)==null?void 0:w.focus()},50):a("")},[o]),d.useEffect(()=>{const w=L=>{l.current&&!l.current.contains(L.target)&&s.current&&!s.current.contains(L.target)&&n(!1)};return o&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[o]);const C=w=>{const L=b.includes(w)?b.filter(F=>F!==w):[...b,w];r.onFilterChange(L)},E=()=>r.onFilterChange([]);return e.jsxs(f.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(f.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:w=>{var L;w.stopPropagation(),o||(L=r.onOpen)==null||L.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:o?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),o&&e.jsxs(f.Box,{ref:l,style:{position:"fixed",top:`${h.top}px`,...h.left!==void 0?{left:`${h.left}px`}:{right:`${h.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(f.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(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(D.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:w=>{w.stopPropagation(),E()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(f.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(ar.Input,{ref:c,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:i,onChange:w=>a(w.target.value),style:{fontSize:"14px"}})}),e.jsx(f.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(f.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(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(f.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(w=>e.jsxs(f.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(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:L=>{L.stopPropagation(),C(w.value)},onMouseEnter:L=>{b.includes(w.value)||(L.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),L.currentTarget.style.transform="translateX(2px)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor=b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",L.currentTarget.style.transform="translateX(0)"},children:[e.jsx(tr.Checkbox,{checked:b.includes(w.value),onChange:()=>{}}),e.jsx(D.Text,{fontSize:"sm",fontWeight:b.includes(w.value)?"medium":"normal",color:b.includes(w.value)?"primary":"gray-700",children:w.label})]},w.value))}):e.jsxs(f.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(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(f.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(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(f.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(D.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},ss=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",o="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:o,l=r==="desc"?t:o,s=r==="asc"?1:.45,c=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:s,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:l,opacity:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},cs=({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"})]}),Ot="var(--sa-background-primary, #ffffff)",dl="var(--sa-background-primary-inverse, #f8f8f8)",hl=({columns:r,records:t,handleDetail:o,handleUpdate:n,handleDelete:l,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:i,visibleHandleDetail:a,showHeadBorder:h=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:C,actionsOrder:E=["detail","update","delete","custom"],customEmptyState:w,enableColumnResize:L=!1,defaultColumnWidths:F,onColumnWidthsChange:I,defaultMinColumnWidth:S=60,sort:k,defaultSort:H,onSortChange:z,showActionDivider:B=!1})=>{const W=k!==void 0,[O,Y]=d.useState(H??null),X=W?k??null:O,q=P=>{if(P.sortKey)return P.sortKey;if(typeof P.accessor=="string")return P.accessor},Z=P=>{const R=q(P);if(!R)return;let J;!X||X.key!==R?J={key:R,direction:"asc"}:X.direction==="asc"?J={key:R,direction:"desc"}:J=null,W||Y(J),z==null||z(J)},te=[o,n,l].filter(P=>P!==void 0).length,_=!!C,V=!!o||!!n||!!l||_,N="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${N}`,ve=`inset 1px 0 0 ${N}`,Ee=`inset -1px 0 0 ${N}`,ue=te===3?_?"178px":"140px":te===2?_?"140px":"102px":te===1?_?"112px":"74px":_?"74px":"",Ce=(P,R)=>{if(!R)return P;if(typeof R=="function")return R(P);if(typeof R=="string")return P[R]},[xe,we]=d.useState(!1);d.useEffect(()=>{if(!(y!=null&&y.current))return;const P=y.current;we(P.scrollHeight>P.clientHeight)},[t,y]);const Ae=d.useRef(null),[Fe,Ne]=d.useState([]),[$,ge]=d.useState(()=>F??{}),We=d.useRef(null);d.useLayoutEffect(()=>{if(!b||!Ae.current){Ne([]);return}const P=Array.from(Ae.current.querySelectorAll("thead tr th")),R=[];let J=0;P.forEach((he,ce)=>{R[ce]=J,ce<b&&(J+=he.offsetWidth)}),Ne(R)},[b,r,t,$]);const Ze=P=>{p&&p(P<b?P:P+1)},de=(P,R)=>{const J=$[P];if(J!==void 0){const he=`${J}px`;return{width:he,minWidth:he,maxWidth:he}}return R?{width:R}:{}},Ge=P=>L&&(P.resizable??!0),lr=(P,R)=>{P.preventDefault(),P.stopPropagation();const J=P.currentTarget.closest("th");if(!J)return;const he=Math.round(J.getBoundingClientRect().width);We.current={colIndex:R,startX:P.clientX,startWidth:he};const ce=document.body.style.userSelect,Me=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ze=Qe=>{var Ue;const Le=We.current;if(!Le)return;const Je=((Ue=r[Le.colIndex])==null?void 0:Ue.minWidth)??S,Se=Math.max(Je,Le.startWidth+(Qe.clientX-Le.startX));ge(nr=>nr[Le.colIndex]===Se?nr:{...nr,[Le.colIndex]:Se})},er=()=>{document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",er),document.body.style.userSelect=ce,document.body.style.cursor=Me,We.current=null,I&&ge(Qe=>(I(Qe),Qe))};document.addEventListener("mousemove",ze),document.addEventListener("mouseup",er)};return e.jsx("div",{ref:Ae,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((P,R)=>{var gr,dr;const J=b>0&&R<b,he=Fe[R]??0,ce=Ge(P),ze=R===r.length-1&&V&&B,er=q(P),Qe=!!P.sortable&&!!er,Le=Qe&&(X==null?void 0:X.key)===er?X.direction:null,Je=P.title||((gr=P.accessor)==null?void 0:gr.toString())||"",Se=(dr=P.headerTooltip)!=null&&dr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ue=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),nr=Qe?e.jsxs("button",{type:"button",onClick:()=>Z(P),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="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:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left"},children:[Ue,Se,e.jsx(ss,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ue,Se]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:J?he:void 0,zIndex:J?4:2,paddingLeft:R===0?"12px":"",borderRight:h&&!ze&&!J?se:void 0,borderBottom:h?se:void 0,boxShadow:h&&J?Ee:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left",...de(R,P.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[P.headerTooltip?e.jsx(me.Tooltip,{label:P.headerTooltip.content,position:"bottom",children:nr}):nr,P.filter&&e.jsx(al,{filter:P.filter,columnTitle:P.title}),p&&e.jsx("button",{onClick:()=>Ze(R),title:J?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:J?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:J?1:.45,transition:"opacity 0.15s"},children:e.jsx(cs,{frozen:J})})]}),ce&&e.jsx("div",{onMouseDown:hr=>lr(hr,R),onClick:hr=>hr.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-${R}`)}),V?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:h?se:void 0,boxShadow:h&&B?ve:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(f.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&w?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:w})}):t==null?void 0:t.map((P,R)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:R===t.length-1&&xe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:J=>{const he=J.currentTarget;he.style.backgroundColor=dl,Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=dl)})},onMouseLeave:J=>{const he=J.currentTarget;he.style.backgroundColor="",Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=Ot)})},children:[r.map((J,he)=>{const ce=J.render?J.render(P,R,t):Ce(P,J.accessor),Me=b>0&&he<b,ze=Fe[he]??0,er=$[he]!==void 0,Qe=Me&&he===b-1;return e.jsx(U.Td,{style:{position:Me?"sticky":void 0,left:Me?ze:void 0,zIndex:Me?1:void 0,backgroundColor:Me?Ot:void 0,transition:Me?"background-color 0.3s ease":void 0,paddingLeft:he===0?"12px":"",whiteSpace:"nowrap",overflow:er?"hidden":void 0,borderLeft:J.showBorderLeft?se:void 0,borderRight:J.showBorderRight?se:void 0,boxShadow:Qe?Ee:void 0,textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left",...de(he,J.width)},children:typeof ce=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left"},children:ce}):ce},`row-${R}-col-${he}`)}),V?e.jsx(U.Td,{style:{width:ue,position:"sticky",right:0,zIndex:1,backgroundColor:Ot,boxShadow:B?ve:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ie.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:E.map(J=>{const he=R===t.length-1?"top":"bottom";return J==="detail"&&o&&(a==null?void 0:a(P))!==!1?e.jsx(me.Tooltip,{label:"Detail",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(P.id,P),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):J==="update"&&n&&(i==null?void 0:i(P))!==!1?e.jsx(me.Tooltip,{label:"Update",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(P),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):J==="delete"&&l&&(c==null?void 0:c(P))!==!1?e.jsx(me.Tooltip,{label:"Delete",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(P.id,P),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):J==="custom"?e.jsx(d.Fragment,{children:C==null?void 0:C(P)},"custom"):null})})}):null]},`${P}${R}`))})]})})};let fl=!1;const is=({wrapperProps:r,dataTableProps:t,headerProps:o,footerProps:n})=>{var b;process.env.NODE_ENV!=="production"&&!fl&&(fl=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const l=d.useRef(null),[s,c]=d.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(o==null?void 0:o.show)??!0,a=d.useRef(null),h=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof h=="number"&&(a.current=h);const y=(n==null?void 0:n.showFooter)??(h===void 0?a.current!==0:h!==0);return e.jsxs(sl,{...r,children:[i&&e.jsx(cl,{...o}),e.jsx(f.Box,{direction:"column",ref:l,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(hl,{...t,scrollParentRef:l,frozenCount:t!=null&&t.enableFreezeColumns?s:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?c: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 as(r){return d.memo(r)}const ds=as(is),ul=200,At="1px solid var(--sa-border-subtle, #0b120e24)",hs=({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"}),Jr=({icon:r,label:t,active:o,danger:n,onClick:l})=>{const s=n?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:l,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:o?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:s,textAlign:"left"},onMouseEnter:c=>{o||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=o?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(D.Text,{as:"span",style:{color:s},children:t})]})},gl=({active:r,canSort:t,canHide:o,sortDir:n,frozen:l,onSort:s,onClearSort:c,onToggleFreeze:i,onHide:a})=>{const[h,y]=d.useState(!1),b=d.useRef(null),p=d.useRef(null),[C,E]=d.useState({top:0,left:0});d.useEffect(()=>{if(h&&b.current){const L=b.current.getBoundingClientRect(),F=L.left+ul>window.innerWidth;E({top:L.bottom+6,...F?{right:window.innerWidth-L.right}:{left:L.left}})}},[h]),d.useEffect(()=>{if(!h)return;const L=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[h]);const w=L=>{L(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||h?"true":"false",onClick:L=>{L.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:At,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(hs,{sortDir:n,frozen:l})}),h&&e.jsxs(f.Box,{ref:p,onClick:L=>L.stopPropagation(),style:{position:"fixed",top:`${C.top}px`,...C.left!==void 0?{left:`${C.left}px`}:{right:`${C.right}px`},minWidth:ul,backgroundColor:"var(--sa-background-primary, #ffffff)",border:At,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Jr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>w(()=>n==="asc"?c():s("asc"))}),e.jsx(Jr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>w(()=>n==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:At,margin:"4px 0"}})]}),e.jsx(Jr,{icon:"Pin1",label:l?"Unfreeze":"Freeze",active:l,onClick:()=>w(i)}),o&&e.jsx(Jr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>w(a)})]})]})},Ir="1px solid var(--sa-border-subtle, #0b120e24)",fs="var(--sa-text-subtle, #8c8f97)",Dr="var(--sa-background-neutral, #f0f1f2)",yl="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Tr=40,Wt="var(--sa-background-brand-subtlest)",Yr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},pl="sa-table-layout-styles",us=()=>{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);
|