@starasia/admin 8.7.0 → 8.8.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/index.cjs.js +1 -1
- package/dist/index.es.js +12 -2
- package/dist/index.umd.js +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,Re){typeof exports=="object"&&typeof module<"u"?Re(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],Re):(g=typeof globalThis<"u"?globalThis:g||self,Re(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,Re,Ze,u,er,P,gt,Qe,Ie,pr,rr,ge,tr,Ge,O,hr,fr,U,ut,Pr,lr,yt,or,De,nr,jr,S,F,ce,pt,Ct,bt,vt,xt,He,wt,e,h,ue,Nr,Ll){"use strict";const Tl={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},_r=h.createContext(Tl),qr=()=>h.useContext(_r),Dt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},St=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),kt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(i=>{l(d=>typeof i=="function"?i(d):i)},[]),o=h.useCallback((i,d)=>{l(a=>{const y=typeof d=="function"?d(a[i]):d;return{...a,[i]:y}})},[]),c=h.useCallback(i=>{l(d=>{if(!(i in d))return d;const a={...d};return delete a[i],a})},[]),s=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(St.Provider,{value:s,children:r})},Bt=()=>h.useContext(St),Cr=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},mt=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:s})=>{const i=Dt({initialUserData:c}),{theme:d}=lr.useTheme();return e.jsx(_r.Provider,{value:{logo:n,appName:o,menus:t,userData:i.userData,setUserData:i.setUserData,menuBottom:l},children:e.jsx(kt,{children:s?e.jsx(lr.ThemeProvider,{value:s,children:r}):d?e.jsx(lr.ThemeProvider,{value:d,children:r}):r})})},Il=h.memo(mt);function Ft({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const Zr=h.createContext(null);function Et({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,s]=h.useState(null),[i,d]=h.useState(0),a=h.useCallback(()=>(d(y=>y+1),()=>d(y=>y-1)),[]);return e.jsx(Zr.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:s,replaceCount:i,registerReplace:a},children:r})}function Mt({children:r}){const t=h.useContext(Zr);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 Ol({children:r,mode:t="append"}){const l=h.useContext(Zr);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?Nr.createPortal(r,n):null}const Gr=h.createContext(null);function Lt({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((d,a)=>{l(y=>y[d]===a?y:{...y,[d]:a})},[]),s=h.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),i=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:s}),[t,c,n,s]);return e.jsx(Gr.Provider,{value:i,children:r})}function Tt({slotKey:r,fallback:t}){const l=h.useContext(Gr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(s=>{var i;return(i=o.current)==null?void 0:i.call(o,r,s)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function Wl({slotKey:r,children:t}){const l=h.useContext(Gr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?Nr.createPortal(t,o):null}const br="moduleSwitcherGroupId",Qr="sa-module-switcher-change";function It(){if(typeof window>"u")return null;const r=window.localStorage.getItem(br);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function Ot(r){typeof window>"u"||(r===null?window.localStorage.removeItem(br):window.localStorage.setItem(br,String(r)),window.dispatchEvent(new CustomEvent(Qr,{detail:r})))}function Al(){Ot(null)}function Ur(){const[r,t]=h.useState(()=>It());return h.useEffect(()=>{const n=()=>{t(It())},o=c=>{c.key===br&&n()};return window.addEventListener(Qr,n),window.addEventListener("storage",o),()=>{window.removeEventListener(Qr,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{Ot(n),t(n)}}}let vr=0,Ue=!1,Wt=new Set;const At=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),zt={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function zl({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:s,sidebarHeaderContent:i,headerActions:d,profileRole:a,profileMenuButtons:y,profileMenuItems:C,logoutButton:p}){var Me,Je;const[x]=ue.useSearchParams(),I=x.get("embed")==="true",b=qr(),{badges:B}=Bt(),M=ue.useNavigate(),W=ue.useLocation(),D=!ge.useMediaQuery("md"),[V,z]=h.useState(!1),[w,L]=h.useState(!1),[_,N]=h.useState(!1),[G,Y]=h.useState(!1),[ne,ye]=h.useState(()=>new Set(Wt)),[le,de]=h.useState(null),{selectedGroupId:$,setSelectedGroupId:R}=Ur();h.useEffect(()=>{Wt=ne},[ne]);const fe=h.useRef(null),te=h.useRef(null);h.useEffect(()=>{const m=fe.current;if(!m)return;const Q=()=>{Ue||(vr=m.scrollTop)};return m.addEventListener("scroll",Q),()=>m.removeEventListener("scroll",Q)},[]);const se=()=>{const m=fe.current;m&&vr>0&&(Ue=!0,m.scrollTop=vr,requestAnimationFrame(()=>{Ue=!1}))};h.useLayoutEffect(()=>{Ue=!0,se();const m=setTimeout(()=>{Ue=!1},300);return()=>clearTimeout(m)},[]),h.useLayoutEffect(()=>{b.menus.length>0&&(vr>0?se():requestAnimationFrame(()=>{var Q;const m=(Q=fe.current)==null?void 0:Q.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[b.menus]),h.useEffect(()=>{Ue=!0,se();const m=setTimeout(se,0),Q=setTimeout(se,50),q=setTimeout(se,100),T=setTimeout(se,200),H=setTimeout(()=>{Ue=!1},300),j=setTimeout(()=>{const Z=fe.current,K=Z==null?void 0:Z.querySelector("[data-menu-active='true']");if(Z&&K){const xe=Z.getBoundingClientRect(),Fe=K.getBoundingClientRect();Fe.top>=xe.top&&Fe.bottom<=xe.bottom||K.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(Q),clearTimeout(q),clearTimeout(T),clearTimeout(H),clearTimeout(j)}},[W.pathname]),h.useEffect(()=>{te.current&&(te.current.scrollTop=0)},[W.pathname]),h.useEffect(()=>{D&&N(!1)},[W.pathname,D]),h.useEffect(()=>{D&&L(!0)},[D]);const Be=()=>{z(!0)},je=()=>{z(!1)},pe=()=>{z(!1),o()},me=m=>{const Q=[m.to];return m.children&&Q.push(...m.children.map(q=>q.to)),Q},Le=[...b.menus.flatMap(m=>m.items.flatMap(me)),...((Me=b.menuBottom)==null?void 0:Me.flatMap(me))??[]],Ce=m=>{if(!W.pathname.startsWith(m))return!1;const Q=Le.filter(q=>W.pathname.startsWith(q)).sort((q,T)=>T.length-q.length)[0];return m===Q};h.useEffect(()=>{var Q;const m=q=>{var T;(T=q.children)!=null&&T.some(H=>W.pathname.startsWith(H.to))&&ye(H=>{const j=new Set(H);return j.add(q.id),j})};b.menus.forEach(q=>{q.items.forEach(m)}),(Q=b.menuBottom)==null||Q.forEach(m)},[W.pathname,b.menus,b.menuBottom]);const We=m=>{ye(Q=>{const q=new Set(Q);return q.has(m)?q.delete(m):q.add(m),q})};h.useEffect(()=>{b.menus.length!==0&&$!==null&&!b.menus.some(m=>m.id===$)&&R(null)},[b.menus,$,R]);const qe=h.useMemo(()=>{if($!==null)return b.menus.filter(q=>q.id===$||q.parentGroupId===$);const m=b.menus.filter(q=>q.parentGroupId===void 0),Q=b.menus.filter(q=>q.parentGroupId!==void 0).flatMap(q=>q.items);return Q.length===0?m:[...m,{id:18,name:"Pengaturan",items:Q,parentGroupId:void 0}]},[b.menus,$]);if(I)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ue.Outlet,{})});const be=m=>{const Q=m.children&&m.children.length>0,q=ne.has(m.id),T=Q?m.children.some(Z=>Ce(Z.to)):Ce(m.to),H=Cr(m.badge,B[m.id]),j=!!H&&w&&!D;return e.jsxs("div",{"data-menu-active":T||void 0,children:[e.jsxs("button",{onClick:Z=>{if(Q)if(w&&!D){const K=Z.currentTarget.getBoundingClientRect();de({item:m,top:K.top,left:K.right+8})}else We(m.id);else M(m.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:w&&!D?"center":void 0,gap:"0.5rem",paddingLeft:w&&!D?"0":"0.5rem",paddingRight:w&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:T?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:T?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:T?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:w&&!D?m.title:void 0,onMouseEnter:Z=>{T||(Z.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Z=>{T||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(F.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),j&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!w||D)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:m.title}),H&&e.jsx(Ze.Badges,{text:String(H.value),variant:H.variant??"info",size:"xs",border:!0}),Q&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:q?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),Q&&(!w||D)&&(()=>{const Z=m.children.findIndex(K=>Ce(K.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:q?`${m.children.length*36}px`:"0px",opacity:q?1:0,marginTop:q?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),Z>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${Z*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),m.children.map(K=>{const xe=Cr(K.badge,B[K.id]);return e.jsxs("button",{onClick:()=>M(K.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:Ce(K.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Ce(K.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:Ce(K.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:Ce(K.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{Ce(K.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{Ce(K.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(F.Icon,{name:K.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:K.title}),xe&&e.jsx(Ze.Badges,{text:String(xe.value),variant:xe.variant??"info",size:"xs",border:!0})]},K.id)})]})})()]},m.id)};return e.jsx(Lt,{children:e.jsxs(Et,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":w?"4.375rem":"16.375rem","--app-footer-zindex":D&&_?"40":"999"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:_?.5:0,pointerEvents:_?"auto":"none",transition:"opacity 0.3s"},onClick:()=>N(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":w?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:_?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const m=!D&&w&&!_,Q=m&&G;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:m?1:void 0,justifyContent:m?"center":void 0,transition:"opacity 0.2s",opacity:Q?0:1,pointerEvents:Q?"none":"auto"},children:[e.jsx("img",{src:b.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!w||_)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:b.appName})]}),!D&&!w&&e.jsx("button",{type:"button",onClick:()=>L(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(At,{})}),m&&e.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:Q?1:0,pointerEvents:Q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(At,{})})}),D&&e.jsx("button",{onClick:()=>N(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),i&&e.jsx(Ft,{collapsed:D?!1:w,children:i}),e.jsx("div",{ref:fe,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:qe.map(m=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!w||D?m.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.name}):m.name&&e.jsx("div",{"aria-label":m.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:m.slotKey?e.jsx(Tt,{slotKey:m.slotKey,fallback:m.items.map(Q=>be(Q))}):m.items.map(Q=>be(Q))})]},m.id))}),b.menuBottom&&b.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:b.menuBottom.map(m=>be(m))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[D&&e.jsx("button",{onClick:()=>N(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(Mt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(F.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(O.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(O.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.email)||"unknown"}),a&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a})]})}),(y&&y.length>0||C)&&e.jsxs(O.MenuBody,{children:[y==null?void 0:y.map((m,Q)=>e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:m.onClick,style:zt,onMouseEnter:q=>{q.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:q=>{q.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(F.Icon,{name:m.icon,size:"md"}),e.jsx("span",{children:m.label})]})},`${m.label}-${Q}`)),C]}),p??e.jsx(O.MenuFooter,{children:e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Be,style:{...zt,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(F.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:te,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ue.Outlet,{})})]})]}),c&&s&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:s}),e.jsxs(Ie.Dialog,{isShow:V,onHide:je,children:[e.jsx(Ie.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Ie.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Ie.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ce.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{secondary:!0,onClick:je,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{primary:!0,onClick:pe,children:"Yes, Sure"})})]})})})]}),le&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>de(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":le.item.title,style:{position:"fixed",top:le.top,left:le.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:le.item.title}),(Je=le.item.children)==null?void 0:Je.map(m=>{const Q=Ce(m.to),q=Cr(m.badge,B[m.id]);return e.jsxs("button",{onClick:()=>{M(m.to),de(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Q?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:T=>{Q||(T.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:T=>{Q||(T.currentTarget.style.backgroundColor="transparent")},children:[m.icon&&e.jsx(F.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:m.title}),q&&e.jsx(Ze.Badges,{text:String(q.value),variant:q.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const xr=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Vt=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[s,i]=h.useState(!1),d=n??"var(--sa-text-subtle, #8c8f97)",a=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",C=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(F.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:s?y:d,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:s?C:a,transition:"color 0.15s ease"},children:r||"Back"})]})},Vl=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,s]=h.useState(!1),i=n??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=r.length>1?r[0]:void 0,y=!!(a!=null&&a.to||a!=null&&a.onClick),C=e.jsx(F.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>s(!0):void 0,onMouseLeave:y?()=>s(!1):void 0,style:{color:y&&c?d:i,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),p=a!=null&&a.to?e.jsx(ue.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:C}):a!=null&&a.onClick?e.jsx(xr,{onClick:a.onClick,children:C}):C;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(er.Breadcrumb,{separator:t,size:"md",children:r.map((x,I)=>{const b=I===r.length-1;return x.to&&!b?e.jsx(er.BreadcrumbItem,{children:e.jsx(ue.Link,{to:x.to,children:x.label})},I):e.jsx(er.BreadcrumbItem,{currentPage:b,children:e.jsx(er.BreadcrumbLink,{onClick:b?void 0:x.onClick,children:x.label})},I)})})]})},Hl=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(Vl,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ue.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(Vt,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(xr,{onClick:n,children:e.jsx(Vt,{...c})})})},Jr=[{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 Ht(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Pt={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},jt={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Nt({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,s]=h.useState(void 0),i=a=>{o(a),t()},d=Jr[0];return e.jsx(Ie.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Ie.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>s("all"),onMouseLeave:()=>s(void 0),style:jt,children:[e.jsx("div",{style:Ht(n===null,c==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(F.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Pt,children:"Semua"})]}),l.map((a,y)=>{var b;const C=n===a.id,p=c===a.id,x=((b=a.items[0])==null?void 0:b.icon)??"Grid",I=Jr[(y+1)%Jr.length];return e.jsxs("button",{onClick:()=>i(a.id),onMouseEnter:()=>s(a.id),onMouseLeave:()=>s(void 0),style:jt,children:[e.jsx("div",{style:Ht(C,p,I),children:e.jsx("div",{style:{color:I.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(F.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Pt,children:a.name})]},a.id)})]})})})}function Pl({onSelect:r,"aria-label":t="Pilih module"}={}){const l=qr(),n=ue.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=Ur(),[s,i]=h.useState(!1),d=a=>{var y;if(c(a),a!==null){const C=l.menus.find(x=>x.id===a),p=(y=C==null?void 0:C.items[0])==null?void 0:y.to;p&&n(p)}r==null||r(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>i(!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:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(F.Icon,{name:"GridApplication",size:"sm"})}),o!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(Nt,{isShow:s,onHide:()=>i(!1),menus:l.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const jl=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Nl=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const s=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),i=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),d=()=>typeof t=="string"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,a=()=>typeof r=="string"||typeof r=="number"?e.jsx(S.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:s,width:n,children:d()}),l?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:s,children:a()})]})}),_l=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(U.Table,{children:r.map((n,o)=>e.jsx(Nl,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),ql=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const s=h.useMemo(()=>jl(n,r),[n,r]),i=s.length>2,d=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(u.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:s.map((a,y)=>e.jsx(u.Box,{direction:"column",flex:i?void 0:"1",width:i?d():void 0,marginBottom:i?"lg":void 0,children:e.jsx(_l,{labelWidth:o,fields:a,separator:l})},y))})}),Zl=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(F.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:t?s:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},Gl=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:s=!1,subHeaders:i,action:d,titleTagProps:a,containerProps:y,headerProps:C})=>{const p=ge.useMediaQuery("md"),x=ue.useNavigate(),I=ue.useLocation(),b=r==null?void 0:r.show,B=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},M=()=>{if(!d)return null;if(h.isValidElement(d))return d;const w=d.filter(L=>L&&(L.title||L.icon));return w.length===0?null:p?e.jsx(u.Box,{direction:"row",gap:"md",children:w.map(({title:L,icon:_,buttonProps:N,onClick:G},Y)=>e.jsx(P.Button,{iconLeft:_?e.jsx(F.Icon,{name:_,size:"md"}):void 0,onClick:G,...N,children:L},`action-${Y}`))}):e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(F.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:200},children:w.map(({title:L,icon:_,buttonProps:N,onClick:G},Y)=>{const ne=(N==null?void 0:N.tone)==="error"||(N==null?void 0:N.danger)===!0;return e.jsx(O.MenuItem,{intent:ne?"danger":void 0,disabled:N==null?void 0:N.disabled,startIcon:_?e.jsx(F.Icon,{name:_}):void 0,onClick:G,children:L},`action-${Y}`)})})})]})},W=()=>{const w=e.jsx(Zl,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ue.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:w})}):e.jsx(u.Box,{direction:"row",children:e.jsx(xr,{onClick:B,children:w})})},k=()=>{const w=!!t,L=Array.isArray(d)&&d.length>0,_=h.isValidElement(d)?!0:L;if(!w&&!_&&!b)return null;const G=p||!p&&L;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(C==null?void 0:C.paddingBlock)??"sm",paddingInline:(C==null?void 0:C.paddingInline)??"md",...C,style:{...s?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:{},...C==null?void 0:C.style},children:[b&&W(),(w||_)&&e.jsxs(u.Box,{direction:G?"row":"column",gap:"sm",justify:"space-between",align:G?"center":"flex-start",children:[w?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(F.Icon,{name:l,size:"md",color:"primary"}),e.jsx(S.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ze.Badge,{border:!0,size:"lg",text:n,...a})]}):t:null,M()]})]})},D=()=>{if(!i||i.length===0)return null;const w=i.filter(N=>N.show!==!1);if(w.length===0)return null;let L=0,_=-1/0;return w.forEach((N,G)=>{const Y=N.order??0;Y>=_&&(_=Y,L=G)}),w.map(({content:N,order:G,borderBottom:Y=!0},ne)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:Y||ne===L?"sm":"spacing-0",paddingInline:"md",style:{...Y?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:{},...G!==void 0?{order:G}:{}},children:N},`sub-header-${ne}`))},V=()=>{const w=c?k():null,L=D();return!w&&!L?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:L?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[w,L]})},z=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[V(),z()]},I.pathname)},Ql=h.memo(Gl),Ul={icon:"Cross",title:""},Jl="calc(100vw - 16px)",_t=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${Jl})`,qt=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Ul,width:s,minWidth:i="357px",maxWidth:d="357px"},a)=>{const y=_t(s??i),C=_t(s??d);return e.jsx(pr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:a,style:{minWidth:y,maxWidth:C,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(F.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(S.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),Yr=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=ge.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Xr=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=ge.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Yl=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),Xl=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:s,containerProps:i,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:C="info"})=>{const p=ge.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(S.Text,{fontWeight:"medium",children:t}),e.jsx(Ze.Badges,{border:!0,text:l,variant:C})]}):e.jsx(S.Text,{fontWeight:"medium",children:t}),I=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...s,children:n??null})]}),b=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[o!==null&&b?e.jsx(Yr,{...a,children:I()}):null,e.jsx(Yl,{...d,children:r}),c?e.jsx(Xr,{...y,children:c}):null]})}),Oe={H1:r=>e.jsx(S.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(S.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(S.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(S.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(S.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(S.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(S.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(S.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(S.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(S.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(S.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(S.Text,{variant:"body-3",children:r.children,...r.props})},ke=()=>{const[r,t]=ue.useSearchParams(),l=tr.searchParamsToObject(r.toString()),n=ue.useParams(),o=ue.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,C)=>r.has(y)&&r.get(y)===C,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},Zt=r=>JSON.stringify(r),Gt=r=>JSON.stringify(r),Qt=r=>JSON.stringify(r),Ut=r=>JSON.stringify(r),Kl=r=>r,$l=r=>JSON.stringify(r),gr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:s,filterKey:i="filter",pageKey:d="page"})=>{if(n){let a;switch(l){case"search":a=Kl(r);break;case"dropdown":case"dropdown-multiple":a=Zt(r);break;case"radio":a=Gt(r);break;case"date-range":a=Qt(r);break;case"advanced-date-range":a=$l(r);break;case"date":a=Ut(r);break;default:a=r;break}if(typeof a<"u"){const C={...c[i]&&typeof c[i]=="string"?JSON.parse(c[i]):void 0,[t]:a},p={...c};s&&typeof s=="string"&&delete p[s],delete p[d];const x={...p,[i]:JSON.stringify(C)},I=new URLSearchParams(c).toString(),b=new URLSearchParams(x).toString();if(I===b)return;o(x)}}},wr=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s)[0].label:n==="value"&&s?JSON.parse(s)[0].value:s},Jt=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s).map(i=>i.label):n==="value"&&s?JSON.parse(s).map(i=>i.value):n==="array"&&s?JSON.parse(s):s},Rl=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="id"&&s?JSON.parse(s).id:n==="label"&&s?JSON.parse(s).label:n==="value"&&s?JSON.parse(s).value:s},Dr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},eo=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},Yt=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},ro=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,s=r.get(n)||void 0;return!!o||!!c||!!s},Xt=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),[d,a]=h.useState({}),y=()=>{c.delete(l||"filter"),s(c)},C=(p,x)=>{switch(p.type){case"radio":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"dropdown":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"dropdown-multiple":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}default:return null}};return e.jsx(qt,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(ce.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((p,x)=>C(p,x))]})})},Kt=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:s=!0,filterKey:i="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:y,filterConfigs:C,buttonToggleProps:p,position:x="right",titleSearchLabel:I="Work Order",withTitleLabels:b=!1})=>{const M=(p==null?void 0:p.isShowLabel)??!0,[W,k]=h.useState(!1),[D,V]=h.useState(0),z=()=>{V(R=>R+1)},{searchParams:w,setSearchParams:L,getQueryParam:_}=ke(),N=tr.searchParamsToObject(w.toString()),G=Dr(r,w,i)||"",[Y,ne]=h.useState(G),ye=_(i),de=!!(ye&&!(()=>{if(ye)try{const R=JSON.parse(ye);return Object.keys(R).length===1&&R[r]===""}catch(R){console.error("Filter parameter is not a valid JSON:",R)}return!1})()),$=ge.useMediaQuery("md");return h.useEffect(()=>{ne(G)},[G]),h.useEffect(()=>{if(Y===G)return;const R=window.setTimeout(()=>{gr({value:Y,name:r,type:"search",searchQueries:N,setSearchParams:L,filterKey:i,pageKey:d})},350);return()=>{window.clearTimeout(R)}},[Y,G,r,N,L,i,d]),e.jsxs(ce.Flex,{gap:"md",style:{flexDirection:$&&x==="left"?"row":$&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[de&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(P.Button,{onClick:()=>{const R=new URLSearchParams(w);R.delete(i),L(R),ne(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(S.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:R,content:fe,title:te,onClickContainer:se},Be)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:se,style:{minWidth:R},children:[te&&e.jsx(Oe.SubH3,{children:te}),fe]},`extended-filter-${Be}-${D}`)),!!(C!=null&&C.length)&&e.jsx(P.Button,{primary:de,secondary:!de,iconLeft:e.jsx(F.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:ye?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!$,onClick:()=>k(!0),children:M?"Filter":void 0}),s&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[b&&e.jsx(Oe.SubH3,{children:"Status"}),e.jsx(rr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:wr({get:"value",name:t,searchParams:w,filterKey:i})?[{label:wr({get:"value",name:t,searchParams:w,filterKey:i})==="active"?"Active":"InActive",value:wr({get:"value",name:t,searchParams:w,filterKey:i})}]:[],onChange:R=>gr({value:R,name:t,type:"dropdown",searchQueries:N,setSearchParams:L,filterKey:i}),placeholder:b?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:a&&$?a:$?"310px":""},children:[b&&e.jsxs(Oe.SubH3,{children:["Search for ",I]}),e.jsx(Ge.Input,{placeholder:l,leftIcon:e.jsx(F.Icon,{name:"Search",width:20,height:20}),onChange:R=>ne(R.target.value),value:Y,fullWidth:!0},D+1+i)]}),e.jsx(Xt,{isOpen:W,onClose:()=>k(!1),filterKey:i,filters:C,pageKey:d})]})},to=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function Kr({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),d=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),a=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(z=>z.trim()).filter(Boolean);let V=[];try{const z=c.get(t);z&&(V=Object.keys(JSON.parse(z)).filter(w=>w!==o))}catch{}return r.map(z=>z.key).filter(z=>{const w=d[z];return(w==null?void 0:w.locked)||D.includes(z)||V.includes(z)})},[c,l,t,o,r,d]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),C=h.useCallback(D=>{const V={...i};D.length?V[l]=D.join(","):delete V[l],s(V)},[i,l,s]),p=h.useCallback(D=>{a.includes(D)||C([...a,D])},[a,C]),x=h.useCallback(D=>{var L;if((L=d[D])!=null&&L.locked)return;const V={...i},z=a.filter(_=>_!==D);z.length?V[l]=z.join(","):delete V[l];const w=y(V);D in w&&(delete w[D],Object.keys(w).length?V[t]=JSON.stringify(w):delete V[t]),delete V[n],s(V)},[i,a,l,t,n,y,s,d]),I=h.useCallback(D=>a.includes(D)?x(D):p(D),[a,p,x]),b=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return Jt({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const V=Yt({name:D.key,searchParams:c,filterKey:t});return V?new Date(V):void 0}case"date-compact":{const z=y(Object.fromEntries(c.entries()))[D.key];return z&&typeof z=="object"?z:void 0}default:return}},[c,t,y]),B=h.useCallback((D,V)=>{if(D.type==="date-compact"){const z={...i},w=y(z);V==null?delete w[D.key]:w[D.key]=V,Object.keys(w).length?z[t]=JSON.stringify(w):delete z[t],delete z[n],s(z);return}gr({value:V,name:D.key,type:to(D.type),searchQueries:i,setSearchParams:s,filterKey:t,pageKey:n})},[i,s,t,n,y]),M=h.useCallback(D=>{const V={...i},z=y(V);D in z&&(delete z[D],Object.keys(z).length?V[t]=JSON.stringify(z):delete V[t]),delete V[n],s(V)},[i,t,n,y,s]),W=h.useCallback(()=>{const D={...i};delete D[t],delete D[l],delete D[n],s(D)},[i,t,l,n,s]),k=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:k,addFilter:p,removeFilter:x,toggleFilter:I,getValue:b,setValue:B,clearValue:M,clearAll:W}}const $r={get(r){return fr.storage.get(r)??null},set(r,t){fr.storage.save(r,t)},remove(r){fr.storage.delete(r)}},cr={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}`},Sr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function lo({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(w=>w.key),hidden:[]}),[r]),s=t?cr.columns(t):void 0,i=(w,L)=>Sr({order:w.order??L,hidden:w.hidden??[]},r),[d,a]=h.useState(()=>{if(o&&(o.order||o.hidden))return i(o,r.map(w=>w.key));if(s){const w=l.get(s);if(w&&Array.isArray(w.order))return Sr(w,r)}return c}),y=r.map(w=>w.key).join("|");h.useEffect(()=>a(w=>Sr(w,r)),[y]);const C=h.useRef(d);C.current=d;const p=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(p);h.useEffect(()=>{if(p==null||x.current===p)return;x.current=p;const w=C.current,L=i(o,w.order);L.order.join("|")===w.order.join("|")&&L.hidden.join("|")===w.hidden.join("|")||(a(L),s&&l.set(s,L))},[p,y]);const I=h.useRef(!1);h.useEffect(()=>{I.current||(I.current=!0,n==null||n(d))},[]);const b=h.useCallback(w=>{a(w),s&&l.set(s,w),n==null||n(w)},[s,l,n]),B=h.useMemo(()=>{const w=new Map(r.map(L=>[L.key,L]));return d.order.filter(L=>w.has(L)).map(L=>({...w.get(L),visible:!d.hidden.includes(L)}))},[d,r]),M=h.useCallback(w=>{const L=d.hidden.includes(w)?d.hidden.filter(_=>_!==w):[...d.hidden,w];b({...d,hidden:L})},[d,b]),W=h.useCallback((w,L)=>{if(w===L)return;const _=[...d.order],[N]=_.splice(w,1);_.splice(L,0,N),b({...d,order:_})},[d,b]),k=h.useCallback(w=>{b({...d,hidden:w?r.filter(L=>!L.locked).map(L=>L.key):[]})},[d,r,b]),D=h.useCallback(()=>b(c),[b,c]),V=h.useCallback(w=>b(Sr(w,r)),[b,r]),z=d.hidden.length===0;return{state:d,orderedColumns:B,allVisible:z,toggleVisibility:M,reorder:W,setAllHidden:k,reset:D,applyState:V}}function oo({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:s,setSearchParams:i}=ke(),d=r?cr.savedViews(r):void 0,[a,y]=h.useState(()=>d?t.get(d)||[]:[]),C=h.useCallback(b=>{y(b),d&&t.set(d,b)},[d]),p=h.useCallback(b=>{const B=b.trim();if(!B)return;const M={};l.forEach(k=>{const D=s.get(k);D!=null&&(M[k]=D)});const W={id:`${Date.now()}`,name:B,query:M,columns:o==null?void 0:o(),createdAt:Date.now()};C([...a,W])},[l,s,o,C,a]),x=h.useCallback(b=>C(a.filter(B=>B.id!==b)),[C,a]),I=h.useCallback(b=>{const B=Object.fromEntries(s.entries());l.forEach(M=>delete B[M]),Object.assign(B,b.query),delete B[n],i(B),b.columns&&(c==null||c(b.columns))},[s,l,n,i,c]);return{enabled:!!d,views:a,saveView:p,deleteView:x,applyView:I}}function no({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=ke(),c=r&&n?cr.lastState(r):void 0,s=h.useRef(c);h.useEffect(()=>{if(!c){s.current=c;return}if(s.current!==c){s.current=c;return}const a={};l.forEach(y=>{const C=o.get(y);C!=null&&(a[y]=C)}),Object.keys(a).length!==0&&t.set(c,a)},[o,c,l,t]);const i=h.useCallback(()=>{if(!c)return null;const a=t.get(c);return a&&Object.keys(a).length>0?a:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:i,clear:d}}function co({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=ke(),s=r&&o?cr.perPage(r):void 0,i=c.toString(),d=h.useRef(s);h.useEffect(()=>{if(!s){d.current=s;return}if(d.current!==s){d.current=s;return}const C=c.get(l);if(!C)return;const p=Number(C);!Number.isFinite(p)||p<=0||t.set(s,p)},[i,s,l,t]);const a=h.useCallback(()=>{if(!s)return null;const C=t.get(s);if(C==null)return null;const p=Number(C);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[s,t,n]),y=h.useCallback(()=>{s&&t.remove(s)},[s,t]);return{enabled:!!s,read:a,clear:y}}let Rr={},et=!1,rt=null;const io=(r,t)=>{Object.assign(Rr,r),rt=t,!et&&(et=!0,queueMicrotask(()=>{const l=Rr,n=rt;Rr={},et=!1,rt=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([s,i])=>c.set(s,i)),c})}))};function so({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:s,location:i}=ke(),d=h.useRef(null);h.useEffect(()=>{if(!r||d.current===i.pathname)return;d.current=i.pathname;const a={};if(!c.has(l)){const y=o();y&&(a[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(a,y)}Object.keys(a).length!==0&&io(a,s)},[i.pathname,r])}const ao=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(O.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,kr=({onClear:r,onRemove:t})=>e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(F.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:180},children:[e.jsx(O.MenuItem,{startIcon:e.jsx(F.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(O.MenuItem,{intent:"danger",startIcon:e.jsx(F.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),ho=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},$t=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Rt=r=>{const t=ho(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:$t(t,-l,r.period),to:t}:{from:t,to:$t(t,l,r.period)}},el=24,rl=r=>r.length>el?`${r.slice(0,el)}...`:r,Br=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),mr={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"},fo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],tt={past:"Past",next:"Next",this:"This"},go=["day","week","month","year"],uo=["past","next","this"],yo=r=>r.field.type==="date-compact"?e.jsx(bo,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(po,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),po=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?Br(new Date(t)):null,s=!!c,i=s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:rl(c)})]}):r.label;return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s?e.jsx(F.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:d=>d==null?n():l(d),withPadding:!1})})})]})},Co=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${mr[r.op]} ${Br(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${Br(new Date(r.from))} - ${Br(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${tt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return mr[r.op];default:return null}},bo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=(t==null?void 0:t.op)??"is",s=t?Co(t):null,i=!!s,d=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:rl(s)})]}):r.label,a=y=>{if(y!==c){if(y==="is-empty"||y==="is-not-empty"){l({op:y});return}if(y==="is-relative-to-today"){l({op:y,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(y==="is-between"){l({op:y,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:y,date:t==null?void 0:t.date})}};return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(F.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(O.MenuLists,{children:[e.jsx(O.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(vo,{op:c,onChange:a})]}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsx(xo,{value:t,op:c,onChange:l})}),c==="is-relative-to-today"&&e.jsx(O.MenuFooter,{children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},vo=({op:r,onChange:t})=>e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:mr[r]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:200},children:fo.map(l=>e.jsx(O.MenuItem,{selected:r===l,onClick:()=>t(l),endIcon:r===l?e.jsx(F.Icon,{name:"Check"}):void 0,children:mr[l]},l))})})]}),xo=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:s}=o;if(!c&&s&&(c=s,s=null),!c&&!s){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:s?s.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(wo,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},wo=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",s=Rt({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:tt[l]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:uo.map(i=>e.jsx(O.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:o}:{direction:i,count:n,period:o}),children:tt[i]},i))})})]}),c&&e.jsx(Ge.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const d=Number(i.target.value);t({direction:l,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:go.map(i=>e.jsx(O.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:i}:{direction:l,count:n,period:i}),children:i},i))})})]})]}),e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:s,onChange:()=>{},withPadding:!1},"relative-preview")]})},tl=18,Do=r=>r.length>tl?`${r.slice(0,tl)}...`:r,So=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",s=t.length,[i,d]=h.useState(""),a=r.options,y=typeof r.onSearch=="function",C=(()=>{if(y)return a;const B=i.trim().toLowerCase();return B?a.filter(M=>M.label.toLowerCase().includes(B)):a})(),p=B=>t.some(M=>M.value===B.value),x=B=>{if(!c){l([{label:B.label,value:B.value}]),d("");return}l(p(B)?t.filter(M=>M.value!==B.value):[...t,{label:B.label,value:B.value}])},I=B=>{var M;d(B),(M=r.onSearch)==null||M.call(r,B)},b=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:s===1?Do(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(F.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(rr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:i,onSearch:I,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):C.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):C.map(B=>e.jsx(O.MenuItem,{closeOnSelect:!c,selected:p(B),startIcon:B.avatar,endIcon:p(B)?e.jsx(F.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>x(B),children:B.label},B.value))})]})})})]})},ll=18,ko=r=>r.length>ll?`${r.slice(0,ll)}...`:r,ol=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(nr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),Bo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(p=>p.value)),s=t.length,i=r.options.length>0&&r.options.every(p=>c.has(p.value)),d=s>0&&!i,a=p=>{l(c.has(p.value)?t.filter(x=>x.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{l(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},C=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(S.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(S.Text,{as:"span",children:s===1?ko(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(F.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:C})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:[e.jsx(O.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(ol,{checked:i||d,indeterminate:d}),children:"Select All"}),r.options.map(p=>e.jsx(O.MenuItem,{closeOnSelect:!1,selected:c.has(p.value),onClick:()=>a(p),startIcon:e.jsx(ol,{checked:c.has(p.value)}),children:p.label},p.value))]})})]})},nl=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(s=>{const i=t[s];if(!i)return null;const d=l(i),a=i.locked?void 0:()=>c(s);return i.type==="date"||i.type==="date-compact"?e.jsx(yo,{field:i,value:d,onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):i.type==="checkbox-multiple"?e.jsx(Bo,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):e.jsx(So,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s)})}),cl=r=>`${r} Rows`,mo=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:s=!0,showPagination:i=!0})=>{var M;const{searchQueries:d,setSearchParams:a,searchParams:y}=ke(),C=y.get(l),p=C?Number(C):o,x=W=>{a({...d,[t]:String(W)})},I=W=>{a({...d,[l]:W,[t]:"1"})},b=(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),B=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${b}-${B} of ${((M=r==null?void 0:r.totalData)==null?void 0:M.toLocaleString())||0}`}),s&&e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:cl(p)})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:n.map(W=>e.jsx(O.MenuItem,{selected:W===p,onClick:()=>I(String(W)),children:cl(W)},W))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(hr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function Fo(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var i;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,s=(i=c==null?void 0:c.tagName)==null?void 0:i.toLowerCase();s==="input"||s==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const Eo=240,il=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:s,setSearchParams:i,searchQueries:d}=ke(),a=Dr(r,s,t)||"",[y,C]=h.useState(!c||!!a),[p,x]=h.useState(c&&!a),[I,b]=h.useState(a),B=ge.useDebounce(I,350),M=h.useRef(null);h.useEffect(()=>{b(a),a&&C(!0)},[a]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{B!==a&&gr({value:B,name:r,type:"search",searchQueries:d,setSearchParams:i,filterKey:t,pageKey:l})},[B]);const W=h.useCallback(()=>{C(!0),requestAnimationFrame(()=>{var z;return(z=M.current)==null?void 0:z.focus()})},[]);Fo(o,W);const k=()=>{c&&!I&&C(!1)},D=z=>{var w;c&&z.key==="Escape"&&!I&&(C(!1),(w=M.current)==null||w.blur())},V=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:W}),e.jsxs(u.Box,{onTransitionEnd:V,style:{position:"relative",width:y?Eo:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Ge.Input,{ref:M,size:"sm",fullWidth:!0,value:I,placeholder:n,leftIcon:e.jsx(F.Icon,{name:"Search",width:16,height:16}),onChange:z=>b(z.target.value),onKeyDown:D,onBlur:k,tabIndex:y?0:-1}),y&&!I&&e.jsx(u.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(S.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},sl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,s]=h.useState(null),[i,d]=h.useState(null),a=()=>{c!==null&&i!==null&&c!==i&&n(c,i),s(null),d(null)},y=(C,p)=>{const x=C+p;x<0||x>=r.length||n(C,x)};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(P.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((C,p)=>{const x=!C.locked,I=i===p&&c!==null&&c!==p;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&s(p),onDragOver:b=>{b.preventDefault(),d(p)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:I?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${C.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:b=>{x&&(b.key==="ArrowUp"?(b.preventDefault(),y(p,-1)):b.key==="ArrowDown"&&(b.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(F.Icon,{name:"DragVertical",width:16,height:16})}),C.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:C.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(or.Toggle,{size:"sm",checked:C.visible,disabled:C.locked,onChange:()=>l(C.key),"aria-label":`Toggle ${C.title} column`})})]},C.key)})})]})})})]})},al=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),s=()=>{const i=o.trim();i&&(n(i),c(""))};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(F.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(O.MenuLists,{style:{width:"260px"},children:[e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(S.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(O.MenuItem,{startIcon:e.jsx(F.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(P.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:d=>{d.stopPropagation(),l(i.id)}}),children:i.name},i.id))})]})}),e.jsx(O.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Ge.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:i=>c(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}})}),e.jsx(P.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:s,children:"Save"})]})})]})]})},Mo=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:i,getValue:d,setValue:a,clearValue:y,removeFilter:C})=>{const p=n.length;return e.jsx(pr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(S.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(P.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(nl,{activeKeys:n,configByKey:o,getValue:d,setValue:a,clearValue:y,removeFilter:C})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const I=n.includes(x.key),b=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:b?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(S.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(or.Toggle,{size:"sm",checked:I||b,disabled:b,onChange:()=>s(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:i,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},Lo=r=>`${r} Rows`,To=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:s,searchParams:i}=ke(),d=i.get(r),a=d?Number(d):n,y=C=>{s({...c,[r]:C,[t]:"1"})};return o?e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(C=>e.jsx(O.MenuItem,{selected:C===a,endIcon:C===a?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>y(String(C)),children:Lo(C)},C))]})})]}):null},Io=r=>{var be;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:s,removeFilter:i,getValue:d,setValue:a,clearValue:y,onReset:C,searchable:p,searchKey:x,filterKey:I,pageKey:b,searchPlaceholder:B,searchShortcut:M,searchCollapsible:W,pagination:k,perPageKey:D,pageSizeOptions:V,defaultPerPage:z,showPagination:w,showResultCount:L,showPageSize:_,hasColumns:N,orderedColumns:G,allVisible:Y,onToggleVisibility:ne,onReorder:ye,onSetAllHidden:le,showSavedViews:de,savedViews:$,onApplyView:R,onDeleteView:fe,onSaveView:te}=r,[se,Be]=h.useState(!1),{searchQueries:je,setSearchParams:pe}=ke(),me=(k==null?void 0:k.rangeStart)??(((k==null?void 0:k.currentPage)||0)>1?(((k==null?void 0:k.currentPage)||0)-1)*((k==null?void 0:k.perPage)||0)+1:1),Le=(k==null?void 0:k.rangeEnd)??((k==null?void 0:k.totalCurrentPage)!==(k==null?void 0:k.perPage)?k==null?void 0:k.totalData:((k==null?void 0:k.currentPage)||1)*((k==null?void 0:k.totalCurrentPage)||0)),Ce=Me=>{pe({...je,[b]:String(Me)})},We=L||w&&!!(k!=null&&k.totalPage),qe=()=>{C(),Be(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(il,{searchKey:x,filterKey:I,pageKey:b,placeholder:B,shortcut:M,collapsible:W}),e.jsx(P.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"FilterHorizontal"}),onClick:()=>Be(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[de&&e.jsx(al,{views:$,onApply:R,onDelete:fe,onSave:te}),N&&e.jsx(sl,{columns:G,allVisible:Y,onToggle:ne,onReorder:ye,onSetAllHidden:le}),e.jsx(To,{perPageKey:D,pageKey:b,pageSizeOptions:V,defaultPerPage:z,showPageSize:_})]})]}),We&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[L?e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${me}-${Le} of ${((be=k==null?void 0:k.totalData)==null?void 0:be.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),w&&!!(k!=null&&k.totalPage)&&e.jsx(hr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:k!=null&&k.currentPage?Number(k.currentPage):1,totalPages:Number(k.totalPage),onPageChange:Ce})]}),e.jsx(Mo,{isOpen:se,onClose:()=>Be(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:qe,getValue:d,setValue:a,clearValue:y,removeFilter:i})]})},Oo=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:s=[25,50,100],defaultPerPage:i,showPagination:d=!0,showResultCount:a=!0,showPageSize:y=!0,searchable:C=!1,searchKey:p="q",searchPlaceholder:x="Search",searchShortcut:I="/",searchPosition:b="right",searchCollapsible:B=!0,pagination:M,columns:W=[],onColumnsChange:k,columnsState:D,scopeId:V,savedViews:z,persistLastState:w=!0,storage:L=$r,onReset:_})=>{const N=V??(z==null?void 0:z.scopeId),{activeKeys:G,configByKey:Y,hasActiveFilter:ne,toggleFilter:ye,removeFilter:le,getValue:de,setValue:$,clearValue:R,clearAll:fe}=Kr({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:p}),te=lo({columns:W,scopeId:N,storage:L,onColumnsChange:k,value:D}),se=oo({scopeId:N,storage:L,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>te.state,applyColumns:te.applyState}),Be=no({scopeId:N,storage:L,snapshotKeys:[n,l,o],enabled:w}),je=co({scopeId:N,storage:L,perPageKey:c,pageSizeOptions:s,enabled:w});so({enabled:w&&!!N,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Be.read,readPerPage:je.read});const pe=i??s[0]??25,me=!!(z!=null&&z.enabled)&&se.enabled,Le=()=>{fe(),Be.clear(),_==null||_()},Ce=ge.useMediaQuery("md"),We=C?e.jsx(il,{searchKey:p,filterKey:l,pageKey:o,placeholder:x,shortcut:I,collapsible:B}):null;return Ce?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(ao,{configs:t,activeKeys:G,onToggle:ye,hasActiveFilter:ne,onReset:Le}),b==="left"&&We,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(nl,{activeKeys:G,configByKey:Y,getValue:de,setValue:$,clearValue:R,removeFilter:le}),ne&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"sm",onClick:Le,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(mo,{pagination:M,pageKey:o,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y}),b==="right"&&We,me&&e.jsx(al,{views:se.views,onApply:se.applyView,onDelete:se.deleteView,onSave:se.saveView}),W.length>0&&e.jsx(sl,{columns:te.orderedColumns,allVisible:te.allVisible,onToggle:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden})]})]}):e.jsx(Io,{withPadding:r,configs:t,activeKeys:G,configByKey:Y,hasActiveFilter:ne,toggleFilter:ye,removeFilter:le,getValue:de,setValue:$,clearValue:R,onReset:Le,searchable:C,searchKey:p,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:I,searchCollapsible:B,pagination:M,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y,hasColumns:W.length>0,orderedColumns:te.orderedColumns,allVisible:te.allVisible,onToggleVisibility:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden,showSavedViews:me,savedViews:se.views,onApplyView:se.applyView,onDeleteView:se.deleteView,onSaveView:se.saveView})},Wo=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},Ao=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},zo=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Wo(t);case"dropdown-multiple":case"checkbox-multiple":return Ao(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},dl=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},Vo=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:s="q",defaultPage:i=1,defaultPerPage:d=10,paramKeys:a,serialize:y}=r,{activeKeys:C,configByKey:p,hasActiveFilter:x,getValue:I}=Kr({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:s}),{searchParams:b}=ke(),B=b.toString();return h.useMemo(()=>{const W={},k={},D=dl(b.get(o),i),V=dl(b.get(c),d);W[(a==null?void 0:a.page)??"page"]=D,W[(a==null?void 0:a.perPage)??"perPage"]=V;const z=Dr(s,b,l)||"";z&&(W[(a==null?void 0:a.search)??"search"]=z);let w=!1;for(const L of C){const _=p[L];if(!_)continue;const N=I(_);k[L]=N;const G=y==null?void 0:y[L],Y=G?G(N):zo(_,N);if(Y==null||Array.isArray(Y)&&Y.length===0)continue;const ne=(a==null?void 0:a[L])??L;W[ne]=Y,w=!0}return{params:W,raw:k,hasActiveFilter:x||!!z||w}},[B,C.join("|"),l,n,o,c,s,i,d,a,y,p])},Ho=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Po=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:s,setValue:i,removeFilter:d,clearAll:a,hasActiveFilter:y}=Kr({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),C=(M,W)=>{var D;const k=M.options;return((D=k==null?void 0:k.find(V=>V.value===W))==null?void 0:D.label)??W},p=h.useCallback(M=>{const W=c[M];if(!W)return[];const k=s(W);return Array.isArray(k)?k.map(D=>String(D.value)):[]},[c,s]),x=h.useCallback((M,W)=>{const k=c[M];if(!k||!Ho.includes(k.type))return;const D=Array.isArray(W)?W:[W];if(D.length===0){d(M);return}i(k,D.map(V=>({label:C(k,V),value:V})))},[c,i,d]),I=h.useCallback((M,W)=>{const k=p(M);x(M,k.includes(W)?k.filter(D=>D!==W):[...k,W])},[p,x]),b=h.useCallback((M,W)=>p(M).includes(W),[p]),B=h.useCallback(M=>d(M),[d]);return{set:x,toggle:I,clear:B,clearAll:a,isActive:b,values:p,hasActiveFilter:y}},jo=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:s,to:i}=Rt(r.relative);return c[l]=s.toISOString(),c[n]=i.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},hl=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const s=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;c(`calc(100vh - ${i}px)`)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},fl=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const s=ge.useMediaQuery("md"),i=c?e.jsx(Kt,{...o}):null,d=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:s?"row":"column",gap:"8px",width:s?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:a,icon:y,buttonProps:C,onClick:p},x)=>!a&&!y?null:e.jsx(P.Button,{fullWidth:!s,iconLeft:y?e.jsx(F.Icon,{name:y}):void 0,onClick:p,...C,children:a},`action-${x}`))}):null;return e.jsx(u.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:s?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,d()]})]})})},No=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(Oe.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Oe.Body1,{children:r||0})]}),gl=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:s,setSearchParams:i,searchParams:d}=ke(),a=d.get(l),y=I=>{i({...s,[t]:String(I)})},C=I=>{i({...s,[l]:I,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(S.Text,{children:"Rows Per Page: "}),e.jsx(rr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:I=>{C(I[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(S.Text,{children:`${p}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(hr.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(No,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},ul=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),s=h.useRef(null),[i,d]=h.useState(""),[a,y]=h.useState({top:0,left:0}),C=r.selectedValues,p=h.useMemo(()=>i?r.options.filter(b=>b.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);h.useEffect(()=>{if(l&&c.current){const b=c.current.getBoundingClientRect(),B=280,M={top:b.bottom+8};r.position==="left"||b.left+B>window.innerWidth?M.right=window.innerWidth-b.right:M.left=b.left,y(M)}},[l,r.position]),h.useEffect(()=>{l&&s.current?setTimeout(()=>{var b;return(b=s.current)==null?void 0:b.focus()},50):d("")},[l]),h.useEffect(()=>{const b=B=>{o.current&&!o.current.contains(B.target)&&c.current&&!c.current.contains(B.target)&&n(!1)};return l&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const x=b=>{const B=C.includes(b)?C.filter(M=>M!==b):[...C,b];r.onFilterChange(B)},I=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:b=>{var B;b.stopPropagation(),l||(B=r.onOpen)==null||B.call(r),n(M=>!M)},children:e.jsx(F.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:C.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.Box,{ref:o,style:{position:"fixed",top:`${a.top}px`,...a.left!==void 0?{left:`${a.left}px`}:{right:`${a.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(S.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),C.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(S.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:b=>{b.stopPropagation(),I()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Ge.Input,{ref:s,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(F.Icon,{name:"Search",size:"sm"}),value:i,onChange:b=>d(b.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(F.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(b=>e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:C.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:B=>{B.stopPropagation(),x(b.value)},onMouseEnter:B=>{C.includes(b.value)||(B.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),B.currentTarget.style.transform="translateX(2px)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor=C.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",B.currentTarget.style.transform="translateX(0)"},children:[e.jsx(nr.Checkbox,{checked:C.includes(b.value),onChange:()=>{}}),e.jsx(S.Text,{fontSize:"sm",fontWeight:C.includes(b.value)?"medium":"normal",color:C.includes(b.value)?"primary":"gray-700",children:b.label})]},b.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(F.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),C.length>0&&e.jsx(u.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:C.length}),e.jsxs(S.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",C.length>1?"s":""," selected"]})]})})]})]})},_o=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,s=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:c,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:s},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},qo=({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"})]}),lt="var(--sa-background-primary, #ffffff)",yl="var(--sa-background-primary-inverse, #f8f8f8)",pl=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:s,visibleHandleUpdate:i,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:y,frozenCount:C=0,onFrozenCountChange:p,customActions:x,actionsOrder:I=["detail","update","delete","custom"],customEmptyState:b,enableColumnResize:B=!1,defaultColumnWidths:M,onColumnWidthsChange:W,defaultMinColumnWidth:k=60,sort:D,defaultSort:V,onSortChange:z,showActionDivider:w=!1})=>{const L=D!==void 0,[_,N]=h.useState(V??null),G=L?D??null:_,Y=T=>{if(T.sortKey)return T.sortKey;if(typeof T.accessor=="string")return T.accessor},ne=T=>{const H=Y(T);if(!H)return;let j;!G||G.key!==H?j={key:H,direction:"asc"}:G.direction==="asc"?j={key:H,direction:"desc"}:j=null,L||N(j),z==null||z(j)},le=[l,n,o].filter(T=>T!==void 0).length,de=!!x,$=!!l||!!n||!!o||de,R="var(--sa-border-subtle, #0b120e24)",fe=`1px solid ${R}`,te=`inset 1px 0 0 ${R}`,se=`inset -1px 0 0 ${R}`,Be=le===3?de?"178px":"140px":le===2?de?"140px":"102px":le===1?de?"112px":"74px":de?"74px":"",je=(T,H)=>{if(!H)return T;if(typeof H=="function")return H(T);if(typeof H=="string")return T[H]},[pe,me]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const T=y.current;me(T.scrollHeight>T.clientHeight)},[t,y]);const Le=h.useRef(null),[Ce,We]=h.useState([]),[qe,be]=h.useState(()=>M??{}),Me=h.useRef(null);h.useLayoutEffect(()=>{if(!C||!Le.current){We([]);return}const T=Array.from(Le.current.querySelectorAll("thead tr th")),H=[];let j=0;T.forEach((Z,K)=>{H[K]=j,K<C&&(j+=Z.offsetWidth)}),We(H)},[C,r,t,qe]);const Je=T=>{p&&p(T<C?T:T+1)},m=(T,H)=>{const j=qe[T];if(j!==void 0){const Z=`${j}px`;return{width:Z,minWidth:Z,maxWidth:Z}}return H?{width:H}:{}},Q=T=>B&&(T.resizable??!0),q=(T,H)=>{T.preventDefault(),T.stopPropagation();const j=T.currentTarget.closest("th");if(!j)return;const Z=Math.round(j.getBoundingClientRect().width);Me.current={colIndex:H,startX:T.clientX,startWidth:Z};const K=document.body.style.userSelect,xe=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=ze=>{var Ke;const Te=Me.current;if(!Te)return;const Ye=((Ke=r[Te.colIndex])==null?void 0:Ke.minWidth)??k,Xe=Math.max(Ye,Te.startWidth+(ze.clientX-Te.startX));be(Ve=>Ve[Te.colIndex]===Xe?Ve:{...Ve,[Te.colIndex]:Xe})},Ae=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ae),document.body.style.userSelect=K,document.body.style.cursor=xe,Me.current=null,W&&be(ze=>(W(ze),ze))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ae)};return e.jsx("div",{ref:Le,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((T,H)=>{var ir,sr;const j=C>0&&H<C,Z=Ce[H]??0,K=Q(T),Fe=H===r.length-1&&$&&w,Ae=Y(T),ze=!!T.sortable&&!!Ae,Te=ze&&(G==null?void 0:G.key)===Ae?G.direction:null,Ye=T.title||((ir=T.accessor)==null?void 0:ir.toString())||"",Xe=(sr=T.headerTooltip)!=null&&sr.showIcon?e.jsx(F.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ke=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ye}),Ve=ze?e.jsxs("button",{type:"button",onClick:()=>ne(T),title:Te==="asc"?"Sorted ascending — click to sort descending":Te==="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:T.textAlign==="text-right"?"right":T.textAlign==="text-center"?"center":"left"},children:[Ke,Xe,e.jsx(_o,{direction:Te})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ke,Xe]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:j?Z:void 0,zIndex:j?4:2,paddingLeft:H===0?"12px":"",borderRight:a&&!Fe&&!j?fe:void 0,borderBottom:a?fe:void 0,boxShadow:a&&j?se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:T.textAlign==="text-right"?"right":T.textAlign==="text-center"?"center":"left",...m(H,T.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[T.headerTooltip?e.jsx(De.Tooltip,{label:T.headerTooltip.content,position:"bottom",children:Ve}):Ve,T.filter&&e.jsx(ul,{filter:T.filter,columnTitle:T.title}),p&&e.jsx("button",{onClick:()=>Je(H),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(qo,{frozen:j})})]}),K&&e.jsx("div",{onMouseDown:ar=>q(ar,H),onClick:ar=>ar.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-${H}`)}),$?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?fe:void 0,boxShadow:a&&w?te:void 0}}):null]})}),e.jsx(U.Tbody,{children:c?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&b?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:b})}):t==null?void 0:t.map((T,H)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:H===t.length-1&&pe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:j=>{const Z=j.currentTarget;Z.style.backgroundColor=yl,Array.from(Z.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=yl)})},onMouseLeave:j=>{const Z=j.currentTarget;Z.style.backgroundColor="",Array.from(Z.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=lt)})},children:[r.map((j,Z)=>{const K=j.render?j.render(T,H,t):je(T,j.accessor),xe=C>0&&Z<C,Fe=Ce[Z]??0,Ae=qe[Z]!==void 0,ze=xe&&Z===C-1;return e.jsx(U.Td,{style:{position:xe?"sticky":void 0,left:xe?Fe:void 0,zIndex:xe?1:void 0,backgroundColor:xe?lt:void 0,transition:xe?"background-color 0.3s ease":void 0,paddingLeft:Z===0?"12px":"",whiteSpace:"nowrap",overflow:Ae?"hidden":void 0,borderLeft:j.showBorderLeft?fe:void 0,borderRight:j.showBorderRight?fe:void 0,boxShadow:ze?se:void 0,textAlign:j.textAlign==="text-right"?"right":j.textAlign==="text-center"?"center":"left",...m(Z,j.width)},children:typeof K=="string"?e.jsx(S.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:j.textAlign==="text-right"?"right":j.textAlign==="text-center"?"center":"left"},children:K}):K},`row-${H}-col-${Z}`)}),$?e.jsx(U.Td,{style:{width:Be,position:"sticky",right:0,zIndex:1,backgroundColor:lt,boxShadow:w?te:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ce.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:I.map(j=>{const Z=H===t.length-1?"top":"bottom";return j==="detail"&&l&&(d==null?void 0:d(T))!==!1?e.jsx(De.Tooltip,{label:"Detail",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(T.id,T),iconLeft:e.jsx(F.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):j==="update"&&n&&(i==null?void 0:i(T))!==!1?e.jsx(De.Tooltip,{label:"Update",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(T),iconLeft:e.jsx(F.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):j==="delete"&&o&&(s==null?void 0:s(T))!==!1?e.jsx(De.Tooltip,{label:"Delete",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(T.id,T),iconLeft:e.jsx(F.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):j==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(T)},"custom"):null})})}):null]},`${T}${H}`))})]})})},Zo=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var C;const o=h.useRef(null),[c,s]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(l==null?void 0:l.show)??!0,d=h.useRef(null),a=(C=t==null?void 0:t.pagination)==null?void 0:C.totalData;typeof a=="number"&&(d.current=a);const y=(n==null?void 0:n.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(hl,{...r,children:[i&&e.jsx(fl,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(pl,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?s:void 0}):null}),y&&e.jsx(gl,{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 Go(r){return h.memo(r)}const Qo=Go(Zo),Cl=200,ot="1px solid var(--sa-border-subtle, #0b120e24)",Uo=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(F.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(F.Icon,{name:"ChevronSmallDown"}):t?e.jsx(F.Icon,{name:"LockOn",size:"xs"}):e.jsx(F.Icon,{name:"Filter",size:"xs"}),Fr=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"var(--sa-color-error-600, #c9184a)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:s=>{s.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(F.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(S.Text,{as:"span",style:{color:c},children:t})]})},bl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:s,onToggleFreeze:i,onHide:d})=>{const[a,y]=h.useState(!1),C=h.useRef(null),p=h.useRef(null),[x,I]=h.useState({top:0,left:0});h.useEffect(()=>{if(a&&C.current){const B=C.current.getBoundingClientRect(),M=B.left+Cl>window.innerWidth;I({top:B.bottom+6,...M?{right:window.innerWidth-B.right}:{left:B.left}})}},[a]),h.useEffect(()=>{if(!a)return;const B=M=>{p.current&&!p.current.contains(M.target)&&C.current&&!C.current.contains(M.target)&&y(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[a]);const b=B=>{B(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:C,type:"button",className:"sa-tl-menu-trigger","data-active":r||a?"true":"false",onClick:B=>{B.stopPropagation(),y(M=>!M)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:ot,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Uo,{sortDir:n,frozen:o})}),a&&e.jsxs(u.Box,{ref:p,onClick:B=>B.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:Cl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:ot,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Fr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>b(()=>n==="asc"?s():c("asc"))}),e.jsx(Fr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>b(()=>n==="desc"?s():c("desc"))}),e.jsx("div",{style:{borderTop:ot,margin:"4px 0"}})]}),e.jsx(Fr,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>b(i)}),l&&e.jsx(Fr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>b(d)})]})]})},Er="1px solid var(--sa-border-subtle, #0b120e24)",Jo="var(--sa-text-subtle, #8c8f97)",ur="var(--sa-background-neutral, #f0f1f2)",vl="2px 0 4px -2px rgba(0,0,0,0.15)",Mr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},xl="sa-table-layout-styles",Yo=()=>{if(typeof document>"u"||document.getElementById(xl))return;const r=document.createElement("style");r.id=xl,r.textContent=`
|
|
1
|
+
(function(g,Re){typeof exports=="object"&&typeof module<"u"?Re(exports,require("@starasia/alert"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-router"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-router","react-dom","react-easy-crop"],Re):(g=typeof globalThis<"u"?globalThis:g||self,Re(g["@starasia/admin"]={},g.alert,g.badges,g.box,g.breadcrumb,g.button,g.card,g.date,g.dialog,g.drawer,g.dropdown,g.hooks,g.http,g.input,g.menu,g.pagination,g.storage,g.table,g.tabs,g.textarea,g.theme,g.toast,g.toggle,g.tooltip,g.checkbox,g.radio,g.text,g.icon,g.flex,g.grid,g.progress,g.stepper,g.accordion,g.storyRecord,g.skeleton,g.progressStepper,g.jsxRuntime,g.React,g.ReactRouter,g.ReactDOM,g.ReactEasyCrop))})(this,function(g,Re,Ze,u,er,P,gt,Qe,Ie,pr,rr,ge,tr,Ge,O,hr,fr,U,ut,Pr,lr,yt,or,De,nr,jr,S,F,ce,pt,Ct,bt,vt,xt,He,wt,e,h,ue,Nr,Ll){"use strict";const Tl={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},_r=h.createContext(Tl),qr=()=>h.useContext(_r),Dt=r=>{const[t,l]=h.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:l}},St=h.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),kt=({children:r})=>{const[t,l]=h.useState({}),n=h.useCallback(i=>{l(d=>typeof i=="function"?i(d):i)},[]),o=h.useCallback((i,d)=>{l(a=>{const y=typeof d=="function"?d(a[i]):d;return{...a,[i]:y}})},[]),c=h.useCallback(i=>{l(d=>{if(!(i in d))return d;const a={...d};return delete a[i],a})},[]),s=h.useMemo(()=>({badges:t,setBadge:o,setBadges:n,clearBadge:c}),[t,o,n,c]);return e.jsx(St.Provider,{value:s,children:r})},Bt=()=>h.useContext(St),Cr=(r,t)=>{const l=t!==void 0?t:r;return l==null?null:typeof l=="string"||typeof l=="number"?{value:l}:l},mt=({router:r,menus:t=[],menuBottom:l,logo:n,appName:o="Workspace",initialUserData:c,theme:s})=>{const i=Dt({initialUserData:c}),{theme:d}=lr.useTheme();return e.jsx(_r.Provider,{value:{logo:n,appName:o,menus:t,userData:i.userData,setUserData:i.setUserData,menuBottom:l},children:e.jsx(kt,{children:s?e.jsx(lr.ThemeProvider,{value:s,children:r}):d?e.jsx(lr.ThemeProvider,{value:d,children:r}):r})})},Il=h.memo(mt);function Ft({collapsed:r=!1,children:t}){if(!t)return null;const l=typeof t=="function",n=l?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"4rem",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:"0.5rem",paddingRight:"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:l?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const Zr=h.createContext(null);function Et({children:r}){const[t,l]=h.useState(null),[n,o]=h.useState(null),[c,s]=h.useState(null),[i,d]=h.useState(0),a=h.useCallback(()=>(d(y=>y+1),()=>d(y=>y-1)),[]);return e.jsx(Zr.Provider,{value:{prependNode:t,appendNode:n,replaceNode:c,setPrependNode:l,setAppendNode:o,setReplaceNode:s,replaceCount:i,registerReplace:a},children:r})}function Mt({children:r}){const t=h.useContext(Zr);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 Ol({children:r,mode:t="append"}){const l=h.useContext(Zr);if(h.useEffect(()=>{if(!(t!=="replace"||!l))return l.registerReplace()},[t,l]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?l.prependNode:t==="replace"?l.replaceNode:l.appendNode;return n?Nr.createPortal(r,n):null}const Gr=h.createContext(null);function Lt({children:r}){const[t,l]=h.useState({}),[n,o]=h.useState({}),c=h.useCallback((d,a)=>{l(y=>y[d]===a?y:{...y,[d]:a})},[]),s=h.useCallback(d=>(o(a=>({...a,[d]:(a[d]??0)+1})),()=>o(a=>({...a,[d]:Math.max(0,(a[d]??0)-1)}))),[]),i=h.useMemo(()=>({outletNodes:t,setOutletNode:c,slotCounts:n,registerSlot:s}),[t,c,n,s]);return e.jsx(Gr.Provider,{value:i,children:r})}function Tt({slotKey:r,fallback:t}){const l=h.useContext(Gr),n=l?(l.slotCounts[r]??0)>0:!1,o=h.useRef(l==null?void 0:l.setOutletNode);o.current=l==null?void 0:l.setOutletNode;const c=h.useCallback(s=>{var i;return(i=o.current)==null?void 0:i.call(o,r,s)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:c,style:{display:"contents"}}):t})}function Wl({slotKey:r,children:t}){const l=h.useContext(Gr),n=h.useRef(l==null?void 0:l.registerSlot);if(n.current=l==null?void 0:l.registerSlot,h.useEffect(()=>{var c;return(c=n.current)==null?void 0:c.call(n,r)},[r]),!l)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const o=l.outletNodes[r];return o?Nr.createPortal(t,o):null}const br="moduleSwitcherGroupId",Qr="sa-module-switcher-change";function It(){if(typeof window>"u")return null;const r=window.localStorage.getItem(br);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function Ot(r){typeof window>"u"||(r===null?window.localStorage.removeItem(br):window.localStorage.setItem(br,String(r)),window.dispatchEvent(new CustomEvent(Qr,{detail:r})))}function Al(){Ot(null)}function Ur(){const[r,t]=h.useState(()=>It());return h.useEffect(()=>{const n=()=>{t(It())},o=c=>{c.key===br&&n()};return window.addEventListener(Qr,n),window.addEventListener("storage",o),()=>{window.removeEventListener(Qr,n),window.removeEventListener("storage",o)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{Ot(n),t(n)}}}let vr=0,Ue=!1,Wt=new Set;const At=()=>e.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"1.667",y:"1.667",width:"12.667",height:"12.667",rx:"2"}),e.jsx("line",{x1:"6",y1:"1.667",x2:"6",y2:"14.333"})]}),zt={width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",paddingLeft:"0.75rem",paddingRight:"0.75rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",fontSize:"0.875rem",color:"var(--sa-text-subtle, #8c8f97)",background:"transparent",border:"none",borderRadius:"0.375rem",cursor:"pointer",textAlign:"left"};function zl({children:r,headerLeftSlot:t,profile:l,isLoadingProfile:n,onLogout:o,isLoggingOut:c,loadingComponent:s,sidebarHeaderContent:i,headerActions:d,profileRole:a,profileMenuButtons:y,profileMenuItems:C,logoutButton:p}){var Me,Je;const[x]=ue.useSearchParams(),I=x.get("embed")==="true",b=qr(),{badges:B}=Bt(),M=ue.useNavigate(),W=ue.useLocation(),D=!ge.useMediaQuery("md"),[V,z]=h.useState(!1),[w,L]=h.useState(!1),[_,N]=h.useState(!1),[G,Y]=h.useState(!1),[ne,ye]=h.useState(()=>new Set(Wt)),[le,de]=h.useState(null),{selectedGroupId:$,setSelectedGroupId:R}=Ur();h.useEffect(()=>{Wt=ne},[ne]);const fe=h.useRef(null),te=h.useRef(null);h.useEffect(()=>{const m=fe.current;if(!m)return;const Q=()=>{Ue||(vr=m.scrollTop)};return m.addEventListener("scroll",Q),()=>m.removeEventListener("scroll",Q)},[]);const se=()=>{const m=fe.current;m&&vr>0&&(Ue=!0,m.scrollTop=vr,requestAnimationFrame(()=>{Ue=!1}))};h.useLayoutEffect(()=>{Ue=!0,se();const m=setTimeout(()=>{Ue=!1},300);return()=>clearTimeout(m)},[]),h.useLayoutEffect(()=>{b.menus.length>0&&(vr>0?se():requestAnimationFrame(()=>{var Q;const m=(Q=fe.current)==null?void 0:Q.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[b.menus]),h.useEffect(()=>{Ue=!0,se();const m=setTimeout(se,0),Q=setTimeout(se,50),q=setTimeout(se,100),T=setTimeout(se,200),H=setTimeout(()=>{Ue=!1},300),j=setTimeout(()=>{const Z=fe.current,K=Z==null?void 0:Z.querySelector("[data-menu-active='true']");if(Z&&K){const xe=Z.getBoundingClientRect(),Fe=K.getBoundingClientRect();Fe.top>=xe.top&&Fe.bottom<=xe.bottom||K.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(Q),clearTimeout(q),clearTimeout(T),clearTimeout(H),clearTimeout(j)}},[W.pathname]),h.useEffect(()=>{te.current&&(te.current.scrollTop=0)},[W.pathname]),h.useEffect(()=>{D&&N(!1)},[W.pathname,D]),h.useEffect(()=>{D&&L(!0)},[D]);const Be=()=>{z(!0)},je=()=>{z(!1)},pe=()=>{z(!1),o()},me=m=>{const Q=[m.to];return m.children&&Q.push(...m.children.map(q=>q.to)),Q},Le=[...b.menus.flatMap(m=>m.items.flatMap(me)),...((Me=b.menuBottom)==null?void 0:Me.flatMap(me))??[]],Ce=m=>{if(!W.pathname.startsWith(m))return!1;const Q=Le.filter(q=>W.pathname.startsWith(q)).sort((q,T)=>T.length-q.length)[0];return m===Q};h.useEffect(()=>{var Q;const m=q=>{var T;(T=q.children)!=null&&T.some(H=>W.pathname.startsWith(H.to))&&ye(H=>{const j=new Set(H);return j.add(q.id),j})};b.menus.forEach(q=>{q.items.forEach(m)}),(Q=b.menuBottom)==null||Q.forEach(m)},[W.pathname,b.menus,b.menuBottom]);const We=m=>{ye(Q=>{const q=new Set(Q);return q.has(m)?q.delete(m):q.add(m),q})};h.useEffect(()=>{b.menus.length!==0&&$!==null&&!b.menus.some(m=>m.id===$)&&R(null)},[b.menus,$,R]);const qe=h.useMemo(()=>{if($!==null)return b.menus.filter(q=>q.id===$||q.parentGroupId===$);const m=b.menus.filter(q=>q.parentGroupId===void 0),Q=b.menus.filter(q=>q.parentGroupId!==void 0).flatMap(q=>q.items);return Q.length===0?m:[...m,{id:18,name:"Pengaturan",items:Q,parentGroupId:void 0}]},[b.menus,$]);if(I)return e.jsx("main",{style:{height:"100vh",overflowY:"auto",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)"},children:r||e.jsx(ue.Outlet,{})});const be=m=>{const Q=m.children&&m.children.length>0,q=ne.has(m.id),T=Q?m.children.some(Z=>Ce(Z.to)):Ce(m.to),H=Cr(m.badge,B[m.id]),j=!!H&&w&&!D;return e.jsxs("div",{"data-menu-active":T||void 0,children:[e.jsxs("button",{onClick:Z=>{if(Q)if(w&&!D){const K=Z.currentTarget.getBoundingClientRect();de({item:m,top:K.top,left:K.right+8})}else We(m.id);else M(m.to)},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:w&&!D?"center":void 0,gap:"0.5rem",paddingLeft:w&&!D?"0":"0.5rem",paddingRight:w&&!D?"0":"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:T?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",border:T?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent",backgroundColor:T?"var(--sa-background-primary, #ffffff)":"transparent",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer"},title:w&&!D?m.title:void 0,onMouseEnter:Z=>{T||(Z.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Z=>{T||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsxs("span",{style:{position:"relative",display:"inline-flex",flexShrink:0},children:[e.jsx(F.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),j&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",top:"-2px",right:"-2px",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-error-500, #ff4d6d)",border:"1px solid var(--sa-background-primary, #ffffff)"}})]}),(!w||D)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",transition:"opacity 0.3s",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:m.title}),H&&e.jsx(Ze.Badges,{text:String(H.value),variant:H.variant??"info",size:"xs",border:!0}),Q&&e.jsx("svg",{style:{width:"1rem",height:"1rem",flexShrink:0,transition:"transform 0.2s",transform:q?"rotate(180deg)":"rotate(0deg)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),Q&&(!w||D)&&(()=>{const Z=m.children.findIndex(K=>Ce(K.to));return e.jsxs("div",{style:{position:"relative",marginLeft:"0.9375rem",paddingLeft:"1.125rem",overflow:"hidden",transition:"all 0.3s ease-in-out",maxHeight:q?`${m.children.length*36}px`:"0px",opacity:q?1:0,marginTop:q?"0.25rem":"0px"},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:0,width:"1.5px",height:"100%",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),Z>=0&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:`${Z*32}px`,width:"1.5px",height:"32px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none",zIndex:1}}),m.children.map(K=>{const xe=Cr(K.badge,B[K.id]);return e.jsxs("button",{onClick:()=>M(K.to),style:{width:"100%",display:"flex",alignItems:"center",gap:"0.5rem",paddingLeft:"0.75rem",paddingRight:"0.5rem",paddingTop:"0.25rem",paddingBottom:"0.25rem",height:"2rem",borderRadius:Ce(K.to)?"var(--sa-radii-sm, 0.375rem)":"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Ce(K.to)?"var(--sa-background-primary, #ffffff)":"transparent",color:Ce(K.to)?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",cursor:"pointer",border:Ce(K.to)?"1px solid var(--sa-border-subtle, #0b120e24)":"1px solid transparent"},onMouseEnter:Fe=>{Ce(K.to)||(Fe.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)")},onMouseLeave:Fe=>{Ce(K.to)||(Fe.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(F.Icon,{name:K.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:"500",whiteSpace:"nowrap",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:K.title}),xe&&e.jsx(Ze.Badges,{text:String(xe.value),variant:xe.variant??"info",size:"xs",border:!0})]},K.id)})]})})()]},m.id)};return e.jsx(Lt,{children:e.jsxs(Et,{children:[e.jsxs("div",{style:{display:"flex",height:"100vh",position:"relative","--app-sidebar-width":D?"0px":w?"4.375rem":"16.375rem","--app-footer-zindex":D&&_?"40":"999"},children:[D&&e.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"var(--sa-color-black-alpha-a50, #181a198f)",zIndex:40,opacity:_?.5:0,pointerEvents:_?"auto":"none",transition:"opacity 0.3s"},onClick:()=>N(!1)}),e.jsxs("aside",{style:{width:D?"16.375rem":w?"4.375rem":"16.375rem",position:D?"fixed":"relative",...D&&{inset:0,zIndex:50,transform:_?"translateX(0)":"translateX(-100%)"},backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",borderRight:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",flexDirection:"column",transition:"all 0.3s ease-in-out",flexShrink:D?void 0:0},children:[e.jsx("div",{onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),style:{height:"4rem",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",position:"relative"},children:(()=>{const m=!D&&w&&!_,Q=m&&G;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",flex:m?1:void 0,justifyContent:m?"center":void 0,transition:"opacity 0.2s",opacity:Q?0:1,pointerEvents:Q?"none":"auto"},children:[e.jsx("img",{src:b.logo,alt:"Logo",style:{width:"2rem",height:"2rem",flexShrink:0}}),(!w||_)&&e.jsx("span",{style:{fontWeight:"600",color:"var(--sa-text-primary, #292a2e)",whiteSpace:"nowrap",transition:"opacity 0.3s"},children:b.appName})]}),!D&&!w&&e.jsx("button",{type:"button",onClick:()=>L(!0),"aria-label":"Collapse sidebar",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1rem",height:"1rem",padding:0,background:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer",flexShrink:0},children:e.jsx(At,{})}),m&&e.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":"Expand sidebar",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2rem",height:"2rem",padding:0,background:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-sm, 0.375rem)",color:"var(--sa-text-primary, #292a2e)",cursor:"pointer",opacity:Q?1:0,pointerEvents:Q?"auto":"none",transition:"opacity 0.2s"},children:e.jsx("span",{style:{width:"1rem",height:"1rem",display:"inline-flex"},children:e.jsx(At,{})})}),D&&e.jsx("button",{onClick:()=>N(!1),"aria-label":"Close menu",style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.25rem",height:"1.25rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})()}),i&&e.jsx(Ft,{collapsed:D?!1:w,children:i}),e.jsx("div",{ref:fe,style:{flex:1,overflowY:"auto",paddingTop:"1rem",paddingBottom:"1rem"},children:qe.map(m=>e.jsxs("div",{style:{marginBottom:"1rem"},children:[!w||D?m.name&&e.jsx("div",{style:{paddingLeft:"1.5rem",paddingRight:"1rem",paddingTop:"0rem",paddingBottom:"0.25rem",fontSize:"0.875rem",fontWeight:"400",color:"var(--sa-text-subtlest, #6b6e76)",transition:"opacity 0.3s",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:m.name}):m.name&&e.jsx("div",{"aria-label":m.name,style:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"0.75rem",paddingBottom:"0.75rem"},children:e.jsx("span",{style:{display:"block",width:"1rem",height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx("div",{style:{paddingLeft:"1rem",paddingRight:"1rem",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)"},children:m.slotKey?e.jsx(Tt,{slotKey:m.slotKey,fallback:m.items.map(Q=>be(Q))}):m.items.map(Q=>be(Q))})]},m.id))}),b.menuBottom&&b.menuBottom.length>0&&e.jsx("div",{style:{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",paddingTop:"0.75rem",paddingBottom:"0.75rem",paddingLeft:"1rem",paddingRight:"1rem",backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",display:"flex",flexDirection:"column",gap:"var(--sa-spacing-xs, 0.25rem)",flexShrink:0},children:b.menuBottom.map(m=>be(m))})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:"4rem",backgroundColor:"var(--sa-background-primary, #ffffff)",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"1rem",paddingRight:"1rem",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[D&&e.jsx("button",{onClick:()=>N(!0),style:{padding:"0.375rem",borderRadius:"0.5rem",backgroundColor:"transparent",border:"none",color:"var(--sa-text-subtle, #8c8f97)",cursor:"pointer"},children:e.jsx("svg",{style:{width:"1.5rem",height:"1.5rem"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(Mt,{children:t})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[d,e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e.jsxs("div",{style:{textAlign:"right",maxWidth:"12.5rem"},children:[e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:500,color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"Loading...":(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n?"":(l==null?void 0:l.email)||"unknown"})]}),e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"0.875rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",flexShrink:0,backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx(F.Icon,{name:"ChevronDown",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})]})}),e.jsxs(O.MenuLists,{style:{width:"280px",paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(O.MenuHeading,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",paddingBlock:"0.5rem"},children:[e.jsx("div",{style:{width:"4rem",height:"4rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--sa-background-primary, #ffffff)",fontWeight:600,fontSize:"1.25rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)",marginBottom:"0.75rem",backgroundColor:"var(--sa-background-brand, #04254f)"},children:((l==null?void 0:l.name)||"U")[0].toUpperCase()}),e.jsx("p",{style:{margin:0,fontSize:"0.875rem",fontWeight:600,color:"var(--sa-text-primary, #292a2e)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.name)||"unknown"}),e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(l==null?void 0:l.email)||"unknown"}),a&&e.jsx("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--sa-text-subtle, #8c8f97)",maxWidth:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a})]})}),(y&&y.length>0||C)&&e.jsxs(O.MenuBody,{children:[y==null?void 0:y.map((m,Q)=>e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:m.onClick,style:zt,onMouseEnter:q=>{q.currentTarget.style.backgroundColor="var(--sa-background-neutral, #f0f1f2)"},onMouseLeave:q=>{q.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(F.Icon,{name:m.icon,size:"md"}),e.jsx("span",{children:m.label})]})},`${m.label}-${Q}`)),C]}),p??e.jsx(O.MenuFooter,{children:e.jsx(O.MenuButton,{children:e.jsxs("button",{type:"button",onClick:Be,style:{...zt,color:"var(--sa-background-error, #c9184a)",fontWeight:500},onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--sa-color-error-50, #fff0f3)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent"},children:[e.jsx(F.Icon,{name:"Logout",size:"md",style:{color:"var(--sa-background-error, #c9184a)"}}),e.jsx("span",{children:"Logout"})]})})})]})]})]})]}),e.jsx("main",{ref:te,style:{flex:1,overflowY:"auto"},children:r||e.jsx(ue.Outlet,{})})]})]}),c&&s&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--sa-color-black-alpha-a70, #181a19b8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:s}),e.jsxs(Ie.Dialog,{isShow:V,onHide:je,children:[e.jsx(Ie.DialogTitle,{children:"Confirmation Logout"}),e.jsx(Ie.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(Ie.DialogFooter,{children:e.jsx(u.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ce.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{secondary:!0,onClick:je,children:"Cancel"})}),e.jsx(u.Box,{direction:"column",children:e.jsx(P.Button,{primary:!0,onClick:pe,children:"Yes, Sure"})})]})})})]}),le&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>de(null),style:{position:"fixed",inset:0,zIndex:60,backgroundColor:"transparent"}}),e.jsxs("div",{role:"dialog","aria-label":le.item.title,style:{position:"fixed",top:le.top,left:le.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem",backgroundColor:"var(--sa-background-primary, #ffffff)",border:"1px solid var(--sa-border-subtle, #0b120e24)",borderRadius:"var(--sa-radii-md, 0.5rem)",boxShadow:"var(--sa-shadow-lg, 0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a)",padding:"0.5rem",display:"flex",flexDirection:"column",gap:"0.125rem"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--sa-color-gray-500, #8c8f97)",padding:"0.25rem 0.5rem 0.5rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:le.item.title}),(Je=le.item.children)==null?void 0:Je.map(m=>{const Q=Ce(m.to),q=Cr(m.badge,B[m.id]);return e.jsxs("button",{onClick:()=>{M(m.to),de(null)},style:{width:"100%",display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:"var(--sa-radii-md, 0.5rem)",textAlign:"left",backgroundColor:Q?"var(--sa-color-gray-100, #f8f8f8)":"transparent",color:Q?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)",border:"1px solid transparent",cursor:"pointer",fontSize:"0.875rem",fontWeight:500},onMouseEnter:T=>{Q||(T.currentTarget.style.backgroundColor="var(--sa-color-gray-100, #f8f8f8)")},onMouseLeave:T=>{Q||(T.currentTarget.style.backgroundColor="transparent")},children:[m.icon&&e.jsx(F.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,whiteSpace:"nowrap"},children:m.title}),q&&e.jsx(Ze.Badges,{text:String(q.value),variant:q.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const xr=h.forwardRef(({children:r,...t},l)=>e.jsx(u.Box,{ref:l,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Vt=({title:r,iconName:t,textColor:l,iconColor:n,hoverTextColor:o,hoverIconColor:c})=>{const[s,i]=h.useState(!1),d=n??"var(--sa-text-subtle, #8c8f97)",a=l??"var(--sa-text-subtle, #8c8f97)",y=c??"var(--sa-text-subtle, #8c8f97)",C=o??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(F.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:s?y:d,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:s?C:a,transition:"color 0.15s ease"},children:r||"Back"})]})},Vl=({items:r,separator:t="/",iconName:l,iconColor:n,hoverIconColor:o})=>{const[c,s]=h.useState(!1),i=n??"var(--sa-text-subtle, #8c8f97)",d=o??"var(--sa-text-subtle, #8c8f97)",a=r.length>1?r[0]:void 0,y=!!(a!=null&&a.to||a!=null&&a.onClick),C=e.jsx(F.Icon,{name:l||"ChevronLeft",size:"xs",onMouseEnter:y?()=>s(!0):void 0,onMouseLeave:y?()=>s(!1):void 0,style:{color:y&&c?d:i,transition:"color 0.15s ease",cursor:y?"pointer":void 0}}),p=a!=null&&a.to?e.jsx(ue.Link,{to:a.to,replace:!0,style:{textDecoration:"none"},children:C}):a!=null&&a.onClick?e.jsx(xr,{onClick:a.onClick,children:C}):C;return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",children:[p,e.jsx(er.Breadcrumb,{separator:t,size:"md",children:r.map((x,I)=>{const b=I===r.length-1;return x.to&&!b?e.jsx(er.BreadcrumbItem,{children:e.jsx(ue.Link,{to:x.to,children:x.label})},I):e.jsx(er.BreadcrumbItem,{currentPage:b,children:e.jsx(er.BreadcrumbLink,{onClick:b?void 0:x.onClick,children:x.label})},I)})})]})},Hl=r=>{const{items:t,separator:l,onClick:n,navigateTo:o,...c}=r;return t&&t.length>0?e.jsx(Vl,{items:t,separator:l,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):o?e.jsx(u.Box,{direction:"row",children:e.jsx(ue.Link,{to:o,replace:!0,style:{textDecoration:"none"},children:e.jsx(Vt,{...c})})}):e.jsx(u.Box,{direction:"row",children:e.jsx(xr,{onClick:n,children:e.jsx(Vt,{...c})})})},Jr=[{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 Ht(r,t,l){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${l.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?l.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${l.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${l.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Pt={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},jt={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Nt({isShow:r,onHide:t,menus:l,selectedGroupId:n,onSelect:o}){const[c,s]=h.useState(void 0),i=a=>{o(a),t()},d=Jr[0];return e.jsx(Ie.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(Ie.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>s("all"),onMouseLeave:()=>s(void 0),style:jt,children:[e.jsx("div",{style:Ht(n===null,c==="all",d),children:e.jsx("div",{style:{color:d.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(F.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Pt,children:"Semua"})]}),l.map((a,y)=>{var b;const C=n===a.id,p=c===a.id,x=((b=a.items[0])==null?void 0:b.icon)??"Grid",I=Jr[(y+1)%Jr.length];return e.jsxs("button",{onClick:()=>i(a.id),onMouseEnter:()=>s(a.id),onMouseLeave:()=>s(void 0),style:jt,children:[e.jsx("div",{style:Ht(C,p,I),children:e.jsx("div",{style:{color:I.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(F.Icon,{name:x,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Pt,children:a.name})]},a.id)})]})})})}function Pl({onSelect:r,"aria-label":t="Pilih module"}={}){const l=qr(),n=ue.useNavigate(),{selectedGroupId:o,setSelectedGroupId:c}=Ur(),[s,i]=h.useState(!1),d=a=>{var y;if(c(a),a!==null){const C=l.menus.find(x=>x.id===a),p=(y=C==null?void 0:C.items[0])==null?void 0:y.to;p&&n(p)}r==null||r(a)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>i(!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:a=>{a.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:e.jsx(F.Icon,{name:"GridApplication",size:"sm"})}),o!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(Nt,{isShow:s,onHide:()=>i(!1),menus:l.menus.filter(a=>a.parentGroupId===void 0),selectedGroupId:o,onSelect:d})]})}const jl=(r,t)=>{const l=[];if(t===0)return l.push(r),l;for(let n=0;n<r.length;n+=t){const o=r.slice(n,n+t);l.push(o)}return l},Nl=h.memo(({value:r,label:t,separator:l,labelWidth:n,lastIndex:o,labelAlign:c="top"})=>{const s=h.useMemo(()=>({padding:0,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),i=h.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:o?0:12,verticalAlign:c}),[o,c]),d=()=>typeof t=="string"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,a=()=>typeof r=="string"||typeof r=="number"?e.jsx(S.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof l=="string"||typeof l=="number"?e.jsx(S.Text,{fontWeight:"medium",color:"subtlest",children:l}):l;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:s,width:n,children:d()}),l?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:s,children:a()})]})}),_l=h.memo(({fields:r,separator:t,labelWidth:l})=>e.jsx(U.Table,{children:r.map((n,o)=>e.jsx(Nl,{separator:t,labelWidth:l,lastIndex:o===r.length-1,...n},`field-group-field-${o}`))})),ql=h.memo(({maxRow:r=0,maxColumn:t=2,separator:l=":",fields:n=[],labelWidth:o=150,bordered:c=!1})=>{const s=h.useMemo(()=>jl(n,r),[n,r]),i=s.length>2,d=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(u.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:c?"border":void 0,borderStyle:c?"border-solid":void 0,borderColor:c?"border-subtle":void 0,children:s.map((a,y)=>e.jsx(u.Box,{direction:"column",flex:i?void 0:"1",width:i?d():void 0,marginBottom:i?"lg":void 0,children:e.jsx(_l,{labelWidth:o,fields:a,separator:l})},y))})}),Zl=({backButton:r})=>{const[t,l]=h.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",o=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(u.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{cursor:"pointer"},children:[e.jsx(F.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?c:n,transition:"color 0.15s ease"}}),e.jsx(S.Text,{variant:"sub-h3",style:{color:t?s:o,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},Gl=({backButton:r,title:t,titleIcon:l,titleTag:n,children:o,header:c=!0,headerBorder:s=!1,subHeaders:i,action:d,titleTagProps:a,containerProps:y,headerProps:C})=>{const p=ge.useMediaQuery("md"),x=ue.useNavigate(),I=ue.useLocation(),b=r==null?void 0:r.show,B=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}x(-1,{replace:!0})},M=()=>{if(!d)return null;if(h.isValidElement(d))return d;const w=d.filter(L=>L&&(L.title||L.icon));return w.length===0?null:p?e.jsx(u.Box,{direction:"row",gap:"md",children:w.map(({title:L,icon:_,buttonProps:N,onClick:G},Y)=>e.jsx(P.Button,{iconLeft:_?e.jsx(F.Icon,{name:_,size:"md"}):void 0,onClick:G,...N,children:L},`action-${Y}`))}):e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(F.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:200},children:w.map(({title:L,icon:_,buttonProps:N,onClick:G},Y)=>{const ne=(N==null?void 0:N.tone)==="error"||(N==null?void 0:N.danger)===!0;return e.jsx(O.MenuItem,{intent:ne?"danger":void 0,disabled:N==null?void 0:N.disabled,startIcon:_?e.jsx(F.Icon,{name:_}):void 0,onClick:G,children:L},`action-${Y}`)})})})]})},W=()=>{const w=e.jsx(Zl,{backButton:r});return r!=null&&r.navigateTo?e.jsx(u.Box,{direction:"row",children:e.jsx(ue.Link,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:w})}):e.jsx(u.Box,{direction:"row",children:e.jsx(xr,{onClick:B,children:w})})},k=()=>{const w=!!t,L=Array.isArray(d)&&d.length>0,_=h.isValidElement(d)?!0:L;if(!w&&!_&&!b)return null;const G=p||!p&&L;return e.jsxs(u.Box,{direction:"column",gap:"xs",paddingBlock:(C==null?void 0:C.paddingBlock)??"sm",paddingInline:(C==null?void 0:C.paddingInline)??"md",...C,style:{...s?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...C==null?void 0:C.style},children:[b&&W(),(w||_)&&e.jsxs(u.Box,{direction:G?"row":"column",gap:"sm",justify:"space-between",align:G?"center":"flex-start",children:[w?typeof t=="string"?e.jsxs(u.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[l&&e.jsx(F.Icon,{name:l,size:"md",color:"primary"}),e.jsx(S.Text,{variant:"h3",fontWeight:"semibold",fontFamily:"Poppins",children:t})]}),n&&e.jsx(Ze.Badge,{border:!0,size:"lg",text:n,...a})]}):t:null,M()]})]})},D=()=>{if(!i||i.length===0)return null;const w=i.filter(N=>N.show!==!1);if(w.length===0)return null;let L=0,_=-1/0;return w.forEach((N,G)=>{const Y=N.order??0;Y>=_&&(_=Y,L=G)}),w.map(({content:N,order:G,borderBottom:Y=!0},ne)=>e.jsx(u.Box,{direction:"column",paddingTop:"sm",paddingBottom:Y||ne===L?"sm":"spacing-0",paddingInline:"md",style:{...Y?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...G!==void 0?{order:G}:{}},children:N},`sub-header-${ne}`))},V=()=>{const w=c?k():null,L=D();return!w&&!L?null:e.jsxs(u.Box,{direction:"column",style:{marginBottom:L?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[w,L]})},z=()=>o;return e.jsxs(u.Box,{direction:"column",as:"main",...y,style:{...(y==null?void 0:y.style)??{},animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"},children:[V(),z()]},I.pathname)},Ql=h.memo(Gl),Ul={icon:"Cross",title:""},Jl="calc(100vw - 16px)",_t=r=>r==null?void 0:`min(${typeof r=="number"?`${r}px`:r}, ${Jl})`,qt=h.forwardRef(({onHide:r,show:t,withBlur:l=!1,style:n,children:o,closeButton:c=Ul,width:s,minWidth:i="357px",maxWidth:d="357px"},a)=>{const y=_t(s??i),C=_t(s??d);return e.jsx(pr.Drawer,{blur:l,isShow:t,position:"right",onHide:r,ref:a,style:{minWidth:y,maxWidth:C,...n},children:e.jsxs(u.Box,{direction:"column",padding:"lg",children:[c?e.jsxs(u.Box,{direction:"row",align:"center",gap:"sm",onClick:r,marginBottom:"lg",cursor:"pointer",children:[e.jsx(F.Icon,{name:c.icon,size:"md",color:"subtle",cursor:"pointer"}),c.title?e.jsx(S.Text,{fontFamily:"Poppins",fontSize:"md",color:"subtlest",children:c.title}):null]}):null,o]})})}),Yr=h.memo(({children:r,borderBottom:t=!0,padding:l=!0})=>{const n=ge.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Xr=h.memo(({children:r,borderTop:t=!0,padding:l=!0})=>{const n=ge.useMediaQuery("lg");return e.jsx(u.Box,{direction:"column",padding:l?"md":"spacing-0",paddingLeft:l?"md":"spacing-0",paddingRight:l?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Yl=h.memo(({children:r,...t})=>e.jsx(u.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),Xl=h.memo(({children:r,title:t,titleTag:l,action:n,header:o,footer:c,actionContainer:s,containerProps:i,bodyProps:d,headerProps:a={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:C="info"})=>{const p=ge.useMediaQuery("lg"),x=()=>l?e.jsxs(u.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(S.Text,{fontWeight:"medium",children:t}),e.jsx(Ze.Badges,{border:!0,text:l,variant:C})]}):e.jsx(S.Text,{fontWeight:"medium",children:t}),I=()=>o||e.jsxs(u.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(u.Box,{direction:"column",children:t?x():null}),e.jsx(u.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...s,children:n??null})]}),b=!!(o||t||n);return e.jsxs(u.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[o!==null&&b?e.jsx(Yr,{...a,children:I()}):null,e.jsx(Yl,{...d,children:r}),c?e.jsx(Xr,{...y,children:c}):null]})}),Oe={H1:r=>e.jsx(S.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(S.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(S.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(S.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(S.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(S.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(S.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(S.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(S.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(S.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(S.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(S.Text,{variant:"body-3",children:r.children,...r.props})},ke=()=>{const[r,t]=ue.useSearchParams(),l=tr.searchParamsToObject(r.toString()),n=ue.useParams(),o=ue.useLocation(),c=n.id;return{setSearchParams:t,searchParams:r,searchQueries:l,isHasQuery:(y,C)=>r.has(y)&&r.get(y)===C,getQueryParam:y=>r.get(y),getRouteParam:y=>n[y],params:n,location:o,id:c,hasId:!!c}},Zt=r=>JSON.stringify(r),Gt=r=>JSON.stringify(r),Qt=r=>JSON.stringify(r),Ut=r=>JSON.stringify(r),Kl=r=>r,$l=r=>JSON.stringify(r),gr=({value:r,name:t,type:l,withSearchParam:n=!0,setSearchParams:o,searchQueries:c,dropdownSearchKey:s,filterKey:i="filter",pageKey:d="page"})=>{if(n){let a;switch(l){case"search":a=Kl(r);break;case"dropdown":case"dropdown-multiple":a=Zt(r);break;case"radio":a=Gt(r);break;case"date-range":a=Qt(r);break;case"advanced-date-range":a=$l(r);break;case"date":a=Ut(r);break;default:a=r;break}if(typeof a<"u"){const C={...c[i]&&typeof c[i]=="string"?JSON.parse(c[i]):void 0,[t]:a},p={...c};s&&typeof s=="string"&&delete p[s],delete p[d];const x={...p,[i]:JSON.stringify(C)},I=new URLSearchParams(c).toString(),b=new URLSearchParams(x).toString();if(I===b)return;o(x)}}},wr=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s)[0].label:n==="value"&&s?JSON.parse(s)[0].value:s},Jt=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="label"&&s?JSON.parse(s).map(i=>i.label):n==="value"&&s?JSON.parse(s).map(i=>i.value):n==="array"&&s?JSON.parse(s):s},Rl=({name:r,filterKey:t="filter",searchParams:l,get:n})=>{const o=l.get(t)||void 0,c=o&&typeof o=="string"?JSON.parse(o):void 0,s=c?c[r]:void 0;return n==="id"&&s?JSON.parse(s).id:n==="label"&&s?JSON.parse(s).label:n==="value"&&s?JSON.parse(s).value:s},Dr=(r,t,l)=>{const n=t.get(l||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0;return o?o[r]:void 0},eo=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return{start:c?JSON.parse(c).from:void 0,end:c?JSON.parse(c).to:void 0}},Yt=({name:r,filterKey:t="filter",searchParams:l})=>{const n=l.get(t||"filter")||void 0,o=n&&typeof n=="string"?JSON.parse(n):void 0,c=o?o[r]:void 0;return c?JSON.parse(c):void 0},ro=(r,{filterKey:t="filter",perPageKey:l="perPage",pageKey:n="page"})=>{const o=r.get(t)||void 0,c=r.get(l)||void 0,s=r.get(n)||void 0;return!!o||!!c||!!s},Xt=({isOpen:r,onClose:t,filterKey:l,pageKey:n,filters:o})=>{const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),[d,a]=h.useState({}),y=()=>{c.delete(l||"filter"),s(c)},C=(p,x)=>{switch(p.type){case"radio":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"dropdown":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}case"date-range":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"date":return e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x);case"dropdown-multiple":{const{show:I=!0}=p;return I&&e.jsx(u.Box,{direction:"column",children:e.jsx(u.Box,{direction:"column",children:p.title})},x)}default:return null}};return e.jsx(qt,{onHide:t,show:r||!1,children:e.jsxs(u.Box,{direction:"column",gap:"md",children:[e.jsxs(ce.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(u.Box,{direction:"column",children:"Filter"}),e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),o==null?void 0:o.map((p,x)=>C(p,x))]})})},Kt=({searchKey:r="q",statusKey:t="status",searchPlaceholder:l="Search",searchHighlightPlaceholder:n,extendedFilter:o,showSearchFilter:c=!0,showStatusFilter:s=!0,filterKey:i="filter",pageKey:d="page",customWidthSearch:a,handleOnReset:y,filterConfigs:C,buttonToggleProps:p,position:x="right",titleSearchLabel:I="Work Order",withTitleLabels:b=!1})=>{const M=(p==null?void 0:p.isShowLabel)??!0,[W,k]=h.useState(!1),[D,V]=h.useState(0),z=()=>{V(R=>R+1)},{searchParams:w,setSearchParams:L,getQueryParam:_}=ke(),N=tr.searchParamsToObject(w.toString()),G=Dr(r,w,i)||"",[Y,ne]=h.useState(G),ye=_(i),de=!!(ye&&!(()=>{if(ye)try{const R=JSON.parse(ye);return Object.keys(R).length===1&&R[r]===""}catch(R){console.error("Filter parameter is not a valid JSON:",R)}return!1})()),$=ge.useMediaQuery("md");return h.useEffect(()=>{ne(G)},[G]),h.useEffect(()=>{if(Y===G)return;const R=window.setTimeout(()=>{gr({value:Y,name:r,type:"search",searchQueries:N,setSearchParams:L,filterKey:i,pageKey:d})},350);return()=>{window.clearTimeout(R)}},[Y,G,r,N,L,i,d]),e.jsxs(ce.Flex,{gap:"md",style:{flexDirection:$&&x==="left"?"row":$&&x==="right"?"row-reverse":"column"},align:"flex-end",children:[de&&e.jsx(u.Box,{direction:"column",justify:"flex-end",children:e.jsx(P.Button,{onClick:()=>{const R=new URLSearchParams(w);R.delete(i),L(R),ne(""),z(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(S.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),o==null?void 0:o.map(({minWidth:R,content:fe,title:te,onClickContainer:se},Be)=>e.jsxs(u.Box,{direction:"column",gap:"sm",onClick:se,style:{minWidth:R},children:[te&&e.jsx(Oe.SubH3,{children:te}),fe]},`extended-filter-${Be}-${D}`)),!!(C!=null&&C.length)&&e.jsx(P.Button,{primary:de,secondary:!de,iconLeft:e.jsx(F.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:ye?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!$,onClick:()=>k(!0),children:M?"Filter":void 0}),s&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[b&&e.jsx(Oe.SubH3,{children:"Status"}),e.jsx(rr.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:wr({get:"value",name:t,searchParams:w,filterKey:i})?[{label:wr({get:"value",name:t,searchParams:w,filterKey:i})==="active"?"Active":"InActive",value:wr({get:"value",name:t,searchParams:w,filterKey:i})}]:[],onChange:R=>gr({value:R,name:t,type:"dropdown",searchQueries:N,setSearchParams:L,filterKey:i}),placeholder:b?"All":"All Status"},D)]}),c&&e.jsxs(u.Box,{direction:"column",gap:"sm",style:{width:a&&$?a:$?"310px":""},children:[b&&e.jsxs(Oe.SubH3,{children:["Search for ",I]}),e.jsx(Ge.Input,{placeholder:l,leftIcon:e.jsx(F.Icon,{name:"Search",width:20,height:20}),onChange:R=>ne(R.target.value),value:Y,fullWidth:!0},D+1+i)]}),e.jsx(Xt,{isOpen:W,onClose:()=>k(!1),filterKey:i,filters:C,pageKey:d})]})},to=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function Kr({configs:r,filterKey:t="filter",activeFilterKey:l="filters",pageKey:n="page",searchKey:o="q"}){const{searchParams:c,setSearchParams:s,searchQueries:i}=ke(),d=h.useMemo(()=>Object.fromEntries(r.map(D=>[D.key,D])),[r]),a=h.useMemo(()=>{const D=(c.get(l)||"").split(",").map(z=>z.trim()).filter(Boolean);let V=[];try{const z=c.get(t);z&&(V=Object.keys(JSON.parse(z)).filter(w=>w!==o))}catch{}return r.map(z=>z.key).filter(z=>{const w=d[z];return(w==null?void 0:w.locked)||D.includes(z)||V.includes(z)})},[c,l,t,o,r,d]),y=h.useCallback(D=>{try{return D[t]?JSON.parse(D[t]):{}}catch{return{}}},[t]),C=h.useCallback(D=>{const V={...i};D.length?V[l]=D.join(","):delete V[l],s(V)},[i,l,s]),p=h.useCallback(D=>{a.includes(D)||C([...a,D])},[a,C]),x=h.useCallback(D=>{var L;if((L=d[D])!=null&&L.locked)return;const V={...i},z=a.filter(_=>_!==D);z.length?V[l]=z.join(","):delete V[l];const w=y(V);D in w&&(delete w[D],Object.keys(w).length?V[t]=JSON.stringify(w):delete V[t]),delete V[n],s(V)},[i,a,l,t,n,y,s,d]),I=h.useCallback(D=>a.includes(D)?x(D):p(D),[a,p,x]),b=h.useCallback(D=>{switch(D.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return Jt({name:D.key,get:"array",searchParams:c,filterKey:t})||[];case"date":{const V=Yt({name:D.key,searchParams:c,filterKey:t});return V?new Date(V):void 0}case"date-compact":{const z=y(Object.fromEntries(c.entries()))[D.key];return z&&typeof z=="object"?z:void 0}default:return}},[c,t,y]),B=h.useCallback((D,V)=>{if(D.type==="date-compact"){const z={...i},w=y(z);V==null?delete w[D.key]:w[D.key]=V,Object.keys(w).length?z[t]=JSON.stringify(w):delete z[t],delete z[n],s(z);return}gr({value:V,name:D.key,type:to(D.type),searchQueries:i,setSearchParams:s,filterKey:t,pageKey:n})},[i,s,t,n,y]),M=h.useCallback(D=>{const V={...i},z=y(V);D in z&&(delete z[D],Object.keys(z).length?V[t]=JSON.stringify(z):delete V[t]),delete V[n],s(V)},[i,t,n,y,s]),W=h.useCallback(()=>{const D={...i};delete D[t],delete D[l],delete D[n],s(D)},[i,t,l,n,s]),k=a.length>0;return{activeKeys:a,configByKey:d,hasActiveFilter:k,addFilter:p,removeFilter:x,toggleFilter:I,getValue:b,setValue:B,clearValue:M,clearAll:W}}const $r={get(r){return fr.storage.get(r)??null},set(r,t){fr.storage.save(r,t)},remove(r){fr.storage.delete(r)}},cr={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}`},Sr=(r,t)=>{const l=new Set(t.map(c=>c.key)),n=r.order.filter(c=>l.has(c));for(const c of t)n.includes(c.key)||n.push(c.key);const o=r.hidden.filter(c=>l.has(c));return{order:n,hidden:o}};function lo({columns:r,scopeId:t,storage:l,onColumnsChange:n,value:o}){const c=h.useMemo(()=>({order:r.map(w=>w.key),hidden:[]}),[r]),s=t?cr.columns(t):void 0,i=(w,L)=>Sr({order:w.order??L,hidden:w.hidden??[]},r),[d,a]=h.useState(()=>{if(o&&(o.order||o.hidden))return i(o,r.map(w=>w.key));if(s){const w=l.get(s);if(w&&Array.isArray(w.order))return Sr(w,r)}return c}),y=r.map(w=>w.key).join("|");h.useEffect(()=>a(w=>Sr(w,r)),[y]);const C=h.useRef(d);C.current=d;const p=o?`${(o.order??[]).join("|")}~${(o.hidden??[]).join("|")}`:null,x=h.useRef(p);h.useEffect(()=>{if(p==null||x.current===p)return;x.current=p;const w=C.current,L=i(o,w.order);L.order.join("|")===w.order.join("|")&&L.hidden.join("|")===w.hidden.join("|")||(a(L),s&&l.set(s,L))},[p,y]);const I=h.useRef(!1);h.useEffect(()=>{I.current||(I.current=!0,n==null||n(d))},[]);const b=h.useCallback(w=>{a(w),s&&l.set(s,w),n==null||n(w)},[s,l,n]),B=h.useMemo(()=>{const w=new Map(r.map(L=>[L.key,L]));return d.order.filter(L=>w.has(L)).map(L=>({...w.get(L),visible:!d.hidden.includes(L)}))},[d,r]),M=h.useCallback(w=>{const L=d.hidden.includes(w)?d.hidden.filter(_=>_!==w):[...d.hidden,w];b({...d,hidden:L})},[d,b]),W=h.useCallback((w,L)=>{if(w===L)return;const _=[...d.order],[N]=_.splice(w,1);_.splice(L,0,N),b({...d,order:_})},[d,b]),k=h.useCallback(w=>{b({...d,hidden:w?r.filter(L=>!L.locked).map(L=>L.key):[]})},[d,r,b]),D=h.useCallback(()=>b(c),[b,c]),V=h.useCallback(w=>b(Sr(w,r)),[b,r]),z=d.hidden.length===0;return{state:d,orderedColumns:B,allVisible:z,toggleVisibility:M,reorder:W,setAllHidden:k,reset:D,applyState:V}}function oo({scopeId:r,storage:t,snapshotKeys:l,pageKey:n="page",getColumns:o,applyColumns:c}){const{searchParams:s,setSearchParams:i}=ke(),d=r?cr.savedViews(r):void 0,[a,y]=h.useState(()=>d?t.get(d)||[]:[]),C=h.useCallback(b=>{y(b),d&&t.set(d,b)},[d]),p=h.useCallback(b=>{const B=b.trim();if(!B)return;const M={};l.forEach(k=>{const D=s.get(k);D!=null&&(M[k]=D)});const W={id:`${Date.now()}`,name:B,query:M,columns:o==null?void 0:o(),createdAt:Date.now()};C([...a,W])},[l,s,o,C,a]),x=h.useCallback(b=>C(a.filter(B=>B.id!==b)),[C,a]),I=h.useCallback(b=>{const B=Object.fromEntries(s.entries());l.forEach(M=>delete B[M]),Object.assign(B,b.query),delete B[n],i(B),b.columns&&(c==null||c(b.columns))},[s,l,n,i,c]);return{enabled:!!d,views:a,saveView:p,deleteView:x,applyView:I}}function no({scopeId:r,storage:t,snapshotKeys:l,enabled:n=!0}){const{searchParams:o}=ke(),c=r&&n?cr.lastState(r):void 0,s=h.useRef(c);h.useEffect(()=>{if(!c){s.current=c;return}if(s.current!==c){s.current=c;return}const a={};l.forEach(y=>{const C=o.get(y);C!=null&&(a[y]=C)}),Object.keys(a).length!==0&&t.set(c,a)},[o,c,l,t]);const i=h.useCallback(()=>{if(!c)return null;const a=t.get(c);return a&&Object.keys(a).length>0?a:null},[c,t]),d=h.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:i,clear:d}}function co({scopeId:r,storage:t,perPageKey:l,pageSizeOptions:n,enabled:o=!0}){const{searchParams:c}=ke(),s=r&&o?cr.perPage(r):void 0,i=c.toString(),d=h.useRef(s);h.useEffect(()=>{if(!s){d.current=s;return}if(d.current!==s){d.current=s;return}const C=c.get(l);if(!C)return;const p=Number(C);!Number.isFinite(p)||p<=0||t.set(s,p)},[i,s,l,t]);const a=h.useCallback(()=>{if(!s)return null;const C=t.get(s);if(C==null)return null;const p=Number(C);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[s,t,n]),y=h.useCallback(()=>{s&&t.remove(s)},[s,t]);return{enabled:!!s,read:a,clear:y}}let Rr={},et=!1,rt=null;const io=(r,t)=>{Object.assign(Rr,r),rt=t,!et&&(et=!0,queueMicrotask(()=>{const l=Rr,n=rt;Rr={},et=!1,rt=null,!(!n||Object.keys(l).length===0)&&n(o=>{const c=new URLSearchParams(o);return Object.entries(l).forEach(([s,i])=>c.set(s,i)),c})}))};function so({enabled:r,snapshotKeys:t,perPageKey:l,readSnapshot:n,readPerPage:o}){const{searchParams:c,setSearchParams:s,location:i}=ke(),d=h.useRef(null);h.useEffect(()=>{if(!r||d.current===i.pathname)return;d.current=i.pathname;const a={};if(!c.has(l)){const y=o();y&&(a[l]=y)}if(!t.some(y=>c.has(y))){const y=n();y&&Object.assign(a,y)}Object.keys(a).length!==0&&io(a,s)},[i.pathname,r])}const ao=({configs:r,activeKeys:t,onToggle:l,hasActiveFilter:n,onReset:o})=>r.length?e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{minWidth:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&o&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"xs",onClick:o,children:"Reset"})]}),children:r.map(c=>e.jsx(O.MenuItem,{selected:c.locked||t.includes(c.key),disabled:c.locked,closeOnSelect:!1,startIcon:c.icon??void 0,onClick:()=>{c.locked||l(c.key)},children:c.label},c.key))})})]}):null,kr=({onClear:r,onRemove:t})=>e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(F.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:180},children:[e.jsx(O.MenuItem,{startIcon:e.jsx(F.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(O.MenuItem,{intent:"danger",startIcon:e.jsx(F.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),ho=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},$t=(r,t,l)=>{const n=new Date(r);return l==="day"?n.setDate(n.getDate()+t):l==="week"?n.setDate(n.getDate()+t*7):l==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Rt=r=>{const t=ho(new Date);if(r.direction==="this"){const n=new Date(t),o=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),o.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),o.setMonth(o.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),o.setMonth(11,31)),{from:n,to:o}}const l=r.count??1;return r.direction==="past"?{from:$t(t,-l,r.period),to:t}:{from:t,to:$t(t,l,r.period)}},el=24,rl=r=>r.length>el?`${r.slice(0,el)}...`:r,Br=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),mr={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"},fo=["is","is-before","is-after","is-on-or-before","is-on-or-after","is-between","is-relative-to-today","is-empty","is-not-empty"],tt={past:"Past",next:"Next",this:"This"},go=["day","week","month","year"],uo=["past","next","this"],yo=r=>r.field.type==="date-compact"?e.jsx(bo,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(po,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),po=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=t?Br(new Date(t)):null,s=!!c,i=s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:rl(c)})]}):r.label;return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s?e.jsx(F.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:d=>d==null?n():l(d),withPadding:!1})})})]})},Co=r=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${mr[r.op]} ${Br(new Date(r.date))}`:null;case"is-between":return r.from&&r.to?`${Br(new Date(r.from))} - ${Br(new Date(r.to))}`:null;case"is-relative-to-today":{const t=r.relative;if(!t)return null;if(t.direction==="this")return`This ${t.period}`;const l=t.count??1,n=l===1?t.period:`${t.period}s`;return`${tt[t.direction]} ${l} ${n}`}case"is-empty":case"is-not-empty":return mr[r.op];default:return null}},bo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=(t==null?void 0:t.op)??"is",s=t?Co(t):null,i=!!s,d=i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:rl(s)})]}):r.label,a=y=>{if(y!==c){if(y==="is-empty"||y==="is-not-empty"){l({op:y});return}if(y==="is-relative-to-today"){l({op:y,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(y==="is-between"){l({op:y,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}l({op:y,date:t==null?void 0:t.date})}};return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:i?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:i?e.jsx(F.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:d})}),e.jsxs(O.MenuLists,{children:[e.jsx(O.MenuBody,{style:{width:320},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(vo,{op:c,onChange:a})]}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsx(xo,{value:t,op:c,onChange:l})}),c==="is-relative-to-today"&&e.jsx(O.MenuFooter,{children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},vo=({op:r,onChange:t})=>e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:mr[r]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:200},children:fo.map(l=>e.jsx(O.MenuItem,{selected:r===l,onClick:()=>t(l),endIcon:r===l?e.jsx(F.Icon,{name:"Check"}):void 0,children:mr[l]},l))})})]}),xo=({value:r,op:t,onChange:l})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const n=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,value:n,onChange:o=>{if(o==null){l({op:t});return}if(typeof o=="object"&&o!==null&&"from"in o&&"to"in o){let{from:c,to:s}=o;if(!c&&s&&(c=s,s=null),!c&&!s){l({op:t});return}l({op:t,from:c?c.toISOString():void 0,to:s?s.toISOString():void 0})}},withPadding:!1},"range")}return t==="is-relative-to-today"?e.jsx(wo,{value:r==null?void 0:r.relative,onChange:n=>l({op:t,relative:n})}):e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,clearable:!0,value:r!=null&&r.date?new Date(r.date):void 0,onChange:n=>{if(n==null){l({op:t});return}n instanceof Date&&l({op:t,date:n.toISOString()})},withPadding:!1},"single")},wo=({value:r,onChange:t})=>{const l=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,o=(r==null?void 0:r.period)??"week",c=l!=="this",s=Rt({direction:l,count:n,period:o});return e.jsxs(u.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:tt[l]})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:uo.map(i=>e.jsx(O.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:o}:{direction:i,count:n,period:o}),children:tt[i]},i))})})]}),c&&e.jsx(Ge.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const d=Number(i.target.value);t({direction:l,count:Number.isFinite(d)&&d>0?d:1,period:o})},style:{width:72}}),e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:o})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:140},children:go.map(i=>e.jsx(O.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>t(l==="this"?{direction:l,period:i}:{direction:l,count:n,period:i}),children:i},i))})})]})]}),e.jsx(Qe.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:s,onChange:()=>{},withPadding:!1},"relative-preview")]})},tl=18,Do=r=>r.length>tl?`${r.slice(0,tl)}...`:r,So=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=r.type==="dropdown-multiple",s=t.length,[i,d]=h.useState(""),a=r.options,y=typeof r.onSearch=="function",C=(()=>{if(y)return a;const B=i.trim().toLowerCase();return B?a.filter(M=>M.label.toLowerCase().includes(B)):a})(),p=B=>t.some(M=>M.value===B.value),x=B=>{if(!c){l([{label:B.label,value:B.value}]),d("");return}l(p(B)?t.filter(M=>M.value!==B.value):[...t,{label:B.label,value:B.value}])},I=B=>{var M;d(B),(M=r.onSearch)==null||M.call(r,B)},b=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:s===1?Do(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(F.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{style:{width:260},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(rr.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:c,searchAble:!0,searchValue:i,onSearch:I,value:t,onChange:l,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):C.length===0?e.jsx(u.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(S.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):C.map(B=>e.jsx(O.MenuItem,{closeOnSelect:!c,selected:p(B),startIcon:B.avatar,endIcon:p(B)?e.jsx(F.Icon,{name:"Check"}):void 0,description:B.description,onClick:()=>x(B),children:B.label},B.value))})]})})})]})},ll=18,ko=r=>r.length>ll?`${r.slice(0,ll)}...`:r,ol=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(nr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),Bo=({field:r,value:t,onChange:l,onClear:n,onRemove:o})=>{const c=new Set(t.map(p=>p.value)),s=t.length,i=r.options.length>0&&r.options.every(p=>c.has(p.value)),d=s>0&&!i,a=p=>{l(c.has(p.value)?t.filter(x=>x.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{l(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},C=s===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(S.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(S.Text,{as:"span",children:s===1?ko(t[0].label):`${s} Selected`})]});return e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:s>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:s>0?e.jsx(F.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),children:C})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{width:240},title:e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(kr,{onClear:n,onRemove:o})]}),children:[e.jsx(O.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(ol,{checked:i||d,indeterminate:d}),children:"Select All"}),r.options.map(p=>e.jsx(O.MenuItem,{closeOnSelect:!1,selected:c.has(p.value),onClick:()=>a(p),startIcon:e.jsx(ol,{checked:c.has(p.value)}),children:p.label},p.value))]})})]})},nl=({activeKeys:r,configByKey:t,getValue:l,setValue:n,clearValue:o,removeFilter:c})=>e.jsx(e.Fragment,{children:r.map(s=>{const i=t[s];if(!i)return null;const d=l(i),a=i.locked?void 0:()=>c(s);return i.type==="date"||i.type==="date-compact"?e.jsx(yo,{field:i,value:d,onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):i.type==="checkbox-multiple"?e.jsx(Bo,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s):e.jsx(So,{field:i,value:d||[],onChange:y=>n(i,y),onClear:()=>o(s),onRemove:a},s)})}),cl=r=>`${r} Rows`,mo=({pagination:r,pageKey:t="page",perPageKey:l="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:o=10,showResultCount:c=!0,showPageSize:s=!0,showPagination:i=!0})=>{var M;const{searchQueries:d,setSearchParams:a,searchParams:y}=ke(),C=y.get(l),p=C?Number(C):o,x=W=>{a({...d,[t]:String(W)})},I=W=>{a({...d,[l]:W,[t]:"1"})},b=(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),B=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[c&&e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${b}-${B} of ${((M=r==null?void 0:r.totalData)==null?void 0:M.toLocaleString())||0}`}),s&&e.jsxs(O.Menu,{position:"bottom-left",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(F.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:cl(p)})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:n.map(W=>e.jsx(O.MenuItem,{selected:W===p,onClick:()=>I(String(W)),children:cl(W)},W))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(u.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(hr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:x})})]})};function Fo(r,t,l=!0){h.useEffect(()=>{if(!l)return;const n=o=>{var i;if(o.metaKey||o.ctrlKey||o.altKey||o.key!==r)return;const c=o.target,s=(i=c==null?void 0:c.tagName)==null?void 0:i.toLowerCase();s==="input"||s==="textarea"||c!=null&&c.isContentEditable||(o.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,l])}const Eo=240,il=({searchKey:r="q",filterKey:t="filter",pageKey:l="page",placeholder:n="Search",shortcut:o="/",collapsible:c=!0})=>{const{searchParams:s,setSearchParams:i,searchQueries:d}=ke(),a=Dr(r,s,t)||"",[y,C]=h.useState(!c||!!a),[p,x]=h.useState(c&&!a),[I,b]=h.useState(a),B=ge.useDebounce(I,350),M=h.useRef(null);h.useEffect(()=>{b(a),a&&C(!0)},[a]),h.useEffect(()=>{y&&x(!1)},[y]),h.useEffect(()=>{B!==a&&gr({value:B,name:r,type:"search",searchQueries:d,setSearchParams:i,filterKey:t,pageKey:l})},[B]);const W=h.useCallback(()=>{C(!0),requestAnimationFrame(()=>{var z;return(z=M.current)==null?void 0:z.focus()})},[]);Fo(o,W);const k=()=>{c&&!I&&C(!1)},D=z=>{var w;c&&z.key==="Escape"&&!I&&(C(!1),(w=M.current)==null||w.blur())},V=()=>{y||x(!0)};return e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:W}),e.jsxs(u.Box,{onTransitionEnd:V,style:{position:"relative",width:y?Eo:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(Ge.Input,{ref:M,size:"sm",fullWidth:!0,value:I,placeholder:n,leftIcon:e.jsx(F.Icon,{name:"Search",width:16,height:16}),onChange:z=>b(z.target.value),onKeyDown:D,onBlur:k,tabIndex:y?0:-1}),y&&!I&&e.jsx(u.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(S.Text,{fontSize:"xs",color:"subtle",children:o})})]})]})},sl=({columns:r,allVisible:t,onToggle:l,onReorder:n,onSetAllHidden:o})=>{const[c,s]=h.useState(null),[i,d]=h.useState(null),a=()=>{c!==null&&i!==null&&c!==i&&n(c,i),s(null),d(null)},y=(C,p)=>{const x=C+p;x<0||x>=r.length||n(C,x)};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(O.MenuLists,{children:e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(P.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>o(t),children:t?"Hide All":"Show All"})]}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((C,p)=>{const x=!C.locked,I=i===p&&c!==null&&c!==p;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:x,onDragStart:()=>x&&s(p),onDragOver:b=>{b.preventDefault(),d(p)},onDrop:a,onDragEnd:a,style:{minHeight:32,boxShadow:I?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(u.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:x?0:-1,"aria-label":`Reorder ${C.title}`,"aria-disabled":!x||void 0,color:"icon-subtlest",onKeyDown:b=>{x&&(b.key==="ArrowUp"?(b.preventDefault(),y(p,-1)):b.key==="ArrowDown"&&(b.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:x?"grab":"default",opacity:x?1:.4},children:e.jsx(F.Icon,{name:"DragVertical",width:16,height:16})}),C.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:C.title}),e.jsx(u.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(or.Toggle,{size:"sm",checked:C.visible,disabled:C.locked,onChange:()=>l(C.key),"aria-label":`Toggle ${C.title} column`})})]},C.key)})})]})})})]})},al=({views:r,onApply:t,onDelete:l,onSave:n})=>{const[o,c]=h.useState(""),s=()=>{const i=o.trim();i&&(n(i),c(""))};return e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(F.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(O.MenuLists,{style:{width:"260px"},children:[e.jsx(O.MenuBody,{children:e.jsxs(u.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(u.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(u.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(S.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(O.MenuItem,{startIcon:e.jsx(F.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(P.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:d=>{d.stopPropagation(),l(i.id)}}),children:i.name},i.id))})]})}),e.jsx(O.MenuFooter,{children:e.jsxs(u.Box,{direction:"row",gap:"xs",children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(Ge.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:o,onChange:i=>c(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}})}),e.jsx(P.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!o.trim(),onClick:s,children:"Save"})]})})]})]})},Mo=({isOpen:r,onClose:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:i,getValue:d,setValue:a,clearValue:y,removeFilter:C})=>{const p=n.length;return e.jsx(pr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(u.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(S.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(S.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(P.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(u.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(u.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(nl,{activeKeys:n,configByKey:o,getValue:d,setValue:a,clearValue:y,removeFilter:C})})]}),l.length>0&&e.jsxs(u.Box,{direction:"column",gap:"sm",children:[e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(u.Box,{direction:"column",children:l.map(x=>{const I=n.includes(x.key),b=!!x.locked;return e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:b?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[x.icon&&e.jsx(u.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:x.icon}),e.jsx(S.Text,{fontSize:"sm",color:"primary",truncate:!0,children:x.label})]}),e.jsx(or.Toggle,{size:"sm",checked:I||b,disabled:b,onChange:()=>s(x.key),"aria-label":`Toggle ${x.label}`})]},x.key)})})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!c,onClick:i,children:"Reset"})}),e.jsx(u.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(P.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},Lo=r=>`${r} Rows`,To=({perPageKey:r,pageKey:t,pageSizeOptions:l,defaultPerPage:n=10,showPageSize:o})=>{const{searchQueries:c,setSearchParams:s,searchParams:i}=ke(),d=i.get(r),a=d?Number(d):n,y=C=>{s({...c,[r]:C,[t]:"1"})};return o?e.jsxs(O.Menu,{position:"bottom-right",children:[e.jsx(O.MenuButton,{children:e.jsx(P.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(O.MenuLists,{children:e.jsxs(O.MenuBody,{style:{minWidth:200},children:[e.jsx(u.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(S.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),l.map(C=>e.jsx(O.MenuItem,{selected:C===a,endIcon:C===a?e.jsx(F.Icon,{name:"Check"}):void 0,onClick:()=>y(String(C)),children:Lo(C)},C))]})})]}):null},Io=r=>{var be;const{withPadding:t,configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,toggleFilter:s,removeFilter:i,getValue:d,setValue:a,clearValue:y,onReset:C,searchable:p,searchKey:x,filterKey:I,pageKey:b,searchPlaceholder:B,searchShortcut:M,searchCollapsible:W,pagination:k,perPageKey:D,pageSizeOptions:V,defaultPerPage:z,showPagination:w,showResultCount:L,showPageSize:_,hasColumns:N,orderedColumns:G,allVisible:Y,onToggleVisibility:ne,onReorder:ye,onSetAllHidden:le,showSavedViews:de,savedViews:$,onApplyView:R,onDeleteView:fe,onSaveView:te}=r,[se,Be]=h.useState(!1),{searchQueries:je,setSearchParams:pe}=ke(),me=(k==null?void 0:k.rangeStart)??(((k==null?void 0:k.currentPage)||0)>1?(((k==null?void 0:k.currentPage)||0)-1)*((k==null?void 0:k.perPage)||0)+1:1),Le=(k==null?void 0:k.rangeEnd)??((k==null?void 0:k.totalCurrentPage)!==(k==null?void 0:k.perPage)?k==null?void 0:k.totalData:((k==null?void 0:k.currentPage)||1)*((k==null?void 0:k.totalCurrentPage)||0)),Ce=Me=>{pe({...je,[b]:String(Me)})},We=L||w&&!!(k!=null&&k.totalPage),qe=()=>{C(),Be(!1)};return e.jsxs(u.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(il,{searchKey:x,filterKey:I,pageKey:b,placeholder:B,shortcut:M,collapsible:W}),e.jsx(P.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(F.Icon,{name:"FilterHorizontal"}),onClick:()=>Be(!0),"aria-label":"Open filters",children:c?`Filter: ${n.length}`:null}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[de&&e.jsx(al,{views:$,onApply:R,onDelete:fe,onSave:te}),N&&e.jsx(sl,{columns:G,allVisible:Y,onToggle:ne,onReorder:ye,onSetAllHidden:le}),e.jsx(To,{perPageKey:D,pageKey:b,pageSizeOptions:V,defaultPerPage:z,showPageSize:_})]})]}),We&&e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[L?e.jsx(S.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${me}-${Le} of ${((be=k==null?void 0:k.totalData)==null?void 0:be.toLocaleString())||0}`}):e.jsx(u.Box,{direction:"column"}),w&&!!(k!=null&&k.totalPage)&&e.jsx(hr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:k!=null&&k.currentPage?Number(k.currentPage):1,totalPages:Number(k.totalPage),onPageChange:Ce})]}),e.jsx(Mo,{isOpen:se,onClose:()=>Be(!1),configs:l,activeKeys:n,configByKey:o,hasActiveFilter:c,onToggle:s,onReset:qe,getValue:d,setValue:a,clearValue:y,removeFilter:i})]})},Oo=({withPadding:r=!1,filterConfigs:t=[],filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",pageSizeOptions:s=[25,50,100],defaultPerPage:i,showPagination:d=!0,showResultCount:a=!0,showPageSize:y=!0,searchable:C=!1,searchKey:p="q",searchPlaceholder:x="Search",searchShortcut:I="/",searchPosition:b="right",searchCollapsible:B=!0,pagination:M,columns:W=[],onColumnsChange:k,columnsState:D,scopeId:V,savedViews:z,persistLastState:w=!0,storage:L=$r,onReset:_})=>{const N=V??(z==null?void 0:z.scopeId),{activeKeys:G,configByKey:Y,hasActiveFilter:ne,toggleFilter:ye,removeFilter:le,getValue:de,setValue:$,clearValue:R,clearAll:fe}=Kr({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:p}),te=lo({columns:W,scopeId:N,storage:L,onColumnsChange:k,value:D}),se=oo({scopeId:N,storage:L,snapshotKeys:[n,l,c],pageKey:o,getColumns:()=>te.state,applyColumns:te.applyState}),Be=no({scopeId:N,storage:L,snapshotKeys:[n,l,o],enabled:w}),je=co({scopeId:N,storage:L,perPageKey:c,pageSizeOptions:s,enabled:w});so({enabled:w&&!!N,snapshotKeys:[n,l,o],perPageKey:c,readSnapshot:Be.read,readPerPage:je.read});const pe=i??s[0]??25,me=!!(z!=null&&z.enabled)&&se.enabled,Le=()=>{fe(),Be.clear(),_==null||_()},Ce=ge.useMediaQuery("md"),We=C?e.jsx(il,{searchKey:p,filterKey:l,pageKey:o,placeholder:x,shortcut:I,collapsible:B}):null;return Ce?e.jsxs(u.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(ao,{configs:t,activeKeys:G,onToggle:ye,hasActiveFilter:ne,onReset:Le}),b==="left"&&We,e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(nl,{activeKeys:G,configByKey:Y,getValue:de,setValue:$,clearValue:R,removeFilter:le}),ne&&e.jsx(P.Button,{variant:"link",tone:"brand",size:"sm",onClick:Le,children:"Reset"})]})]}),e.jsxs(u.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[e.jsx(mo,{pagination:M,pageKey:o,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y}),b==="right"&&We,me&&e.jsx(al,{views:se.views,onApply:se.applyView,onDelete:se.deleteView,onSave:se.saveView}),W.length>0&&e.jsx(sl,{columns:te.orderedColumns,allVisible:te.allVisible,onToggle:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden})]})]}):e.jsx(Io,{withPadding:r,configs:t,activeKeys:G,configByKey:Y,hasActiveFilter:ne,toggleFilter:ye,removeFilter:le,getValue:de,setValue:$,clearValue:R,onReset:Le,searchable:C,searchKey:p,filterKey:l,pageKey:o,searchPlaceholder:x,searchShortcut:I,searchCollapsible:B,pagination:M,perPageKey:c,pageSizeOptions:s,defaultPerPage:pe,showPagination:d,showResultCount:a,showPageSize:y,hasColumns:W.length>0,orderedColumns:te.orderedColumns,allVisible:te.allVisible,onToggleVisibility:te.toggleVisibility,onReorder:te.reorder,onSetAllHidden:te.setAllHidden,showSavedViews:me,savedViews:se.views,onApplyView:se.applyView,onDeleteView:se.deleteView,onSaveView:se.saveView})},Wo=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},Ao=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(l=>(l==null?void 0:l.value)!=null?String(l.value):null).filter(l=>l!=null);return t.length?t:void 0},zo=(r,t)=>{switch(r.type){case"dropdown":case"radio":return Wo(t);case"dropdown-multiple":case"checkbox-multiple":return Ao(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},dl=(r,t)=>{if(r==null||r==="")return t;const l=Number(r);return Number.isFinite(l)&&l>0?l:t},Vo=r=>{const{filterConfigs:t,filterKey:l="filter",activeFilterKey:n="filters",pageKey:o="page",perPageKey:c="perPage",searchKey:s="q",defaultPage:i=1,defaultPerPage:d=10,paramKeys:a,serialize:y}=r,{activeKeys:C,configByKey:p,hasActiveFilter:x,getValue:I}=Kr({configs:t,filterKey:l,activeFilterKey:n,pageKey:o,searchKey:s}),{searchParams:b}=ke(),B=b.toString();return h.useMemo(()=>{const W={},k={},D=dl(b.get(o),i),V=dl(b.get(c),d);W[(a==null?void 0:a.page)??"page"]=D,W[(a==null?void 0:a.perPage)??"perPage"]=V;const z=Dr(s,b,l)||"";z&&(W[(a==null?void 0:a.search)??"search"]=z);let w=!1;for(const L of C){const _=p[L];if(!_)continue;const N=I(_);k[L]=N;const G=y==null?void 0:y[L],Y=G?G(N):zo(_,N);if(Y==null||Array.isArray(Y)&&Y.length===0)continue;const ne=(a==null?void 0:a[L])??L;W[ne]=Y,w=!0}return{params:W,raw:k,hasActiveFilter:x||!!z||w}},[B,C.join("|"),l,n,o,c,s,i,d,a,y,p])},Ho=["dropdown","dropdown-multiple","checkbox-multiple","radio"],Po=({filterConfigs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o})=>{const{configByKey:c,getValue:s,setValue:i,removeFilter:d,clearAll:a,hasActiveFilter:y}=Kr({configs:r,filterKey:t,activeFilterKey:l,pageKey:n,searchKey:o}),C=(M,W)=>{var D;const k=M.options;return((D=k==null?void 0:k.find(V=>V.value===W))==null?void 0:D.label)??W},p=h.useCallback(M=>{const W=c[M];if(!W)return[];const k=s(W);return Array.isArray(k)?k.map(D=>String(D.value)):[]},[c,s]),x=h.useCallback((M,W)=>{const k=c[M];if(!k||!Ho.includes(k.type))return;const D=Array.isArray(W)?W:[W];if(D.length===0){d(M);return}i(k,D.map(V=>({label:C(k,V),value:V})))},[c,i,d]),I=h.useCallback((M,W)=>{const k=p(M);x(M,k.includes(W)?k.filter(D=>D!==W):[...k,W])},[p,x]),b=h.useCallback((M,W)=>p(M).includes(W),[p]),B=h.useCallback(M=>d(M),[d]);return{set:x,toggle:I,clear:B,clearAll:a,isActive:b,values:p,hasActiveFilter:y}},jo=(r,t)=>{if(!r)return{};const{fromKey:l,toKey:n,opKey:o}=t,c={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(c[l]=new Date(r.date).toISOString()),o&&(c[o]=r.op),c;case"is-between":return r.from&&(c[l]=new Date(r.from).toISOString()),r.to&&(c[n]=new Date(r.to).toISOString()),c;case"is-relative-to-today":{if(!r.relative)return c;const{from:s,to:i}=Rt(r.relative);return c[l]=s.toISOString(),c[n]=i.toISOString(),c}case"is-empty":case"is-not-empty":return o&&(c[o]=r.op==="is-empty"?"empty":"not-empty"),c;default:return c}},hl=({children:r,borderRadius:t,height:l})=>{const n=h.useRef(null),[o,c]=h.useState("100vh");return h.useEffect(()=>{if(l)return;const s=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;c(`calc(100vh - ${i}px)`)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[l]),e.jsx(u.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:l??o,display:"flex",flexDirection:"column"},children:r})},fl=({action:r,rightContent:t,leftContent:l,headerSlot:n,advanceFilter:o,showFilter:c=!0})=>{const s=ge.useMediaQuery("md"),i=c?e.jsx(Kt,{...o}):null,d=()=>r?h.isValidElement(r)?r:e.jsx(u.Box,{style:{display:"flex",flexDirection:s?"row":"column",gap:"8px",width:s?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:a,icon:y,buttonProps:C,onClick:p},x)=>!a&&!y?null:e.jsx(P.Button,{fullWidth:!s,iconLeft:y?e.jsx(F.Icon,{name:y}):void 0,onClick:p,...C,children:a},`action-${x}`))}):null;return e.jsx(u.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:s?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,l]}),e.jsxs(u.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,d()]})]})})},No=({totalData:r,withMarginBottom:t=!0,withMarginTop:l=!0})=>e.jsxs(u.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:l?"16px":void 0},children:[e.jsxs(Oe.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Oe.Body1,{children:r||0})]}),gl=({pagination:r,pageKey:t="page",perPageKey:l="perPage",defaultPerPage:n=10,showPagination:o=!0,totalData:c})=>{const{searchQueries:s,setSearchParams:i,searchParams:d}=ke(),a=d.get(l),y=I=>{i({...s,[t]:String(I)})},C=I=>{i({...s,[l]:I,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),x=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(u.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:o?e.jsxs(e.Fragment,{children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(S.Text,{children:"Rows Per Page: "}),e.jsx(rr.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:I=>{C(I[0].value)},value:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:a?[{label:`${a} per row`,value:a}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(S.Text,{children:`${p}-${x} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(hr.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(No,{totalData:c,withMarginBottom:!1,withMarginTop:!1})})},ul=({filter:r,columnTitle:t})=>{const[l,n]=h.useState(!1),o=h.useRef(null),c=h.useRef(null),s=h.useRef(null),[i,d]=h.useState(""),[a,y]=h.useState({top:0,left:0}),C=r.selectedValues,p=h.useMemo(()=>i?r.options.filter(b=>b.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);h.useEffect(()=>{if(l&&c.current){const b=c.current.getBoundingClientRect(),B=280,M={top:b.bottom+8};r.position==="left"||b.left+B>window.innerWidth?M.right=window.innerWidth-b.right:M.left=b.left,y(M)}},[l,r.position]),h.useEffect(()=>{l&&s.current?setTimeout(()=>{var b;return(b=s.current)==null?void 0:b.focus()},50):d("")},[l]),h.useEffect(()=>{const b=B=>{o.current&&!o.current.contains(B.target)&&c.current&&!c.current.contains(B.target)&&n(!1)};return l&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const x=b=>{const B=C.includes(b)?C.filter(M=>M!==b):[...C,b];r.onFilterChange(B)},I=()=>r.onFilterChange([]);return e.jsxs(u.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(u.Box,{ref:c,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:b=>{var B;b.stopPropagation(),l||(B=r.onOpen)==null||B.call(r),n(M=>!M)},children:e.jsx(F.Icon,{name:l?"ChevronUp":"ChevronDown",size:"sm",style:{color:C.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),l&&e.jsxs(u.Box,{ref:o,style:{position:"fixed",top:`${a.top}px`,...a.left!==void 0?{left:`${a.left}px`}:{right:`${a.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(S.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),C.length>0&&e.jsx(u.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(S.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:b=>{b.stopPropagation(),I()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(u.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(Ge.Input,{ref:s,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(F.Icon,{name:"Search",size:"sm"}),value:i,onChange:b=>d(b.target.value),style:{fontSize:"14px"}})}),e.jsx(u.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(F.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(u.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(b=>e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:C.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:B=>{B.stopPropagation(),x(b.value)},onMouseEnter:B=>{C.includes(b.value)||(B.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),B.currentTarget.style.transform="translateX(2px)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor=C.includes(b.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",B.currentTarget.style.transform="translateX(0)"},children:[e.jsx(nr.Checkbox,{checked:C.includes(b.value),onChange:()=>{}}),e.jsx(S.Text,{fontSize:"sm",fontWeight:C.includes(b.value)?"medium":"normal",color:C.includes(b.value)?"primary":"gray-700",children:b.label})]},b.value))}):e.jsxs(u.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(F.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(S.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),C.length>0&&e.jsx(u.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(u.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(u.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:C.length}),e.jsxs(S.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",C.length>1?"s":""," selected"]})]})})]})]})},_o=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",l="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:l,o=r==="desc"?t:l,c=r==="asc"?1:.45,s=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:c,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:o,opacity:s},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},qo=({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"})]}),lt="var(--sa-background-primary, #ffffff)",yl="var(--sa-background-primary-inverse, #f8f8f8)",pl=({columns:r,records:t,handleDetail:l,handleUpdate:n,handleDelete:o,isLoading:c,visibleHandleDelete:s,visibleHandleUpdate:i,visibleHandleDetail:d,showHeadBorder:a=!1,scrollParentRef:y,frozenCount:C=0,onFrozenCountChange:p,customActions:x,actionsOrder:I=["detail","update","delete","custom"],customEmptyState:b,enableColumnResize:B=!1,defaultColumnWidths:M,onColumnWidthsChange:W,defaultMinColumnWidth:k=60,sort:D,defaultSort:V,onSortChange:z,showActionDivider:w=!1})=>{const L=D!==void 0,[_,N]=h.useState(V??null),G=L?D??null:_,Y=T=>{if(T.sortKey)return T.sortKey;if(typeof T.accessor=="string")return T.accessor},ne=T=>{const H=Y(T);if(!H)return;let j;!G||G.key!==H?j={key:H,direction:"asc"}:G.direction==="asc"?j={key:H,direction:"desc"}:j=null,L||N(j),z==null||z(j)},le=[l,n,o].filter(T=>T!==void 0).length,de=!!x,$=!!l||!!n||!!o||de,R="var(--sa-border-subtle, #0b120e24)",fe=`1px solid ${R}`,te=`inset 1px 0 0 ${R}`,se=`inset -1px 0 0 ${R}`,Be=le===3?de?"178px":"140px":le===2?de?"140px":"102px":le===1?de?"112px":"74px":de?"74px":"",je=(T,H)=>{if(!H)return T;if(typeof H=="function")return H(T);if(typeof H=="string")return T[H]},[pe,me]=h.useState(!1);h.useEffect(()=>{if(!(y!=null&&y.current))return;const T=y.current;me(T.scrollHeight>T.clientHeight)},[t,y]);const Le=h.useRef(null),[Ce,We]=h.useState([]),[qe,be]=h.useState(()=>M??{}),Me=h.useRef(null);h.useLayoutEffect(()=>{if(!C||!Le.current){We([]);return}const T=Array.from(Le.current.querySelectorAll("thead tr th")),H=[];let j=0;T.forEach((Z,K)=>{H[K]=j,K<C&&(j+=Z.offsetWidth)}),We(H)},[C,r,t,qe]);const Je=T=>{p&&p(T<C?T:T+1)},m=(T,H)=>{const j=qe[T];if(j!==void 0){const Z=`${j}px`;return{width:Z,minWidth:Z,maxWidth:Z}}return H?{width:H}:{}},Q=T=>B&&(T.resizable??!0),q=(T,H)=>{T.preventDefault(),T.stopPropagation();const j=T.currentTarget.closest("th");if(!j)return;const Z=Math.round(j.getBoundingClientRect().width);Me.current={colIndex:H,startX:T.clientX,startWidth:Z};const K=document.body.style.userSelect,xe=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const Fe=ze=>{var Ke;const Te=Me.current;if(!Te)return;const Ye=((Ke=r[Te.colIndex])==null?void 0:Ke.minWidth)??k,Xe=Math.max(Ye,Te.startWidth+(ze.clientX-Te.startX));be(Ve=>Ve[Te.colIndex]===Xe?Ve:{...Ve,[Te.colIndex]:Xe})},Ae=()=>{document.removeEventListener("mousemove",Fe),document.removeEventListener("mouseup",Ae),document.body.style.userSelect=K,document.body.style.cursor=xe,Me.current=null,W&&be(ze=>(W(ze),ze))};document.addEventListener("mousemove",Fe),document.addEventListener("mouseup",Ae)};return e.jsx("div",{ref:Le,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((T,H)=>{var ir,sr;const j=C>0&&H<C,Z=Ce[H]??0,K=Q(T),Fe=H===r.length-1&&$&&w,Ae=Y(T),ze=!!T.sortable&&!!Ae,Te=ze&&(G==null?void 0:G.key)===Ae?G.direction:null,Ye=T.title||((ir=T.accessor)==null?void 0:ir.toString())||"",Xe=(sr=T.headerTooltip)!=null&&sr.showIcon?e.jsx(F.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ke=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ye}),Ve=ze?e.jsxs("button",{type:"button",onClick:()=>ne(T),title:Te==="asc"?"Sorted ascending — click to sort descending":Te==="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:T.textAlign==="text-right"?"right":T.textAlign==="text-center"?"center":"left"},children:[Ke,Xe,e.jsx(_o,{direction:Te})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ke,Xe]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:j?Z:void 0,zIndex:j?4:2,paddingLeft:H===0?"12px":"",borderRight:a&&!Fe&&!j?fe:void 0,borderBottom:a?fe:void 0,boxShadow:a&&j?se:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:T.textAlign==="text-right"?"right":T.textAlign==="text-center"?"center":"left",...m(H,T.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[T.headerTooltip?e.jsx(De.Tooltip,{label:T.headerTooltip.content,position:"bottom",children:Ve}):Ve,T.filter&&e.jsx(ul,{filter:T.filter,columnTitle:T.title}),p&&e.jsx("button",{onClick:()=>Je(H),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(qo,{frozen:j})})]}),K&&e.jsx("div",{onMouseDown:ar=>q(ar,H),onClick:ar=>ar.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-${H}`)}),$?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:a?fe:void 0,boxShadow:a&&w?te:void 0}}):null]})}),e.jsx(U.Tbody,{children:c?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(u.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"}),e.jsx(He.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&b?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:b})}):t==null?void 0:t.map((T,H)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:H===t.length-1&&pe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:j=>{const Z=j.currentTarget;Z.style.backgroundColor=yl,Array.from(Z.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=yl)})},onMouseLeave:j=>{const Z=j.currentTarget;Z.style.backgroundColor="",Array.from(Z.querySelectorAll("td")).forEach(K=>{K.style.position==="sticky"&&(K.style.backgroundColor=lt)})},children:[r.map((j,Z)=>{const K=j.render?j.render(T,H,t):je(T,j.accessor),xe=C>0&&Z<C,Fe=Ce[Z]??0,Ae=qe[Z]!==void 0,ze=xe&&Z===C-1;return e.jsx(U.Td,{style:{position:xe?"sticky":void 0,left:xe?Fe:void 0,zIndex:xe?1:void 0,backgroundColor:xe?lt:void 0,transition:xe?"background-color 0.3s ease":void 0,paddingLeft:Z===0?"12px":"",whiteSpace:"nowrap",overflow:Ae?"hidden":void 0,borderLeft:j.showBorderLeft?fe:void 0,borderRight:j.showBorderRight?fe:void 0,boxShadow:ze?se:void 0,textAlign:j.textAlign==="text-right"?"right":j.textAlign==="text-center"?"center":"left",...m(Z,j.width)},children:typeof K=="string"?e.jsx(S.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:j.textAlign==="text-right"?"right":j.textAlign==="text-center"?"center":"left"},children:K}):K},`row-${H}-col-${Z}`)}),$?e.jsx(U.Td,{style:{width:Be,position:"sticky",right:0,zIndex:1,backgroundColor:lt,boxShadow:w?te:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ce.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:I.map(j=>{const Z=H===t.length-1?"top":"bottom";return j==="detail"&&l&&(d==null?void 0:d(T))!==!1?e.jsx(De.Tooltip,{label:"Detail",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(T.id,T),iconLeft:e.jsx(F.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):j==="update"&&n&&(i==null?void 0:i(T))!==!1?e.jsx(De.Tooltip,{label:"Update",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(T),iconLeft:e.jsx(F.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):j==="delete"&&o&&(s==null?void 0:s(T))!==!1?e.jsx(De.Tooltip,{label:"Delete",position:Z,children:e.jsx(P.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(T.id,T),iconLeft:e.jsx(F.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):j==="custom"?e.jsx(h.Fragment,{children:x==null?void 0:x(T)},"custom"):null})})}):null]},`${T}${H}`))})]})})},Zo=({wrapperProps:r,dataTableProps:t,headerProps:l,footerProps:n})=>{var C;const o=h.useRef(null),[c,s]=h.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(l==null?void 0:l.show)??!0,d=h.useRef(null),a=(C=t==null?void 0:t.pagination)==null?void 0:C.totalData;typeof a=="number"&&(d.current=a);const y=(n==null?void 0:n.showFooter)??(a===void 0?d.current!==0:a!==0);return e.jsxs(hl,{...r,children:[i&&e.jsx(fl,{...l}),e.jsx(u.Box,{direction:"column",ref:o,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(pl,{...t,scrollParentRef:o,frozenCount:t!=null&&t.enableFreezeColumns?c:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?s:void 0}):null}),y&&e.jsx(gl,{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 Go(r){return h.memo(r)}const Qo=Go(Zo),Cl=200,ot="1px solid var(--sa-border-subtle, #0b120e24)",Uo=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(F.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(F.Icon,{name:"ChevronSmallDown"}):t?e.jsx(F.Icon,{name:"LockOn",size:"xs"}):e.jsx(F.Icon,{name:"Filter",size:"xs"}),Fr=({icon:r,label:t,active:l,danger:n,onClick:o})=>{const c=n?"var(--sa-color-error-600, #c9184a)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:o,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:l?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:c,textAlign:"left"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:s=>{s.currentTarget.style.background=l?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(F.Icon,{name:r,size:"sm",style:{color:c,flexShrink:0}}),e.jsx(S.Text,{as:"span",style:{color:c},children:t})]})},bl=({active:r,canSort:t,canHide:l,sortDir:n,frozen:o,onSort:c,onClearSort:s,onToggleFreeze:i,onHide:d})=>{const[a,y]=h.useState(!1),C=h.useRef(null),p=h.useRef(null),[x,I]=h.useState({top:0,left:0});h.useEffect(()=>{if(a&&C.current){const B=C.current.getBoundingClientRect(),M=B.left+Cl>window.innerWidth;I({top:B.bottom+6,...M?{right:window.innerWidth-B.right}:{left:B.left}})}},[a]),h.useEffect(()=>{if(!a)return;const B=M=>{p.current&&!p.current.contains(M.target)&&C.current&&!C.current.contains(M.target)&&y(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[a]);const b=B=>{B(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:C,type:"button",className:"sa-tl-menu-trigger","data-active":r||a?"true":"false",onClick:B=>{B.stopPropagation(),y(M=>!M)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:ot,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(Uo,{sortDir:n,frozen:o})}),a&&e.jsxs(u.Box,{ref:p,onClick:B=>B.stopPropagation(),style:{position:"fixed",top:`${x.top}px`,...x.left!==void 0?{left:`${x.left}px`}:{right:`${x.right}px`},minWidth:Cl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:ot,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"0 6px 24px rgba(0,0,0,0.12)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Fr,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>b(()=>n==="asc"?s():c("asc"))}),e.jsx(Fr,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>b(()=>n==="desc"?s():c("desc"))}),e.jsx("div",{style:{borderTop:ot,margin:"4px 0"}})]}),e.jsx(Fr,{icon:"Pin1",label:o?"Unfreeze":"Freeze",active:o,onClick:()=>b(i)}),l&&e.jsx(Fr,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>b(d)})]})]})},Er="1px solid var(--sa-border-subtle, #0b120e24)",Jo="var(--sa-text-subtle, #8c8f97)",ur="var(--sa-background-neutral, #f0f1f2)",vl="2px 0 4px -2px rgba(0,0,0,0.15)",Mr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},xl="sa-table-layout-styles",Yo=()=>{if(typeof document>"u"||document.getElementById(xl))return;const r=document.createElement("style");r.id=xl,r.textContent=`
|
|
2
2
|
.sa-table-layout tbody td { transition: background-color 0.15s ease; }
|
|
3
3
|
.sa-table-layout tbody tr:hover td {
|
|
4
4
|
background-color: var(--sa-background-primary-inverse, #f8f8f8);
|