@starasia/admin 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/tanstack.cjs.js +1 -1
- package/dist/adapters/tanstack.es.js +29 -20
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +15 -9
- package/dist/index.umd.js +2 -2
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(u,yr){typeof exports=="object"&&typeof module<"u"?yr(exports,require("@starasia/alert"),require("@starasia/avatar"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/avatar","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-dom","react-easy-crop"],yr):(u=typeof globalThis<"u"?globalThis:u||self,yr(u["@starasia/admin"]={},u.alert,u.avatar,u.badges,u.box,u.breadcrumb,u.button,u.card,u.date,u.dialog,u.drawer,u.dropdown,u.hooks,u.http,u.input,u.menu,u.pagination,u.storage,u.table,u.tabs,u.textarea,u.theme,u.toast,u.toggle,u.tooltip,u.checkbox,u.radio,u.text,u.icon,u.flex,u.grid,u.progress,u.stepper,u.accordion,u.storyRecord,u.skeleton,u.progressStepper,u.jsxRuntime,u.React,u.ReactDOM,u.ReactEasyCrop))})(this,function(u,yr,zr,sr,f,pr,j,ct,fr,je,Hr,br,De,vr,ar,A,kr,Er,U,$t,it,Cr,Kt,xr,me,tr,at,D,M,ie,Rt,eo,ro,to,oo,$e,lo,e,d,Pr,Nl){"use strict";const _l={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},dt=d.createContext(_l),ht=()=>d.useContext(dt),no=r=>{const[t,o]=d.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:o}},so=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),co=({children:r})=>{const[t,o]=d.useState({}),n=d.useCallback(i=>{o(a=>typeof i=="function"?i(a):i)},[]),l=d.useCallback((i,a)=>{o(h=>{const y=typeof a=="function"?a(h[i]):a;return{...h,[i]:y}})},[]),s=d.useCallback(i=>{o(a=>{if(!(i in a))return a;const h={...a};return delete h[i],h})},[]),c=d.useMemo(()=>({badges:t,setBadge:l,setBadges:n,clearBadge:s}),[t,l,n,s]);return e.jsx(so.Provider,{value:c,children:r})},io=()=>d.useContext(so),Vr=(r,t)=>{const o=t!==void 0?t:r;return o==null?null:typeof o=="string"||typeof o=="number"?{value:o}:o},ft=240,ut=200,gt=480,ql="sa-sidebar-width",yt=(r,t,o)=>Math.min(Math.max(r,t),o),Zl=(r,t,o,n)=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(r);if(!l)return t;const s=parseInt(l,10);return Number.isFinite(s)?yt(s,o,n):t}catch{return t}},ao=(r,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(r,String(t))}catch{}},ho=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:ft,setWidth:()=>{},resetWidth:()=>{},minWidth:ut,maxWidth:gt,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),fo=({children:r,defaultCollapsed:t=!1,defaultWidth:o=ft,minWidth:n=ut,maxWidth:l=gt,widthStorageKey:s=ql})=>{const[c,i]=d.useState(t),[a,h]=d.useState(!1),[y,b]=d.useState(()=>Zl(s,o,n,l)),p=d.useCallback(S=>{i(z=>typeof S=="function"?S(z):S)},[]),C=d.useCallback(()=>i(S=>!S),[]),E=d.useCallback(()=>i(!0),[]),w=d.useCallback(()=>i(!1),[]),L=d.useCallback(S=>{b(z=>{const O=typeof S=="function"?S(z):S,Y=yt(Math.round(O),n,l);return ao(s,Y),Y})},[n,l,s]),F=d.useCallback(()=>{const S=yt(o,n,l);ao(s,S),b(S)},[o,n,l,s]),I=d.useCallback(S=>{h(z=>typeof S=="function"?S(z):S)},[]),B=d.useCallback(()=>h(!0),[]),k=d.useCallback(()=>h(!1),[]),H=d.useCallback(()=>h(S=>!S),[]),W=d.useMemo(()=>({collapsed:c,setCollapsed:p,toggle:C,collapse:E,expand:w,width:y,setWidth:L,resetWidth:F,minWidth:n,maxWidth:l,mobileOpen:a,setMobileOpen:I,openMobile:B,closeMobile:k,toggleMobile:H}),[c,p,C,E,w,y,L,F,n,l,a,I,B,k,H]);return e.jsx(ho.Provider,{value:W,children:r})},uo=()=>d.useContext(ho),go=d.createContext(null),yo=({adapter:r,children:t})=>e.jsx(go.Provider,{value:r,children:t}),or=()=>{const r=d.useContext(go);if(!r)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return r},po=({router:r,routerAdapter:t,menus:o=[],menuBottom:n,logo:l,appName:s="Workspace",initialUserData:c,theme:i})=>{const a=no({initialUserData:c}),{theme:h}=Cr.useTheme();return e.jsx(yo,{adapter:t,children:e.jsx(dt.Provider,{value:{logo:l,appName:s,menus:o,userData:a.userData,setUserData:a.setUserData,menuBottom:n},children:e.jsx(co,{children:e.jsx(fo,{children:i?e.jsx(Cr.ThemeProvider,{value:i,children:r}):h?e.jsx(Cr.ThemeProvider,{value:h,children:r}):r})})})})},Gl=d.memo(po);function bo({collapsed:r=!1,children:t}){if(!t)return null;const o=typeof t=="function",n=o?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:o?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const pt=d.createContext(null);function vo({children:r}){const[t,o]=d.useState(null),[n,l]=d.useState(null),[s,c]=d.useState(null),[i,a]=d.useState(0),h=d.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx(pt.Provider,{value:{prependNode:t,appendNode:n,replaceNode:s,setPrependNode:o,setAppendNode:l,setReplaceNode:c,replaceCount:i,registerReplace:h},children:r})}function Co({children:r}){const t=d.useContext(pt);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 Ql({children:r,mode:t="append"}){const o=d.useContext(pt);if(d.useEffect(()=>{if(!(t!=="replace"||!o))return o.registerReplace()},[t,o]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?o.prependNode:t==="replace"?o.replaceNode:o.appendNode;return n?Pr.createPortal(r,n):null}const bt=d.createContext(null);function xo({children:r}){const[t,o]=d.useState({}),[n,l]=d.useState({}),s=d.useCallback((a,h)=>{o(y=>y[a]===h?y:{...y,[a]:h})},[]),c=d.useCallback(a=>(l(h=>({...h,[a]:(h[a]??0)+1})),()=>l(h=>({...h,[a]:Math.max(0,(h[a]??0)-1)}))),[]),i=d.useMemo(()=>({outletNodes:t,setOutletNode:s,slotCounts:n,registerSlot:c}),[t,s,n,c]);return e.jsx(bt.Provider,{value:i,children:r})}function wo({slotKey:r,fallback:t}){const o=d.useContext(bt),n=o?(o.slotCounts[r]??0)>0:!1,l=d.useRef(o==null?void 0:o.setOutletNode);l.current=o==null?void 0:o.setOutletNode;const s=d.useCallback(c=>{var i;return(i=l.current)==null?void 0:i.call(l,r,c)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:s,style:{display:"contents"}}):t})}function Ul({slotKey:r,children:t}){const o=d.useContext(bt),n=d.useRef(o==null?void 0:o.registerSlot);if(n.current=o==null?void 0:o.registerSlot,d.useEffect(()=>{var s;return(s=n.current)==null?void 0:s.call(n,r)},[r]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const l=o.outletNodes[r];return l?Pr.createPortal(t,l):null}const jr="moduleSwitcherGroupId",vt="sa-module-switcher-change";function Do(){if(typeof window>"u")return null;const r=window.localStorage.getItem(jr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function So(r){typeof window>"u"||(r===null?window.localStorage.removeItem(jr):window.localStorage.setItem(jr,String(r)),window.dispatchEvent(new CustomEvent(vt,{detail:r})))}function Jl(){So(null)}function Ct(){const[r,t]=d.useState(()=>Do());return d.useEffect(()=>{const n=()=>{t(Do())},l=s=>{s.key===jr&&n()};return window.addEventListener(vt,n),window.addEventListener("storage",l),()=>{window.removeEventListener(vt,n),window.removeEventListener("storage",l)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{So(n),t(n)}}}let Nr=0,ur=!1,Bo=new Set;function Yl(r){const[t,o]=d.useState(!1),n=d.useRef(null),l=d.useRef(null);return d.useLayoutEffect(()=>{const s=n.current;if(!s)return;let c=0;const i=()=>{c=0;const h=l.current;if(!h)return;const y=h.scrollWidth>s.clientWidth;o(b=>b===y?b:y)},a=new ResizeObserver(()=>{c||(c=requestAnimationFrame(i))});return a.observe(s),i(),()=>{c&&cancelAnimationFrame(c),a.disconnect()}},[r]),{containerRef:n,textRef:l,truncated:t}}function ko({text:r,textStyle:t}){const{containerRef:o,textRef:n,truncated:l}=Yl(r),s=e.jsx(D.Text,{ref:n,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...t},children:r});return e.jsx(f.Box,{ref:o,display:"block",style:{flex:1,minWidth:0},children:l?e.jsx(me.Tooltip,{fluid:!0,label:r,position:"top",children:s}):s})}const Xl=200,xt="var(--app-header-height, 4rem)",Eo="44px",wt=`calc((${xt} - 2rem) / 2)`,mo=16;function $l({children:r,headerLeftSlot:t,profile:o,isLoadingProfile:n,onLogout:l,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:i,headerActions:a,profileRole:h,profileMenuButtons:y,profileMenuItems:b,logoutButton:p,resizableSidebar:C=!0}){var hr,Sr;const{useSearchParams:E,useNavigate:w,useLocation:L,Outlet:F}=or(),[I]=E(),B=I.get("embed")==="true",k=ht(),{badges:H}=io(),W=w(),S=L(),O=!De.useMediaQuery("md"),[Y,X]=d.useState(!1),{collapsed:q,setCollapsed:Z,width:K,setWidth:te,resetWidth:_,minWidth:V,maxWidth:N,mobileOpen:se,setMobileOpen:ve}=uo(),[Ee,ue]=d.useState(!1),[Ce,xe]=d.useState(()=>new Set(Bo)),[we,Ae]=d.useState(null),{selectedGroupId:Fe,setSelectedGroupId:_e}=Ct(),$=q&&!O;d.useEffect(()=>{Bo=Ce},[Ce]);const ge=d.useRef(null),We=d.useRef(null),Ze=d.useRef(null),[de,Ge]=d.useState(!1),[lr,P]=d.useState(null),R=C&&!O&&!q,J=m=>Math.min(Math.max(m,V),N),he=lr??K,ce=m=>{var ke,Ie,Ve;if(!R)return;m.preventDefault();const G=m.clientX,re=((ke=Ze.current)==null?void 0:ke.getBoundingClientRect().width)??K;(Ve=(Ie=m.currentTarget).setPointerCapture)==null||Ve.call(Ie,m.pointerId),Ge(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let Se=0,Oe=re;const Ye=Or=>{Oe=re+(Or.clientX-G),Se||(Se=requestAnimationFrame(()=>{Se=0,P(J(Oe))}))},He=()=>{Se&&cancelAnimationFrame(Se),window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",He),document.body.style.userSelect="",document.body.style.cursor="",P(null),Ge(!1),Oe<Xl?Z(!0):te(J(Oe))};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",He)},Me=m=>{R&&(m.key==="ArrowLeft"?(m.preventDefault(),te(G=>G-mo)):m.key==="ArrowRight"?(m.preventDefault(),te(G=>G+mo)):m.key==="Home"?(m.preventDefault(),te(V)):m.key==="End"&&(m.preventDefault(),te(N)))};d.useEffect(()=>{const m=ge.current;if(!m)return;const G=()=>{ur||(Nr=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const ze=()=>{const m=ge.current;m&&Nr>0&&(ur=!0,m.scrollTop=Nr,requestAnimationFrame(()=>{ur=!1}))};d.useLayoutEffect(()=>{ur=!0,ze();const m=setTimeout(()=>{ur=!1},300);return()=>clearTimeout(m)},[]),d.useLayoutEffect(()=>{k.menus.length>0&&(Nr>0?ze():requestAnimationFrame(()=>{var G;const m=(G=ge.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[k.menus]),d.useEffect(()=>{ur=!0,ze();const m=setTimeout(ze,0),G=setTimeout(ze,50),re=setTimeout(ze,100),Se=setTimeout(ze,200),Oe=setTimeout(()=>{ur=!1},300),Ye=setTimeout(()=>{const He=ge.current,ke=He==null?void 0:He.querySelector("[data-menu-active='true']");if(He&&ke){const Ie=He.getBoundingClientRect(),Ve=ke.getBoundingClientRect();Ve.top>=Ie.top&&Ve.bottom<=Ie.bottom||ke.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout(re),clearTimeout(Se),clearTimeout(Oe),clearTimeout(Ye)}},[S.pathname]),d.useEffect(()=>{We.current&&(We.current.scrollTop=0)},[S.pathname]),d.useEffect(()=>{O&&ve(!1)},[S.pathname,O]),d.useEffect(()=>{O&&Z(!0)},[O]),d.useEffect(()=>{const m=document.documentElement;return m.style.setProperty("--app-header-height",Eo),()=>{m.style.removeProperty("--app-header-height")}},[]);const er=()=>{X(!0)},Qe=()=>{X(!1)},Le=()=>{X(!1),l()},Je=m=>{const G=[m.to];return m.children&&G.push(...m.children.map(re=>re.to)),G},Be=[...k.menus.flatMap(m=>m.items.flatMap(Je)),...((hr=k.menuBottom)==null?void 0:hr.flatMap(Je))??[]],Ue=m=>{if(!S.pathname.startsWith(m))return!1;const G=Be.filter(re=>S.pathname.startsWith(re)).sort((re,Se)=>Se.length-re.length)[0];return m===G};d.useEffect(()=>{var G;const m=re=>{var Se;(Se=re.children)!=null&&Se.some(Oe=>S.pathname.startsWith(Oe.to))&&xe(Oe=>{const Ye=new Set(Oe);return Ye.add(re.id),Ye})};k.menus.forEach(re=>{re.items.forEach(m)}),(G=k.menuBottom)==null||G.forEach(m)},[S.pathname,k.menus,k.menuBottom]);const nr=m=>{xe(G=>{const re=new Set(G);return re.has(m)?re.delete(m):re.add(m),re})};d.useEffect(()=>{k.menus.length!==0&&Fe!==null&&!k.menus.some(m=>m.id===Fe)&&_e(null)},[k.menus,Fe,_e]);const gr=d.useMemo(()=>{if(Fe!==null)return k.menus.filter(re=>re.id===Fe||re.parentGroupId===Fe);const m=k.menus.filter(re=>re.parentGroupId===void 0),G=k.menus.filter(re=>re.parentGroupId!==void 0).flatMap(re=>re.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[k.menus,Fe]);if(B)return e.jsx(f.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:r||e.jsx(F,{})});const dr=m=>{const G=m.children&&m.children.length>0,re=Ce.has(m.id),Se=G?m.children.some(He=>Ue(He.to)):Ue(m.to),Oe=Vr(m.badge,H[m.id]),Ye=!!Oe&&q&&!O;return e.jsxs(f.Box,{display:"block","data-menu-active":Se||void 0,children:[e.jsxs(f.Box,{as:"button",onClick:He=>{if(G)if(q&&!O){const ke=He.currentTarget.getBoundingClientRect();Ae({item:m,top:ke.top,left:ke.right+8})}else nr(m.id);else W(m.to)},fullWidth:!0,direction:"row",align:"center",justify:q&&!O?"center":void 0,gap:"sm",paddingInline:q&&!O?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Se?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:Se?"border-base":void 0,bg:Se?"white":void 0,hover:Se?void 0:{bg:"neutral"},title:q&&!O?m.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",...Se?null:{borderColor:"transparent"}},children:[e.jsxs(f.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),Ye&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(sr.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!q||O)&&e.jsxs(e.Fragment,{children:[e.jsx(ko,{text:m.title,textStyle:{transition:"opacity 0.3s"}}),Oe&&e.jsx(sr.Badge,{text:String(Oe.value),variant:Oe.variant??"info",size:"xs",border:!0}),G&&e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:re?"rotate(180deg)":"rotate(0deg)"}})]})]}),G&&(!q||O)&&(()=>{const He=m.children.findIndex(ke=>Ue(ke.to));return e.jsxs(f.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:re?`${m.children.length*36}px`:"0px",opacity:re?1:0,marginTop:re?"0.25rem":"0px"},children:[e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),He>=0&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${He*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),m.children.map(ke=>{const Ie=Vr(ke.badge,H[ke.id]),Ve=Ue(ke.to);return e.jsxs(f.Box,{as:"button",onClick:()=>W(ke.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Ve?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:Ve?"border-base":void 0,bg:Ve?"white":void 0,hover:Ve?void 0:{bg:"neutral"},style:{textAlign:"left",color:Ve?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",...Ve?null:{borderColor:"transparent"}},children:[e.jsx(M.Icon,{name:ke.icon,size:"sm",style:{flexShrink:0}}),e.jsx(ko,{text:ke.title}),Ie&&e.jsx(sr.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0})]},ke.id)})]})})()]},m.id)};return e.jsx(xo,{children:e.jsxs(vo,{children:[e.jsxs(f.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":Eo,"--app-sidebar-width":O?"0px":q?xt:`${he}px`,"--app-footer-zindex":O&&se?"40":"998"},children:[O&&e.jsx(f.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ve(!1)}),e.jsxs(f.Box,{as:"aside",ref:Ze,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:O?void 0:"0",style:{width:O?"16.375rem":q?xt:`${he}px`,position:O?"fixed":"relative",...O&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:de?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(f.Box,{onMouseEnter:()=>ue(!0),onMouseLeave:()=>ue(!1),direction:"row",align:"center",justify:"space-between",paddingInline:$?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...$?{paddingInline:wt}:null},children:(()=>{const m=!O&&q&&!se,G=m&&Ee;return e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flex:m?"1":void 0,justify:m?"center":void 0,style:{transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:k.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!q||se)&&e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:k.appName})]}),!O&&!q&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),m&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"Cross",size:"md"})})]})})()}),i&&e.jsx(bo,{collapsed:O?!1:q,children:i}),e.jsx(f.Box,{ref:ge,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:gr.map(m=>e.jsxs(f.Box,{marginBottom:"lg",children:[!q||O?m.name&&e.jsx(D.Text,{fontSize:"md",fontWeight:"normal",color:"subtlest",truncate:!0,style:{paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:m.name}):m.name&&e.jsx(f.Box,{"aria-label":m.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(f.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(f.Box,{paddingInline:$?void 0:"md",gap:"xs",style:$?{paddingInline:wt}:void 0,children:m.slotKey?e.jsx(wo,{slotKey:m.slotKey,fallback:m.items.map(G=>dr(G))}):m.items.map(G=>dr(G))})]},m.id))}),k.menuBottom&&k.menuBottom.length>0&&e.jsx(f.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:$?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:$?{paddingInline:wt}:void 0,children:k.menuBottom.map(m=>dr(m))}),R&&e.jsx(f.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":K,"aria-valuemin":V,"aria-valuemax":N,tabIndex:0,onPointerDown:ce,onKeyDown:Me,onDoubleClick:_,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:de?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:m=>{de||(m.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:m=>{de||(m.currentTarget.style.background="transparent")}})]}),e.jsxs(f.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(f.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:O?"lg":void 0,children:[O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(Co,{children:t})]}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(f.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:n?"Loading...":(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:n?"":(o==null?void 0:o.email)||"unknown"})]}),e.jsx(zr.Avatar,{size:"sm",initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(M.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(A.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs(f.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(zr.Avatar,{customSize:64,initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(D.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.email)||"unknown"}),h&&e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:h})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuItem,{onClick:m.onClick,startIcon:e.jsx(M.Icon,{name:m.icon,size:"md"}),children:m.label},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuItem,{intent:"danger",onClick:er,startIcon:e.jsx(M.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(f.Box,{as:"main",ref:We,flex:"1",overflow:"overflow-y-auto",children:r||e.jsx(F,{})})]})]}),s&&c&&e.jsx(f.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:c}),e.jsxs(je.Dialog,{isShow:Y,onHide:Qe,children:[e.jsx(je.DialogTitle,{children:"Confirmation Logout"}),e.jsx(je.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(je.DialogFooter,{children:e.jsx(f.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ie.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Qe,children:"Cancel"})}),e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:Le,children:"Yes, Sure"})})]})})})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{onClick:()=>Ae(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(f.Box,{role:"dialog","aria-label":we.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:we.top,left:we.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:we.item.title}),(Sr=we.item.children)==null?void 0:Sr.map(m=>{const G=Ue(m.to),re=Vr(m.badge,H[m.id]);return e.jsxs(f.Box,{as:"button",onClick:()=>{W(m.to),Ae(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:G?"primary-inverse":void 0,hover:G?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:m.title}),re&&e.jsx(sr.Badge,{text:String(re.value),variant:re.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const mr=d.forwardRef(({children:r,...t},o)=>e.jsx(f.Box,{ref:o,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Fo=({title:r,iconName:t,textColor:o,iconColor:n,hoverTextColor:l,hoverIconColor:s})=>{const[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=o??"var(--sa-text-subtle, #8c8f97)",y=s??"var(--sa-text-subtle, #8c8f97)",b=l??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:c?y:a,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:c?b:h,transition:"color 0.15s ease"},children:r||"Back"})]})},Kl=({items:r,separator:t="/",iconName:o,iconColor:n,hoverIconColor:l})=>{const{Link:s}=or(),[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=l??"var(--sa-text-subtle, #8c8f97)",y=r.length>1?r[0]:void 0,b=!!(y!=null&&y.to||y!=null&&y.onClick),p=e.jsx(M.Icon,{name:o||"ChevronLeft",size:"xs",onMouseEnter:b?()=>i(!0):void 0,onMouseLeave:b?()=>i(!1):void 0,style:{color:b&&c?h:a,transition:"color 0.15s ease",cursor:b?"pointer":void 0}}),C=y!=null&&y.to?e.jsx(s,{to:y.to,replace:!0,style:{textDecoration:"none"},children:p}):y!=null&&y.onClick?e.jsx(mr,{onClick:y.onClick,children:p}):p;return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",children:[C,e.jsx(pr.Breadcrumb,{separator:t,size:"md",children:r.map((E,w)=>{const L=w===r.length-1;return E.to&&!L?e.jsx(pr.BreadcrumbItem,{children:e.jsx(s,{to:E.to,children:E.label})},w):e.jsx(pr.BreadcrumbItem,{currentPage:L,children:e.jsx(pr.BreadcrumbLink,{onClick:L?void 0:E.onClick,children:E.label})},w)})})]})},Rl=r=>{const{Link:t}=or(),{items:o,separator:n,onClick:l,navigateTo:s,...c}=r;return o&&o.length>0?e.jsx(Kl,{items:o,separator:n,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):s?e.jsx(f.Box,{direction:"row",children:e.jsx(t,{to:s,replace:!0,style:{textDecoration:"none"},children:e.jsx(Fo,{...c})})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:l,children:e.jsx(Fo,{...c})})})},Dt=[{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 Mo(r,t,o){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${o.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?o.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${o.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${o.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Io={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},To={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Lo({isShow:r,onHide:t,menus:o,selectedGroupId:n,onSelect:l}){const[s,c]=d.useState(void 0),i=h=>{l(h),t()},a=Dt[0];return e.jsx(je.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(je.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:To,children:[e.jsx("div",{style:Mo(n===null,s==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Io,children:"Semua"})]}),o.map((h,y)=>{var w;const b=n===h.id,p=s===h.id,C=((w=h.items[0])==null?void 0:w.icon)??"Grid",E=Dt[(y+1)%Dt.length];return e.jsxs("button",{onClick:()=>i(h.id),onMouseEnter:()=>c(h.id),onMouseLeave:()=>c(void 0),style:To,children:[e.jsx("div",{style:Mo(b,p,E),children:e.jsx("div",{style:{color:E.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:C,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Io,children:h.name})]},h.id)})]})})})}function en({onSelect:r,"aria-label":t="Pilih module"}={}){const o=ht(),{useNavigate:n}=or(),l=n(),{selectedGroupId:s,setSelectedGroupId:c}=Ct(),[i,a]=d.useState(!1),h=y=>{var b;if(c(y),y!==null){const p=o.menus.find(E=>E.id===y),C=(b=p==null?void 0:p.items[0])==null?void 0:b.to;C&&l(C)}r==null||r(y)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":t,onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),s!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(Lo,{isShow:i,onHide:()=>a(!1),menus:o.menus.filter(y=>y.parentGroupId===void 0),selectedGroupId:s,onSelect:h})]})}const rn=(r,t)=>{const o=[];if(t===0)return o.push(r),o;for(let n=0;n<r.length;n+=t){const l=r.slice(n,n+t);o.push(l)}return o},tn=d.memo(({value:r,label:t,separator:o,labelWidth:n,lastIndex:l,labelAlign:s="top"})=>{const c=d.useMemo(()=>({padding:0,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),i=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),a=()=>typeof t=="string"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,h=()=>typeof r=="string"||typeof r=="number"?e.jsx(D.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof o=="string"||typeof o=="number"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:o}):o;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:n,children:a()}),o?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:c,children:h()})]})}),on=d.memo(({fields:r,separator:t,labelWidth:o})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,l)=>e.jsx(tn,{separator:t,labelWidth:o,lastIndex:l===r.length-1,...n},`field-group-field-${l}`))})),ln=d.memo(({maxRow:r=0,maxColumn:t=2,separator:o=":",fields:n=[],labelWidth:l=150,bordered:s=!1})=>{const c=d.useMemo(()=>rn(n,r),[n,r]),i=c.length>2,a=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(f.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((h,y)=>e.jsx(f.Box,{direction:"column",flex:i?void 0:"1",width:i?a():void 0,marginBottom:i?"lg":void 0,children:e.jsx(on,{labelWidth:l,fields:h,separator:o})},y))})}),nn=({backButton:r})=>{const[t,o]=d.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",l=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?s:n,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:t?c:l,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},sn=({backButton:r,title:t,titleIcon:o,titleTag:n,children:l,header:s=!0,headerBorder:c=!1,disableAnimation:i=!1,scrollable:a=!1,stickyHeader:h=!1,subHeaders:y,action:b,titleTagProps:p,containerProps:C,headerProps:E})=>{const w=De.useMediaQuery("md"),{Link:L,useNavigate:F,useLocation:I}=or(),B=F(),k=I(),H=r==null?void 0:r.show,W=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}B(-1,{replace:!0})},S=()=>{if(!b)return null;if(d.isValidElement(b))return b;const Z=b.filter(K=>K&&(K.title||K.icon));return Z.length===0?null:w?e.jsx(f.Box,{direction:"row",gap:"md",children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>e.jsx(j.Button,{iconLeft:te?e.jsx(M.Icon,{name:te,size:"md"}):void 0,onClick:V,..._,children:K},`action-${N}`))}):e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:200},children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>{const se=(_==null?void 0:_.tone)==="error"||(_==null?void 0:_.danger)===!0;return e.jsx(A.MenuItem,{intent:se?"danger":void 0,disabled:_==null?void 0:_.disabled,startIcon:te?e.jsx(M.Icon,{name:te}):void 0,onClick:V,children:K},`action-${N}`)})})})]})},z=()=>{const Z=e.jsx(nn,{backButton:r});return r!=null&&r.navigateTo?e.jsx(f.Box,{direction:"row",children:e.jsx(L,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:Z})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:W,children:Z})})},O=()=>{const Z=!!t,K=Array.isArray(b)&&b.length>0,te=d.isValidElement(b)?!0:K;if(!Z&&!te&&!H)return null;const V=w||!w&&K;return e.jsxs(f.Box,{direction:"column",gap:"xs",paddingBlock:(E==null?void 0:E.paddingBlock)??"sm",paddingInline:(E==null?void 0:E.paddingInline)??"md",...E,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...E==null?void 0:E.style},children:[H&&z(),(Z||te)&&e.jsxs(f.Box,{direction:V?"row":"column",gap:"sm",justify:"space-between",align:V?"center":"flex-start",children:[Z?typeof t=="string"?e.jsxs(f.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[o&&e.jsx(M.Icon,{name:o,size:"md",color:"primary"}),e.jsx(D.Text,{variant:"h3",fontWeight:"semibold",children:t})]}),n&&e.jsx(sr.Badge,{border:!0,size:"lg",text:n,...p})]}):t:null,S()]})]})},Y=()=>{if(!y||y.length===0)return null;const Z=y.filter(_=>_.show!==!1);if(Z.length===0)return null;let K=0,te=-1/0;return Z.forEach((_,V)=>{const N=_.order??0;N>=te&&(te=N,K=V)}),Z.map(({content:_,order:V,borderBottom:N=!0,keepBottomPadding:se=!1,paddingInline:ve=!0,paddingBlock:Ee=!0},ue)=>e.jsx(f.Box,{direction:"column",paddingTop:Ee?"sm":"spacing-0",paddingBottom:Ee&&(N||se||ue===K)?"sm":"spacing-0",paddingInline:ve?"md":"spacing-0",style:{...N?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...V!==void 0?{order:V}:{}},children:_},`sub-header-${ue}`))},X=()=>{const Z=s?O():null,K=Y();return!Z&&!K?null:e.jsxs(f.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...h?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:K?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[Z,K]})},q=()=>l;return e.jsxs(f.Box,{direction:"column",as:"main",...C,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(C==null?void 0:C.style)??{},...i?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[X(),q()]},k.pathname)},cn=d.memo(sn),an={icon:"Cross",title:""},dn=320,Oo=16,Ao=4,hn=8,Wo=d.forwardRef(({onHide:r,show:t,withBlur:o=!1,style:n,children:l,closeButton:s=an,paddingHorizontal:c=!0,width:i,minWidth:a,maxWidth:h,hideBackdrop:y=!1,title:b,headerAction:p,header:C=!0,widthPresets:E,resizable:w=!0,resizeMin:L=dn,resizeMax:F,onWidthChange:I},B)=>{const H=!De.useMediaQuery("md"),W=i??h??a??"357px",S=E??[],z=S.length>1,[O,Y]=d.useState(()=>{const $=S.indexOf(W);return $>=0?$:0}),[X,q]=d.useState(null),[Z,K]=d.useState(!1),[te,_]=d.useState(!1),V=d.useRef(null),N=$=>{V.current=$,typeof B=="function"?B($):B&&(B.current=$)},se=z?S[O]:W,ve=X!=null?`${X}px`:se,Ee=w&&!H,ue=O===S.length-1,Ce=()=>{const $=(O+1)%S.length;q(null),Y($),I==null||I(S[$])},xe=d.useCallback($=>{const ge=F??window.innerWidth;return Math.min(Math.max($,L),ge)},[L,F]),we=d.useRef(null),Ae=$=>{if(!Ee)return;$.preventDefault();const ge=$.currentTarget;ge.setPointerCapture($.pointerId),K(!0);const We=document.body.style.cursor,Ze=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let de=null;const Ge=P=>{const R=xe(window.innerWidth-P.clientX);we.current=R,de==null&&(de=window.requestAnimationFrame(()=>{de=null,we.current!=null&&q(we.current)}))},lr=P=>{de!=null&&window.cancelAnimationFrame(de),we.current!=null&&q(we.current),ge.releasePointerCapture(P.pointerId),ge.removeEventListener("pointermove",Ge),ge.removeEventListener("pointerup",lr),ge.removeEventListener("pointercancel",lr),document.body.style.cursor=We,document.body.style.userSelect=Ze,K(!1),we.current!=null&&(I==null||I(`${we.current}px`))};ge.addEventListener("pointermove",Ge),ge.addEventListener("pointerup",lr),ge.addEventListener("pointercancel",lr)},Fe=$=>{var de;if(!Ee||$.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;$.preventDefault();const ge=$.key==="ArrowLeft"?Oo:-Oo,We=X??((de=V.current)==null?void 0:de.offsetWidth)??L,Ze=xe(We+ge);q(Ze),I==null||I(`${Ze}px`)},_e=()=>{Ee&&(q(null),I==null||I(se))};return e.jsx(Hr.Drawer,{blur:o,isShow:t,position:"right",onHide:r,ref:N,size:ve,style:n,flush:!0,radius:"none",hideBackdrop:y,children:e.jsxs(f.Box,{direction:"column",height:"height-full",children:[Ee?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Ae,onKeyDown:Fe,onDoubleClick:_e,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>_(!0),onPointerLeave:()=>_(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:hn,cursor:"col-resize",zIndex:1,background:Z||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Ao}px, transparent ${Ao}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,C?e.jsxs(f.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(f.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof b=="string"?e.jsx(D.Text,{fontSize:"md",fontWeight:"bold",children:b}):b}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[p,z?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:Ce,"aria-label":ue?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(M.Icon,{name:ue?"ChevronRight":"ChevronLeft"})}):null,s?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:r,"aria-label":s.title||"Tutup",iconRight:e.jsx(M.Icon,{name:s.icon}),children:s.title||void 0}):null]})]}):null,e.jsx(f.Box,{direction:"column",paddingBlock:"md",paddingInline:c?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:l})]})})}),St=d.memo(({children:r,borderBottom:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Bt=d.memo(({children:r,borderTop:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),fn=d.memo(({children:r,...t})=>e.jsx(f.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),un=d.memo(({children:r,title:t,titleTag:o,action:n,header:l,footer:s,actionContainer:c,containerProps:i,bodyProps:a,headerProps:h={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=De.useMediaQuery("lg"),C=()=>o?e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(D.Text,{fontWeight:"medium",children:t}),e.jsx(sr.Badges,{border:!0,text:o,variant:b})]}):e.jsx(D.Text,{fontWeight:"medium",children:t}),E=()=>l||e.jsxs(f.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(f.Box,{direction:"column",children:t?C():null}),e.jsx(f.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:n??null})]}),w=!!(l||t||n);return e.jsxs(f.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[l!==null&&w?e.jsx(St,{...h,children:E()}):null,e.jsx(fn,{...a,children:r}),s?e.jsx(Bt,{...y,children:s}):null]})}),Ke={H1:r=>e.jsx(D.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(D.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(D.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(D.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(D.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(D.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(D.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(D.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(D.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(D.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(D.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(D.Text,{variant:"body-3",children:r.children,...r.props})},Ne=()=>{const{useSearchParams:r,useParams:t,useLocation:o}=or(),[n,l]=r(),s=vr.searchParamsToObject(n.toString()),c=t(),i=o(),a=c.id;return{setSearchParams:l,searchParams:n,searchQueries:s,isHasQuery:(C,E)=>n.has(C)&&n.get(C)===E,getQueryParam:C=>n.get(C),getRouteParam:C=>c[C],params:c,location:i,id:a,hasId:!!a}},zo=r=>JSON.stringify(r),Ho=r=>JSON.stringify(r),Po=r=>JSON.stringify(r),Vo=r=>JSON.stringify(r),gn=r=>r,yn=r=>JSON.stringify(r),Fr=({value:r,name:t,type:o,withSearchParam:n=!0,setSearchParams:l,searchQueries:s,dropdownSearchKey:c,filterKey:i="filter",pageKey:a="page"})=>{if(n){let h;switch(o){case"search":h=gn(r);break;case"dropdown":case"dropdown-multiple":h=zo(r);break;case"radio":h=Ho(r);break;case"date-range":h=Po(r);break;case"advanced-date-range":h=yn(r);break;case"date":h=Vo(r);break;default:h=r;break}if(typeof h<"u"){const b={...s[i]&&typeof s[i]=="string"?JSON.parse(s[i]):void 0,[t]:h},p={...s};c&&typeof c=="string"&&delete p[c],delete p[a];const C={...p,[i]:JSON.stringify(b)},E=new URLSearchParams(s).toString(),w=new URLSearchParams(C).toString();if(E===w)return;l(C)}}},_r=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c)[0].label:n==="value"&&c?JSON.parse(c)[0].value:c},jo=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c).map(i=>i.label):n==="value"&&c?JSON.parse(c).map(i=>i.value):n==="array"&&c?JSON.parse(c):c},pn=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="id"&&c?JSON.parse(c).id:n==="label"&&c?JSON.parse(c).label:n==="value"&&c?JSON.parse(c).value:c},qr=(r,t,o)=>{const n=t.get(o||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0;return l?l[r]:void 0},bn=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},No=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return s?JSON.parse(s):void 0},vn=(r,{filterKey:t="filter",perPageKey:o="perPage",pageKey:n="page"})=>{const l=r.get(t)||void 0,s=r.get(o)||void 0,c=r.get(n)||void 0;return!!l||!!s||!!c},_o=({isOpen:r,onClose:t,filterKey:o,pageKey:n,filters:l})=>{const{searchParams:s,setSearchParams:c,searchQueries:i}=Ne(),[a,h]=d.useState({}),y=()=>{s.delete(o||"filter"),c(s)},b=(p,C)=>{switch(p.type){case"radio":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"dropdown":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"date-range":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"date":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"dropdown-multiple":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}default:return null}};return e.jsx(Wo,{onHide:t,show:r||!1,children:e.jsxs(f.Box,{direction:"column",gap:"md",children:[e.jsxs(ie.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(f.Box,{direction:"column",children:"Filter"}),e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),l==null?void 0:l.map((p,C)=>b(p,C))]})})},qo=({searchKey:r="q",statusKey:t="status",searchPlaceholder:o="Search",searchHighlightPlaceholder:n,extendedFilter:l,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:i="filter",pageKey:a="page",customWidthSearch:h,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:C="right",titleSearchLabel:E="Work Order",withTitleLabels:w=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[I,B]=d.useState(!1),[k,H]=d.useState(0),W=()=>{H(N=>N+1)},{searchParams:S,setSearchParams:z,getQueryParam:O}=Ne(),Y=vr.searchParamsToObject(S.toString()),X=qr(r,S,i)||"",[q,Z]=d.useState(X),K=O(i),_=!!(K&&!(()=>{if(K)try{const N=JSON.parse(K);return Object.keys(N).length===1&&N[r]===""}catch(N){console.error("Filter parameter is not a valid JSON:",N)}return!1})()),V=De.useMediaQuery("md");return d.useEffect(()=>{Z(X)},[X]),d.useEffect(()=>{if(q===X)return;const N=window.setTimeout(()=>{Fr({value:q,name:r,type:"search",searchQueries:Y,setSearchParams:z,filterKey:i,pageKey:a})},350);return()=>{window.clearTimeout(N)}},[q,X,r,Y,z,i,a]),e.jsxs(ie.Flex,{gap:"md",style:{flexDirection:V&&C==="left"?"row":V&&C==="right"?"row-reverse":"column"},align:"flex-end",children:[_&&e.jsx(f.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const N=new URLSearchParams(S);N.delete(i),z(N),Z(""),W(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(D.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),l==null?void 0:l.map(({minWidth:N,content:se,title:ve,onClickContainer:Ee},ue)=>e.jsxs(f.Box,{direction:"column",gap:"sm",onClick:Ee,style:{minWidth:N},children:[ve&&e.jsx(Ke.SubH3,{children:ve}),se]},`extended-filter-${ue}-${k}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:_,secondary:!_,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:K?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!V,onClick:()=>B(!0),children:F?"Filter":void 0}),c&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[w&&e.jsx(Ke.SubH3,{children:"Status"}),e.jsx(br.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:_r({get:"value",name:t,searchParams:S,filterKey:i})?[{label:_r({get:"value",name:t,searchParams:S,filterKey:i})==="active"?"Active":"InActive",value:_r({get:"value",name:t,searchParams:S,filterKey:i})}]:[],onChange:N=>Fr({value:N,name:t,type:"dropdown",searchQueries:Y,setSearchParams:z,filterKey:i}),placeholder:w?"All":"All Status"},k)]}),s&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{width:h&&V?h:V?"310px":""},children:[w&&e.jsxs(Ke.SubH3,{children:["Search for ",E]}),e.jsx(ar.Input,{placeholder:o,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:N=>Z(N.target.value),value:q,fullWidth:!0},k+1+i)]}),e.jsx(_o,{isOpen:I,onClose:()=>B(!1),filterKey:i,filters:b,pageKey:a})]})},Cn=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function kt({configs:r,filterKey:t="filter",activeFilterKey:o="filters",pageKey:n="page",searchKey:l="q"}){const{searchParams:s,setSearchParams:c,searchQueries:i}=Ne(),a=d.useMemo(()=>Object.fromEntries(r.map(k=>[k.key,k])),[r]),h=d.useMemo(()=>{const k=(s.get(o)||"").split(",").map(W=>W.trim()).filter(Boolean);let H=[];try{const W=s.get(t);W&&(H=Object.keys(JSON.parse(W)).filter(S=>S!==l))}catch{}return r.map(W=>W.key).filter(W=>{const S=a[W];return(S==null?void 0:S.locked)||k.includes(W)||H.includes(W)})},[s,o,t,l,r,a]),y=d.useCallback(k=>{try{return k[t]?JSON.parse(k[t]):{}}catch{return{}}},[t]),b=d.useCallback(k=>{const H={...i};k.length?H[o]=k.join(","):delete H[o],c(H)},[i,o,c]),p=d.useCallback(k=>{h.includes(k)||b([...h,k])},[h,b]),C=d.useCallback(k=>{var z;if((z=a[k])!=null&&z.locked)return;const H={...i},W=h.filter(O=>O!==k);W.length?H[o]=W.join(","):delete H[o];const S=y(H);k in S&&(delete S[k],Object.keys(S).length?H[t]=JSON.stringify(S):delete H[t]),delete H[n],c(H)},[i,h,o,t,n,y,c,a]),E=d.useCallback(k=>h.includes(k)?C(k):p(k),[h,p,C]),w=d.useCallback(k=>{switch(k.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return jo({name:k.key,get:"array",searchParams:s,filterKey:t})||[];case"date":{const H=No({name:k.key,searchParams:s,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const W=y(Object.fromEntries(s.entries()))[k.key];return W&&typeof W=="object"?W:void 0}default:return}},[s,t,y]),L=d.useCallback((k,H)=>{if(k.type==="date-compact"){const W={...i},S=y(W);H==null?delete S[k.key]:S[k.key]=H,Object.keys(S).length?W[t]=JSON.stringify(S):delete W[t],delete W[n],c(W);return}Fr({value:H,name:k.key,type:Cn(k.type),searchQueries:i,setSearchParams:c,filterKey:t,pageKey:n})},[i,c,t,n,y]),F=d.useCallback(k=>{const H={...i},W=y(H);k in W&&(delete W[k],Object.keys(W).length?H[t]=JSON.stringify(W):delete H[t]),delete H[n],c(H)},[i,t,n,y,c]),I=d.useCallback(()=>{const k={...i};delete k[t],delete k[o],delete k[n],c(k)},[i,t,o,n,c]),B=h.length>0;return{activeKeys:h,configByKey:a,hasActiveFilter:B,addFilter:p,removeFilter:C,toggleFilter:E,getValue:w,setValue:L,clearValue:F,clearAll:I}}const Et={get(r){return Er.storage.get(r)??null},set(r,t){Er.storage.save(r,t)},remove(r){Er.storage.delete(r)}},wr={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},Zr=(r,t)=>{const o=new Set(t.map(s=>s.key)),n=r.order.filter(s=>o.has(s));for(const s of t)n.includes(s.key)||n.push(s.key);const l=r.hidden.filter(s=>o.has(s));return{order:n,hidden:l}};function xn({columns:r,scopeId:t,storage:o,onColumnsChange:n,value:l}){const s=d.useMemo(()=>({order:r.map(S=>S.key),hidden:[]}),[r]),c=t?wr.columns(t):void 0,i=(S,z)=>Zr({order:S.order??z,hidden:S.hidden??[]},r),[a,h]=d.useState(()=>{if(l&&(l.order||l.hidden))return i(l,r.map(S=>S.key));if(c){const S=o.get(c);if(S&&Array.isArray(S.order))return Zr(S,r)}return s}),y=r.map(S=>S.key).join("|");d.useEffect(()=>h(S=>Zr(S,r)),[y]);const b=d.useRef(a);b.current=a;const p=l?`${(l.order??[]).join("|")}~${(l.hidden??[]).join("|")}`:null,C=d.useRef(p);d.useEffect(()=>{if(p==null||C.current===p)return;C.current=p;const S=b.current,z=i(l,S.order);z.order.join("|")===S.order.join("|")&&z.hidden.join("|")===S.hidden.join("|")||(h(z),c&&o.set(c,z))},[p,y]);const E=d.useRef(!1);d.useEffect(()=>{E.current||(E.current=!0,n==null||n(a))},[]);const w=d.useCallback(S=>{h(S),c&&o.set(c,S),n==null||n(S)},[c,o,n]),L=d.useMemo(()=>{const S=new Map(r.map(z=>[z.key,z]));return a.order.filter(z=>S.has(z)).map(z=>({...S.get(z),visible:!a.hidden.includes(z)}))},[a,r]),F=d.useCallback(S=>{const z=a.hidden.includes(S)?a.hidden.filter(O=>O!==S):[...a.hidden,S];w({...a,hidden:z})},[a,w]),I=d.useCallback((S,z)=>{if(S===z)return;const O=[...a.order],[Y]=O.splice(S,1);O.splice(z,0,Y),w({...a,order:O})},[a,w]),B=d.useCallback(S=>{w({...a,hidden:S?r.filter(z=>!z.locked).map(z=>z.key):[]})},[a,r,w]),k=d.useCallback(()=>w(s),[w,s]),H=d.useCallback(S=>w(Zr(S,r)),[w,r]),W=a.hidden.length===0;return{state:a,orderedColumns:L,allVisible:W,toggleVisibility:F,reorder:I,setAllHidden:B,reset:k,applyState:H}}function wn({scopeId:r,storage:t,snapshotKeys:o,pageKey:n="page",getColumns:l,applyColumns:s}){const{searchParams:c,setSearchParams:i}=Ne(),a=r?wr.savedViews(r):void 0,[h,y]=d.useState(()=>a?t.get(a)||[]:[]),b=d.useCallback(w=>{y(w),a&&t.set(a,w)},[a]),p=d.useCallback(w=>{const L=w.trim();if(!L)return;const F={};o.forEach(B=>{const k=c.get(B);k!=null&&(F[B]=k)});const I={id:`${Date.now()}`,name:L,query:F,columns:l==null?void 0:l(),createdAt:Date.now()};b([...h,I])},[o,c,l,b,h]),C=d.useCallback(w=>b(h.filter(L=>L.id!==w)),[b,h]),E=d.useCallback(w=>{const L=Object.fromEntries(c.entries());o.forEach(F=>delete L[F]),Object.assign(L,w.query),delete L[n],i(L),w.columns&&(s==null||s(w.columns))},[c,o,n,i,s]);return{enabled:!!a,views:h,saveView:p,deleteView:C,applyView:E}}function Dn(r,t){let o;try{o=JSON.parse(r)}catch{return r}return!o||typeof o!="object"?r:(delete o[t],Object.keys(o).length>0?JSON.stringify(o):void 0)}function Zo(r,t,o){const n=r[t];if(n==null)return;const l=Dn(n,o);l===void 0?delete r[t]:r[t]=l}function Sn({scopeId:r,storage:t,snapshotKeys:o,enabled:n=!0,filterKey:l="filter",searchKey:s="q",persistSearch:c=!0}){const{searchParams:i}=Ne(),a=r&&n?wr.lastState(r):void 0,h=d.useRef(a),y=d.useRef(!1);d.useEffect(()=>{if(!a){h.current=a;return}if(h.current!==a){h.current=a,y.current=!1;return}const C={};if(o.forEach(E=>{const w=i.get(E);w!=null&&(C[E]=w)}),c||Zo(C,l,s),Object.keys(C).length===0){y.current&&t.remove(a);return}y.current=!0,t.set(a,C)},[i,a,o,t,c,l,s]);const b=d.useCallback(()=>{if(!a)return null;const C=t.get(a);return!C||Object.keys(C).length===0||!c&&(Zo(C,l,s),Object.keys(C).length===0)?null:C},[a,t,c,l,s]),p=d.useCallback(()=>{a&&t.remove(a)},[a,t]);return{enabled:!!a,read:b,clear:p}}function Bn({scopeId:r,storage:t,perPageKey:o,pageSizeOptions:n,enabled:l=!0}){const{searchParams:s}=Ne(),c=r&&l?wr.perPage(r):void 0,i=s.toString(),a=d.useRef(c);d.useEffect(()=>{if(!c){a.current=c;return}if(a.current!==c){a.current=c;return}const b=s.get(o);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(c,p)},[i,c,o,t]);const h=d.useCallback(()=>{if(!c)return null;const b=t.get(c);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[c,t,n]),y=d.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:h,clear:y}}let mt={},Ft=!1,Mt=null;const kn=(r,t)=>{Object.assign(mt,r),Mt=t,!Ft&&(Ft=!0,queueMicrotask(()=>{const o=mt,n=Mt;mt={},Ft=!1,Mt=null,!(!n||Object.keys(o).length===0)&&n(l=>{const s=new URLSearchParams(l);return Object.entries(o).forEach(([c,i])=>s.set(c,i)),s})}))};function En({enabled:r,snapshotKeys:t,perPageKey:o,readSnapshot:n,readPerPage:l}){const{searchParams:s,setSearchParams:c,location:i}=Ne(),a=d.useRef(null);d.useEffect(()=>{if(!r||a.current===i.pathname)return;a.current=i.pathname;const h={};if(!s.has(o)){const y=l();y&&(h[o]=y)}if(!t.some(y=>s.has(y))){const y=n();y&&Object.assign(h,y)}Object.keys(h).length!==0&&kn(h,c)},[i.pathname,r])}const mn=({configs:r,activeKeys:t,onToggle:o,hasActiveFilter:n,onReset:l})=>r.length?e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&l&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:l,children:"Reset"})]}),children:r.map(s=>e.jsx(A.MenuItem,{selected:s.locked||t.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||o(s.key)},children:s.label},s.key))})})]}):null,Gr=({onClear:r,onRemove:t})=>e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(M.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:180},children:[e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(A.MenuItem,{intent:"danger",startIcon:e.jsx(M.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),Fn=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},Go=(r,t,o)=>{const n=new Date(r);return o==="day"?n.setDate(n.getDate()+t):o==="week"?n.setDate(n.getDate()+t*7):o==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Qo=r=>{const t=Fn(new Date);if(r.direction==="this"){const n=new Date(t),l=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),l.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),l.setMonth(l.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),l.setMonth(11,31)),{from:n,to:l}}const o=r.count??1;return r.direction==="past"?{from:Go(t,-o,r.period),to:t}:{from:t,to:Go(t,o,r.period)}},Uo=24,Jo=r=>r.length>Uo?`${r.slice(0,Uo)}...`:r,Yo=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),It=(r,t="days")=>t==="months"?r.toLocaleDateString(void 0,{month:"short",year:"numeric"}):t==="years"?String(r.getFullYear()):Yo(r),Qr={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"},Mn=["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"},In=["day","week","month","year"],Tn=["past","next","this"],Ln=r=>r.field.type==="date-compact"?e.jsx(Wn,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(On,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),On=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=t?Yo(new Date(t)):null,c=!!s,i=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Jo(s)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():o(a),withPadding:!1})})})]})},An=(r,t="days")=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Qr[r.op]} ${It(new Date(r.date),t)}`:null;case"is-between":return r.from&&r.to?`${It(new Date(r.from),t)} - ${It(new Date(r.to),t)}`:null;case"is-relative-to-today":{const o=r.relative;if(!o)return null;if(o.direction==="this")return`This ${o.period}`;const n=o.count??1,l=n===1?o.period:`${o.period}s`;return`${Tt[o.direction]} ${n} ${l}`}case"is-empty":case"is-not-empty":return Qr[r.op];default:return null}},Wn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.ops&&r.ops.length>0?r.ops:Mn,c=r.defaultOp&&s.includes(r.defaultOp)?r.defaultOp:s[0],i=r.mode??"days",a=(t==null?void 0:t.op)??c,h=t?An(t,i):null,y=!!h,b=y?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Jo(h)})]}):r.label,p=C=>{if(C!==a){if(C==="is-empty"||C==="is-not-empty"){o({op:C});return}if(C==="is-relative-to-today"){o({op:C,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(C==="is-between"){o({op:C,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}o({op:C,date:t==null?void 0:t.date})}};return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:y?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:y?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(zn,{op:a,ops:s,onChange:p})]}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsx(Hn,{value:t,op:a,mode:i,onChange:o})}),a==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},zn=({op:r,ops:t,onChange:o})=>e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Qr[r]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:200},children:t.map(n=>e.jsx(A.MenuItem,{selected:r===n,onClick:()=>o(n),endIcon:r===n?e.jsx(M.Icon,{name:"Check"}):void 0,children:Qr[n]},n))})})]}),Hn=({value:r,op:t,mode:o="days",onChange:n})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const l=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:o,value:l,onChange:s=>{if(s==null){n({op:t});return}if(typeof s=="object"&&s!==null&&"from"in s&&"to"in s){let{from:c,to:i}=s;if(!c&&i&&(c=i,i=null),!c&&!i){n({op:t});return}n({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},`range-${o}`)}return t==="is-relative-to-today"?e.jsx(Pn,{value:r==null?void 0:r.relative,onChange:l=>n({op:t,relative:l})}):e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:o,value:r!=null&&r.date?new Date(r.date):void 0,onChange:l=>{if(l==null){n({op:t});return}l instanceof Date&&n({op:t,date:l.toISOString()})},withPadding:!1},`single-${o}`)},Pn=({value:r,onChange:t})=>{const o=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,l=(r==null?void 0:r.period)??"week",s=o!=="this",c=Qo({direction:o,count:n,period:l});return e.jsxs(f.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Tt[o]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Tn.map(i=>e.jsx(A.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:l}:{direction:i,count:n,period:l}),children:Tt[i]},i))})})]}),s&&e.jsx(ar.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const a=Number(i.target.value);t({direction:o,count:Number.isFinite(a)&&a>0?a:1,period:l})},style:{width:72}}),e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:l})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:In.map(i=>e.jsx(A.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(o==="this"?{direction:o,period:i}:{direction:o,count:n,period:i}),children:i},i))})})]})]}),e.jsx(fr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},Xo=18,Vn=r=>r.length>Xo?`${r.slice(0,Xo)}...`:r,jn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.type==="dropdown-multiple",c=t.length,i=r.searchable!==!1,[a,h]=d.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(I=>I.label.toLowerCase().includes(F)):y})(),C=F=>t.some(I=>I.value===F.value),E=F=>{if(!s){o([{label:F.label,value:F.value}]),h("");return}o(C(F)?t.filter(I=>I.value!==F.value):[...t,{label:F.label,value:F.value}])},w=F=>{var I;h(F),(I=r.onSearch)==null||I.call(r,F)},L=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?Vn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:L})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsxs(f.Box,{direction:"column",gap:"sm",children:[i&&e.jsx(br.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:a,onSearch:w,value:t,onChange:o,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!s,selected:C(F),startIcon:F.avatar,endIcon:C(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>E(F),children:F.label},F.value))})]})})})]})},$o=18,Nn=r=>r.length>$o?`${r.slice(0,$o)}...`:r,Ko=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(tr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),_n=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=new Set(t.map(p=>p.value)),c=t.length,i=r.options.length>0&&r.options.every(p=>s.has(p.value)),a=c>0&&!i,h=p=>{o(s.has(p.value)?t.filter(C=>C.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{o(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(D.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(D.Text,{as:"span",children:c===1?Nn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:240},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(Ko,{checked:i||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s.has(p.value),onClick:()=>h(p),startIcon:e.jsx(Ko,{checked:s.has(p.value)}),children:p.label},p.value))]})})]})},Ro=({activeKeys:r,configByKey:t,getValue:o,setValue:n,clearValue:l,removeFilter:s})=>e.jsx(e.Fragment,{children:r.map(c=>{const i=t[c];if(!i)return null;const a=o(i),h=i.locked?void 0:()=>s(c);return i.type==="date"||i.type==="date-compact"?e.jsx(Ln,{field:i,value:a,onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):i.type==="checkbox-multiple"?e.jsx(_n,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):e.jsx(jn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c)})}),el=r=>`${r} Rows`,qn=({pagination:r,pageKey:t="page",perPageKey:o="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:l=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:i=!0})=>{var F;const{searchQueries:a,setSearchParams:h,searchParams:y}=Ne(),b=y.get(o),p=b?Number(b):l,C=I=>{h({...a,[t]:String(I)})},E=I=>{h({...a,[o]:I,[t]:"1"})},w=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),L=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[s&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${w}-${L} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),c&&e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:el(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(I=>e.jsx(A.MenuItem,{selected:I===p,onClick:()=>E(String(I)),children:el(I)},I))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(f.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(kr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:C})})]})};function Zn(r,t,o=!0){d.useEffect(()=>{if(!o)return;const n=l=>{var i;if(l.metaKey||l.ctrlKey||l.altKey||l.key!==r||je.isOverlayOpen())return;const s=l.target,c=(i=s==null?void 0:s.tagName)==null?void 0:i.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(l.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,o])}const Gn=240,rl=({searchKey:r="q",filterKey:t="filter",pageKey:o="page",placeholder:n="Search",shortcut:l="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:i,searchQueries:a}=Ne(),h=qr(r,c,t)||"",[y,b]=d.useState(!s||!!h),[p,C]=d.useState(s&&!h),[E,w]=d.useState(h),L=De.useDebounce(E,350),F=d.useRef(null);d.useEffect(()=>{w(h),h&&b(!0)},[h]),d.useEffect(()=>{y&&C(!1)},[y]),d.useEffect(()=>{L!==h&&Fr({value:L,name:r,type:"search",searchQueries:a,setSearchParams:i,filterKey:t,pageKey:o})},[L]);const I=d.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var W;return(W=F.current)==null?void 0:W.focus()})},[]);Zn(l,I);const B=()=>{s&&!E&&b(!1)},k=W=>{var S;s&&W.key==="Escape"&&!E&&(b(!1),(S=F.current)==null||S.blur())},H=()=>{y||C(!0)};return e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:I}),e.jsxs(f.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Gn:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(ar.Input,{ref:F,size:"sm",fullWidth:!0,value:E,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:W=>w(W.target.value),onKeyDown:k,onBlur:B,tabIndex:y?0:-1}),y&&!E&&e.jsx(f.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(D.Text,{fontSize:"xs",color:"subtle",children:l})})]})]})},tl=({columns:r,allVisible:t,onToggle:o,onReorder:n,onSetAllHidden:l})=>{const[s,c]=d.useState(null),[i,a]=d.useState(null),h=()=>{s!==null&&i!==null&&s!==i&&n(s,i),c(null),a(null)},y=(b,p)=>{const C=b+p;C<0||C>=r.length||n(b,C)};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:e.jsxs(f.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>l(t),children:t?"Hide All":"Show All"})]}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const C=!b.locked,E=i===p&&s!==null&&s!==p;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:C,onDragStart:()=>C&&c(p),onDragOver:w=>{w.preventDefault(),a(p)},onDrop:h,onDragEnd:h,style:{minHeight:32,boxShadow:E?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(f.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:C?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!C||void 0,color:"icon-subtlest",onKeyDown:w=>{C&&(w.key==="ArrowUp"?(w.preventDefault(),y(p,-1)):w.key==="ArrowDown"&&(w.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:C?"grab":"default",opacity:C?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(f.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(xr.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>o(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},ol=({views:r,onApply:t,onDelete:o,onSave:n})=>{const[l,s]=d.useState(""),c=()=>{const i=l.trim();i&&(n(i),s(""))};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(M.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(A.MenuLists,{style:{width:"260px"},children:[e.jsx(A.MenuBody,{children:e.jsxs(f.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(f.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(D.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:a=>{a.stopPropagation(),o(i.id)}}),children:i.name},i.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(f.Box,{direction:"row",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(ar.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:l,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&c()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!l.trim(),onClick:c,children:"Save"})]})})]})]})},Qn=({isOpen:r,onClose:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:i,getValue:a,setValue:h,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(Hr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(f.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(D.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(j.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(f.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(f.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(Ro,{activeKeys:n,configByKey:l,getValue:a,setValue:h,clearValue:y,removeFilter:b})})]}),o.length>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(f.Box,{direction:"column",children:o.map(C=>{const E=n.includes(C.key),w=!!C.locked;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:w?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[C.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(D.Text,{fontSize:"sm",color:"primary",truncate:!0,children:C.label})]}),e.jsx(xr.Toggle,{size:"sm",checked:E||w,disabled:w,onChange:()=>c(C.key),"aria-label":`Toggle ${C.label}`})]},C.key)})})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:i,children:"Reset"})}),e.jsx(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},Un=r=>`${r} Rows`,Jn=({perPageKey:r,pageKey:t,pageSizeOptions:o,defaultPerPage:n=10,showPageSize:l})=>{const{searchQueries:s,setSearchParams:c,searchParams:i}=Ne(),a=i.get(r),h=a?Number(a):n,y=b=>{c({...s,[r]:b,[t]:"1"})};return l?e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{minWidth:200},children:[e.jsx(f.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),o.map(b=>e.jsx(A.MenuItem,{selected:b===h,endIcon:b===h?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:Un(b)},b))]})})]}):null},Yn=r=>{var We;const{withPadding:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,toggleFilter:c,removeFilter:i,getValue:a,setValue:h,clearValue:y,onReset:b,searchable:p,searchKey:C,filterKey:E,pageKey:w,searchPlaceholder:L,searchShortcut:F,searchCollapsible:I,pagination:B,perPageKey:k,pageSizeOptions:H,defaultPerPage:W,showPagination:S,showResultCount:z,showPageSize:O,hasColumns:Y,orderedColumns:X,allVisible:q,onToggleVisibility:Z,onReorder:K,onSetAllHidden:te,showSavedViews:_,savedViews:V,onApplyView:N,onDeleteView:se,onSaveView:ve,leadingActions:Ee}=r,[ue,Ce]=d.useState(!1),{searchQueries:xe,setSearchParams:we}=Ne(),Ae=(B==null?void 0:B.rangeStart)??(((B==null?void 0:B.currentPage)||0)>1?(((B==null?void 0:B.currentPage)||0)-1)*((B==null?void 0:B.perPage)||0)+1:1),Fe=(B==null?void 0:B.rangeEnd)??((B==null?void 0:B.totalCurrentPage)!==(B==null?void 0:B.perPage)?B==null?void 0:B.totalData:((B==null?void 0:B.currentPage)||1)*((B==null?void 0:B.totalCurrentPage)||0)),_e=Ze=>{we({...xe,[w]:String(Ze)})},$=z||S&&!!(B!=null&&B.totalPage),ge=()=>{b(),Ce(!1)};return e.jsxs(f.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(rl,{searchKey:C,filterKey:E,pageKey:w,placeholder:L,shortcut:F,collapsible:I}),e.jsx(j.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Ce(!0),"aria-label":"Open filters",children:s?`Filter: ${n.length}`:null}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Ee,_&&e.jsx(ol,{views:V,onApply:N,onDelete:se,onSave:ve}),Y&&e.jsx(tl,{columns:X,allVisible:q,onToggle:Z,onReorder:K,onSetAllHidden:te}),e.jsx(Jn,{perPageKey:k,pageKey:w,pageSizeOptions:H,defaultPerPage:W,showPageSize:O})]})]}),$&&e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[z?e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ae}-${Fe} of ${((We=B==null?void 0:B.totalData)==null?void 0:We.toLocaleString())||0}`}):e.jsx(f.Box,{direction:"column"}),S&&!!(B!=null&&B.totalPage)&&e.jsx(kr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:B!=null&&B.currentPage?Number(B.currentPage):1,totalPages:Number(B.totalPage),onPageChange:_e})]}),e.jsx(Qn,{isOpen:ue,onClose:()=>Ce(!1),configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:ge,getValue:a,setValue:h,clearValue:y,removeFilter:i})]})},Xn=({withPadding:r=!1,filterConfigs:t=[],filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:i,showPagination:a=!0,showResultCount:h=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:C="Search",searchShortcut:E="/",searchPosition:w="right",searchCollapsible:L=!0,pagination:F,columns:I=[],onColumnsChange:B,columnsState:k,scopeId:H,savedViews:W,persistLastState:S=!0,persistSearch:z=!0,storage:O=Et,onReset:Y,leadingActions:X})=>{const q=H??(W==null?void 0:W.scopeId),{activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,clearAll:Ee}=kt({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:p}),ue=xn({columns:I,scopeId:q,storage:O,onColumnsChange:B,value:k}),Ce=wn({scopeId:q,storage:O,snapshotKeys:[n,o,s],pageKey:l,getColumns:()=>ue.state,applyColumns:ue.applyState}),xe=Sn({scopeId:q,storage:O,snapshotKeys:[n,o,l],enabled:S,filterKey:o,searchKey:p,persistSearch:z}),we=Bn({scopeId:q,storage:O,perPageKey:s,pageSizeOptions:c,enabled:S});En({enabled:S&&!!q,snapshotKeys:[n,o,l],perPageKey:s,readSnapshot:xe.read,readPerPage:we.read});const Ae=i??c[0]??25,Fe=!!(W!=null&&W.enabled)&&Ce.enabled,_e=()=>{Ee(),xe.clear(),Y==null||Y()},$=De.useMediaQuery("md"),ge=b?e.jsx(rl,{searchKey:p,filterKey:o,pageKey:l,placeholder:C,shortcut:E,collapsible:L}):null;return $?e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(mn,{configs:t,activeKeys:Z,onToggle:_,hasActiveFilter:te,onReset:_e}),w==="left"&&ge,e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Ro,{activeKeys:Z,configByKey:K,getValue:N,setValue:se,clearValue:ve,removeFilter:V}),te&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:_e,children:"Reset"})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[X,e.jsx(qn,{pagination:F,pageKey:l,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y}),w==="right"&&ge,Fe&&e.jsx(ol,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),I.length>0&&e.jsx(tl,{columns:ue.orderedColumns,allVisible:ue.allVisible,onToggle:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden})]})]}):e.jsx(Yn,{withPadding:r,configs:t,activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,onReset:_e,searchable:b,searchKey:p,filterKey:o,pageKey:l,searchPlaceholder:C,searchShortcut:E,searchCollapsible:L,pagination:F,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y,hasColumns:I.length>0,orderedColumns:ue.orderedColumns,allVisible:ue.allVisible,onToggleVisibility:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden,showSavedViews:Fe,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:X})},$n=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},Kn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(o=>(o==null?void 0:o.value)!=null?String(o.value):null).filter(o=>o!=null);return t.length?t:void 0},Rn=(r,t)=>{switch(r.type){case"dropdown":case"radio":return $n(t);case"dropdown-multiple":case"checkbox-multiple":return Kn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},ll=(r,t)=>{if(r==null||r==="")return t;const o=Number(r);return Number.isFinite(o)&&o>0?o:t},es=r=>{const{filterConfigs:t,filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:i=1,defaultPerPage:a=10,paramKeys:h,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:C,getValue:E}=kt({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:c}),{searchParams:w}=Ne(),L=w.toString();return d.useMemo(()=>{const I={},B={},k=ll(w.get(l),i),H=ll(w.get(s),a);I[(h==null?void 0:h.page)??"page"]=k,I[(h==null?void 0:h.perPage)??"perPage"]=H;const W=qr(c,w,o)||"";W&&(I[(h==null?void 0:h.search)??"search"]=W);let S=!1;for(const z of b){const O=p[z];if(!O)continue;const Y=E(O);B[z]=Y;const X=y==null?void 0:y[z],q=X?X(Y):Rn(O,Y);if(q==null||Array.isArray(q)&&q.length===0)continue;const Z=(h==null?void 0:h[z])??z;I[Z]=q,S=!0}return{params:I,raw:B,hasActiveFilter:C||!!W||S}},[L,b.join("|"),o,n,l,s,c,i,a,h,y,p])},rs=["dropdown","dropdown-multiple","checkbox-multiple","radio"],ts=({filterConfigs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l})=>{const{configByKey:s,getValue:c,setValue:i,removeFilter:a,clearAll:h,hasActiveFilter:y}=kt({configs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l}),b=(F,I)=>{var k;const B=F.options;return((k=B==null?void 0:B.find(H=>H.value===I))==null?void 0:k.label)??I},p=d.useCallback(F=>{const I=s[F];if(!I)return[];const B=c(I);return Array.isArray(B)?B.map(k=>String(k.value)):[]},[s,c]),C=d.useCallback((F,I)=>{const B=s[F];if(!B||!rs.includes(B.type))return;const k=Array.isArray(I)?I:[I];if(k.length===0){a(F);return}i(B,k.map(H=>({label:b(B,H),value:H})))},[s,i,a]),E=d.useCallback((F,I)=>{const B=p(F);C(F,B.includes(I)?B.filter(k=>k!==I):[...B,I])},[p,C]),w=d.useCallback((F,I)=>p(F).includes(I),[p]),L=d.useCallback(F=>a(F),[a]);return{set:C,toggle:E,clear:L,clearAll:h,isActive:w,values:p,hasActiveFilter:y}},os=(r,t)=>{if(!r)return{};const{fromKey:o,toKey:n,opKey:l}=t,s={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(s[o]=new Date(r.date).toISOString()),l&&(s[l]=r.op),s;case"is-between":return r.from&&(s[o]=new Date(r.from).toISOString()),r.to&&(s[n]=new Date(r.to).toISOString()),s;case"is-relative-to-today":{if(!r.relative)return s;const{from:c,to:i}=Qo(r.relative);return s[o]=c.toISOString(),s[n]=i.toISOString(),s}case"is-empty":case"is-not-empty":return l&&(s[l]=r.op==="is-empty"?"empty":"not-empty"),s;default:return s}},nl=({children:r,borderRadius:t,height:o})=>{const n=d.useRef(null),[l,s]=d.useState("100vh");return d.useEffect(()=>{if(o)return;const c=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;s(`calc(100vh - ${i}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[o]),e.jsx(f.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:o??l,display:"flex",flexDirection:"column"},children:r})},sl=({action:r,rightContent:t,leftContent:o,headerSlot:n,advanceFilter:l,showFilter:s=!0})=>{const c=De.useMediaQuery("md"),i=s?e.jsx(qo,{...l}):null,a=()=>r?d.isValidElement(r)?r:e.jsx(f.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:h,icon:y,buttonProps:b,onClick:p},C)=>!h&&!y?null:e.jsx(j.Button,{fullWidth:!c,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:h},`action-${C}`))}):null;return e.jsx(f.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:c?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,o]}),e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},ls=({totalData:r,withMarginBottom:t=!0,withMarginTop:o=!0})=>e.jsxs(f.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:o?"16px":void 0},children:[e.jsxs(Ke.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ke.Body1,{children:r||0})]}),cl=({pagination:r,pageKey:t="page",perPageKey:o="perPage",defaultPerPage:n=10,showPagination:l=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:i,searchParams:a}=Ne(),h=a.get(o),y=E=>{i({...c,[t]:String(E)})},b=E=>{i({...c,[o]:E,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),C=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(f.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:l?e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(D.Text,{children:"Rows Per Page: "}),e.jsx(br.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:E=>{b(E[0].value)},value:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(D.Text,{children:`${p}-${C} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(kr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(ls,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},il=({filter:r,columnTitle:t})=>{const[o,n]=d.useState(!1),l=d.useRef(null),s=d.useRef(null),c=d.useRef(null),[i,a]=d.useState(""),[h,y]=d.useState({top:0,left:0}),b=r.selectedValues,p=d.useMemo(()=>i?r.options.filter(w=>w.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);d.useEffect(()=>{if(o&&s.current){const w=s.current.getBoundingClientRect(),L=280,F={top:w.bottom+8};r.position==="left"||w.left+L>window.innerWidth?F.right=window.innerWidth-w.right:F.left=w.left,y(F)}},[o,r.position]),d.useEffect(()=>{o&&c.current?setTimeout(()=>{var w;return(w=c.current)==null?void 0:w.focus()},50):a("")},[o]),d.useEffect(()=>{const w=L=>{l.current&&!l.current.contains(L.target)&&s.current&&!s.current.contains(L.target)&&n(!1)};return o&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[o]);const C=w=>{const L=b.includes(w)?b.filter(F=>F!==w):[...b,w];r.onFilterChange(L)},E=()=>r.onFilterChange([]);return e.jsxs(f.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(f.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:w=>{var L;w.stopPropagation(),o||(L=r.onOpen)==null||L.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:o?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),o&&e.jsxs(f.Box,{ref:l,style:{position:"fixed",top:`${h.top}px`,...h.left!==void 0?{left:`${h.left}px`}:{right:`${h.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(D.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:w=>{w.stopPropagation(),E()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(f.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(ar.Input,{ref:c,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:i,onChange:w=>a(w.target.value),style:{fontSize:"14px"}})}),e.jsx(f.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(f.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(f.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(w=>e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:L=>{L.stopPropagation(),C(w.value)},onMouseEnter:L=>{b.includes(w.value)||(L.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),L.currentTarget.style.transform="translateX(2px)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor=b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",L.currentTarget.style.transform="translateX(0)"},children:[e.jsx(tr.Checkbox,{checked:b.includes(w.value),onChange:()=>{}}),e.jsx(D.Text,{fontSize:"sm",fontWeight:b.includes(w.value)?"medium":"normal",color:b.includes(w.value)?"primary":"gray-700",children:w.label})]},w.value))}):e.jsxs(f.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(f.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:b.length}),e.jsxs(D.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},ns=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",o="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:o,l=r==="desc"?t:o,s=r==="asc"?1:.45,c=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:s,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:l,opacity:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},ss=({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)",al="var(--sa-background-primary-inverse, #f8f8f8)",dl=({columns:r,records:t,handleDetail:o,handleUpdate:n,handleDelete:l,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:i,visibleHandleDetail:a,showHeadBorder:h=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:C,actionsOrder:E=["detail","update","delete","custom"],customEmptyState:w,enableColumnResize:L=!1,defaultColumnWidths:F,onColumnWidthsChange:I,defaultMinColumnWidth:B=60,sort:k,defaultSort:H,onSortChange:W,showActionDivider:S=!1})=>{const z=k!==void 0,[O,Y]=d.useState(H??null),X=z?k??null:O,q=P=>{if(P.sortKey)return P.sortKey;if(typeof P.accessor=="string")return P.accessor},Z=P=>{const R=q(P);if(!R)return;let J;!X||X.key!==R?J={key:R,direction:"asc"}:X.direction==="asc"?J={key:R,direction:"desc"}:J=null,z||Y(J),W==null||W(J)},te=[o,n,l].filter(P=>P!==void 0).length,_=!!C,V=!!o||!!n||!!l||_,N="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${N}`,ve=`inset 1px 0 0 ${N}`,Ee=`inset -1px 0 0 ${N}`,ue=te===3?_?"178px":"140px":te===2?_?"140px":"102px":te===1?_?"112px":"74px":_?"74px":"",Ce=(P,R)=>{if(!R)return P;if(typeof R=="function")return R(P);if(typeof R=="string")return P[R]},[xe,we]=d.useState(!1);d.useEffect(()=>{if(!(y!=null&&y.current))return;const P=y.current;we(P.scrollHeight>P.clientHeight)},[t,y]);const Ae=d.useRef(null),[Fe,_e]=d.useState([]),[$,ge]=d.useState(()=>F??{}),We=d.useRef(null);d.useLayoutEffect(()=>{if(!b||!Ae.current){_e([]);return}const P=Array.from(Ae.current.querySelectorAll("thead tr th")),R=[];let J=0;P.forEach((he,ce)=>{R[ce]=J,ce<b&&(J+=he.offsetWidth)}),_e(R)},[b,r,t,$]);const Ze=P=>{p&&p(P<b?P:P+1)},de=(P,R)=>{const J=$[P];if(J!==void 0){const he=`${J}px`;return{width:he,minWidth:he,maxWidth:he}}return R?{width:R}:{}},Ge=P=>L&&(P.resizable??!0),lr=(P,R)=>{P.preventDefault(),P.stopPropagation();const J=P.currentTarget.closest("th");if(!J)return;const he=Math.round(J.getBoundingClientRect().width);We.current={colIndex:R,startX:P.clientX,startWidth:he};const ce=document.body.style.userSelect,Me=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ze=Qe=>{var Ue;const Le=We.current;if(!Le)return;const Je=((Ue=r[Le.colIndex])==null?void 0:Ue.minWidth)??B,Be=Math.max(Je,Le.startWidth+(Qe.clientX-Le.startX));ge(nr=>nr[Le.colIndex]===Be?nr:{...nr,[Le.colIndex]:Be})},er=()=>{document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",er),document.body.style.userSelect=ce,document.body.style.cursor=Me,We.current=null,I&&ge(Qe=>(I(Qe),Qe))};document.addEventListener("mousemove",ze),document.addEventListener("mouseup",er)};return e.jsx("div",{ref:Ae,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((P,R)=>{var gr,dr;const J=b>0&&R<b,he=Fe[R]??0,ce=Ge(P),ze=R===r.length-1&&V&&S,er=q(P),Qe=!!P.sortable&&!!er,Le=Qe&&(X==null?void 0:X.key)===er?X.direction:null,Je=P.title||((gr=P.accessor)==null?void 0:gr.toString())||"",Be=(dr=P.headerTooltip)!=null&&dr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ue=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),nr=Qe?e.jsxs("button",{type:"button",onClick:()=>Z(P),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left"},children:[Ue,Be,e.jsx(ns,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ue,Be]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:J?he:void 0,zIndex:J?4:2,paddingLeft:R===0?"12px":"",borderRight:h&&!ze&&!J?se:void 0,borderBottom:h?se:void 0,boxShadow:h&&J?Ee:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left",...de(R,P.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[P.headerTooltip?e.jsx(me.Tooltip,{label:P.headerTooltip.content,position:"bottom",children:nr}):nr,P.filter&&e.jsx(il,{filter:P.filter,columnTitle:P.title}),p&&e.jsx("button",{onClick:()=>Ze(R),title:J?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:J?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:J?1:.45,transition:"opacity 0.15s"},children:e.jsx(ss,{frozen:J})})]}),ce&&e.jsx("div",{onMouseDown:hr=>lr(hr,R),onClick:hr=>hr.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${R}`)}),V?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:h?se:void 0,boxShadow:h&&S?ve:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(f.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&w?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:w})}):t==null?void 0:t.map((P,R)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:R===t.length-1&&xe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:J=>{const he=J.currentTarget;he.style.backgroundColor=al,Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=al)})},onMouseLeave:J=>{const he=J.currentTarget;he.style.backgroundColor="",Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=Lt)})},children:[r.map((J,he)=>{const ce=J.render?J.render(P,R,t):Ce(P,J.accessor),Me=b>0&&he<b,ze=Fe[he]??0,er=$[he]!==void 0,Qe=Me&&he===b-1;return e.jsx(U.Td,{style:{position:Me?"sticky":void 0,left:Me?ze:void 0,zIndex:Me?1:void 0,backgroundColor:Me?Lt:void 0,transition:Me?"background-color 0.3s ease":void 0,paddingLeft:he===0?"12px":"",whiteSpace:"nowrap",overflow:er?"hidden":void 0,borderLeft:J.showBorderLeft?se:void 0,borderRight:J.showBorderRight?se:void 0,boxShadow:Qe?Ee:void 0,textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left",...de(he,J.width)},children:typeof ce=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left"},children:ce}):ce},`row-${R}-col-${he}`)}),V?e.jsx(U.Td,{style:{width:ue,position:"sticky",right:0,zIndex:1,backgroundColor:Lt,boxShadow:S?ve:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ie.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:E.map(J=>{const he=R===t.length-1?"top":"bottom";return J==="detail"&&o&&(a==null?void 0:a(P))!==!1?e.jsx(me.Tooltip,{label:"Detail",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(P.id,P),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):J==="update"&&n&&(i==null?void 0:i(P))!==!1?e.jsx(me.Tooltip,{label:"Update",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(P),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):J==="delete"&&l&&(c==null?void 0:c(P))!==!1?e.jsx(me.Tooltip,{label:"Delete",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(P.id,P),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):J==="custom"?e.jsx(d.Fragment,{children:C==null?void 0:C(P)},"custom"):null})})}):null]},`${P}${R}`))})]})})};let hl=!1;const cs=({wrapperProps:r,dataTableProps:t,headerProps:o,footerProps:n})=>{var b;process.env.NODE_ENV!=="production"&&!hl&&(hl=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const l=d.useRef(null),[s,c]=d.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(o==null?void 0:o.show)??!0,a=d.useRef(null),h=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof h=="number"&&(a.current=h);const y=(n==null?void 0:n.showFooter)??(h===void 0?a.current!==0:h!==0);return e.jsxs(nl,{...r,children:[i&&e.jsx(sl,{...o}),e.jsx(f.Box,{direction:"column",ref:l,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(dl,{...t,scrollParentRef:l,frozenCount:t!=null&&t.enableFreezeColumns?s:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?c:void 0}):null}),y&&e.jsx(cl,{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 is(r){return d.memo(r)}const as=is(cs),fl=200,Ot="1px solid var(--sa-border-subtle, #0b120e24)",ds=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(M.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(M.Icon,{name:"ChevronSmallDown"}):t?e.jsx(M.Icon,{name:"LockOn",size:"xs"}):e.jsx(M.Icon,{name:"Filter",size:"xs"}),Ur=({icon:r,label:t,active:o,danger:n,onClick:l})=>{const s=n?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:l,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:o?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:s,textAlign:"left"},onMouseEnter:c=>{o||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=o?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(D.Text,{as:"span",style:{color:s},children:t})]})},ul=({active:r,canSort:t,canHide:o,sortDir:n,frozen:l,onSort:s,onClearSort:c,onToggleFreeze:i,onHide:a})=>{const[h,y]=d.useState(!1),b=d.useRef(null),p=d.useRef(null),[C,E]=d.useState({top:0,left:0});d.useEffect(()=>{if(h&&b.current){const L=b.current.getBoundingClientRect(),F=L.left+fl>window.innerWidth;E({top:L.bottom+6,...F?{right:window.innerWidth-L.right}:{left:L.left}})}},[h]),d.useEffect(()=>{if(!h)return;const L=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[h]);const w=L=>{L(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||h?"true":"false",onClick:L=>{L.stopPropagation(),y(F=>!F)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:Ot,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(ds,{sortDir:n,frozen:l})}),h&&e.jsxs(f.Box,{ref:p,onClick:L=>L.stopPropagation(),style:{position:"fixed",top:`${C.top}px`,...C.left!==void 0?{left:`${C.left}px`}:{right:`${C.right}px`},minWidth:fl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:Ot,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Ur,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>w(()=>n==="asc"?c():s("asc"))}),e.jsx(Ur,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>w(()=>n==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:Ot,margin:"4px 0"}})]}),e.jsx(Ur,{icon:"Pin1",label:l?"Unfreeze":"Freeze",active:l,onClick:()=>w(i)}),o&&e.jsx(Ur,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>w(a)})]})]})},Mr="1px solid var(--sa-border-subtle, #0b120e24)",hs="var(--sa-text-subtle, #8c8f97)",Dr="var(--sa-background-neutral, #f0f1f2)",gl="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Ir=40,At="var(--sa-background-brand-subtlest)",Jr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},yl="sa-table-layout-styles",fs=()=>{if(typeof document>"u"||document.getElementById(yl))return;const r=document.createElement("style");r.id=yl,r.textContent=`
|
|
1
|
+
(function(u,yr){typeof exports=="object"&&typeof module<"u"?yr(exports,require("@starasia/alert"),require("@starasia/avatar"),require("@starasia/badges"),require("@starasia/box"),require("@starasia/breadcrumb"),require("@starasia/button"),require("@starasia/card"),require("@starasia/date"),require("@starasia/dialog"),require("@starasia/drawer"),require("@starasia/dropdown"),require("@starasia/hooks"),require("@starasia/http"),require("@starasia/input"),require("@starasia/menu"),require("@starasia/pagination"),require("@starasia/storage"),require("@starasia/table"),require("@starasia/tabs"),require("@starasia/textarea"),require("@starasia/theme"),require("@starasia/toast"),require("@starasia/toggle"),require("@starasia/tooltip"),require("@starasia/checkbox"),require("@starasia/radio"),require("@starasia/text"),require("@starasia/icon"),require("@starasia/flex"),require("@starasia/grid"),require("@starasia/progress"),require("@starasia/stepper"),require("@starasia/accordion"),require("@starasia/story-record"),require("@starasia/skeleton"),require("@starasia/progress-stepper"),require("react/jsx-runtime"),require("react"),require("react-dom"),require("react-easy-crop")):typeof define=="function"&&define.amd?define(["exports","@starasia/alert","@starasia/avatar","@starasia/badges","@starasia/box","@starasia/breadcrumb","@starasia/button","@starasia/card","@starasia/date","@starasia/dialog","@starasia/drawer","@starasia/dropdown","@starasia/hooks","@starasia/http","@starasia/input","@starasia/menu","@starasia/pagination","@starasia/storage","@starasia/table","@starasia/tabs","@starasia/textarea","@starasia/theme","@starasia/toast","@starasia/toggle","@starasia/tooltip","@starasia/checkbox","@starasia/radio","@starasia/text","@starasia/icon","@starasia/flex","@starasia/grid","@starasia/progress","@starasia/stepper","@starasia/accordion","@starasia/story-record","@starasia/skeleton","@starasia/progress-stepper","react/jsx-runtime","react","react-dom","react-easy-crop"],yr):(u=typeof globalThis<"u"?globalThis:u||self,yr(u["@starasia/admin"]={},u.alert,u.avatar,u.badges,u.box,u.breadcrumb,u.button,u.card,u.date,u.dialog,u.drawer,u.dropdown,u.hooks,u.http,u.input,u.menu,u.pagination,u.storage,u.table,u.tabs,u.textarea,u.theme,u.toast,u.toggle,u.tooltip,u.checkbox,u.radio,u.text,u.icon,u.flex,u.grid,u.progress,u.stepper,u.accordion,u.storyRecord,u.skeleton,u.progressStepper,u.jsxRuntime,u.React,u.ReactDOM,u.ReactEasyCrop))})(this,function(u,yr,zr,sr,f,pr,j,ct,fr,je,Hr,br,De,vr,ar,A,kr,Er,U,$t,it,Cr,Kt,xr,me,tr,at,D,M,ie,Rt,eo,ro,to,oo,$e,lo,e,d,Pr,Nl){"use strict";const _l={menus:[],menuBottom:void 0,logo:"",appName:"Workspace",userData:null,setUserData:()=>{}},dt=d.createContext(_l),ht=()=>d.useContext(dt),no=r=>{const[t,o]=d.useState((r==null?void 0:r.initialUserData)||null);return{userData:t,setUserData:o}},so=d.createContext({badges:{},setBadge:()=>{},setBadges:()=>{},clearBadge:()=>{}}),co=({children:r})=>{const[t,o]=d.useState({}),n=d.useCallback(i=>{o(a=>typeof i=="function"?i(a):i)},[]),l=d.useCallback((i,a)=>{o(h=>{const y=typeof a=="function"?a(h[i]):a;return{...h,[i]:y}})},[]),s=d.useCallback(i=>{o(a=>{if(!(i in a))return a;const h={...a};return delete h[i],h})},[]),c=d.useMemo(()=>({badges:t,setBadge:l,setBadges:n,clearBadge:s}),[t,l,n,s]);return e.jsx(so.Provider,{value:c,children:r})},io=()=>d.useContext(so),Vr=(r,t)=>{const o=t!==void 0?t:r;return o==null?null:typeof o=="string"||typeof o=="number"?{value:o}:o},ft=240,ut=200,gt=480,ql="sa-sidebar-width",yt=(r,t,o)=>Math.min(Math.max(r,t),o),Zl=(r,t,o,n)=>{if(typeof window>"u")return t;try{const l=window.localStorage.getItem(r);if(!l)return t;const s=parseInt(l,10);return Number.isFinite(s)?yt(s,o,n):t}catch{return t}},ao=(r,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(r,String(t))}catch{}},ho=d.createContext({collapsed:!1,setCollapsed:()=>{},toggle:()=>{},collapse:()=>{},expand:()=>{},width:ft,setWidth:()=>{},resetWidth:()=>{},minWidth:ut,maxWidth:gt,mobileOpen:!1,setMobileOpen:()=>{},openMobile:()=>{},closeMobile:()=>{},toggleMobile:()=>{}}),fo=({children:r,defaultCollapsed:t=!1,defaultWidth:o=ft,minWidth:n=ut,maxWidth:l=gt,widthStorageKey:s=ql})=>{const[c,i]=d.useState(t),[a,h]=d.useState(!1),[y,b]=d.useState(()=>Zl(s,o,n,l)),p=d.useCallback(S=>{i(z=>typeof S=="function"?S(z):S)},[]),C=d.useCallback(()=>i(S=>!S),[]),E=d.useCallback(()=>i(!0),[]),w=d.useCallback(()=>i(!1),[]),L=d.useCallback(S=>{b(z=>{const O=typeof S=="function"?S(z):S,Y=yt(Math.round(O),n,l);return ao(s,Y),Y})},[n,l,s]),F=d.useCallback(()=>{const S=yt(o,n,l);ao(s,S),b(S)},[o,n,l,s]),I=d.useCallback(S=>{h(z=>typeof S=="function"?S(z):S)},[]),B=d.useCallback(()=>h(!0),[]),k=d.useCallback(()=>h(!1),[]),H=d.useCallback(()=>h(S=>!S),[]),W=d.useMemo(()=>({collapsed:c,setCollapsed:p,toggle:C,collapse:E,expand:w,width:y,setWidth:L,resetWidth:F,minWidth:n,maxWidth:l,mobileOpen:a,setMobileOpen:I,openMobile:B,closeMobile:k,toggleMobile:H}),[c,p,C,E,w,y,L,F,n,l,a,I,B,k,H]);return e.jsx(ho.Provider,{value:W,children:r})},uo=()=>d.useContext(ho),go=d.createContext(null),yo=({adapter:r,children:t})=>e.jsx(go.Provider,{value:r,children:t}),or=()=>{const r=d.useContext(go);if(!r)throw new Error("[@starasia/admin] Router adapter belum dipasang. Bungkus aplikasi dengan <App routerAdapter={...} /> atau <StarasiaRouterProvider adapter={...}>. Import adapter dari '@starasia/admin/adapters/react-router' atau '@starasia/admin/adapters/tanstack'.");return r},po=({router:r,routerAdapter:t,menus:o=[],menuBottom:n,logo:l,appName:s="Workspace",initialUserData:c,theme:i})=>{const a=no({initialUserData:c}),{theme:h}=Cr.useTheme();return e.jsx(yo,{adapter:t,children:e.jsx(dt.Provider,{value:{logo:l,appName:s,menus:o,userData:a.userData,setUserData:a.setUserData,menuBottom:n},children:e.jsx(co,{children:e.jsx(fo,{children:i?e.jsx(Cr.ThemeProvider,{value:i,children:r}):h?e.jsx(Cr.ThemeProvider,{value:h,children:r}):r})})})})},Gl=d.memo(po);function bo({collapsed:r=!1,children:t}){if(!t)return null;const o=typeof t=="function",n=o?t({collapsed:r}):t;return n==null||n===!1?null:e.jsx("div",{style:{position:"sticky",top:"var(--app-header-height, 4rem)",zIndex:1,borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",paddingLeft:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingRight:r?"calc((var(--app-header-height, 4rem) - 2rem) / 2)":"0.5rem",paddingTop:"0.5rem",paddingBottom:"0.5rem",boxSizing:"border-box"},children:o?n:e.jsx("div",{style:{opacity:r?0:1,transition:"opacity 0.3s",visibility:r?"hidden":"visible"},children:n})})}const pt=d.createContext(null);function vo({children:r}){const[t,o]=d.useState(null),[n,l]=d.useState(null),[s,c]=d.useState(null),[i,a]=d.useState(0),h=d.useCallback(()=>(a(y=>y+1),()=>a(y=>y-1)),[]);return e.jsx(pt.Provider,{value:{prependNode:t,appendNode:n,replaceNode:s,setPrependNode:o,setAppendNode:l,setReplaceNode:c,replaceCount:i,registerReplace:h},children:r})}function Co({children:r}){const t=d.useContext(pt);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 Ql({children:r,mode:t="append"}){const o=d.useContext(pt);if(d.useEffect(()=>{if(!(t!=="replace"||!o))return o.registerReplace()},[t,o]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[HeaderLeftSlot] used outside AppLayout — content not rendered"),null;const n=t==="prepend"?o.prependNode:t==="replace"?o.replaceNode:o.appendNode;return n?Pr.createPortal(r,n):null}const bt=d.createContext(null);function xo({children:r}){const[t,o]=d.useState({}),[n,l]=d.useState({}),s=d.useCallback((a,h)=>{o(y=>y[a]===h?y:{...y,[a]:h})},[]),c=d.useCallback(a=>(l(h=>({...h,[a]:(h[a]??0)+1})),()=>l(h=>({...h,[a]:Math.max(0,(h[a]??0)-1)}))),[]),i=d.useMemo(()=>({outletNodes:t,setOutletNode:s,slotCounts:n,registerSlot:c}),[t,s,n,c]);return e.jsx(bt.Provider,{value:i,children:r})}function wo({slotKey:r,fallback:t}){const o=d.useContext(bt),n=o?(o.slotCounts[r]??0)>0:!1,l=d.useRef(o==null?void 0:o.setOutletNode);l.current=o==null?void 0:o.setOutletNode;const s=d.useCallback(c=>{var i;return(i=l.current)==null?void 0:i.call(l,r,c)},[r]);return e.jsx(e.Fragment,{children:n?e.jsx("div",{ref:s,style:{display:"contents"}}):t})}function Ul({slotKey:r,children:t}){const o=d.useContext(bt),n=d.useRef(o==null?void 0:o.registerSlot);if(n.current=o==null?void 0:o.registerSlot,d.useEffect(()=>{var s;return(s=n.current)==null?void 0:s.call(n,r)},[r]),!o)return process.env.NODE_ENV!=="production"&&console.warn("[SidebarGroupSlot] used outside AppLayout — content not rendered"),null;const l=o.outletNodes[r];return l?Pr.createPortal(t,l):null}const jr="moduleSwitcherGroupId",vt="sa-module-switcher-change";function Do(){if(typeof window>"u")return null;const r=window.localStorage.getItem(jr);if(r===null)return null;const t=Number(r);return Number.isFinite(t)?t:null}function So(r){typeof window>"u"||(r===null?window.localStorage.removeItem(jr):window.localStorage.setItem(jr,String(r)),window.dispatchEvent(new CustomEvent(vt,{detail:r})))}function Jl(){So(null)}function Ct(){const[r,t]=d.useState(()=>Do());return d.useEffect(()=>{const n=()=>{t(Do())},l=s=>{s.key===jr&&n()};return window.addEventListener(vt,n),window.addEventListener("storage",l),()=>{window.removeEventListener(vt,n),window.removeEventListener("storage",l)}},[]),{selectedGroupId:r,setSelectedGroupId:n=>{So(n),t(n)}}}let Nr=0,ur=!1,Bo=new Set;function Yl(r){const[t,o]=d.useState(!1),n=d.useRef(null),l=d.useRef(null);return d.useLayoutEffect(()=>{const s=n.current;if(!s)return;let c=0;const i=()=>{c=0;const h=l.current;if(!h)return;const y=h.scrollWidth>s.clientWidth;o(b=>b===y?b:y)},a=new ResizeObserver(()=>{c||(c=requestAnimationFrame(i))});return a.observe(s),i(),()=>{c&&cancelAnimationFrame(c),a.disconnect()}},[r]),{containerRef:n,textRef:l,truncated:t}}function ko({text:r,textStyle:t}){const{containerRef:o,textRef:n,truncated:l}=Yl(r),s=e.jsx(D.Text,{ref:n,as:"span",fontSize:"md",fontWeight:"medium",truncate:!0,style:{display:"block",...t},children:r});return e.jsx(f.Box,{ref:o,display:"block",style:{flex:1,minWidth:0},children:l?e.jsx(me.Tooltip,{fluid:!0,label:r,position:"top",children:s}):s})}const Xl=200,xt="var(--app-header-height, 4rem)",Eo="44px",wt=`calc((${xt} - 2rem) / 2)`,mo=16;function $l({children:r,headerLeftSlot:t,profile:o,isLoadingProfile:n,onLogout:l,isLoggingOut:s,loadingComponent:c,sidebarHeaderContent:i,headerActions:a,profileRole:h,profileMenuButtons:y,profileMenuItems:b,logoutButton:p,resizableSidebar:C=!0}){var hr,Sr;const{useSearchParams:E,useNavigate:w,useLocation:L,Outlet:F}=or(),[I]=E(),B=I.get("embed")==="true",k=ht(),{badges:H}=io(),W=w(),S=L(),O=!De.useMediaQuery("md"),[Y,X]=d.useState(!1),{collapsed:q,setCollapsed:Z,width:K,setWidth:te,resetWidth:_,minWidth:V,maxWidth:N,mobileOpen:se,setMobileOpen:ve}=uo(),[Ee,ue]=d.useState(!1),[Ce,xe]=d.useState(()=>new Set(Bo)),[we,Ae]=d.useState(null),{selectedGroupId:Fe,setSelectedGroupId:_e}=Ct(),$=q&&!O;d.useEffect(()=>{Bo=Ce},[Ce]);const ge=d.useRef(null),We=d.useRef(null),Ze=d.useRef(null),[de,Ge]=d.useState(!1),[lr,P]=d.useState(null),R=C&&!O&&!q,J=m=>Math.min(Math.max(m,V),N),he=lr??K,ce=m=>{var ke,Ie,Ve;if(!R)return;m.preventDefault();const G=m.clientX,re=((ke=Ze.current)==null?void 0:ke.getBoundingClientRect().width)??K;(Ve=(Ie=m.currentTarget).setPointerCapture)==null||Ve.call(Ie,m.pointerId),Ge(!0),document.body.style.userSelect="none",document.body.style.cursor="col-resize";let Se=0,Oe=re;const Ye=Or=>{Oe=re+(Or.clientX-G),Se||(Se=requestAnimationFrame(()=>{Se=0,P(J(Oe))}))},He=()=>{Se&&cancelAnimationFrame(Se),window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",He),document.body.style.userSelect="",document.body.style.cursor="",P(null),Ge(!1),Oe<Xl?Z(!0):te(J(Oe))};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",He)},Me=m=>{R&&(m.key==="ArrowLeft"?(m.preventDefault(),te(G=>G-mo)):m.key==="ArrowRight"?(m.preventDefault(),te(G=>G+mo)):m.key==="Home"?(m.preventDefault(),te(V)):m.key==="End"&&(m.preventDefault(),te(N)))};d.useEffect(()=>{const m=ge.current;if(!m)return;const G=()=>{ur||(Nr=m.scrollTop)};return m.addEventListener("scroll",G),()=>m.removeEventListener("scroll",G)},[]);const ze=()=>{const m=ge.current;m&&Nr>0&&(ur=!0,m.scrollTop=Nr,requestAnimationFrame(()=>{ur=!1}))};d.useLayoutEffect(()=>{ur=!0,ze();const m=setTimeout(()=>{ur=!1},300);return()=>clearTimeout(m)},[]),d.useLayoutEffect(()=>{k.menus.length>0&&(Nr>0?ze():requestAnimationFrame(()=>{var G;const m=(G=ge.current)==null?void 0:G.querySelector("[data-menu-active='true']");m&&m.scrollIntoView({block:"center",behavior:"instant"})}))},[k.menus]),d.useEffect(()=>{ur=!0,ze();const m=setTimeout(ze,0),G=setTimeout(ze,50),re=setTimeout(ze,100),Se=setTimeout(ze,200),Oe=setTimeout(()=>{ur=!1},300),Ye=setTimeout(()=>{const He=ge.current,ke=He==null?void 0:He.querySelector("[data-menu-active='true']");if(He&&ke){const Ie=He.getBoundingClientRect(),Ve=ke.getBoundingClientRect();Ve.top>=Ie.top&&Ve.bottom<=Ie.bottom||ke.scrollIntoView({block:"center",behavior:"smooth"})}},250);return()=>{clearTimeout(m),clearTimeout(G),clearTimeout(re),clearTimeout(Se),clearTimeout(Oe),clearTimeout(Ye)}},[S.pathname]),d.useEffect(()=>{We.current&&(We.current.scrollTop=0)},[S.pathname]),d.useEffect(()=>{O&&ve(!1)},[S.pathname,O]),d.useEffect(()=>{O&&Z(!0)},[O]),d.useEffect(()=>{const m=document.documentElement;return m.style.setProperty("--app-header-height",Eo),()=>{m.style.removeProperty("--app-header-height")}},[]);const er=()=>{X(!0)},Qe=()=>{X(!1)},Le=()=>{X(!1),l()},Je=m=>{const G=[m.to];return m.children&&G.push(...m.children.map(re=>re.to)),G},Be=[...k.menus.flatMap(m=>m.items.flatMap(Je)),...((hr=k.menuBottom)==null?void 0:hr.flatMap(Je))??[]],Ue=m=>{if(!S.pathname.startsWith(m))return!1;const G=Be.filter(re=>S.pathname.startsWith(re)).sort((re,Se)=>Se.length-re.length)[0];return m===G};d.useEffect(()=>{var G;const m=re=>{var Se;(Se=re.children)!=null&&Se.some(Oe=>S.pathname.startsWith(Oe.to))&&xe(Oe=>{const Ye=new Set(Oe);return Ye.add(re.id),Ye})};k.menus.forEach(re=>{re.items.forEach(m)}),(G=k.menuBottom)==null||G.forEach(m)},[S.pathname,k.menus,k.menuBottom]);const nr=m=>{xe(G=>{const re=new Set(G);return re.has(m)?re.delete(m):re.add(m),re})};d.useEffect(()=>{k.menus.length!==0&&Fe!==null&&!k.menus.some(m=>m.id===Fe)&&_e(null)},[k.menus,Fe,_e]);const gr=d.useMemo(()=>{if(Fe!==null)return k.menus.filter(re=>re.id===Fe||re.parentGroupId===Fe);const m=k.menus.filter(re=>re.parentGroupId===void 0),G=k.menus.filter(re=>re.parentGroupId!==void 0).flatMap(re=>re.items);return G.length===0?m:[...m,{id:18,name:"Pengaturan",items:G,parentGroupId:void 0}]},[k.menus,Fe]);if(B)return e.jsx(f.Box,{as:"main",overflow:"overflow-y-auto",bg:"surface-inverse",style:{height:"100vh"},children:r||e.jsx(F,{})});const dr=m=>{const G=m.children&&m.children.length>0,re=Ce.has(m.id),Se=G?m.children.some(He=>Ue(He.to)):Ue(m.to),Oe=Vr(m.badge,H[m.id]),Ye=!!Oe&&q&&!O;return e.jsxs(f.Box,{display:"block","data-menu-active":Se||void 0,children:[e.jsxs(f.Box,{as:"button",onClick:He=>{if(G)if(q&&!O){const ke=He.currentTarget.getBoundingClientRect();Ae({item:m,top:ke.top,left:ke.right+8})}else nr(m.id);else W(m.to)},fullWidth:!0,direction:"row",align:"center",justify:q&&!O?"center":void 0,gap:"sm",paddingInline:q&&!O?void 0:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Se?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:Se?"border-base":void 0,bg:Se?"white":void 0,hover:Se?void 0:{bg:"neutral"},title:q&&!O?m.title:void 0,style:{textAlign:"left",color:"var(--sa-text-primary, #292a2e)",...Se?null:{borderColor:"transparent"}},children:[e.jsxs(f.Box,{position:"relative",display:"inline-flex",flexShrink:"0",style:{alignItems:"center"},children:[e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),Ye&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",top:"top-n2",right:"right-n2",display:"inline-flex",borderRadius:"rounded-full",style:{boxShadow:"0 0 0 1px var(--sa-background-primary, #ffffff)"},children:e.jsx(sr.BadgeDot,{tone:"error",variant:"solid",size:"xs"})})]}),(!q||O)&&e.jsxs(e.Fragment,{children:[e.jsx(ko,{text:m.title,textStyle:{transition:"opacity 0.3s"}}),Oe&&e.jsx(sr.Badge,{text:String(Oe.value),variant:Oe.variant??"info",size:"xs",border:!0}),G&&e.jsx(M.Icon,{name:"ChevronDown",size:"sm",style:{flexShrink:0,transition:"transform 0.2s",transform:re?"rotate(180deg)":"rotate(0deg)"}})]})]}),G&&(!q||O)&&(()=>{const He=m.children.findIndex(ke=>Ue(ke.to));return e.jsxs(f.Box,{position:"relative",overflow:"overflow-hidden",style:{marginLeft:"1rem",paddingLeft:"0.75rem",transition:"all 0.3s ease-in-out",maxHeight:re?`${m.children.length*36}px`:"0px",opacity:re?1:0,marginTop:re?"0.25rem":"0px"},children:[e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",top:"top-0",fullHeight:!0,style:{width:"1.5px",backgroundColor:"var(--sa-border-subtle, #0b120e24)",pointerEvents:"none"}}),He>=0&&e.jsx(f.Box,{"aria-hidden":"true",position:"absolute",left:"left-0",height:"height-32",zIndex:"10",style:{top:`${He*32}px`,width:"1.5px",backgroundColor:"var(--sa-text-primary, #292a2e)",transition:"top 0.2s ease-in-out",pointerEvents:"none"}}),m.children.map(ke=>{const Ie=Vr(ke.badge,H[ke.id]),Ve=Ue(ke.to);return e.jsxs(f.Box,{as:"button",onClick:()=>W(ke.to),fullWidth:!0,direction:"row",align:"center",gap:"sm",paddingLeft:"sm",paddingRight:"sm",paddingBlock:"xs",height:"height-32",borderRadius:Ve?"rounded-sm":"rounded-md",borderWidth:"border",borderStyle:"border-solid",borderColor:Ve?"border-base":void 0,bg:Ve?"white":void 0,hover:Ve?void 0:{bg:"neutral"},style:{textAlign:"left",color:Ve?"var(--sa-text-primary, #292a2e)":"var(--sa-text-subtle, #505258)",...Ve?null:{borderColor:"transparent"}},children:[e.jsx(M.Icon,{name:ke.icon,size:"sm",style:{flexShrink:0}}),e.jsx(ko,{text:ke.title}),Ie&&e.jsx(sr.Badge,{text:String(Ie.value),variant:Ie.variant??"info",size:"xs",border:!0})]},ke.id)})]})})()]},m.id)};return e.jsx(xo,{children:e.jsxs(vo,{children:[e.jsxs(f.Box,{direction:"row",position:"relative",style:{height:"100vh","--app-header-height":Eo,"--app-sidebar-width":O?"0px":q?xt:`${he}px`,"--app-footer-zindex":O&&se?"40":"998"},children:[O&&e.jsx(f.Box,{position:"fixed",zIndex:"40",bg:"black-alpha-a50",style:{inset:0,opacity:se?.5:0,pointerEvents:se?"auto":"none",transition:"opacity 0.3s"},onClick:()=>ve(!1)}),e.jsxs(f.Box,{as:"aside",ref:Ze,bg:"surface-inverse",borderWidth:"border-r",borderStyle:"border-solid-r",borderColor:"border-base",flexShrink:O?void 0:"0",style:{width:O?"16.375rem":q?xt:`${he}px`,position:O?"fixed":"relative",...O&&{inset:0,zIndex:50,transform:se?"translateX(0)":"translateX(-100%)"},transition:de?"none":"all 0.3s ease-in-out",minWidth:0},children:[e.jsx(f.Box,{onMouseEnter:()=>ue(!0),onMouseLeave:()=>ue(!1),direction:"row",align:"center",justify:"space-between",paddingInline:$?void 0:"lg",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",position:"relative",style:{height:"var(--app-header-height, 4rem)",...$?{paddingInline:wt}:null},children:(()=>{const m=!O&&q&&!se,G=m&&Ee;return e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flex:m?"1":void 0,justify:m?"center":void 0,style:{transition:"opacity 0.2s",opacity:G?0:1,pointerEvents:G?"none":"auto"},children:[e.jsx("img",{src:k.logo,alt:"Logo",style:{width:"1.5rem",height:"1.5rem",flexShrink:0}}),(!q||se)&&e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"semibold",color:"primary",truncate:!0,style:{transition:"opacity 0.3s"},children:k.appName})]}),!O&&!q&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!0),"aria-label":"Collapse sidebar",display:"inline-flex",align:"center",justify:"center",flexShrink:"0",style:{color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),m&&e.jsx(f.Box,{as:"button",onClick:()=>Z(!1),"aria-label":"Expand sidebar",position:"absolute",display:"inline-flex",align:"center",justify:"center",width:"width-32",height:"height-32",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-sm",style:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"var(--sa-text-primary, #292a2e)",opacity:G?1:0,pointerEvents:G?"auto":"none",transition:"opacity 0.2s"},children:e.jsx(M.Icon,{name:"LayoutLeft",size:"sm"})}),O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!1),"aria-label":"Close menu",align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"Cross",size:"md"})})]})})()}),i&&e.jsx(bo,{collapsed:O?!1:q,children:i}),e.jsx(f.Box,{ref:ge,flex:"1",overflow:"overflow-y-auto",paddingBlock:"lg",children:gr.map(m=>e.jsxs(f.Box,{marginBottom:"lg",children:[!q||O?m.name&&e.jsx(D.Text,{fontSize:"md",fontWeight:"normal",color:"subtlest",truncate:!0,style:{paddingLeft:"1.25rem",paddingRight:"0.75rem",paddingBottom:"0.25rem",transition:"opacity 0.3s"},children:m.name}):m.name&&e.jsx(f.Box,{"aria-label":m.name,direction:"row",align:"center",justify:"center",paddingBlock:"md",children:e.jsx(f.Box,{width:"width-16",style:{height:"2px",borderRadius:"1px",backgroundColor:m.color??"var(--sa-background-brand, #04254f)"}})}),e.jsx(f.Box,{paddingInline:$?void 0:"md",gap:"xs",style:$?{paddingInline:wt}:void 0,children:m.slotKey?e.jsx(wo,{slotKey:m.slotKey,fallback:m.items.map(G=>dr(G))}):m.items.map(G=>dr(G))})]},m.id))}),k.menuBottom&&k.menuBottom.length>0&&e.jsx(f.Box,{borderWidth:"border-t",borderStyle:"border-solid-t",borderColor:"border-base",paddingBlock:"md",paddingInline:$?void 0:"md",bg:"surface-inverse",gap:"xs",flexShrink:"0",style:$?{paddingInline:wt}:void 0,children:k.menuBottom.map(m=>dr(m))}),R&&e.jsx(f.Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar","aria-valuenow":K,"aria-valuemin":V,"aria-valuemax":N,tabIndex:0,onPointerDown:ce,onKeyDown:Me,onDoubleClick:_,title:"Drag to resize · double-click to reset",position:"absolute",top:"top-0",right:"right-0",fullHeight:!0,style:{width:"6px",transform:"translateX(50%)",cursor:"col-resize",zIndex:5,touchAction:"none",background:de?"var(--sa-background-brand, #04254f)":"transparent",transition:"background 0.15s"},onMouseEnter:m=>{de||(m.currentTarget.style.background="var(--sa-border-bold, #0b120e40)")},onMouseLeave:m=>{de||(m.currentTarget.style.background="transparent")}})]}),e.jsxs(f.Box,{flex:"1",overflow:"overflow-hidden",children:[e.jsxs(f.Box,{as:"header",bg:"white",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",direction:"row",align:"center",justify:"space-between",paddingInline:"lg",flexShrink:"0",style:{height:"var(--app-header-height, 4rem)"},children:[e.jsxs(f.Box,{direction:"row",align:"center",gap:O?"lg":void 0,children:[O&&e.jsx(f.Box,{as:"button",onClick:()=>ve(!0),align:"center",justify:"center",borderRadius:"rounded-md",style:{padding:"0.375rem",color:"var(--sa-text-subtle, #8c8f97)"},children:e.jsx(M.Icon,{name:"MenuBurger",size:"lg"})}),e.jsx(Co,{children:t})]}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"md",children:[a,e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",cursor:"pointer",children:[e.jsxs(f.Box,{display:"block",textAlign:"right",customMaxWidth:"12.5rem",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",textAlign:"right",truncate:!0,lineHeight:"leading-none",children:n?"Loading...":(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"right",truncate:!0,children:n?"":(o==null?void 0:o.email)||"unknown"})]}),e.jsx(zr.Avatar,{size:"sm",initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)"}),e.jsx(M.Icon,{name:"ChevronDown",size:"xs",color:"subtle"})]})}),e.jsxs(A.MenuLists,{width:280,style:{paddingBlock:"12px",paddingInline:"12px",gap:"8px",marginTop:"16px"},children:[e.jsx(A.MenuHeading,{children:e.jsxs(f.Box,{align:"center",textAlign:"center",paddingBlock:"sm",fullWidth:!0,children:[e.jsx(zr.Avatar,{customSize:64,initials:((o==null?void 0:o.name)||"U")[0].toUpperCase(),bg:"var(--sa-background-brand, #04254f)",color:"var(--sa-background-primary, #ffffff)",style:{fontSize:"1.25rem",marginBottom:"0.75rem",boxShadow:"var(--sa-shadow-sm, 0 1px 2px 0 #0000000d)"}}),e.jsx(D.Text,{fontSize:"md",fontWeight:"semibold",color:"primary",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.name)||"unknown"}),e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:(o==null?void 0:o.email)||"unknown"}),h&&e.jsx(D.Text,{fontSize:"sm",color:"subtle",textAlign:"center",truncate:!0,style:{maxWidth:"100%"},children:h})]})}),(y&&y.length>0||b)&&e.jsxs(A.MenuBody,{children:[y==null?void 0:y.map((m,G)=>e.jsx(A.MenuItem,{onClick:m.onClick,startIcon:e.jsx(M.Icon,{name:m.icon,size:"md"}),children:m.label},`${m.label}-${G}`)),b]}),p??e.jsx(A.MenuFooter,{children:e.jsx(A.MenuItem,{intent:"danger",onClick:er,startIcon:e.jsx(M.Icon,{name:"Logout",size:"md"}),children:"Logout"})})]})]})]})]}),e.jsx(f.Box,{as:"main",ref:We,flex:"1",overflow:"overflow-y-auto",children:r||e.jsx(F,{})})]})]}),s&&c&&e.jsx(f.Box,{position:"fixed",align:"center",justify:"center",bg:"black-alpha-a70",style:{inset:0,zIndex:9999},children:c}),e.jsxs(je.Dialog,{isShow:Y,onHide:Qe,children:[e.jsx(je.DialogTitle,{children:"Confirmation Logout"}),e.jsx(je.DialogBody,{children:"Are you sure you want to end the session and exit the page?"}),e.jsx(je.DialogFooter,{children:e.jsx(f.Box,{direction:"column",display:"flex",align:"flex-end",justify:"center",children:e.jsxs(ie.Flex,{direction:"row",gap:"sm",align:"center",children:[e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{secondary:!0,onClick:Qe,children:"Cancel"})}),e.jsx(f.Box,{direction:"column",children:e.jsx(j.Button,{primary:!0,onClick:Le,children:"Yes, Sure"})})]})})})]}),we&&e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{onClick:()=>Ae(null),position:"fixed",style:{inset:0,zIndex:60}}),e.jsxs(f.Box,{role:"dialog","aria-label":we.item.title,position:"fixed",bg:"white",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",borderRadius:"rounded-md",shadow:"shadow-lg",padding:"sm",gap:"spacing-2",style:{top:we.top,left:we.left,zIndex:61,minWidth:"13rem",maxWidth:"16rem"},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-500",textTransform:"uppercase",style:{padding:"0.25rem 0.5rem 0.5rem",letterSpacing:"0.05em"},children:we.item.title}),(Sr=we.item.children)==null?void 0:Sr.map(m=>{const G=Ue(m.to),re=Vr(m.badge,H[m.id]);return e.jsxs(f.Box,{as:"button",onClick:()=>{W(m.to),Ae(null)},fullWidth:!0,direction:"row",align:"center",gap:"md",paddingBlock:"sm",paddingInline:"md",borderRadius:"rounded-md",borderWidth:"border",borderStyle:"border-solid",bg:G?"primary-inverse":void 0,hover:G?void 0:{bg:"primary-inverse"},style:{textAlign:"left",borderColor:"transparent",color:G?"var(--sa-text-primary, #292a2e)":"var(--sa-color-gray-800, #505258)"},children:[m.icon&&e.jsx(M.Icon,{name:m.icon,size:"sm",style:{flexShrink:0}}),e.jsx(D.Text,{as:"span",fontSize:"md",fontWeight:"medium",whiteSpace:"nowrap",style:{flex:1},children:m.title}),re&&e.jsx(sr.Badge,{text:String(re.value),variant:re.variant??"info",size:"xs",border:!0})]},m.id)})]})]})]})})}const mr=d.forwardRef(({children:r,...t},o)=>e.jsx(f.Box,{ref:o,role:"button",cursor:"pointer","aria-pressed":"true",display:"inline-block",tabIndex:0,...t,children:r})),Fo=({title:r,iconName:t,textColor:o,iconColor:n,hoverTextColor:l,hoverIconColor:s})=>{const[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=o??"var(--sa-text-subtle, #8c8f97)",y=s??"var(--sa-text-subtle, #8c8f97)",b=l??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:t||"ChevronLeft",size:"xs",style:{color:c?y:a,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:c?b:h,transition:"color 0.15s ease"},children:r||"Back"})]})},Kl=({items:r,separator:t="/",iconName:o,iconColor:n,hoverIconColor:l})=>{const{Link:s}=or(),[c,i]=d.useState(!1),a=n??"var(--sa-text-subtle, #8c8f97)",h=l??"var(--sa-text-subtle, #8c8f97)",y=r.length>1?r[0]:void 0,b=!!(y!=null&&y.to||y!=null&&y.onClick),p=e.jsx(M.Icon,{name:o||"ChevronLeft",size:"xs",onMouseEnter:b?()=>i(!0):void 0,onMouseLeave:b?()=>i(!1):void 0,style:{color:b&&c?h:a,transition:"color 0.15s ease",cursor:b?"pointer":void 0}}),C=y!=null&&y.to?e.jsx(s,{to:y.to,replace:!0,style:{textDecoration:"none"},children:p}):y!=null&&y.onClick?e.jsx(mr,{onClick:y.onClick,children:p}):p;return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",children:[C,e.jsx(pr.Breadcrumb,{separator:t,size:"md",children:r.map((E,w)=>{const L=w===r.length-1;return E.to&&!L?e.jsx(pr.BreadcrumbItem,{children:e.jsx(s,{to:E.to,children:E.label})},w):e.jsx(pr.BreadcrumbItem,{currentPage:L,children:e.jsx(pr.BreadcrumbLink,{onClick:L?void 0:E.onClick,children:E.label})},w)})})]})},Rl=r=>{const{Link:t}=or(),{items:o,separator:n,onClick:l,navigateTo:s,...c}=r;return o&&o.length>0?e.jsx(Kl,{items:o,separator:n,iconName:c.iconName,iconColor:c.iconColor,hoverIconColor:c.hoverIconColor}):s?e.jsx(f.Box,{direction:"row",children:e.jsx(t,{to:s,replace:!0,style:{textDecoration:"none"},children:e.jsx(Fo,{...c})})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:l,children:e.jsx(Fo,{...c})})})},Dt=[{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 Mo(r,t,o){return{display:"flex",alignItems:"center",justifyContent:"center",width:"64px",height:"64px",borderRadius:"var(--sa-radii-sm, 6px)",border:r?`2px solid ${o.activeBorder}`:"2px solid var(--sa-color-gray-200, #f0f1f2)",backgroundColor:r?o.activeBg:"var(--sa-color-gray-50, #ffffff)",boxShadow:r?t?`0 8px 20px ${o.activeShadow.replace("0.25","0.35")}`:`0 2px 8px ${o.activeShadow}`:t?"0 8px 20px rgba(0, 0, 0, 0.14)":"0 1px 4px rgba(0, 0, 0, 0.08)",transform:t?"translateY(-3px) scale(1.05)":"translateY(0) scale(1)",transition:"box-shadow 0.2s ease, transform 0.2s ease, background-color 0.15s ease, border-color 0.15s ease"}}const Io={fontSize:"11px",fontWeight:500,textAlign:"center",overflowWrap:"normal",wordBreak:"normal",color:"var(--sa-background-primary, #ffffff)",lineHeight:"1.3",maxWidth:"80px"},To={display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:0};function Lo({isShow:r,onHide:t,menus:o,selectedGroupId:n,onSelect:l}){const[s,c]=d.useState(void 0),i=h=>{l(h),t()},a=Dt[0];return e.jsx(je.Dialog,{isShow:r,onHide:t,style:{width:560,background:"transparent",boxShadow:"none",border:"none"},children:e.jsx(je.DialogBody,{children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"16px"},children:[e.jsxs("button",{onClick:()=>i(null),onMouseEnter:()=>c("all"),onMouseLeave:()=>c(void 0),style:To,children:[e.jsx("div",{style:Mo(n===null,s==="all",a),children:e.jsx("div",{style:{color:a.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:"Grid",size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Io,children:"Semua"})]}),o.map((h,y)=>{var w;const b=n===h.id,p=s===h.id,C=((w=h.items[0])==null?void 0:w.icon)??"Grid",E=Dt[(y+1)%Dt.length];return e.jsxs("button",{onClick:()=>i(h.id),onMouseEnter:()=>c(h.id),onMouseLeave:()=>c(void 0),style:To,children:[e.jsx("div",{style:Mo(b,p,E),children:e.jsx("div",{style:{color:E.icon,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(M.Icon,{name:C,size:"lg",style:{width:32,height:32}})})}),e.jsx("span",{style:Io,children:h.name})]},h.id)})]})})})}function en({onSelect:r,"aria-label":t="Pilih module"}={}){const o=ht(),{useNavigate:n}=or(),l=n(),{selectedGroupId:s,setSelectedGroupId:c}=Ct(),[i,a]=d.useState(!1),h=y=>{var b;if(c(y),y!==null){const p=o.menus.find(E=>E.id===y),C=(b=p==null?void 0:p.items[0])==null?void 0:b.to;C&&l(C)}r==null||r(y)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>a(!0),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"2.25rem",height:"2.25rem",borderRadius:"var(--sa-radii-sm, 0.25rem)",border:"1px solid var(--sa-border-subtle, #0b120e24)",color:"var(--sa-text-subtle, #8c8f97)",backgroundColor:"transparent",cursor:"pointer"},"aria-label":t,onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--sa-background-primary-inverse, #f8f8f8)"},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent"},children:e.jsx(M.Icon,{name:"GridApplication",size:"sm"})}),s!==null&&e.jsx("span",{style:{position:"absolute",top:"0.25rem",right:"0.25rem",width:"0.5rem",height:"0.5rem",borderRadius:"9999px",backgroundColor:"var(--sa-color-brand-500, #1a4fa0)"},"aria-hidden":"true"})]}),e.jsx(Lo,{isShow:i,onHide:()=>a(!1),menus:o.menus.filter(y=>y.parentGroupId===void 0),selectedGroupId:s,onSelect:h})]})}const rn=(r,t)=>{const o=[];if(t===0)return o.push(r),o;for(let n=0;n<r.length;n+=t){const l=r.slice(n,n+t);o.push(l)}return o},tn=d.memo(({value:r,label:t,separator:o,labelWidth:n,lastIndex:l,labelAlign:s="top"})=>{const c=d.useMemo(()=>({padding:0,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),i=d.useMemo(()=>({padding:0,paddingRight:12,paddingLeft:12,paddingBottom:l?0:12,verticalAlign:s}),[l,s]),a=()=>typeof t=="string"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:t}):t,h=()=>typeof r=="string"||typeof r=="number"?e.jsx(D.Text,{color:"primary",fontWeight:"medium",children:r}):r,y=()=>typeof o=="string"||typeof o=="number"?e.jsx(D.Text,{fontWeight:"medium",color:"subtlest",children:o}):o;return e.jsxs(U.Tr,{children:[e.jsx(U.Td,{style:c,width:n,children:a()}),o?e.jsx(U.Td,{style:i,width:24,children:y()}):null,e.jsx(U.Td,{style:c,children:h()})]})}),on=d.memo(({fields:r,separator:t,labelWidth:o})=>e.jsx(U.Table,{withColumnBorder:!1,withRowBorder:!1,children:r.map((n,l)=>e.jsx(tn,{separator:t,labelWidth:o,lastIndex:l===r.length-1,...n},`field-group-field-${l}`))})),ln=d.memo(({maxRow:r=0,maxColumn:t=2,separator:o=":",fields:n=[],labelWidth:l=150,bordered:s=!1})=>{const c=d.useMemo(()=>rn(n,r),[n,r]),i=c.length>2,a=()=>{switch(t){case 1:return"width-full";case 2:return"width-1-2";case 3:return"width-1-3";case 4:return"width-1-4";default:return"width-1-2"}};return e.jsx(f.Box,{gap:i?void 0:"lg",direction:"row",flexWrap:"wrap",borderRadius:"rounded-sm",padding:"lg",paddingBottom:i?"xs":"lg",bg:"accent-dark-tertiary",borderWidth:s?"border":void 0,borderStyle:s?"border-solid":void 0,borderColor:s?"border-subtle":void 0,children:c.map((h,y)=>e.jsx(f.Box,{direction:"column",flex:i?void 0:"1",width:i?a():void 0,marginBottom:i?"lg":void 0,children:e.jsx(on,{labelWidth:l,fields:h,separator:o})},y))})}),nn=({backButton:r})=>{const[t,o]=d.useState(!1),n=(r==null?void 0:r.iconColor)??"var(--sa-text-subtle, #8c8f97)",l=(r==null?void 0:r.textColor)??"var(--sa-text-subtle, #8c8f97)",s=(r==null?void 0:r.hoverIconColor)??"var(--sa-text-subtle, #8c8f97)",c=(r==null?void 0:r.hoverTextColor)??"var(--sa-text-primary, #292a2e)";return e.jsxs(f.Box,{direction:"row",gap:"xs",align:"center",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{cursor:"pointer"},children:[e.jsx(M.Icon,{name:(r==null?void 0:r.iconName)||"ChevronLeft",size:"xs",style:{color:t?s:n,transition:"color 0.15s ease"}}),e.jsx(D.Text,{variant:"sub-h3",style:{color:t?c:l,textDecoration:t?"underline":"none",transition:"color 0.15s ease"},children:(r==null?void 0:r.title)||"Back"})]})},sn=({backButton:r,title:t,titleIcon:o,titleTag:n,children:l,header:s=!0,headerBorder:c=!1,disableAnimation:i=!1,scrollable:a=!1,stickyHeader:h=!1,subHeaders:y,action:b,titleTagProps:p,containerProps:C,headerProps:E})=>{const w=De.useMediaQuery("md"),{Link:L,useNavigate:F,useLocation:I}=or(),B=F(),k=I(),H=r==null?void 0:r.show,W=()=>{if(typeof(r==null?void 0:r.onClick)=="function"){r.onClick();return}B(-1,{replace:!0})},S=()=>{if(!b)return null;if(d.isValidElement(b))return b;const Z=b.filter(K=>K&&(K.title||K.icon));return Z.length===0?null:w?e.jsx(f.Box,{direction:"row",gap:"md",children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>e.jsx(j.Button,{iconLeft:te?e.jsx(M.Icon,{name:te,size:"md"}):void 0,onClick:V,..._,children:K},`action-${N}`))}):e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"tertiary",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuBurger"}),"aria-label":"Actions"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:200},children:Z.map(({title:K,icon:te,buttonProps:_,onClick:V},N)=>{const se=(_==null?void 0:_.tone)==="error"||(_==null?void 0:_.danger)===!0;return e.jsx(A.MenuItem,{intent:se?"danger":void 0,disabled:_==null?void 0:_.disabled,startIcon:te?e.jsx(M.Icon,{name:te}):void 0,onClick:V,children:K},`action-${N}`)})})})]})},z=()=>{const Z=e.jsx(nn,{backButton:r});return r!=null&&r.navigateTo?e.jsx(f.Box,{direction:"row",children:e.jsx(L,{to:r.navigateTo,replace:!0,style:{textDecoration:"none"},children:Z})}):e.jsx(f.Box,{direction:"row",children:e.jsx(mr,{onClick:W,children:Z})})},O=()=>{const Z=!!t,K=Array.isArray(b)&&b.length>0,te=d.isValidElement(b)?!0:K;if(!Z&&!te&&!H)return null;const V=w||!w&&K;return e.jsxs(f.Box,{direction:"column",gap:"xs",paddingBlock:(E==null?void 0:E.paddingBlock)??"sm",paddingInline:(E==null?void 0:E.paddingInline)??"md",...E,style:{...c?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...E==null?void 0:E.style},children:[H&&z(),(Z||te)&&e.jsxs(f.Box,{direction:V?"row":"column",gap:"sm",justify:"space-between",align:V?"center":"flex-start",children:[Z?typeof t=="string"?e.jsxs(f.Box,{direction:"row",gap:"lg",align:"center",children:[e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[o&&e.jsx(M.Icon,{name:o,size:"md",color:"primary"}),e.jsx(D.Text,{variant:"h3",fontWeight:"semibold",children:t})]}),n&&e.jsx(sr.Badge,{border:!0,size:"lg",text:n,...p})]}):t:null,S()]})]})},Y=()=>{if(!y||y.length===0)return null;const Z=y.filter(_=>_.show!==!1);if(Z.length===0)return null;let K=0,te=-1/0;return Z.forEach((_,V)=>{const N=_.order??0;N>=te&&(te=N,K=V)}),Z.map(({content:_,order:V,borderBottom:N=!0,keepBottomPadding:se=!1,paddingInline:ve=!0,paddingBlock:Ee=!0},ue)=>e.jsx(f.Box,{direction:"column",paddingTop:Ee?"sm":"spacing-0",paddingBottom:Ee&&(N||se||ue===K)?"sm":"spacing-0",paddingInline:ve?"md":"spacing-0",style:{...N?{boxShadow:"inset 0 -1px 0 0 var(--sa-border-subtle, #0b120e24)"}:{},...V!==void 0?{order:V}:{}},children:_},`sub-header-${ue}`))},X=()=>{const Z=s?O():null,K=Y();return!Z&&!K?null:e.jsxs(f.Box,{direction:"column",style:{...a?{position:"sticky",left:0,...h?{top:0}:{},zIndex:2,background:"var(--sa-background-primary, #ffffff)"}:{},marginBottom:K?"var(--sa-spacing-0)":"var(--sa-spacing-md)"},children:[Z,K]})},q=()=>l;return e.jsxs(f.Box,{direction:"column",as:"main",...C,style:{...a?{height:"100%",minHeight:0,overflow:"auto"}:{},...(C==null?void 0:C.style)??{},...i?{}:{animation:"pageLayoutEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards"}},children:[X(),q()]},k.pathname)},cn=d.memo(sn),an={icon:"Cross",title:""},dn=320,Oo=16,Ao=4,hn=8,Wo=d.forwardRef(({onHide:r,show:t,withBlur:o=!1,style:n,children:l,closeButton:s=an,paddingHorizontal:c=!0,width:i,minWidth:a,maxWidth:h,hideBackdrop:y=!1,title:b,headerAction:p,header:C=!0,widthPresets:E,resizable:w=!0,resizeMin:L=dn,resizeMax:F,onWidthChange:I},B)=>{const H=!De.useMediaQuery("md"),W=i??h??a??"357px",S=E??[],z=S.length>1,[O,Y]=d.useState(()=>{const $=S.indexOf(W);return $>=0?$:0}),[X,q]=d.useState(null),[Z,K]=d.useState(!1),[te,_]=d.useState(!1),V=d.useRef(null),N=$=>{V.current=$,typeof B=="function"?B($):B&&(B.current=$)},se=z?S[O]:W,ve=X!=null?`${X}px`:se,Ee=w&&!H,ue=O===S.length-1,Ce=()=>{const $=(O+1)%S.length;q(null),Y($),I==null||I(S[$])},xe=d.useCallback($=>{const ge=F??window.innerWidth;return Math.min(Math.max($,L),ge)},[L,F]),we=d.useRef(null),Ae=$=>{if(!Ee)return;$.preventDefault();const ge=$.currentTarget;ge.setPointerCapture($.pointerId),K(!0);const We=document.body.style.cursor,Ze=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let de=null;const Ge=P=>{const R=xe(window.innerWidth-P.clientX);we.current=R,de==null&&(de=window.requestAnimationFrame(()=>{de=null,we.current!=null&&q(we.current)}))},lr=P=>{de!=null&&window.cancelAnimationFrame(de),we.current!=null&&q(we.current),ge.releasePointerCapture(P.pointerId),ge.removeEventListener("pointermove",Ge),ge.removeEventListener("pointerup",lr),ge.removeEventListener("pointercancel",lr),document.body.style.cursor=We,document.body.style.userSelect=Ze,K(!1),we.current!=null&&(I==null||I(`${we.current}px`))};ge.addEventListener("pointermove",Ge),ge.addEventListener("pointerup",lr),ge.addEventListener("pointercancel",lr)},Fe=$=>{var de;if(!Ee||$.key!=="ArrowLeft"&&$.key!=="ArrowRight")return;$.preventDefault();const ge=$.key==="ArrowLeft"?Oo:-Oo,We=X??((de=V.current)==null?void 0:de.offsetWidth)??L,Ze=xe(We+ge);q(Ze),I==null||I(`${Ze}px`)},_e=()=>{Ee&&(q(null),I==null||I(se))};return e.jsx(Hr.Drawer,{blur:o,isShow:t,position:"right",onHide:r,ref:N,size:ve,style:n,flush:!0,radius:"none",hideBackdrop:y,children:e.jsxs(f.Box,{direction:"column",height:"height-full",children:[Ee?e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Ubah lebar panel",tabIndex:0,onPointerDown:Ae,onKeyDown:Fe,onDoubleClick:_e,title:"Tarik untuk mengubah lebar — klik dua kali untuk reset",onPointerEnter:()=>_(!0),onPointerLeave:()=>_(!1),style:{position:"absolute",left:0,top:0,bottom:0,width:hn,cursor:"col-resize",zIndex:1,background:Z||te?`linear-gradient(to right, var(--sa-border-brand, var(--sa-border-subtle)) 0 ${Ao}px, transparent ${Ao}px)`:"transparent",transition:"background 0.15s",touchAction:"none"}}):null,C?e.jsxs(f.Box,{direction:"row",align:"center",justify:"space-between",gap:"sm",paddingInline:"md",borderWidth:"border-b",borderStyle:"border-solid-b",borderColor:"border-base",customHeight:"var(--app-header-height, 44px)",flexShrink:"0",children:[e.jsx(f.Box,{direction:"row",align:"center",gap:"sm",overflow:"overflow-hidden",children:typeof b=="string"?e.jsx(D.Text,{fontSize:"md",fontWeight:"bold",children:b}):b}),e.jsxs(f.Box,{direction:"row",align:"center",gap:"sm",flexShrink:"0",children:[p,z?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:Ce,"aria-label":ue?"Kecilkan panel":"Lebarkan panel",iconRight:e.jsx(M.Icon,{name:ue?"ChevronRight":"ChevronLeft"})}):null,s?e.jsx(j.Button,{variant:"tertiary",tone:"neutral",size:"xs",onClick:r,"aria-label":s.title||"Tutup",iconRight:e.jsx(M.Icon,{name:s.icon}),children:s.title||void 0}):null]})]}):null,e.jsx(f.Box,{direction:"column",paddingBlock:"md",paddingInline:c?"md":"spacing-0",overflow:"overflow-y-auto",style:{flex:1,minHeight:0},children:l})]})})}),St=d.memo(({children:r,borderBottom:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),Bt=d.memo(({children:r,borderTop:t=!0,padding:o=!0})=>{const n=De.useMediaQuery("lg");return e.jsx(f.Box,{direction:"column",padding:o?"md":"spacing-0",paddingLeft:o?"md":"spacing-0",paddingRight:o?"md":"spacing-0",style:t?{borderTop:"1px solid var(--sa-border-subtle, #0b120e24)"}:void 0,children:r})}),fn=d.memo(({children:r,...t})=>e.jsx(f.Box,{direction:"column",padding:"md",paddingLeft:"md",paddingRight:"md",gap:"md",...t,children:r})),un=d.memo(({children:r,title:t,titleTag:o,action:n,header:l,footer:s,actionContainer:c,containerProps:i,bodyProps:a,headerProps:h={borderBottom:!0},footerProps:y={borderTop:!0},variantTag:b="info"})=>{const p=De.useMediaQuery("lg"),C=()=>o?e.jsxs(f.Box,{direction:"row",gap:"sm",align:"center",children:[e.jsx(D.Text,{fontWeight:"medium",children:t}),e.jsx(sr.Badges,{border:!0,text:o,variant:b})]}):e.jsx(D.Text,{fontWeight:"medium",children:t}),E=()=>l||e.jsxs(f.Box,{direction:"row",justify:"space-between",align:"flex-start",gap:"md",children:[e.jsx(f.Box,{direction:"column",children:t?C():null}),e.jsx(f.Box,{direction:"column",style:p?{width:"100%",maxWidth:"19.313rem"}:{flex:1},...c,children:n??null})]}),w=!!(l||t||n);return e.jsxs(f.Box,{direction:"column",bg:"white",borderRadius:"rounded-xs",as:"section",borderWidth:"border",borderStyle:"border-solid",borderColor:"border-base",...i,style:{backgroundColor:"var(--sa-background-primary, #ffffff)",...(i==null?void 0:i.style)??{}},children:[l!==null&&w?e.jsx(St,{...h,children:E()}):null,e.jsx(fn,{...a,children:r}),s?e.jsx(Bt,{...y,children:s}):null]})}),Ke={H1:r=>e.jsx(D.Text,{variant:"h1",children:r.children,...r.props}),H2:r=>e.jsx(D.Text,{variant:"h2",children:r.children,...r.props}),H3:r=>e.jsx(D.Text,{variant:"h3",children:r.children,...r.props}),H4:r=>e.jsx(D.Text,{variant:"h4",children:r.children,...r.props}),H5:r=>e.jsx(D.Text,{variant:"h5",children:r.children,...r.props}),H6:r=>e.jsx(D.Text,{variant:"h6",children:r.children,...r.props}),SubH1:r=>e.jsx(D.Text,{variant:"sub-h1",children:r.children,...r.props}),SubH2:r=>e.jsx(D.Text,{variant:"sub-h2",children:r.children,...r.props}),SubH3:r=>e.jsx(D.Text,{variant:"sub-h3",children:r.children,...r.props}),Body1:r=>e.jsx(D.Text,{variant:"body-1",children:r.children,...r.props}),Body2:r=>e.jsx(D.Text,{variant:"body-2",children:r.children,...r.props}),Body3:r=>e.jsx(D.Text,{variant:"body-3",children:r.children,...r.props})},Ne=()=>{const{useSearchParams:r,useParams:t,useLocation:o}=or(),[n,l]=r(),s=vr.searchParamsToObject(n.toString()),c=t(),i=o(),a=c.id;return{setSearchParams:l,searchParams:n,searchQueries:s,isHasQuery:(C,E)=>n.has(C)&&n.get(C)===E,getQueryParam:C=>n.get(C),getRouteParam:C=>c[C],params:c,location:i,id:a,hasId:!!a}},zo=r=>JSON.stringify(r),Ho=r=>JSON.stringify(r),Po=r=>JSON.stringify(r),Vo=r=>JSON.stringify(r),gn=r=>r,yn=r=>JSON.stringify(r),Fr=({value:r,name:t,type:o,withSearchParam:n=!0,setSearchParams:l,searchQueries:s,dropdownSearchKey:c,filterKey:i="filter",pageKey:a="page"})=>{if(n){let h;switch(o){case"search":h=gn(r);break;case"dropdown":case"dropdown-multiple":h=zo(r);break;case"radio":h=Ho(r);break;case"date-range":h=Po(r);break;case"advanced-date-range":h=yn(r);break;case"date":h=Vo(r);break;default:h=r;break}if(typeof h<"u"){const b={...s[i]&&typeof s[i]=="string"?JSON.parse(s[i]):void 0,[t]:h},p={...s};c&&typeof c=="string"&&delete p[c],delete p[a];const C={...p,[i]:JSON.stringify(b)},E=new URLSearchParams(s).toString(),w=new URLSearchParams(C).toString();if(E===w)return;l(C)}}},_r=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c)[0].label:n==="value"&&c?JSON.parse(c)[0].value:c},jo=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="label"&&c?JSON.parse(c).map(i=>i.label):n==="value"&&c?JSON.parse(c).map(i=>i.value):n==="array"&&c?JSON.parse(c):c},pn=({name:r,filterKey:t="filter",searchParams:o,get:n})=>{const l=o.get(t)||void 0,s=l&&typeof l=="string"?JSON.parse(l):void 0,c=s?s[r]:void 0;return n==="id"&&c?JSON.parse(c).id:n==="label"&&c?JSON.parse(c).label:n==="value"&&c?JSON.parse(c).value:c},qr=(r,t,o)=>{const n=t.get(o||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0;return l?l[r]:void 0},bn=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return{start:s?JSON.parse(s).from:void 0,end:s?JSON.parse(s).to:void 0}},No=({name:r,filterKey:t="filter",searchParams:o})=>{const n=o.get(t||"filter")||void 0,l=n&&typeof n=="string"?JSON.parse(n):void 0,s=l?l[r]:void 0;return s?JSON.parse(s):void 0},vn=(r,{filterKey:t="filter",perPageKey:o="perPage",pageKey:n="page"})=>{const l=r.get(t)||void 0,s=r.get(o)||void 0,c=r.get(n)||void 0;return!!l||!!s||!!c},_o=({isOpen:r,onClose:t,filterKey:o,pageKey:n,filters:l})=>{const{searchParams:s,setSearchParams:c,searchQueries:i}=Ne(),[a,h]=d.useState({}),y=()=>{s.delete(o||"filter"),c(s)},b=(p,C)=>{switch(p.type){case"radio":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"dropdown":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}case"date-range":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"date":return e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C);case"dropdown-multiple":{const{show:E=!0}=p;return E&&e.jsx(f.Box,{direction:"column",children:e.jsx(f.Box,{direction:"column",children:p.title})},C)}default:return null}};return e.jsx(Wo,{onHide:t,show:r||!1,children:e.jsxs(f.Box,{direction:"column",gap:"md",children:[e.jsxs(ie.Flex,{direction:"row",justify:"space-between",align:"center",children:[e.jsx(f.Box,{direction:"column",children:"Filter"}),e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},onClick:y,children:"Reset"})]}),l==null?void 0:l.map((p,C)=>b(p,C))]})})},qo=({searchKey:r="q",statusKey:t="status",searchPlaceholder:o="Search",searchHighlightPlaceholder:n,extendedFilter:l,showSearchFilter:s=!0,showStatusFilter:c=!0,filterKey:i="filter",pageKey:a="page",customWidthSearch:h,handleOnReset:y,filterConfigs:b,buttonToggleProps:p,position:C="right",titleSearchLabel:E="Work Order",withTitleLabels:w=!1})=>{const F=(p==null?void 0:p.isShowLabel)??!0,[I,B]=d.useState(!1),[k,H]=d.useState(0),W=()=>{H(N=>N+1)},{searchParams:S,setSearchParams:z,getQueryParam:O}=Ne(),Y=vr.searchParamsToObject(S.toString()),X=qr(r,S,i)||"",[q,Z]=d.useState(X),K=O(i),_=!!(K&&!(()=>{if(K)try{const N=JSON.parse(K);return Object.keys(N).length===1&&N[r]===""}catch(N){console.error("Filter parameter is not a valid JSON:",N)}return!1})()),V=De.useMediaQuery("md");return d.useEffect(()=>{Z(X)},[X]),d.useEffect(()=>{if(q===X)return;const N=window.setTimeout(()=>{Fr({value:q,name:r,type:"search",searchQueries:Y,setSearchParams:z,filterKey:i,pageKey:a})},350);return()=>{window.clearTimeout(N)}},[q,X,r,Y,z,i,a]),e.jsxs(ie.Flex,{gap:"md",style:{flexDirection:V&&C==="left"?"row":V&&C==="right"?"row-reverse":"column"},align:"flex-end",children:[_&&e.jsx(f.Box,{direction:"column",justify:"flex-end",children:e.jsx(j.Button,{onClick:()=>{const N=new URLSearchParams(S);N.delete(i),z(N),Z(""),W(),y&&y()},variant:"outline",tone:"neutral",children:e.jsx(D.Text,{color:"error",fontWeight:"semibold",children:"Reset"})})}),l==null?void 0:l.map(({minWidth:N,content:se,title:ve,onClickContainer:Ee},ue)=>e.jsxs(f.Box,{direction:"column",gap:"sm",onClick:Ee,style:{minWidth:N},children:[ve&&e.jsx(Ke.SubH3,{children:ve}),se]},`extended-filter-${ue}-${k}`)),!!(b!=null&&b.length)&&e.jsx(j.Button,{primary:_,secondary:!_,iconLeft:e.jsx(M.Icon,{size:"sm",name:(p==null?void 0:p.icon)||"FilterHorizontal",style:{color:K?"var(--sa-background-brand, #04254f)":"var(--sa-text-primary, #292a2e)"}}),fullWidth:!V,onClick:()=>B(!0),children:F?"Filter":void 0}),c&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{minWidth:"126px"},children:[w&&e.jsx(Ke.SubH3,{children:"Status"}),e.jsx(br.Dropdown,{dropdownLists:[{label:"Active",value:"active"},{label:"InActive",value:"inactive"}],defaultValue:_r({get:"value",name:t,searchParams:S,filterKey:i})?[{label:_r({get:"value",name:t,searchParams:S,filterKey:i})==="active"?"Active":"InActive",value:_r({get:"value",name:t,searchParams:S,filterKey:i})}]:[],onChange:N=>Fr({value:N,name:t,type:"dropdown",searchQueries:Y,setSearchParams:z,filterKey:i}),placeholder:w?"All":"All Status"},k)]}),s&&e.jsxs(f.Box,{direction:"column",gap:"sm",style:{width:h&&V?h:V?"310px":""},children:[w&&e.jsxs(Ke.SubH3,{children:["Search for ",E]}),e.jsx(ar.Input,{placeholder:o,leftIcon:e.jsx(M.Icon,{name:"Search",width:20,height:20}),onChange:N=>Z(N.target.value),value:q,fullWidth:!0},k+1+i)]}),e.jsx(_o,{isOpen:I,onClose:()=>B(!1),filterKey:i,filters:b,pageKey:a})]})},Cn=r=>r==="checkbox-multiple"?"dropdown-multiple":r==="radio"?"dropdown":r==="date-compact"?"date":r;function kt({configs:r,filterKey:t="filter",activeFilterKey:o="filters",pageKey:n="page",searchKey:l="q"}){const{searchParams:s,setSearchParams:c,searchQueries:i}=Ne(),a=d.useMemo(()=>Object.fromEntries(r.map(k=>[k.key,k])),[r]),h=d.useMemo(()=>{const k=(s.get(o)||"").split(",").map(W=>W.trim()).filter(Boolean);let H=[];try{const W=s.get(t);W&&(H=Object.keys(JSON.parse(W)).filter(S=>S!==l))}catch{}return r.map(W=>W.key).filter(W=>{const S=a[W];return(S==null?void 0:S.locked)||k.includes(W)||H.includes(W)})},[s,o,t,l,r,a]),y=d.useCallback(k=>{try{return k[t]?JSON.parse(k[t]):{}}catch{return{}}},[t]),b=d.useCallback(k=>{const H={...i};k.length?H[o]=k.join(","):delete H[o],c(H)},[i,o,c]),p=d.useCallback(k=>{h.includes(k)||b([...h,k])},[h,b]),C=d.useCallback(k=>{var z;if((z=a[k])!=null&&z.locked)return;const H={...i},W=h.filter(O=>O!==k);W.length?H[o]=W.join(","):delete H[o];const S=y(H);k in S&&(delete S[k],Object.keys(S).length?H[t]=JSON.stringify(S):delete H[t]),delete H[n],c(H)},[i,h,o,t,n,y,c,a]),E=d.useCallback(k=>h.includes(k)?C(k):p(k),[h,p,C]),w=d.useCallback(k=>{switch(k.type){case"dropdown":case"dropdown-multiple":case"checkbox-multiple":case"radio":return jo({name:k.key,get:"array",searchParams:s,filterKey:t})||[];case"date":{const H=No({name:k.key,searchParams:s,filterKey:t});return H?new Date(H):void 0}case"date-compact":{const W=y(Object.fromEntries(s.entries()))[k.key];return W&&typeof W=="object"?W:void 0}default:return}},[s,t,y]),L=d.useCallback((k,H)=>{if(k.type==="date-compact"){const W={...i},S=y(W);H==null?delete S[k.key]:S[k.key]=H,Object.keys(S).length?W[t]=JSON.stringify(S):delete W[t],delete W[n],c(W);return}Fr({value:H,name:k.key,type:Cn(k.type),searchQueries:i,setSearchParams:c,filterKey:t,pageKey:n})},[i,c,t,n,y]),F=d.useCallback(k=>{const H={...i},W=y(H);k in W&&(delete W[k],Object.keys(W).length?H[t]=JSON.stringify(W):delete H[t]),delete H[n],c(H)},[i,t,n,y,c]),I=d.useCallback(()=>{const k={...i};delete k[t],delete k[o],delete k[n],c(k)},[i,t,o,n,c]),B=h.length>0;return{activeKeys:h,configByKey:a,hasActiveFilter:B,addFilter:p,removeFilter:C,toggleFilter:E,getValue:w,setValue:L,clearValue:F,clearAll:I}}const Et={get(r){return Er.storage.get(r)??null},set(r,t){Er.storage.save(r,t)},remove(r){Er.storage.delete(r)}},wr={columns:r=>`filterbar:colprefs:${r}`,savedViews:r=>`filterbar:views:${r}`,lastState:r=>`filterbar:last:${r}`,perPage:r=>`filterbar:perpage:${r}`,tableSort:r=>`tablelayout:sort:${r}`},Zr=(r,t)=>{const o=new Set(t.map(s=>s.key)),n=r.order.filter(s=>o.has(s));for(const s of t)n.includes(s.key)||n.push(s.key);const l=r.hidden.filter(s=>o.has(s));return{order:n,hidden:l}};function xn({columns:r,scopeId:t,storage:o,onColumnsChange:n,value:l}){const s=d.useMemo(()=>({order:r.map(S=>S.key),hidden:[]}),[r]),c=t?wr.columns(t):void 0,i=(S,z)=>Zr({order:S.order??z,hidden:S.hidden??[]},r),[a,h]=d.useState(()=>{if(l&&(l.order||l.hidden))return i(l,r.map(S=>S.key));if(c){const S=o.get(c);if(S&&Array.isArray(S.order))return Zr(S,r)}return s}),y=r.map(S=>S.key).join("|");d.useEffect(()=>h(S=>Zr(S,r)),[y]);const b=d.useRef(a);b.current=a;const p=l?`${(l.order??[]).join("|")}~${(l.hidden??[]).join("|")}`:null,C=d.useRef(p);d.useEffect(()=>{if(p==null||C.current===p)return;C.current=p;const S=b.current,z=i(l,S.order);z.order.join("|")===S.order.join("|")&&z.hidden.join("|")===S.hidden.join("|")||(h(z),c&&o.set(c,z))},[p,y]);const E=d.useRef(!1);d.useEffect(()=>{E.current||(E.current=!0,n==null||n(a))},[]);const w=d.useCallback(S=>{h(S),c&&o.set(c,S),n==null||n(S)},[c,o,n]),L=d.useMemo(()=>{const S=new Map(r.map(z=>[z.key,z]));return a.order.filter(z=>S.has(z)).map(z=>({...S.get(z),visible:!a.hidden.includes(z)}))},[a,r]),F=d.useCallback(S=>{const z=a.hidden.includes(S)?a.hidden.filter(O=>O!==S):[...a.hidden,S];w({...a,hidden:z})},[a,w]),I=d.useCallback((S,z)=>{if(S===z)return;const O=[...a.order],[Y]=O.splice(S,1);O.splice(z,0,Y),w({...a,order:O})},[a,w]),B=d.useCallback(S=>{w({...a,hidden:S?r.filter(z=>!z.locked).map(z=>z.key):[]})},[a,r,w]),k=d.useCallback(()=>w(s),[w,s]),H=d.useCallback(S=>w(Zr(S,r)),[w,r]),W=a.hidden.length===0;return{state:a,orderedColumns:L,allVisible:W,toggleVisibility:F,reorder:I,setAllHidden:B,reset:k,applyState:H}}function wn({scopeId:r,storage:t,snapshotKeys:o,pageKey:n="page",getColumns:l,applyColumns:s}){const{searchParams:c,setSearchParams:i}=Ne(),a=r?wr.savedViews(r):void 0,[h,y]=d.useState(()=>a?t.get(a)||[]:[]),b=d.useCallback(w=>{y(w),a&&t.set(a,w)},[a]),p=d.useCallback(w=>{const L=w.trim();if(!L)return;const F={};o.forEach(B=>{const k=c.get(B);k!=null&&(F[B]=k)});const I={id:`${Date.now()}`,name:L,query:F,columns:l==null?void 0:l(),createdAt:Date.now()};b([...h,I])},[o,c,l,b,h]),C=d.useCallback(w=>b(h.filter(L=>L.id!==w)),[b,h]),E=d.useCallback(w=>{const L=Object.fromEntries(c.entries());o.forEach(F=>delete L[F]),Object.assign(L,w.query),delete L[n],i(L),w.columns&&(s==null||s(w.columns))},[c,o,n,i,s]);return{enabled:!!a,views:h,saveView:p,deleteView:C,applyView:E}}function Dn(r,t){let o;try{o=JSON.parse(r)}catch{return r}return!o||typeof o!="object"?r:(delete o[t],Object.keys(o).length>0?JSON.stringify(o):void 0)}function Zo(r,t,o){const n=r[t];if(n==null)return;const l=Dn(n,o);l===void 0?delete r[t]:r[t]=l}function Sn({scopeId:r,storage:t,snapshotKeys:o,enabled:n=!0,filterKey:l="filter",searchKey:s="q",persistSearch:c=!0}){const{searchParams:i}=Ne(),a=r&&n?wr.lastState(r):void 0,h=d.useRef(a),y=d.useRef(!1);d.useEffect(()=>{if(!a){h.current=a;return}if(h.current!==a){h.current=a,y.current=!1;return}const C={};if(o.forEach(E=>{const w=i.get(E);w!=null&&(C[E]=w)}),c||Zo(C,l,s),Object.keys(C).length===0){y.current&&t.remove(a);return}y.current=!0,t.set(a,C)},[i,a,o,t,c,l,s]);const b=d.useCallback(()=>{if(!a)return null;const C=t.get(a);return!C||Object.keys(C).length===0||!c&&(Zo(C,l,s),Object.keys(C).length===0)?null:C},[a,t,c,l,s]),p=d.useCallback(()=>{a&&t.remove(a)},[a,t]);return{enabled:!!a,read:b,clear:p}}function Bn({scopeId:r,storage:t,perPageKey:o,pageSizeOptions:n,enabled:l=!0}){const{searchParams:s}=Ne(),c=r&&l?wr.perPage(r):void 0,i=s.toString(),a=d.useRef(c);d.useEffect(()=>{if(!c){a.current=c;return}if(a.current!==c){a.current=c;return}const b=s.get(o);if(!b)return;const p=Number(b);!Number.isFinite(p)||p<=0||t.set(c,p)},[i,c,o,t]);const h=d.useCallback(()=>{if(!c)return null;const b=t.get(c);if(b==null)return null;const p=Number(b);return!Number.isFinite(p)||p<=0||n&&!n.includes(p)?null:String(p)},[c,t,n]),y=d.useCallback(()=>{c&&t.remove(c)},[c,t]);return{enabled:!!c,read:h,clear:y}}let mt={},Ft=!1,Mt=null;const kn=(r,t)=>{Object.assign(mt,r),Mt=t,!Ft&&(Ft=!0,queueMicrotask(()=>{const o=mt,n=Mt;mt={},Ft=!1,Mt=null,!(!n||Object.keys(o).length===0)&&n(l=>{const s=new URLSearchParams(l);return Object.entries(o).forEach(([c,i])=>s.set(c,i)),s},{replace:!0})}))};function En({enabled:r,snapshotKeys:t,perPageKey:o,readSnapshot:n,readPerPage:l}){const{searchParams:s,setSearchParams:c,location:i}=Ne(),a=d.useRef(null);d.useEffect(()=>{if(!r||a.current===i.pathname)return;a.current=i.pathname;const h={};if(!s.has(o)){const y=l();y&&(h[o]=y)}if(!t.some(y=>s.has(y))){const y=n();y&&Object.assign(h,y)}Object.keys(h).length!==0&&kn(h,c)},[i.pathname,r])}const mn=({configs:r,activeKeys:t,onToggle:o,hasActiveFilter:n,onReset:l})=>r.length?e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:n?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),"aria-label":"Add filter"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{minWidth:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:"Add Filter"}),n&&l&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"xs",onClick:l,children:"Reset"})]}),children:r.map(s=>e.jsx(A.MenuItem,{selected:s.locked||t.includes(s.key),disabled:s.locked,closeOnSelect:!1,startIcon:s.icon??void 0,onClick:()=>{s.locked||o(s.key)},children:s.label},s.key))})})]}):null,Gr=({onClear:r,onRemove:t})=>e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconLeft:e.jsx(M.Icon,{name:"MenuHorizontal"}),"aria-label":"Filter actions"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:180},children:[e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"CrossCircle"}),onClick:r,children:"Clear value"}),t&&e.jsx(A.MenuItem,{intent:"danger",startIcon:e.jsx(M.Icon,{name:"Trash1"}),onClick:t,children:"Remove filter"})]})})]}),Fn=r=>{const t=new Date(r);return t.setHours(0,0,0,0),t},Go=(r,t,o)=>{const n=new Date(r);return o==="day"?n.setDate(n.getDate()+t):o==="week"?n.setDate(n.getDate()+t*7):o==="month"?n.setMonth(n.getMonth()+t):n.setFullYear(n.getFullYear()+t),n},Qo=r=>{const t=Fn(new Date);if(r.direction==="this"){const n=new Date(t),l=new Date(t);return r.period==="week"?(n.setDate(t.getDate()-t.getDay()),l.setDate(n.getDate()+6)):r.period==="month"?(n.setDate(1),l.setMonth(l.getMonth()+1,0)):r.period==="year"&&(n.setMonth(0,1),l.setMonth(11,31)),{from:n,to:l}}const o=r.count??1;return r.direction==="past"?{from:Go(t,-o,r.period),to:t}:{from:t,to:Go(t,o,r.period)}},Uo=24,Jo=r=>r.length>Uo?`${r.slice(0,Uo)}...`:r,Yo=r=>r.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}),It=(r,t="days")=>t==="months"?r.toLocaleDateString(void 0,{month:"short",year:"numeric"}):t==="years"?String(r.getFullYear()):Yo(r),Qr={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"},Mn=["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"},In=["day","week","month","year"],Tn=["past","next","this"],Ln=r=>r.field.type==="date-compact"?e.jsx(Wn,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}):e.jsx(On,{field:r.field,value:r.value,onChange:r.onChange,onClear:r.onClear,onRemove:r.onRemove}),On=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=t?Yo(new Date(t)):null,c=!!s,i=c?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Jo(s)})]}):r.label;return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:i})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:r.mode,value:t,onChange:a=>a==null?n():o(a),withPadding:!1})})})]})},An=(r,t="days")=>{switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date?`${Qr[r.op]} ${It(new Date(r.date),t)}`:null;case"is-between":return r.from&&r.to?`${It(new Date(r.from),t)} - ${It(new Date(r.to),t)}`:null;case"is-relative-to-today":{const o=r.relative;if(!o)return null;if(o.direction==="this")return`This ${o.period}`;const n=o.count??1,l=n===1?o.period:`${o.period}s`;return`${Tt[o.direction]} ${n} ${l}`}case"is-empty":case"is-not-empty":return Qr[r.op];default:return null}},Wn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.ops&&r.ops.length>0?r.ops:Mn,c=r.defaultOp&&s.includes(r.defaultOp)?r.defaultOp:s[0],i=r.mode??"days",a=(t==null?void 0:t.op)??c,h=t?An(t,i):null,y=!!h,b=y?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:Jo(h)})]}):r.label,p=C=>{if(C!==a){if(C==="is-empty"||C==="is-not-empty"){o({op:C});return}if(C==="is-relative-to-today"){o({op:C,relative:(t==null?void 0:t.relative)??{direction:"past",count:1,period:"week"}});return}if(C==="is-between"){o({op:C,from:t==null?void 0:t.from,to:t==null?void 0:t.to});return}o({op:C,date:t==null?void 0:t.date})}};return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:y?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:y?e.jsx(M.Icon,{name:"Calendar",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsxs(A.MenuLists,{children:[e.jsx(A.MenuBody,{style:{width:320},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",gap:"xs",fullWidth:!0,children:[e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"xs",style:{minWidth:0},children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(zn,{op:a,ops:s,onChange:p})]}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsx(Hn,{value:t,op:a,mode:i,onChange:o})}),a==="is-relative-to-today"&&e.jsx(A.MenuFooter,{children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Filter will update with the current date"})})]})]})},zn=({op:r,ops:t,onChange:o})=>e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"link",tone:"neutral",size:"xs",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Qr[r]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:200},children:t.map(n=>e.jsx(A.MenuItem,{selected:r===n,onClick:()=>o(n),endIcon:r===n?e.jsx(M.Icon,{name:"Check"}):void 0,children:Qr[n]},n))})})]}),Hn=({value:r,op:t,mode:o="days",onChange:n})=>{if(t==="is-empty"||t==="is-not-empty")return e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No further input required."})});if(t==="is-between"){const l=r!=null&&r.from||r!=null&&r.to?{from:r!=null&&r.from?new Date(r.from):null,to:r!=null&&r.to?new Date(r.to):null}:void 0;return e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,rangedDate:!0,filter:o,value:l,onChange:s=>{if(s==null){n({op:t});return}if(typeof s=="object"&&s!==null&&"from"in s&&"to"in s){let{from:c,to:i}=s;if(!c&&i&&(c=i,i=null),!c&&!i){n({op:t});return}n({op:t,from:c?c.toISOString():void 0,to:i?i.toISOString():void 0})}},withPadding:!1},`range-${o}`)}return t==="is-relative-to-today"?e.jsx(Pn,{value:r==null?void 0:r.relative,onChange:l=>n({op:t,relative:l})}):e.jsx(fr.StarasiaDate,{size:"sm",input:!1,clearable:!0,filter:o,value:r!=null&&r.date?new Date(r.date):void 0,onChange:l=>{if(l==null){n({op:t});return}l instanceof Date&&n({op:t,date:l.toISOString()})},withPadding:!1},`single-${o}`)},Pn=({value:r,onChange:t})=>{const o=(r==null?void 0:r.direction)??"past",n=(r==null?void 0:r.count)??1,l=(r==null?void 0:r.period)??"week",s=o!=="this",c=Qo({direction:o,count:n,period:l});return e.jsxs(f.Box,{direction:"column",display:"flex",gap:"sm",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:Tt[o]})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:Tn.map(i=>e.jsx(A.MenuItem,{selected:o===i,endIcon:o===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(i==="this"?{direction:i,period:l}:{direction:i,count:n,period:l}),children:Tt[i]},i))})})]}),s&&e.jsx(ar.Input,{type:"number",size:"sm",min:1,clearable:!1,value:n,onChange:i=>{const a=Number(i.target.value);t({direction:o,count:Number.isFinite(a)&&a>0?a:1,period:l})},style:{width:72}}),e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:l})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:140},children:In.map(i=>e.jsx(A.MenuItem,{selected:l===i,endIcon:l===i?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>t(o==="this"?{direction:o,period:i}:{direction:o,count:n,period:i}),children:i},i))})})]})]}),e.jsx(fr.StarasiaDate,{size:"sm",input:!1,disabled:!0,rangedDate:!0,value:c,onChange:()=>{},withPadding:!1},"relative-preview")]})},Xo=18,Vn=r=>r.length>Xo?`${r.slice(0,Xo)}...`:r,jn=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=r.type==="dropdown-multiple",c=t.length,i=r.searchable!==!1,[a,h]=d.useState(""),y=r.options,b=typeof r.onSearch=="function",p=(()=>{if(b)return y;const F=a.trim().toLowerCase();return F?y.filter(I=>I.label.toLowerCase().includes(F)):y})(),C=F=>t.some(I=>I.value===F.value),E=F=>{if(!s){o([{label:F.label,value:F.value}]),h("");return}o(C(F)?t.filter(I=>I.value!==F.value):[...t,{label:F.label,value:F.value}])},w=F=>{var I;h(F),(I=r.onSearch)==null||I.call(r,F)},L=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{fontWeight:500},children:[r.label,":"]})," ",e.jsx("span",{style:{fontWeight:400},children:c===1?Vn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:L})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{style:{width:260},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:e.jsxs(f.Box,{direction:"column",gap:"sm",children:[i&&e.jsx(br.Dropdown,{size:"sm",triggerInput:!0,fullWidth:!0,hideChevronIcon:!0,clearable:!0,multiSelect:s,searchAble:!0,searchValue:a,onSearch:w,value:t,onChange:o,placeholder:`Search ${r.label.toLowerCase()}…`}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",customMaxHeight:"240px",children:r.isLoading?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"Loading…"})}):p.length===0?e.jsx(f.Box,{paddingBlock:"sm",paddingInline:"sm",children:e.jsx(D.Text,{fontSize:"xs",color:"subtlest",children:"No results"})}):p.map(F=>e.jsx(A.MenuItem,{closeOnSelect:!s,selected:C(F),startIcon:F.avatar,endIcon:C(F)?e.jsx(M.Icon,{name:"Check"}):void 0,description:F.description,onClick:()=>E(F),children:F.label},F.value))})]})})})]})},$o=18,Nn=r=>r.length>$o?`${r.slice(0,$o)}...`:r,Ko=({checked:r,indeterminate:t})=>e.jsx("span",{style:{pointerEvents:"none",display:"inline-flex"},children:e.jsx(tr.Checkbox,{size:"sm",checked:r,readOnly:!0,onChange:()=>{},variant:t?"indeterminate":"select"})}),_n=({field:r,value:t,onChange:o,onClear:n,onRemove:l})=>{const s=new Set(t.map(p=>p.value)),c=t.length,i=r.options.length>0&&r.options.every(p=>s.has(p.value)),a=c>0&&!i,h=p=>{o(s.has(p.value)?t.filter(C=>C.value!==p.value):[...t,{label:p.label,value:p.value}])},y=()=>{o(i?[]:r.options.map(p=>({label:p.label,value:p.value})))},b=c===0?r.label:e.jsxs(e.Fragment,{children:[e.jsxs(D.Text,{as:"span",fontWeight:"semibold",children:[r.label,":"]})," ",e.jsx(D.Text,{as:"span",children:c===1?Nn(t[0].label):`${c} Selected`})]});return e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:c>0?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:c>0?e.jsx(M.Icon,{name:"Tag",size:"sm"}):void 0,iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),children:b})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{width:240},title:e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",justify:"space-between",fullWidth:!0,children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtlest",children:r.label}),e.jsx(Gr,{onClear:n,onRemove:l})]}),children:[e.jsx(A.MenuItem,{closeOnSelect:!1,selected:i,onClick:y,startIcon:e.jsx(Ko,{checked:i||a,indeterminate:a}),children:"Select All"}),r.options.map(p=>e.jsx(A.MenuItem,{closeOnSelect:!1,selected:s.has(p.value),onClick:()=>h(p),startIcon:e.jsx(Ko,{checked:s.has(p.value)}),children:p.label},p.value))]})})]})},Ro=({activeKeys:r,configByKey:t,getValue:o,setValue:n,clearValue:l,removeFilter:s})=>e.jsx(e.Fragment,{children:r.map(c=>{const i=t[c];if(!i)return null;const a=o(i),h=i.locked?void 0:()=>s(c);return i.type==="date"||i.type==="date-compact"?e.jsx(Ln,{field:i,value:a,onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):i.type==="checkbox-multiple"?e.jsx(_n,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c):e.jsx(jn,{field:i,value:a||[],onChange:y=>n(i,y),onClear:()=>l(c),onRemove:h},c)})}),el=r=>`${r} Rows`,qn=({pagination:r,pageKey:t="page",perPageKey:o="perPage",pageSizeOptions:n=[10,25,50,100],defaultPerPage:l=10,showResultCount:s=!0,showPageSize:c=!0,showPagination:i=!0})=>{var F;const{searchQueries:a,setSearchParams:h,searchParams:y}=Ne(),b=y.get(o),p=b?Number(b):l,C=I=>{h({...a,[t]:String(I)})},E=I=>{h({...a,[o]:I,[t]:"1"})},w=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:0),L=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsxs(e.Fragment,{children:[s&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${w}-${L} of ${((F=r==null?void 0:r.totalData)==null?void 0:F.toLocaleString())||0}`}),c&&e.jsxs(A.Menu,{position:"bottom-left",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconRight:e.jsx(M.Icon,{name:"ChevronSmallDown"}),"aria-label":"Rows per page",children:el(p)})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:n.map(I=>e.jsx(A.MenuItem,{selected:I===p,onClick:()=>E(String(I)),children:el(I)},I))})})]}),i&&((r==null?void 0:r.totalPage)??0)>1&&e.jsx(f.Box,{direction:"column",display:"flex",align:"center",gap:"sm",paddingRight:"sm",style:{borderRight:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:e.jsx(kr.Pagination,{size:"sm",variant:"neutral",siblingCount:0,currentPage:r!=null&&r.currentPage?Number(r.currentPage):1,totalPages:Number(r==null?void 0:r.totalPage),onPageChange:C})})]})};function Zn(r,t,o=!0){d.useEffect(()=>{if(!o)return;const n=l=>{var i;if(l.metaKey||l.ctrlKey||l.altKey||l.key!==r||je.isOverlayOpen())return;const s=l.target,c=(i=s==null?void 0:s.tagName)==null?void 0:i.toLowerCase();c==="input"||c==="textarea"||s!=null&&s.isContentEditable||(l.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r,t,o])}const Gn=240,rl=({searchKey:r="q",filterKey:t="filter",pageKey:o="page",placeholder:n="Search",shortcut:l="/",collapsible:s=!0})=>{const{searchParams:c,setSearchParams:i,searchQueries:a}=Ne(),h=qr(r,c,t)||"",[y,b]=d.useState(!s||!!h),[p,C]=d.useState(s&&!h),[E,w]=d.useState(h),L=De.useDebounce(E,350),F=d.useRef(null);d.useEffect(()=>{w(h),h&&b(!0)},[h]),d.useEffect(()=>{y&&C(!1)},[y]),d.useEffect(()=>{L!==h&&Fr({value:L,name:r,type:"search",searchQueries:a,setSearchParams:i,filterKey:t,pageKey:o})},[L]);const I=d.useCallback(()=>{b(!0),requestAnimationFrame(()=>{var W;return(W=F.current)==null?void 0:W.focus()})},[]);Zn(l,I);const B=()=>{s&&!E&&b(!1)},k=W=>{var S;s&&W.key==="Escape"&&!E&&(b(!1),(S=F.current)==null||S.blur())},H=()=>{y||C(!0)};return e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"spacing-0",children:[p&&e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Search",size:"sm"}),"aria-label":"Search","aria-expanded":!1,onClick:I}),e.jsxs(f.Box,{onTransitionEnd:H,style:{position:"relative",width:y?Gn:0,overflow:"hidden",transition:"width 220ms ease"},children:[e.jsx(ar.Input,{ref:F,size:"sm",fullWidth:!0,value:E,placeholder:n,leftIcon:e.jsx(M.Icon,{name:"Search",width:16,height:16}),onChange:W=>w(W.target.value),onKeyDown:k,onBlur:B,tabIndex:y?0:-1}),y&&!E&&e.jsx(f.Box,{align:"center",justify:"center",borderColor:"border-subtle",borderWidth:"border",borderStyle:"border-solid",borderRadius:"rounded-xs",paddingInline:"spacing-1",customBackgroundColor:"var(--sa-background-surface-hover, #f1f2f4)",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",minWidth:18,height:18,display:"inline-flex"},children:e.jsx(D.Text,{fontSize:"xs",color:"subtle",children:l})})]})]})},tl=({columns:r,allVisible:t,onToggle:o,onReorder:n,onSetAllHidden:l})=>{const[s,c]=d.useState(null),[i,a]=d.useState(null),h=()=>{s!==null&&i!==null&&s!==i&&n(s,i),c(null),a(null)},y=(b,p)=>{const C=b+p;C<0||C>=r.length||n(b,C)};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:t?"outline":"secondary",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Grid",size:"sm"}),"aria-label":"Customize columns"})}),e.jsx(A.MenuLists,{children:e.jsx(A.MenuBody,{children:e.jsxs(f.Box,{padding:"sm",direction:"column",customWidth:"296px",customMaxHeight:"60vh",overflow:"overflow-hidden",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Customize Column Table"}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingBlock:"md",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"subtle",children:"Show in table"}),e.jsx(j.Button,{variant:"link",tone:"info",size:"xs",onClick:()=>l(t),children:t?"Hide All":"Show All"})]}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.map((b,p)=>{const C=!b.locked,E=i===p&&s!==null&&s!==p;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",paddingBlock:"xs",draggable:C,onDragStart:()=>C&&c(p),onDragOver:w=>{w.preventDefault(),a(p)},onDrop:h,onDragEnd:h,style:{minHeight:32,boxShadow:E?"inset 0 2px 0 0 var(--sa-background-brand, #04254f)":void 0},children:[e.jsx(f.Box,{direction:"column",as:"div",align:"center",justify:"center",role:"button",tabIndex:C?0:-1,"aria-label":`Reorder ${b.title}`,"aria-disabled":!C||void 0,color:"icon-subtlest",onKeyDown:w=>{C&&(w.key==="ArrowUp"?(w.preventDefault(),y(p,-1)):w.key==="ArrowDown"&&(w.preventDefault(),y(p,1)))},style:{display:"inline-flex",cursor:C?"grab":"default",opacity:C?1:.4},children:e.jsx(M.Icon,{name:"DragVertical",width:16,height:16})}),b.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:b.icon}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:b.title}),e.jsx(f.Box,{direction:"column",style:{marginLeft:"auto"},children:e.jsx(xr.Toggle,{size:"sm",checked:b.visible,disabled:b.locked,onChange:()=>o(b.key),"aria-label":`Toggle ${b.title} column`})})]},b.key)})})]})})})]})},ol=({views:r,onApply:t,onDelete:o,onSave:n})=>{const[l,s]=d.useState(""),c=()=>{const i=l.trim();i&&(n(i),s(""))};return e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:r.length>0?"secondary":"outline",tone:(r.length>0,"neutral"),size:"sm",iconLeft:e.jsx(M.Icon,{name:"Bookmark",size:"sm"}),"aria-label":"Saved views"})}),e.jsxs(A.MenuLists,{style:{width:"260px"},children:[e.jsx(A.MenuBody,{children:e.jsxs(f.Box,{direction:"column",padding:"xs",gap:"sm",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Saved Views"}),e.jsx(f.Box,{direction:"column",overflow:"overflow-y-auto",children:r.length===0?e.jsx(f.Box,{direction:"column",paddingBlock:"sm",children:e.jsx(D.Text,{fontSize:"sm",color:"subtlest",children:"No saved views yet"})}):r.map(i=>e.jsx(A.MenuItem,{startIcon:e.jsx(M.Icon,{name:"Bookmark"}),onClick:()=>t(i),endIcon:e.jsx(j.Button,{variant:"link",tone:"error",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Trash2"}),"aria-label":`Delete ${i.name}`,onClick:a=>{a.stopPropagation(),o(i.id)}}),children:i.name},i.id))})]})}),e.jsx(A.MenuFooter,{children:e.jsxs(f.Box,{direction:"row",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 0 0",minWidth:0},children:e.jsx(ar.Input,{size:"sm",fullWidth:!0,placeholder:"Save current view as…",value:l,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&c()}})}),e.jsx(j.Button,{variant:"primary",tone:"brand",size:"sm",disabled:!l.trim(),onClick:c,children:"Save"})]})})]})]})},Qn=({isOpen:r,onClose:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:i,getValue:a,setValue:h,clearValue:y,removeFilter:b})=>{const p=n.length;return e.jsx(Hr.Drawer,{position:"bottom",isShow:r,onHide:t,children:e.jsxs(f.Box,{direction:"column",customMaxHeight:"85vh",style:{minHeight:280},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",paddingInline:"md",paddingBlock:"sm",style:{borderBottom:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"semibold",color:"primary",children:"Filter"}),p>0&&e.jsxs(D.Text,{fontSize:"sm",color:"subtle",children:["(",p,")"]})]}),e.jsx(j.Button,{variant:"link",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"Cross"}),"aria-label":"Close filter",onClick:t})]}),e.jsxs(f.Box,{direction:"column",gap:"lg",padding:"md",overflow:"overflow-y-auto",style:{flex:"1 1 auto",minHeight:0},children:[p>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Filter aktif"}),e.jsx(f.Box,{direction:"row",display:"flex",wrap:"wrap",gap:"sm",align:"center",children:e.jsx(Ro,{activeKeys:n,configByKey:l,getValue:a,setValue:h,clearValue:y,removeFilter:b})})]}),o.length>0&&e.jsxs(f.Box,{direction:"column",gap:"sm",children:[e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Tambah filter"}),e.jsx(f.Box,{direction:"column",children:o.map(C=>{const E=n.includes(C.key),w=!!C.locked;return e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",paddingBlock:"sm",style:{opacity:w?.5:1,borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.08))"},children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{minWidth:0},children:[C.icon&&e.jsx(f.Box,{direction:"column",align:"center",color:"icon-subtle",style:{display:"inline-flex"},children:C.icon}),e.jsx(D.Text,{fontSize:"sm",color:"primary",truncate:!0,children:C.label})]}),e.jsx(xr.Toggle,{size:"sm",checked:E||w,disabled:w,onChange:()=>c(C.key),"aria-label":`Toggle ${C.label}`})]},C.key)})})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",gap:"sm",paddingInline:"md",paddingBlock:"sm",style:{borderTop:"1px solid var(--sa-border-subtle, rgba(11, 18, 14, 0.14))"},children:[e.jsx(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"md",fullWidth:!0,disabled:!s,onClick:i,children:"Reset"})}),e.jsx(f.Box,{direction:"column",style:{flex:"1 1 0"},children:e.jsx(j.Button,{variant:"primary",tone:"brand",size:"md",fullWidth:!0,onClick:t,children:"Selesai"})})]})]})})},Un=r=>`${r} Rows`,Jn=({perPageKey:r,pageKey:t,pageSizeOptions:o,defaultPerPage:n=10,showPageSize:l})=>{const{searchQueries:s,setSearchParams:c,searchParams:i}=Ne(),a=i.get(r),h=a?Number(a):n,y=b=>{c({...s,[r]:b,[t]:"1"})};return l?e.jsxs(A.Menu,{position:"bottom-right",children:[e.jsx(A.MenuButton,{children:e.jsx(j.Button,{variant:"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"}),"aria-label":"More options"})}),e.jsx(A.MenuLists,{children:e.jsxs(A.MenuBody,{style:{minWidth:200},children:[e.jsx(f.Box,{paddingInline:"sm",paddingBlock:"xs",children:e.jsx(D.Text,{fontSize:"xs",fontWeight:"medium",color:"subtlest",children:"Rows per page"})}),o.map(b=>e.jsx(A.MenuItem,{selected:b===h,endIcon:b===h?e.jsx(M.Icon,{name:"Check"}):void 0,onClick:()=>y(String(b)),children:Un(b)},b))]})})]}):null},Yn=r=>{var We;const{withPadding:t,configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,toggleFilter:c,removeFilter:i,getValue:a,setValue:h,clearValue:y,onReset:b,searchable:p,searchKey:C,filterKey:E,pageKey:w,searchPlaceholder:L,searchShortcut:F,searchCollapsible:I,pagination:B,perPageKey:k,pageSizeOptions:H,defaultPerPage:W,showPagination:S,showResultCount:z,showPageSize:O,hasColumns:Y,orderedColumns:X,allVisible:q,onToggleVisibility:Z,onReorder:K,onSetAllHidden:te,showSavedViews:_,savedViews:V,onApplyView:N,onDeleteView:se,onSaveView:ve,leadingActions:Ee}=r,[ue,Ce]=d.useState(!1),{searchQueries:xe,setSearchParams:we}=Ne(),Ae=(B==null?void 0:B.rangeStart)??(((B==null?void 0:B.currentPage)||0)>1?(((B==null?void 0:B.currentPage)||0)-1)*((B==null?void 0:B.perPage)||0)+1:1),Fe=(B==null?void 0:B.rangeEnd)??((B==null?void 0:B.totalCurrentPage)!==(B==null?void 0:B.perPage)?B==null?void 0:B.totalData:((B==null?void 0:B.currentPage)||1)*((B==null?void 0:B.totalCurrentPage)||0)),_e=Ze=>{we({...xe,[w]:String(Ze)})},$=z||S&&!!(B!=null&&B.totalPage),ge=()=>{b(),Ce(!1)};return e.jsxs(f.Box,{direction:"column",gap:"sm",fullWidth:!0,paddingTop:t?"sm":void 0,paddingBottom:t?"sm":void 0,paddingLeft:t?"md":void 0,paddingRight:t?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",wrap:"wrap",gap:"sm",fullWidth:!0,overflow:"overflow-auto",children:[p&&e.jsx(rl,{searchKey:C,filterKey:E,pageKey:w,placeholder:L,shortcut:F,collapsible:I}),e.jsx(j.Button,{variant:s?"secondary":"outline",tone:"neutral",size:"sm",iconLeft:e.jsx(M.Icon,{name:"FilterHorizontal"}),onClick:()=>Ce(!0),"aria-label":"Open filters",children:s?`Filter: ${n.length}`:null}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{marginLeft:"auto"},children:[Ee,_&&e.jsx(ol,{views:V,onApply:N,onDelete:se,onSave:ve}),Y&&e.jsx(tl,{columns:X,allVisible:q,onToggle:Z,onReorder:K,onSetAllHidden:te}),e.jsx(Jn,{perPageKey:k,pageKey:w,pageSizeOptions:H,defaultPerPage:W,showPageSize:O})]})]}),$&&e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",justify:"space-between",gap:"sm",fullWidth:!0,children:[z?e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",color:"primary",truncate:!0,children:`${Ae}-${Fe} of ${((We=B==null?void 0:B.totalData)==null?void 0:We.toLocaleString())||0}`}):e.jsx(f.Box,{direction:"column"}),S&&!!(B!=null&&B.totalPage)&&e.jsx(kr.Pagination,{size:"xs",variant:"neutral",siblingCount:0,currentPage:B!=null&&B.currentPage?Number(B.currentPage):1,totalPages:Number(B.totalPage),onPageChange:_e})]}),e.jsx(Qn,{isOpen:ue,onClose:()=>Ce(!1),configs:o,activeKeys:n,configByKey:l,hasActiveFilter:s,onToggle:c,onReset:ge,getValue:a,setValue:h,clearValue:y,removeFilter:i})]})},Xn=({withPadding:r=!1,filterConfigs:t=[],filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",pageSizeOptions:c=[25,50,100],defaultPerPage:i,showPagination:a=!0,showResultCount:h=!0,showPageSize:y=!0,searchable:b=!1,searchKey:p="q",searchPlaceholder:C="Search",searchShortcut:E="/",searchPosition:w="right",searchCollapsible:L=!0,pagination:F,columns:I=[],onColumnsChange:B,columnsState:k,scopeId:H,savedViews:W,persistLastState:S=!0,persistSearch:z=!0,storage:O=Et,onReset:Y,leadingActions:X})=>{const q=H??(W==null?void 0:W.scopeId),{activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,clearAll:Ee}=kt({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:p}),ue=xn({columns:I,scopeId:q,storage:O,onColumnsChange:B,value:k}),Ce=wn({scopeId:q,storage:O,snapshotKeys:[n,o,s],pageKey:l,getColumns:()=>ue.state,applyColumns:ue.applyState}),xe=Sn({scopeId:q,storage:O,snapshotKeys:[n,o,l],enabled:S,filterKey:o,searchKey:p,persistSearch:z}),we=Bn({scopeId:q,storage:O,perPageKey:s,pageSizeOptions:c,enabled:S});En({enabled:S&&!!q,snapshotKeys:[n,o,l],perPageKey:s,readSnapshot:xe.read,readPerPage:we.read});const Ae=i??c[0]??25,Fe=!!(W!=null&&W.enabled)&&Ce.enabled,_e=()=>{Ee(),xe.clear(),Y==null||Y()},$=De.useMediaQuery("md"),ge=b?e.jsx(rl,{searchKey:p,filterKey:o,pageKey:l,placeholder:C,shortcut:E,collapsible:L}):null;return $?e.jsxs(f.Box,{display:"flex",direction:"row",align:"center",gap:"sm",wrap:"wrap",fullWidth:!0,paddingTop:r?"sm":void 0,paddingBottom:r?"sm":void 0,paddingLeft:r?"md":void 0,paddingRight:r?"md":void 0,role:"toolbar","aria-label":"Filter bar",children:[e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(mn,{configs:t,activeKeys:Z,onToggle:_,hasActiveFilter:te,onReset:_e}),w==="left"&&ge,e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",overflow:"overflow-x-auto",style:{flex:"1 1 0",minWidth:0},children:[e.jsx(Ro,{activeKeys:Z,configByKey:K,getValue:N,setValue:se,clearValue:ve,removeFilter:V}),te&&e.jsx(j.Button,{variant:"link",tone:"brand",size:"sm",onClick:_e,children:"Reset"})]})]}),e.jsxs(f.Box,{direction:"row",display:"flex",align:"center",gap:"sm",children:[X,e.jsx(qn,{pagination:F,pageKey:l,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y}),w==="right"&&ge,Fe&&e.jsx(ol,{views:Ce.views,onApply:Ce.applyView,onDelete:Ce.deleteView,onSave:Ce.saveView}),I.length>0&&e.jsx(tl,{columns:ue.orderedColumns,allVisible:ue.allVisible,onToggle:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden})]})]}):e.jsx(Yn,{withPadding:r,configs:t,activeKeys:Z,configByKey:K,hasActiveFilter:te,toggleFilter:_,removeFilter:V,getValue:N,setValue:se,clearValue:ve,onReset:_e,searchable:b,searchKey:p,filterKey:o,pageKey:l,searchPlaceholder:C,searchShortcut:E,searchCollapsible:L,pagination:F,perPageKey:s,pageSizeOptions:c,defaultPerPage:Ae,showPagination:a,showResultCount:h,showPageSize:y,hasColumns:I.length>0,orderedColumns:ue.orderedColumns,allVisible:ue.allVisible,onToggleVisibility:ue.toggleVisibility,onReorder:ue.reorder,onSetAllHidden:ue.setAllHidden,showSavedViews:Fe,savedViews:Ce.views,onApplyView:Ce.applyView,onDeleteView:Ce.deleteView,onSaveView:Ce.saveView,leadingActions:X})},$n=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},Kn=r=>{if(!Array.isArray(r)||r.length===0)return;const t=r.map(o=>(o==null?void 0:o.value)!=null?String(o.value):null).filter(o=>o!=null);return t.length?t:void 0},Rn=(r,t)=>{switch(r.type){case"dropdown":case"radio":return $n(t);case"dropdown-multiple":case"checkbox-multiple":return Kn(t);case"date":return t instanceof Date?t.toISOString():void 0;case"date-compact":return t;default:return}},ll=(r,t)=>{if(r==null||r==="")return t;const o=Number(r);return Number.isFinite(o)&&o>0?o:t},es=r=>{const{filterConfigs:t,filterKey:o="filter",activeFilterKey:n="filters",pageKey:l="page",perPageKey:s="perPage",searchKey:c="q",defaultPage:i=1,defaultPerPage:a=10,paramKeys:h,serialize:y}=r,{activeKeys:b,configByKey:p,hasActiveFilter:C,getValue:E}=kt({configs:t,filterKey:o,activeFilterKey:n,pageKey:l,searchKey:c}),{searchParams:w}=Ne(),L=w.toString();return d.useMemo(()=>{const I={},B={},k=ll(w.get(l),i),H=ll(w.get(s),a);I[(h==null?void 0:h.page)??"page"]=k,I[(h==null?void 0:h.perPage)??"perPage"]=H;const W=qr(c,w,o)||"";W&&(I[(h==null?void 0:h.search)??"search"]=W);let S=!1;for(const z of b){const O=p[z];if(!O)continue;const Y=E(O);B[z]=Y;const X=y==null?void 0:y[z],q=X?X(Y):Rn(O,Y);if(q==null||Array.isArray(q)&&q.length===0)continue;const Z=(h==null?void 0:h[z])??z;I[Z]=q,S=!0}return{params:I,raw:B,hasActiveFilter:C||!!W||S}},[L,b.join("|"),o,n,l,s,c,i,a,h,y,p])},rs=["dropdown","dropdown-multiple","checkbox-multiple","radio"],ts=({filterConfigs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l})=>{const{configByKey:s,getValue:c,setValue:i,removeFilter:a,clearAll:h,hasActiveFilter:y}=kt({configs:r,filterKey:t,activeFilterKey:o,pageKey:n,searchKey:l}),b=(F,I)=>{var k;const B=F.options;return((k=B==null?void 0:B.find(H=>H.value===I))==null?void 0:k.label)??I},p=d.useCallback(F=>{const I=s[F];if(!I)return[];const B=c(I);return Array.isArray(B)?B.map(k=>String(k.value)):[]},[s,c]),C=d.useCallback((F,I)=>{const B=s[F];if(!B||!rs.includes(B.type))return;const k=Array.isArray(I)?I:[I];if(k.length===0){a(F);return}i(B,k.map(H=>({label:b(B,H),value:H})))},[s,i,a]),E=d.useCallback((F,I)=>{const B=p(F);C(F,B.includes(I)?B.filter(k=>k!==I):[...B,I])},[p,C]),w=d.useCallback((F,I)=>p(F).includes(I),[p]),L=d.useCallback(F=>a(F),[a]);return{set:C,toggle:E,clear:L,clearAll:h,isActive:w,values:p,hasActiveFilter:y}},os=(r,t)=>{if(!r)return{};const{fromKey:o,toKey:n,opKey:l}=t,s={};switch(r.op){case"is":case"is-before":case"is-after":case"is-on-or-before":case"is-on-or-after":return r.date&&(s[o]=new Date(r.date).toISOString()),l&&(s[l]=r.op),s;case"is-between":return r.from&&(s[o]=new Date(r.from).toISOString()),r.to&&(s[n]=new Date(r.to).toISOString()),s;case"is-relative-to-today":{if(!r.relative)return s;const{from:c,to:i}=Qo(r.relative);return s[o]=c.toISOString(),s[n]=i.toISOString(),s}case"is-empty":case"is-not-empty":return l&&(s[l]=r.op==="is-empty"?"empty":"not-empty"),s;default:return s}},nl=({children:r,borderRadius:t,height:o})=>{const n=d.useRef(null),[l,s]=d.useState("100vh");return d.useEffect(()=>{if(o)return;const c=()=>{if(n.current){const i=n.current.getBoundingClientRect().top;s(`calc(100vh - ${i}px)`)}};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[o]),e.jsx(f.Box,{ref:n,fullWidth:!0,borderStyle:"border-solid",borderWidth:"border",borderColor:"border-base",borderRadius:t||"rounded-xs",style:{height:o??l,display:"flex",flexDirection:"column"},children:r})},sl=({action:r,rightContent:t,leftContent:o,headerSlot:n,advanceFilter:l,showFilter:s=!0})=>{const c=De.useMediaQuery("md"),i=s?e.jsx(qo,{...l}):null,a=()=>r?d.isValidElement(r)?r:e.jsx(f.Box,{style:{display:"flex",flexDirection:c?"row":"column",gap:"8px",width:c?"auto":"100%",textWrap:"nowrap"},children:r.map(({title:h,icon:y,buttonProps:b,onClick:p},C)=>!h&&!y?null:e.jsx(j.Button,{fullWidth:!c,iconLeft:y?e.jsx(M.Icon,{name:y}):void 0,onClick:p,...b,children:h},`action-${C}`))}):null;return e.jsx(f.Box,{style:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",paddingLeft:"8px",paddingRight:"8px",paddingTop:"8px",paddingBottom:"8px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0,position:"relative",zIndex:10,flexDirection:c?"row":"column-reverse",gap:"16px"},children:n?n({filter:i}):e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flex:1,minWidth:0},children:[i,o]}),e.jsxs(f.Box,{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center",flexShrink:0},children:[t,a()]})]})})},ls=({totalData:r,withMarginBottom:t=!0,withMarginTop:o=!0})=>e.jsxs(f.Box,{style:{display:"flex",gap:"4px",flexDirection:"row",alignItems:"center",marginBottom:t?"16px":void 0,marginTop:o?"16px":void 0},children:[e.jsxs(Ke.Body1,{props:{color:"gray-500"},children:["Total data:"," "]}),e.jsx(Ke.Body1,{children:r||0})]}),cl=({pagination:r,pageKey:t="page",perPageKey:o="perPage",defaultPerPage:n=10,showPagination:l=!0,totalData:s})=>{const{searchQueries:c,setSearchParams:i,searchParams:a}=Ne(),h=a.get(o),y=E=>{i({...c,[t]:String(E)})},b=E=>{i({...c,[o]:E,[t]:"1"})},p=(r==null?void 0:r.rangeStart)??(((r==null?void 0:r.currentPage)||0)>1?(((r==null?void 0:r.currentPage)||0)-1)*((r==null?void 0:r.perPage)||0)+1:1),C=(r==null?void 0:r.rangeEnd)??((r==null?void 0:r.totalCurrentPage)!==(r==null?void 0:r.perPage)?r==null?void 0:r.totalData:((r==null?void 0:r.currentPage)||1)*((r==null?void 0:r.totalCurrentPage)||0));return e.jsx(f.Box,{style:{display:"flex",width:"100%",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",flexShrink:0},children:l?e.jsxs(e.Fragment,{children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",gap:"8px",alignItems:"center",textWrap:"nowrap"},children:[e.jsx(D.Text,{children:"Rows Per Page: "}),e.jsx(br.Dropdown,{dropdownLists:[{label:"5",value:"5"},{label:"10",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100",value:"100"}],onChange:E=>{b(E[0].value)},value:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}],defaultValue:h?[{label:`${h} per row`,value:h}]:[{label:`${n} per row`,value:`${n}`}]}),e.jsx(D.Text,{children:`${p}-${C} of ${(r==null?void 0:r.totalData)||0}`})]}),e.jsx(kr.Pagination,{currentPage:r!=null&&r.currentPage?Number(r==null?void 0:r.currentPage):1,totalPages:r!=null&&r.totalPage?Number(r==null?void 0:r.totalPage):1,onPageChange:y})]}):e.jsx(ls,{totalData:s,withMarginBottom:!1,withMarginTop:!1})})},il=({filter:r,columnTitle:t})=>{const[o,n]=d.useState(!1),l=d.useRef(null),s=d.useRef(null),c=d.useRef(null),[i,a]=d.useState(""),[h,y]=d.useState({top:0,left:0}),b=r.selectedValues,p=d.useMemo(()=>i?r.options.filter(w=>w.label.toLowerCase().includes(i.toLowerCase())):r.options,[r.options,i]);d.useEffect(()=>{if(o&&s.current){const w=s.current.getBoundingClientRect(),L=280,F={top:w.bottom+8};r.position==="left"||w.left+L>window.innerWidth?F.right=window.innerWidth-w.right:F.left=w.left,y(F)}},[o,r.position]),d.useEffect(()=>{o&&c.current?setTimeout(()=>{var w;return(w=c.current)==null?void 0:w.focus()},50):a("")},[o]),d.useEffect(()=>{const w=L=>{l.current&&!l.current.contains(L.target)&&s.current&&!s.current.contains(L.target)&&n(!1)};return o&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[o]);const C=w=>{const L=b.includes(w)?b.filter(F=>F!==w):[...b,w];r.onFilterChange(L)},E=()=>r.onFilterChange([]);return e.jsxs(f.Box,{direction:"column",style:{position:"relative"},children:[e.jsx(f.Box,{ref:s,style:{display:"flex",flexDirection:"row",alignItems:"center",cursor:"pointer"},onClick:w=>{var L;w.stopPropagation(),o||(L=r.onOpen)==null||L.call(r),n(F=>!F)},children:e.jsx(M.Icon,{name:o?"ChevronUp":"ChevronDown",size:"sm",style:{color:b.length>0?"var(--sa-color-brand-500, #1a4fa0)":"var(--sa-text-subtle, #8c8f97)"}})}),o&&e.jsxs(f.Box,{ref:l,style:{position:"fixed",top:`${h.top}px`,...h.left!==void 0?{left:`${h.left}px`}:{right:`${h.right}px`},backgroundColor:"white",borderRadius:"4px",minWidth:"280px",maxHeight:"400px",display:"flex",flexDirection:"column",zIndex:9999,animation:"fadeInDropdown 0.15s ease-out",border:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",borderBottom:"1px solid var(--sa-border-subtle, #0b120e24)"},children:[e.jsxs(D.Text,{fontSize:"sm",fontWeight:"semibold",color:"gray-700",children:["Filter ",t]}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{cursor:"pointer"},children:e.jsx(D.Text,{fontSize:"xs",color:"primary",fontWeight:"semibold",onClick:w=>{w.stopPropagation(),E()},children:"CLEAR"})})]}),!r.hideSearch&&e.jsx(f.Box,{direction:"column",style:{paddingLeft:"16px",paddingRight:"16px",paddingTop:"8px",paddingBottom:"8px"},children:e.jsx(ar.Input,{ref:c,placeholder:`Search ${t.toLowerCase()}...`,leftIcon:e.jsx(M.Icon,{name:"Search",size:"sm"}),value:i,onChange:w=>a(w.target.value),style:{fontSize:"14px"}})}),e.jsx(f.Box,{direction:"column",className:"ts-filter-dropdown-options",style:{overflowY:"auto",maxHeight:"250px",paddingLeft:"8px",paddingRight:"8px"},children:r.isLoadingOptions?e.jsxs(f.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Loading",size:"lg",style:{color:"var(--sa-background-brand, #04254f)",animation:"spin 1s linear infinite"}}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"Loading options..."})]}):p.length>0?e.jsx(f.Box,{direction:"column",style:{gap:"2px",paddingTop:"4px",paddingBottom:"4px"},children:p.map(w=>e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",paddingTop:"8px",paddingBottom:"8px",paddingLeft:"8px",paddingRight:"8px",cursor:"pointer",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent"},onClick:L=>{L.stopPropagation(),C(w.value)},onMouseEnter:L=>{b.includes(w.value)||(L.currentTarget.style.backgroundColor="var(--sa-background-primary, #ffffff)"),L.currentTarget.style.transform="translateX(2px)"},onMouseLeave:L=>{L.currentTarget.style.backgroundColor=b.includes(w.value)?"var(--sa-color-brand-50, #e6edf6)":"transparent",L.currentTarget.style.transform="translateX(0)"},children:[e.jsx(tr.Checkbox,{checked:b.includes(w.value),onChange:()=>{}}),e.jsx(D.Text,{fontSize:"sm",fontWeight:b.includes(w.value)?"medium":"normal",color:b.includes(w.value)?"primary":"gray-700",children:w.label})]},w.value))}):e.jsxs(f.Box,{style:{paddingTop:"40px",paddingBottom:"40px",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[e.jsx(M.Icon,{name:"Search",size:"lg",style:{color:"var(--sa-text-subtle, #8c8f97)"}}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",style:{textAlign:"center",marginTop:"8px"},children:"No results found"})]})}),b.length>0&&e.jsx(f.Box,{direction:"column",style:{paddingTop:"8px",paddingBottom:"8px",paddingLeft:"16px",paddingRight:"16px",borderTop:"1px solid var(--sa-border-subtle, #0b120e24)",backgroundColor:"var(--sa-color-brand-50, #e6edf6)",marginTop:"auto"},children:e.jsxs(f.Box,{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsx(f.Box,{direction:"column",style:{backgroundColor:"var(--sa-background-brand, #04254f)",borderRadius:"12px",padding:"2px 8px",fontSize:"11px",fontWeight:600,color:"white"},children:b.length}),e.jsxs(D.Text,{fontSize:"xs",color:"primary",fontWeight:"medium",children:["item",b.length>1?"s":""," selected"]})]})})]})]})},ns=({direction:r})=>{const t="var(--sa-text-primary, #292a2e)",o="var(--sa-text-subtle, #8c8f97)",n=r==="asc"?t:o,l=r==="desc"?t:o,s=r==="asc"?1:.45,c=r==="desc"?1:.45;return e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:0},"aria-hidden":!0,children:[e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:n,opacity:s,marginBottom:1},children:e.jsx("path",{d:"M4 0 L8 5 L0 5 Z",fill:"currentColor"})}),e.jsx("svg",{width:"8",height:"5",viewBox:"0 0 8 5",style:{color:l,opacity:c},children:e.jsx("path",{d:"M0 0 L8 0 L4 5 Z",fill:"currentColor"})})]})},ss=({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)",al="var(--sa-background-primary-inverse, #f8f8f8)",dl=({columns:r,records:t,handleDetail:o,handleUpdate:n,handleDelete:l,isLoading:s,visibleHandleDelete:c,visibleHandleUpdate:i,visibleHandleDetail:a,showHeadBorder:h=!1,scrollParentRef:y,frozenCount:b=0,onFrozenCountChange:p,customActions:C,actionsOrder:E=["detail","update","delete","custom"],customEmptyState:w,enableColumnResize:L=!1,defaultColumnWidths:F,onColumnWidthsChange:I,defaultMinColumnWidth:B=60,sort:k,defaultSort:H,onSortChange:W,showActionDivider:S=!1})=>{const z=k!==void 0,[O,Y]=d.useState(H??null),X=z?k??null:O,q=P=>{if(P.sortKey)return P.sortKey;if(typeof P.accessor=="string")return P.accessor},Z=P=>{const R=q(P);if(!R)return;let J;!X||X.key!==R?J={key:R,direction:"asc"}:X.direction==="asc"?J={key:R,direction:"desc"}:J=null,z||Y(J),W==null||W(J)},te=[o,n,l].filter(P=>P!==void 0).length,_=!!C,V=!!o||!!n||!!l||_,N="var(--sa-border-subtle, #0b120e24)",se=`1px solid ${N}`,ve=`inset 1px 0 0 ${N}`,Ee=`inset -1px 0 0 ${N}`,ue=te===3?_?"178px":"140px":te===2?_?"140px":"102px":te===1?_?"112px":"74px":_?"74px":"",Ce=(P,R)=>{if(!R)return P;if(typeof R=="function")return R(P);if(typeof R=="string")return P[R]},[xe,we]=d.useState(!1);d.useEffect(()=>{if(!(y!=null&&y.current))return;const P=y.current;we(P.scrollHeight>P.clientHeight)},[t,y]);const Ae=d.useRef(null),[Fe,_e]=d.useState([]),[$,ge]=d.useState(()=>F??{}),We=d.useRef(null);d.useLayoutEffect(()=>{if(!b||!Ae.current){_e([]);return}const P=Array.from(Ae.current.querySelectorAll("thead tr th")),R=[];let J=0;P.forEach((he,ce)=>{R[ce]=J,ce<b&&(J+=he.offsetWidth)}),_e(R)},[b,r,t,$]);const Ze=P=>{p&&p(P<b?P:P+1)},de=(P,R)=>{const J=$[P];if(J!==void 0){const he=`${J}px`;return{width:he,minWidth:he,maxWidth:he}}return R?{width:R}:{}},Ge=P=>L&&(P.resizable??!0),lr=(P,R)=>{P.preventDefault(),P.stopPropagation();const J=P.currentTarget.closest("th");if(!J)return;const he=Math.round(J.getBoundingClientRect().width);We.current={colIndex:R,startX:P.clientX,startWidth:he};const ce=document.body.style.userSelect,Me=document.body.style.cursor;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ze=Qe=>{var Ue;const Le=We.current;if(!Le)return;const Je=((Ue=r[Le.colIndex])==null?void 0:Ue.minWidth)??B,Be=Math.max(Je,Le.startWidth+(Qe.clientX-Le.startX));ge(nr=>nr[Le.colIndex]===Be?nr:{...nr,[Le.colIndex]:Be})},er=()=>{document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",er),document.body.style.userSelect=ce,document.body.style.cursor=Me,We.current=null,I&&ge(Qe=>(I(Qe),Qe))};document.addEventListener("mousemove",ze),document.addEventListener("mouseup",er)};return e.jsx("div",{ref:Ae,children:e.jsxs(U.Table,{fullWidth:!0,children:[e.jsx(U.Thead,{style:{height:"40px",whiteSpace:"nowrap"},children:e.jsxs(U.Tr,{children:[r.map((P,R)=>{var gr,dr;const J=b>0&&R<b,he=Fe[R]??0,ce=Ge(P),ze=R===r.length-1&&V&&S,er=q(P),Qe=!!P.sortable&&!!er,Le=Qe&&(X==null?void 0:X.key)===er?X.direction:null,Je=P.title||((gr=P.accessor)==null?void 0:gr.toString())||"",Be=(dr=P.headerTooltip)!=null&&dr.showIcon?e.jsx(M.Icon,{name:"InfoCircle",size:"xs",style:{flexShrink:0,color:"var(--sa-icon-subtle, #8c8f97)",opacity:.75}}):null,Ue=e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Je}),nr=Qe?e.jsxs("button",{type:"button",onClick:()=>Z(P),title:Le==="asc"?"Sorted ascending — click to sort descending":Le==="desc"?"Sorted descending — click to clear":"Click to sort ascending",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4,background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",cursor:"pointer",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left"},children:[Ue,Be,e.jsx(ns,{direction:Le})]}):e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:4},children:[Ue,Be]});return e.jsxs(U.Th,{style:{position:"sticky",top:0,left:J?he:void 0,zIndex:J?4:2,paddingLeft:R===0?"12px":"",borderRight:h&&!ze&&!J?se:void 0,borderBottom:h?se:void 0,boxShadow:h&&J?Ee:void 0,backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",textAlign:P.textAlign==="text-right"?"right":P.textAlign==="text-center"?"center":"left",...de(R,P.width)},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:"space-between",minWidth:0},children:[P.headerTooltip?e.jsx(me.Tooltip,{label:P.headerTooltip.content,position:"bottom",children:nr}):nr,P.filter&&e.jsx(il,{filter:P.filter,columnTitle:P.title}),p&&e.jsx("button",{onClick:()=>Ze(R),title:J?"Unfreeze column":"Freeze column",style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",flexShrink:0,color:J?"var(--sa-background-brand, #04254f)":"var(--sa-text-subtle, #8c8f97)",opacity:J?1:.45,transition:"opacity 0.15s"},children:e.jsx(ss,{frozen:J})})]}),ce&&e.jsx("div",{onMouseDown:hr=>lr(hr,R),onClick:hr=>hr.stopPropagation(),role:"separator","aria-orientation":"vertical",title:"Drag to resize",style:{position:"absolute",top:0,right:-3,width:6,height:"100%",cursor:"col-resize",userSelect:"none",zIndex:5,touchAction:"none"}})]},`table-head-${R}`)}),V?e.jsx(U.Th,{style:{backgroundColor:"var(--sa-background-primary-inverse, #f8f8f8)",position:"sticky",top:0,right:0,zIndex:3,borderBottom:h?se:void 0,boxShadow:h&&S?ve:void 0}}):null]})}),e.jsx(U.Tbody,{children:s?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:e.jsxs(f.Box,{direction:"column",style:{gap:"16px"},children:[e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"}),e.jsx($e.Skeleton,{variant:"list"})]})})}):!(t!=null&&t.length)&&w?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:r.length+1,children:w})}):t==null?void 0:t.map((P,R)=>e.jsxs(U.Tr,{style:{transition:"background-color 0.3s ease",padding:0,borderBottom:R===t.length-1&&xe?void 0:"1px solid var(--sa-border-subtle, #0b120e24)"},onMouseEnter:J=>{const he=J.currentTarget;he.style.backgroundColor=al,Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=al)})},onMouseLeave:J=>{const he=J.currentTarget;he.style.backgroundColor="",Array.from(he.querySelectorAll("td")).forEach(ce=>{ce.style.position==="sticky"&&(ce.style.backgroundColor=Lt)})},children:[r.map((J,he)=>{const ce=J.render?J.render(P,R,t):Ce(P,J.accessor),Me=b>0&&he<b,ze=Fe[he]??0,er=$[he]!==void 0,Qe=Me&&he===b-1;return e.jsx(U.Td,{style:{position:Me?"sticky":void 0,left:Me?ze:void 0,zIndex:Me?1:void 0,backgroundColor:Me?Lt:void 0,transition:Me?"background-color 0.3s ease":void 0,paddingLeft:he===0?"12px":"",whiteSpace:"nowrap",overflow:er?"hidden":void 0,borderLeft:J.showBorderLeft?se:void 0,borderRight:J.showBorderRight?se:void 0,boxShadow:Qe?Ee:void 0,textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left",...de(he,J.width)},children:typeof ce=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:J.textAlign==="text-right"?"right":J.textAlign==="text-center"?"center":"left"},children:ce}):ce},`row-${R}-col-${he}`)}),V?e.jsx(U.Td,{style:{width:ue,position:"sticky",right:0,zIndex:1,backgroundColor:Lt,boxShadow:S?ve:void 0,transition:"background-color 0.3s ease"},children:e.jsx(ie.Flex,{direction:"row",align:"center",justify:"center",gap:"sm",children:E.map(J=>{const he=R===t.length-1?"top":"bottom";return J==="detail"&&o&&(a==null?void 0:a(P))!==!1?e.jsx(me.Tooltip,{label:"Detail",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>o(P.id,P),iconLeft:e.jsx(M.Icon,{name:"DocumentClean",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"detail"):J==="update"&&n&&(i==null?void 0:i(P))!==!1?e.jsx(me.Tooltip,{label:"Update",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>n(P),iconLeft:e.jsx(M.Icon,{name:"Edit1",size:"sm",style:{color:"var(--sa-text-subtle, #8c8f97)"}})})},"update"):J==="delete"&&l&&(c==null?void 0:c(P))!==!1?e.jsx(me.Tooltip,{label:"Delete",position:he,children:e.jsx(j.Button,{size:"xs",variant:"outline",tone:"neutral",onClick:()=>l(P.id,P),iconLeft:e.jsx(M.Icon,{name:"Trash1",size:"sm",style:{color:"var(--sa-color-error-600, #c9184a)"}})})},"delete"):J==="custom"?e.jsx(d.Fragment,{children:C==null?void 0:C(P)},"custom"):null})})}):null]},`${P}${R}`))})]})})};let hl=!1;const cs=({wrapperProps:r,dataTableProps:t,headerProps:o,footerProps:n})=>{var b;process.env.NODE_ENV!=="production"&&!hl&&(hl=!0,console.warn("[@starasia/admin] `TableSection` deprecated — pakai `<FilterBar>` + `<TableLayout>`. Lihat skill `starasia-list-page-pattern`. Akan dihapus di salah satu major berikutnya."));const l=d.useRef(null),[s,c]=d.useState((t==null?void 0:t.defaultFrozenCount)??0),i=(o==null?void 0:o.show)??!0,a=d.useRef(null),h=(b=t==null?void 0:t.pagination)==null?void 0:b.totalData;typeof h=="number"&&(a.current=h);const y=(n==null?void 0:n.showFooter)??(h===void 0?a.current!==0:h!==0);return e.jsxs(nl,{...r,children:[i&&e.jsx(sl,{...o}),e.jsx(f.Box,{direction:"column",ref:l,style:{flex:1,overflowY:"auto",overflowX:"auto"},children:t?e.jsx(dl,{...t,scrollParentRef:l,frozenCount:t!=null&&t.enableFreezeColumns?s:0,onFrozenCountChange:t!=null&&t.enableFreezeColumns?c:void 0}):null}),y&&e.jsx(cl,{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 is(r){return d.memo(r)}const as=is(cs),fl=200,Ot="1px solid var(--sa-border-subtle, #0b120e24)",ds=({sortDir:r,frozen:t})=>r==="asc"?e.jsx(M.Icon,{name:"ChevronSmallUp"}):r==="desc"?e.jsx(M.Icon,{name:"ChevronSmallDown"}):t?e.jsx(M.Icon,{name:"LockOn",size:"xs"}):e.jsx(M.Icon,{name:"Filter",size:"xs"}),Ur=({icon:r,label:t,active:o,danger:n,onClick:l})=>{const s=n?"var(--sa-text-error, #a4133c)":"var(--sa-text-primary, #292a2e)";return e.jsxs("button",{type:"button",onClick:l,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:"8px 12px",background:o?"var(--sa-background-brand-subtlest, #e6edf6)":"none",border:"none",cursor:"pointer",font:"inherit",color:s,textAlign:"left"},onMouseEnter:c=>{o||(c.currentTarget.style.background="var(--sa-background-primary-inverse, #f8f8f8)")},onMouseLeave:c=>{c.currentTarget.style.background=o?"var(--sa-background-brand-subtlest, #e6edf6)":"none"},children:[e.jsx(M.Icon,{name:r,size:"sm",style:{color:s,flexShrink:0}}),e.jsx(D.Text,{as:"span",style:{color:s},children:t})]})},ul=({active:r,canSort:t,canHide:o,sortDir:n,frozen:l,onSort:s,onClearSort:c,onToggleFreeze:i,onHide:a})=>{const[h,y]=d.useState(!1),b=d.useRef(null),p=d.useRef(null),[C,E]=d.useState({top:0,left:0});d.useEffect(()=>{if(h&&b.current){const L=b.current.getBoundingClientRect(),F=L.left+fl>window.innerWidth;E({top:L.bottom+6,...F?{right:window.innerWidth-L.right}:{left:L.left}})}},[h]),d.useEffect(()=>{if(!h)return;const L=F=>{p.current&&!p.current.contains(F.target)&&b.current&&!b.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[h]);const w=L=>{L(),y(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,type:"button",className:"sa-tl-menu-trigger","data-active":r||h?"true":"false",onClick:L=>{L.stopPropagation(),y(F=>!F)},title:"Column options",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:"var(--sa-radii-sm, 6px)",border:Ot,background:"var(--sa-background-primary, #ffffff)",cursor:"pointer",color:"var(--sa-text-subtle, #8c8f97)",flexShrink:0},children:e.jsx(ds,{sortDir:n,frozen:l})}),h&&e.jsxs(f.Box,{ref:p,onClick:L=>L.stopPropagation(),style:{position:"fixed",top:`${C.top}px`,...C.left!==void 0?{left:`${C.left}px`}:{right:`${C.right}px`},minWidth:fl,backgroundColor:"var(--sa-background-primary, #ffffff)",border:Ot,borderRadius:"var(--sa-radii-sm, 6px)",boxShadow:"var(--sa-shadow-xl, 0 20px 25px -5px #0000001a, 0 8px 10px -6px #0000001a)",zIndex:9999,padding:"4px",display:"flex",flexDirection:"column"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx(Ur,{icon:"ChevronUp",label:"Ascending",active:n==="asc",onClick:()=>w(()=>n==="asc"?c():s("asc"))}),e.jsx(Ur,{icon:"ChevronDown",label:"Descending",active:n==="desc",onClick:()=>w(()=>n==="desc"?c():s("desc"))}),e.jsx("div",{style:{borderTop:Ot,margin:"4px 0"}})]}),e.jsx(Ur,{icon:"Pin1",label:l?"Unfreeze":"Freeze",active:l,onClick:()=>w(i)}),o&&e.jsx(Ur,{icon:"EyeClosed",label:"Hide column",danger:!0,onClick:()=>w(a)})]})]})},Mr="1px solid var(--sa-border-subtle, #0b120e24)",hs="var(--sa-text-subtle, #8c8f97)",Dr="var(--sa-background-neutral, #f0f1f2)",gl="2px 0 4px -2px var(--sa-border-subtle, #0b120e24)",Ir=40,At="var(--sa-background-brand-subtlest)",Jr={display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},yl="sa-table-layout-styles",fs=()=>{if(typeof document>"u"||document.getElementById(yl))return;const r=document.createElement("style");r.id=yl,r.textContent=`
|
|
2
2
|
.sa-table-layout tbody td {
|
|
3
3
|
transition: background-color 0.15s ease;
|
|
4
4
|
background-color: var(--sa-tl-bg, transparent);
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
.sa-table-layout tfoot.sa-tl-sticky-foot > tr:first-child > th {
|
|
55
55
|
box-shadow: 0 -2px 4px -2px var(--sa-border-subtle, #0b120e24);
|
|
56
56
|
}
|
|
57
|
-
`,document.head.appendChild(r)},Tr=r=>r==="right"?"right":r==="center"?"center":"left",us=/^(#|rgb|hsl|var\()/,Yr=r=>r?us.test(r)?r:`var(--sa-background-${r})`:void 0,gs=(r,t)=>{if(t)return r[t]},ys=(r,t)=>r==null&&t==null?0:r==null?-1:t==null?1:typeof r=="number"&&typeof t=="number"?r-t:String(r).localeCompare(String(t)),ps=({columns:r,data:t,getRowKey:o,rowBg:n,size:l="md",resizable:s=!1,layout:c="auto",widthStorageKey:i,columnState:a,onColumnStateChange:h,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:C,height:E,mobileLayout:w="cards",mobileBreakpoint:L="md",groupSeparator:F,summary:I,footer:B,stickyFooter:k=!1,emptyState:H,loading:W=!1,loadingRows:S=8,rowActions:z,selectable:O=!1,selectedKeys:Y,defaultSelectedKeys:X,onSelectionChange:q,isRowSelectable:Z})=>{fs();const te=!De.useMediaQuery(L)&&w!=="scroll",_=!!(z!=null&&z.length),[V,N]=d.useState(null);d.useEffect(()=>{if(!V)return;const v=()=>N(null),x=setTimeout(()=>document.addEventListener("click",v),0);return()=>{clearTimeout(x),document.removeEventListener("click",v)}},[V]);const[se,ve]=d.useState(()=>new Set),Ee=a!==void 0,[ue,Ce]=d.useState({}),xe=a??ue,we=v=>{h==null||h(v),Ee||Ce(v)},Ae=b!==void 0,[Fe,_e]=d.useState(p??null),$=Ae?b??null:Fe,ge=!C,We=v=>{C==null||C(v),Ae||_e(v)},{headerGroups:Ze,leafColumns:de,hasGroups:Ge}=d.useMemo(()=>{var ae;const v=new Set(xe.hidden??[]),x=(le,pe)=>le.key??(typeof le.accessor=="string"?le.accessor:`col-${pe}`),T=r.map((le,pe)=>{var Xe;if((Xe=le.children)!=null&&Xe.length){const Ar=le.children.map((rr,Wr)=>({col:rr,key:x(rr,`${pe}-${Wr}`)})).filter(rr=>!v.has(rr.key));return{col:le,key:le.key??`group-${pe}`,isGroup:!0,leaves:Ar}}const be={col:le,key:x(le,`${pe}`)};return{col:le,key:be.key,isGroup:!1,leaves:v.has(be.key)?[]:[be]}}).filter(le=>le.leaves.length>0),Q=T.some(le=>le.isGroup);let oe=T.flatMap(le=>le.leaves);if(!Q&&((ae=xe.order)!=null&&ae.length)){const le=new Map(xe.order.map((pe,be)=>[pe,be]));oe=[...oe].sort((pe,be)=>(le.get(pe.key)??1/0)-(le.get(be.key)??1/0))}return{headerGroups:T,leafColumns:oe,hasGroups:Q}},[r,xe]),lr=d.useMemo(()=>new Map(de.map((v,x)=>[v.key,x])),[de]),P=!Ge&&de.some(v=>(v.col.headerColSpan??1)>1),R=de.map(v=>v.key).join("|"),J=(v,x)=>{const T=v.sortKey??(typeof v.accessor=="string"?v.accessor:void 0);return T?x[T]:void 0},he=v=>v.sortable??(!!v.sortKey||typeof v.accessor=="string"),ce=d.useMemo(()=>{if(!ge||!$)return t;const v=de.find(T=>T.key===$.key);if(!v)return t;const x=$.direction==="asc"?1:-1;return[...t].sort((T,Q)=>ys(J(v.col,T),J(v.col,Q))*x)},[t,ge,$,de]),Me=!Ge&&!P,ze=!!i&&Me,[er,Qe]=U.useColumnWidths(i??""),Le=ze?er:void 0,Je=d.useRef(null),[Be,Ue]=d.useState();d.useLayoutEffect(()=>{Ue(void 0)},[R]),d.useLayoutEffect(()=>{if(!Me||Be||!Je.current)return;const v=Je.current.querySelectorAll("th.sa-tl-leaf");Ue(Array.from(v).map(x=>x.offsetWidth))},[Be,Me]);const[nr,gr]=d.useState(),[dr,hr]=d.useState(0);d.useLayoutEffect(()=>{if(!Ge||!Je.current)return;const v=Je.current.querySelector(":scope > tr");v&&hr(v.offsetHeight)},[Ge,R]);const Sr=(v,x)=>{if((Le==null?void 0:Le[x])!=null)return Le[x];if(v.width!=null)return v.width;if((Be==null?void 0:Be[x])!=null)return Be[x]},m=(v,x)=>typeof v.width=="number"?v.width:Be==null?void 0:Be[x],G=xe.frozenKey&&!Ge&&!P?de.findIndex(v=>v.key===xe.frozenKey):-1,re=v=>v<=G,Se=O?Ir:0,Oe=v=>{const x=nr??Be;if(!x)return Se;let T=Se;for(let Q=0;Q<v;Q++)T+=x[Q]??0;return T};d.useLayoutEffect(()=>{const v=Je.current;if(!v||G<0){gr(void 0);return}let x=0;const T=()=>{x=0;const oe=v.querySelectorAll("th.sa-tl-leaf"),ae=Array.from(oe).map(le=>le.getBoundingClientRect().width);gr(le=>le&&le.length===ae.length&&le.every((pe,be)=>Math.abs(pe-ae[be])<.5)?le:ae)},Q=new ResizeObserver(()=>{x||(x=requestAnimationFrame(T))});return Q.observe(v),v.querySelectorAll("th.sa-tl-leaf").forEach(oe=>Q.observe(oe)),T(),()=>{x&&cancelAnimationFrame(x),Q.disconnect()}},[R,G,O,Be,Le]);const Ye=d.useRef(null),[He,ke]=d.useState("100vh");d.useLayoutEffect(()=>{if(E!==void 0)return;const v=()=>{if(Ye.current){const x=Ye.current.getBoundingClientRect().top;ke(`calc(100vh - ${x}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[E]);const Ie=(v,x)=>o?o(v,x):x,Ve=Y!==void 0,[Or,Nc]=d.useState(()=>new Set(X??[])),ir=d.useMemo(()=>Ve?new Set(Y):Or,[Ve,Y,Or]);d.useEffect(()=>{O&&!o&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[O,!o]);const Il=v=>{if(Ve||Nc(v),q){const x=ce.filter((T,Q)=>v.has(Ie(T,Q)));q(Array.from(v),x)}},jt=(v,x)=>O&&(Z?Z(v,x):!0),Nt=v=>{const x=new Set(ir);x.has(v)?x.delete(v):x.add(v),Il(x)},Br=d.useMemo(()=>O?ce.map((v,x)=>({row:v,i:x,key:Ie(v,x)})).filter(({row:v,i:x})=>Z?Z(v,x):!0).map(({key:v})=>v):[],[O,ce,Z,o]),Tl=Br.filter(v=>ir.has(v)),_t=Br.length>0&&Tl.length===Br.length,Ll=Tl.length>0&&!_t,_c=()=>{const v=new Set(ir);_t?Br.forEach(x=>v.delete(x)):Br.forEach(x=>v.add(x)),Il(v)},qt=(v,x,T)=>v.render?v.render(x,T,ce):gs(x,v.accessor),Zt=de.length+(O?1:0)+(_?1:0),Ol=["80%","55%","70%","45%","90%","60%"],qc=(v,x)=>Ol[(v*7+x*3)%Ol.length],Zc=(v,x)=>e.jsx($e.Skeleton,{height:14,width:qc(v,x),borderRadius:"rounded-sm"}),Gc=Array.from({length:S},(v,x)=>e.jsxs(U.Tr,{children:[O&&e.jsx(U.Td,{style:{width:Ir,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx($e.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),de.map(({col:T,key:Q},oe)=>e.jsx(U.Td,{style:{textAlign:Tr(T.align)},children:Zc(x,oe)},`sa-tl-sk-${x}-${Q}`)),_&&e.jsx(U.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${x}`)),Qc=(v,x)=>{x||we({...xe,hidden:[...xe.hidden??[],v]})},Uc=v=>we({...xe,frozenKey:xe.frozenKey===v?void 0:v}),lt=v=>(z??[]).filter(x=>{var T;return!((T=x.hidden)!=null&&T.call(x,v))}),Al={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},nt=(v,x,T,Q)=>{var Xe;const oe=(Xe=v.disabled)==null?void 0:Xe.call(v,x),ae=(Q==null?void 0:Q.showLabel)??v.showLabel,le=(Q==null?void 0:Q.size)??"xs",pe=e.jsx(j.Button,{size:le,variant:v.variant??"tertiary",tone:v.tone??"neutral",disabled:oe,onClick:()=>v.onClick(x,T),iconLeft:v.icon?e.jsx(M.Icon,{name:v.icon,size:"sm"}):void 0,children:ae&&v.label}),be=v.tooltip;return be?e.jsx(me.Tooltip,{label:be,position:"top-end",children:pe}):pe},Jc=(v,x)=>{const T=lt(v);if(!T.length)return null;if(T.length>5){const oe=Ie(v,x),ae=(V==null?void 0:V.rowKey)===oe;return e.jsx("div",{className:"sa-tl-row-actions",style:Al,onClick:le=>le.stopPropagation(),children:e.jsx(me.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(j.Button,{size:"xs",variant:"tertiary",onClick:le=>{const pe=le.currentTarget.getBoundingClientRect();N(ae?null:{rowKey:oe,top:pe.bottom+4,right:window.innerWidth-pe.right})},children:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Al,children:T.map(oe=>e.jsx(d.Fragment,{children:nt(oe,v,x)},oe.key))})},Yc=(v,x)=>{const T=lt(v);return T.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Mr},children:T.map(Q=>e.jsx(d.Fragment,{children:nt(Q,v,x,{showLabel:!0,size:"sm"})},Q.key))}):null},Xc=(v,x)=>{const T=lt(v);return T.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:T.map(Q=>e.jsx(d.Fragment,{children:nt(Q,v,x,{showLabel:!1})},Q.key))}):null},Gt=(v,x)=>{const{col:T,key:Q}=v,oe=lr.get(Q)??0,ae=re(oe),le=ae&&oe===G,pe=($==null?void 0:$.key)===Q?$.direction:null,be=y&&!T.disableMenu?e.jsx(ul,{active:!!pe||ae,canSort:he(T),canHide:!T.locked,sortDir:pe,frozen:ae,onSort:Wr=>We({key:Q,direction:Wr}),onClearSort:()=>We(null),onToggleFreeze:()=>Uc(Q),onHide:()=>Qc(Q,T.locked)}):null,Xe=T.align==="right",Ar=T.align==="right"?"flex-end":T.align==="center"?"center":"flex-start",rr=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Ar,overflow:"hidden"},children:[T.icon&&e.jsx(M.Icon,{name:T.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Jr,children:T.title})]});return e.jsx(U.Th,{className:`sa-tl-leaf${ae?" sa-tl-frozen":""}`,rowSpan:x==null?void 0:x.rowSpan,colSpan:x==null?void 0:x.colSpan,minWidth:T.minWidth,resizable:Me?T.resizable:!1,defaultWidth:m(T,oe),style:{textAlign:Tr(T.align),width:Sr(T,oe),position:"sticky",top:(x==null?void 0:x.top)??0,left:ae?Oe(oe):void 0,zIndex:ae?3:2,backgroundColor:Dr,boxShadow:le?gl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Xe?e.jsxs(e.Fragment,{children:[be,rr]}):e.jsxs(e.Fragment,{children:[rr,be]})})},`th-${Q}`)},$c=()=>{const v=[];for(let x=0;x<de.length;){const T=de[x],Q=T.col.headerColSpan??1,oe=Math.max(1,Math.min(Q,de.length-x));v.push(Gt(T,oe>1?{colSpan:oe}:void 0)),x+=oe}return v},Wl=v=>e.jsx(U.Th,{rowSpan:v==null?void 0:v.rowSpan,style:{width:Ir,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:Dr,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:x=>x.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",variant:Ll?"indeterminate":"select",checked:_t||Ll,disabled:Br.length===0,onChange:_c,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Kc=(v,x,T)=>{const Q=Ie(v,x);return e.jsx(U.Td,{className:"sa-tl-frozen",style:{width:Ir,padding:0,position:"sticky",left:0,zIndex:2,...T?{"--sa-tl-bg":T}:{}},children:jt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:oe=>oe.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(Q),onChange:()=>Nt(Q),"aria-label":"Pilih baris"})})},`tl-select-${x}`)},Qt=de.filter(v=>!v.col.hideOnMobile),Ut=Qt.find(v=>v.col.primary)??Qt[0],Rc=Qt.filter(v=>v!==Ut),ei=v=>ve(x=>{const T=new Set(x);return T.has(v)?T.delete(v):T.add(v),T}),zl=(v,x)=>Rc.map(({col:T,key:Q})=>{const oe=qt(T,v,x),ae=typeof oe=="string"||typeof oe=="number"?e.jsx(D.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:oe}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:oe});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof T.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:hs,flexShrink:0},children:T.title}):e.jsx("div",{style:{flexShrink:0},children:T.title}),ae]},Q)}),Jt=(v,x)=>{const T=Ut?qt(Ut.col,v,x):null;return typeof T=="string"||typeof T=="number"?e.jsx(D.Text,{as:"span",style:Jr,children:T}):e.jsx("span",{style:Jr,children:T})},ri=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:S},(v,x)=>e.jsxs(f.Box,{style:{border:Mr,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx($e.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${x}`))}),Hl=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(H==null?void 0:H.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:H==null?void 0:H.content}),ti=W?ri:ce.length===0?Hl:w==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:ce.map((v,x)=>{const T=Ie(v,x),Q=se.has(T),ae=O&&ir.has(T)?At:Yr(n==null?void 0:n(v,x));return e.jsxs("div",{style:{borderBottom:Mr,backgroundColor:ae},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(T),onChange:()=>Nt(T),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ei(T),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[Jt(v,x),e.jsx(M.Icon,{name:Q?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),_&&Xc(v,x)]}),Q&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:zl(v,x)})]},T)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ce.map((v,x)=>{const T=Ie(v,x),Q=O&&ir.has(T);return e.jsxs(f.Box,{style:{border:Mr,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Q?At:Yr(n==null?void 0:n(v,x))},children:[jt(v,x)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(T),onChange:()=>Nt(T),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:Jt(v,x)})]}):Jt(v,x),zl(v,x),_&&Yc(v,x)]},T)})}),oi=s&&Me&&Be!==void 0,Pl=c==="fixed"&&!s&&(Me?Be!==void 0:!0),li=Pl&&!Me,st=B&&B.length>0?B.map((v,x)=>e.jsx(U.Tr,{children:v.cells.map((T,Q)=>e.jsx(U.Td,{colSpan:T.colSpan,rowSpan:T.rowSpan,style:{textAlign:Tr(T.align)},children:T.content},`tl-foot-${x}-${Q}`))},`tl-foot-${x}`)):null,ni=e.jsxs(U.Table,{className:"sa-table-layout",fullWidth:!0,size:l,resizable:oi,style:Pl?{tableLayout:"fixed"}:void 0,onWidthsChange:ze?Qe:void 0,children:[li&&e.jsxs("colgroup",{children:[O&&e.jsx("col",{style:{width:Ir}}),de.map(({col:v,key:x},T)=>e.jsx("col",{style:{width:Sr(v,T)}},`col-${x}`)),_&&e.jsx("col",{style:{width:1}})]}),e.jsx(U.Thead,{ref:Je,children:Ge?e.jsxs(e.Fragment,{children:[e.jsxs(U.Tr,{children:[O&&Wl({rowSpan:2}),Ze.map(v=>v.isGroup?e.jsx(U.Th,{colSpan:v.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:Dr},children:e.jsx("span",{style:Jr,children:v.col.title})},`grp-${v.key}`):Gt(v.leaves[0],{rowSpan:2})),_&&e.jsx(U.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]}),e.jsx(U.Tr,{children:Ze.flatMap(v=>v.isGroup?v.leaves.map(x=>Gt(x,{top:dr})):[])})]}):e.jsxs(U.Tr,{children:[O&&Wl(),$c(),_&&e.jsx(U.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]})}),e.jsx(U.Tbody,{children:W?Gc:ce.length===0?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,children:Hl})}):e.jsxs(e.Fragment,{children:[ce.map((v,x)=>{const T=F==null?void 0:F(v,x,x>0?ce[x-1]:void 0),oe=O&&ir.has(Ie(v,x))?At:Yr(n==null?void 0:n(v,x));return e.jsxs(d.Fragment,{children:[T!=null&&T!==!1&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,style:{backgroundColor:Dr},children:T})}),e.jsxs(U.Tr,{children:[O&&Kc(v,x,oe),de.map(({col:ae,key:le},pe)=>{var jl;const be=(jl=ae.cellProps)==null?void 0:jl.call(ae,v,x,ce);if(be!=null&&be.hidden)return null;const Xe=re(pe),Ar=Xe&&pe===G,rr=qt(ae,v,x),Wr=typeof ae.bg=="function"?ae.bg(v,x,ce):ae.bg,Vl=Yr(Wr)??oe;return e.jsx(U.Td,{className:Xe?"sa-tl-frozen":void 0,colSpan:be==null?void 0:be.colSpan,rowSpan:be==null?void 0:be.rowSpan,style:{textAlign:Tr(ae.align),width:Sr(ae,pe),minWidth:ae.minWidth,position:Xe?"sticky":void 0,left:Xe?Oe(pe):void 0,zIndex:Xe?1:void 0,boxShadow:Ar?gl:void 0,...Vl?{"--sa-tl-bg":Vl}:{}},children:typeof rr=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Tr(ae.align)},children:rr}):rr},`tl-cell-${x}-${le}`)}),_&&e.jsx(U.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Jc(v,x)})]})]},Ie(v,x))}),I!=null&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,children:I})})]})}),st&&e.jsx(U.Tfoot,{className:k?"sa-tl-sticky-foot":void 0,children:st})]}),Yt=V?ce.findIndex((v,x)=>Ie(v,x)===V.rowKey):-1,Xt=Yt>=0?ce[Yt]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:Ye,fullWidth:!0,style:{overflow:"auto",height:E??He},children:te?e.jsxs(e.Fragment,{children:[ti,st&&!W&&ce.length>0&&e.jsx(f.Box,{style:{borderTop:Mr},children:e.jsx(U.Table,{fullWidth:!0,size:l,className:"sa-table-layout",children:e.jsx(U.Tbody,{children:st})})})]}):ni}),V&&Xt&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:V.top,right:V.right},onClick:v=>v.stopPropagation(),children:lt(Xt).map(v=>e.jsx("div",{style:{padding:"2px 4px"},children:nt(v,Xt,Yt,{showLabel:!0,size:"sm"})},v.key))})]})},Wt=r=>r==="asc"||r==="desc",bs=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:o="sortOrder",pageKey:n="page",defaultSort:l=null,paramKeys:s,scopeId:c,storage:i=Et}=r,{searchParams:a,setSearchParams:h,searchQueries:y}=Ne(),b=a.toString(),p=c?wr.tableSort(c):void 0,C=d.useRef(!1);d.useEffect(()=>{if(C.current||(C.current=!0,!p)||a.has(t)||a.has(o))return;const B=i.get(p);!(B!=null&&B.key)||!Wt(B.direction)||h({...Object.fromEntries(a.entries()),[t]:B.key,[o]:B.direction})},[]);const E=d.useMemo(()=>{const B=a.get(t),k=a.get(o);return B&&Wt(k)?{key:B,direction:k}:l},[b,t,o,l]);d.useEffect(()=>{if(!p)return;const B=a.get(t),k=a.get(o);B&&Wt(k)?i.set(p,{key:B,direction:k}):i.remove(p)},[b,p,t,o,i]);const w=(s==null?void 0:s.sortBy)??"sortBy",L=(s==null?void 0:s.sortOrder)??"sortOrder",F=d.useMemo(()=>E?{[w]:E.key,[L]:E.direction}:{},[E,w,L]),I=d.useCallback(B=>{const k={...y};B?(k[t]=B.key,k[o]=B.direction):(delete k[t],delete k[o]),delete k[n],h(k)},[y,t,o,n,h]);return{sort:E,setSort:I,params:F}},Xr=({of:r,render:t})=>d.Children.toArray(r==null?void 0:r.map((o,n,l)=>t(o,n,l))),fe=({condition:r,fallback:t,children:o,loading:n,isLoading:l})=>e.jsx(e.Fragment,{children:l?n:r?o:t}),ye=r=>e.jsx(D.Text,{...r,fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),cr=r=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:r.message}),vs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(ar.Input,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default",fullWidth:!0}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},Cs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:l.inputProps.fullWidth?"100%":t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(br.Dropdown,{size:r,...l.inputProps,error:!!l.errorMessage})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},xs=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",ws=r=>{var i;const[t,o]=d.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},l=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},s=a=>{a.preventDefault(),o(!0)},c=a=>{a.preventDefault(),o(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:l,onDragEnter:s,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${xs(r.errorMessage,r.status)}`},children:[e.jsx(M.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ds(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const pl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Ss=r=>{const t={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},o=r.split(" ");if(o.length!==3)return null;const n=parseInt(o[0],10),l=t[o[1]],s=parseInt(o[2],10);return isNaN(n)||isNaN(l)||isNaN(s)?null:new Date(s,l,n)};function Bs(r,t=!0){if(!r)return"Rp 0";const o=typeof r=="number"?r.toString():r;if(isNaN(Number(o)))return"Rp 0";const n=o.split("."),l=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),s=n.length===2?l+"."+n[1]:l;return t?"Rp"+s:s}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")},String.prototype.toNumber=function(){return Number(this)};const ks=r=>{const t=r.split(" ");let o=t[0].charAt(0);return t.length>1&&(o+=""+t[1].charAt(0)),o.toUpperCase()};function Es(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const o=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${l}`}const ms="sa-admin",Re=r=>`var(--${ms}-${r})`,Fs={base:{borderColor:Re("base-border-color"),textColor:Re("base-text-color"),iconColor:Re("base-icon-color"),placeholderColor:Re("base-placeholder-color")},document:{bgColor:Re("document-bg-color")},sidebar:{bgColor:Re("sidebar-bg-color"),borderColor:Re("sidebar-border-color"),maxWidth:Re("sidebar-max-width"),width:Re("sidebar-width"),collapseWidth:Re("sidebar-collapse-width"),collapseV2Width:Re("sidebar-v2-collapse-width")}},Ms=24*60*60*1e3,Is=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const l=n.measureText(r).width;return Number(Math.ceil(l))},Ts=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ls=/--+/,Os=/-$/;function As(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function Ws(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function zs(r){return/^[A-Za-z\s]+$/.test(r)}const Hs=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&(r.key==="a"||r.key==="c"||r.key==="v")||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Ps=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Vs=r=>{const t=/^[0-9.]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},js=r=>Ts.test(r);function Ns(r){return!(Ls.test(r)||Os.test(r))}const _s=r=>{const t=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((r.ctrlKey||r.metaKey)&&["a","c","v","x"].includes(r.key.toLowerCase()))return;const o=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!o.includes(".")||r.key==="-"&&o.length===0&&!o.includes("-")||t.includes(r.key)||r.preventDefault()},qs=r=>{const t=document.getElementById(r);if(t){const o=t.getBoundingClientRect(),n=window.scrollY+o.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function Zs(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(s=>t.endsWith(s)))return r;const l=Number(r);if(isNaN(l))throw new Error("Invalid size format");return l>=1e6?`${(l/1e6).toFixed(2)}MB`:l>=1e3?`${(l/1e3).toFixed(2)}KB`:`${l}B`}function Gs(r){const t=r.split("/");return t[t.length-1]}const Qs=r=>{var t,o;return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:r.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ie.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(M.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ie.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?Gs(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(M.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Zs(((o=r.fileSelected)==null?void 0:o.size.toString())||"100000")}),e.jsx(M.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:pl(new Date)})]})]})]}),e.jsx(j.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(M.Icon,{name:"Trash1"})})]})},bl=({status:r="default",labelPosition:t="outside-top",...o})=>{var p;const n=d.useRef(null),l=()=>{if(o.defaultFile){window.open(o.defaultFile.url);return}n.current&&n.current.click()},s=De.useMediaQuery("md"),c=r==="error"||typeof o.errorMessage=="string"&&!!o.errorMessage,i=o.label?e.jsxs(ie.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:o.label}),o.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),o.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=o.description?e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.description}):null,h=e.jsxs(e.Fragment,{children:[o.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.helperText}),o.errorText&&r==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorText}),o.errorMessage&&!o.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:C=>{var E;return o.handleOnChangeFile(((E=C.target.files)==null?void 0:E.item(0))||null)},accept:(p=o.fileSupportOption)==null?void 0:p.map(C=>"."+(C==null?void 0:C.toLowerCase())).join(", ")}),b=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...o.containerProps,children:[y,(o.fileSelected||o.defaultFile)&&e.jsx(Qs,{fileSelected:o.fileSelected,defaultFile:o.defaultFile,handleOnDeleteFile:o.handleOnDeleteFile,handleOnClickFile:l}),!o.fileSelected&&!o.defaultFile&&e.jsx(ws,{fileSupports:o.fileSupportOption,isDesktop:s,errorMessage:c?o.errorText||o.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:l,handleOnFileChange:o.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ie.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ie.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ie.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,h]})]}):e.jsxs(ie.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,h]})},Us=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(bl,{...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Js=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y,b;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(Ke.Body3,{props:{color:"gray-500"},children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(me.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Xr,{of:(b=s.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:s.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...s.badgeContainerProps,children:[e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description})})}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Ys=({position:r="vertical",size:t="md",fullWidth:o=!1,...n})=>{var s;const l=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(fe,{condition:!!n.description||!!n.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[n.title&&e.jsx(ye,{children:n.title}),e.jsx(fe,{condition:!!n.description,children:e.jsx(D.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Xr,{of:(s=n.radioList)==null?void 0:s.map(c=>({...c,isChecked:n.radioIsChecked===c.id})),render:({value:c,id:i,isChecked:a,subInput:h,label:y,description:b})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:l,children:[e.jsx(at.Radio,{id:`${i.toString()}-${c}`,name:n.groupName||y,label:y,value:c,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:b}),h]})})}),n.errorMessage&&e.jsx(cr,{message:n.errorMessage})]})},Xs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(it.Textarea,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},$s=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",required:n=!1,fullWidth:l=!1,...s})=>{var i,a,h;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:n,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=s.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=s.tooltip)==null?void 0:a.label,arrowPosition:(h=s.tooltip)==null?void 0:h.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.titleDescription,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})})]})}),e.jsx(xr.Toggle,{checked:s.checked,onChange:s.onChange,label:s.label,description:s.description}),s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Ks=({variant:r="primary",size:t="md",...o})=>{const n=Cr.useColor(),l=c=>{var a,h,y,b,p,C;if(!c)return;const i=o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(h=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:h[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(C=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:C[50];return e.jsx(M.Icon,{name:c,size:t,style:{color:i}})},s=()=>{var i,a,h,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return o.title;const c={color:o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary-danger"?(a=(i=n==null?void 0:n.computed)==null?void 0:i.red)==null?void 0:a[600]:(y=(h=n==null?void 0:n.computed)==null?void 0:h.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(Ke.Body2,{props:{style:c},children:o.title});case"sm":case"md":return e.jsx(Ke.SubH3,{props:{style:c},children:o.title});case"lg":return e.jsx(Ke.SubH2,{props:{style:c},children:o.title});default:return o.title}};return e.jsx(j.Button,{fullWidth:!0,disabled:o.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:o.onClick,type:o.type,iconLeft:l(o.iconLeft),iconRight:l(o.iconRight),size:t,children:s()})},Rs=r=>e.jsx(Ke.H5,{props:{...r},children:r.title}),ec=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(fr.StarasiaDate,{size:r,...l.inputProps,status:l.errorMessage?"error":void 0})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})};async function rc(r,t){const o=new Image;o.src=r,await new Promise((s,c)=>{o.onload=s,o.onerror=c});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const l=n.getContext("2d",{alpha:!0});if(!l)throw new Error("No 2D context");return l.drawImage(o,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((s,c)=>{n.toBlob(i=>{if(!i)return c("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});s(a)},"image/png")})}const vl={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},Cl=d.forwardRef(({handleUpload:r,urlImage:t,isUploading:o,croppedImage:n,setCroppedImage:l,size:s="96",aspect:c="1:1",containerProps:i,maxFileSize:a=2,onError:h},y)=>{const b=De.useMediaQuery("md"),[p,C]=d.useState(!1),[E,w]=d.useState(null),[L,F]=d.useState(!1),[I,B]=d.useState({x:0,y:0}),[k,H]=d.useState(1),[W,S]=d.useState(null);d.useEffect(()=>{t===null&&l(null)},[t]);const z=d.useCallback((V,N)=>{S(N)},[]),O=V=>{var ve;const N=(ve=V.target.files)==null?void 0:ve[0];if(!N)return;const se=new FileReader;se.onload=()=>{w(se.result),F(!0)},se.readAsDataURL(N)},Y=async()=>{if(!(!E||!W))try{const V=await rc(E,W);if(a&&V.size>a*1024*1024){h==null||h(`Ukuran file maksimal ${a}MB`);return}r==null||r(V);const N=URL.createObjectURL(V);l(N,V),F(!1)}catch{h==null||h("Gagal memproses gambar")}},X=d.useRef(null),q=()=>{X.current&&X.current.click()};d.useImperativeHandle(y,()=>({openFileDialog:()=>{var V;(V=X.current)==null||V.click()}}));const Z=parseInt(s,10),K=vl[c];let te,_;return K>=1?(_=Z,te=Z*K):(te=Z,_=Z/K),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(i==null?void 0:i.bg)||"gray-200",borderStyle:(i==null?void 0:i.borderStyle)||"border-none",borderColor:(i==null?void 0:i.borderColor)||"gray-200",borderWidth:(i==null?void 0:i.borderWidth)||"border-2",borderRadius:(i==null?void 0:i.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:i!=null&&i.fullWidth?"100%":`${te}px`,height:i!=null&&i.fullWidth?"auto":`${_}px`,aspectRatio:K,flexShrink:0},onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(f.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(M.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(s)/2<40?Number(s)/2:40,height:Number(s)/2<40?Number(s)/2:40}})}),e.jsxs(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:q,children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",onChange:O,disabled:o,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(M.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(fe,{condition:s.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:s.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),o&&e.jsx(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(f.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),L&&Pr.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>F(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:b?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:V=>V.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:E&&e.jsx(Nl,{image:E,crop:I,zoom:k,aspect:c?vl[c]:void 0,onCropChange:B,onZoomChange:H,onCropComplete:z,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(j.Button,{size:"sm",secondary:!0,onClick:()=>F(!1),children:"Cancel"}),e.jsx(j.Button,{size:"sm",primary:!0,onClick:Y,children:"Crop"})]})]})}),document.body)]})}),tc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(me.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(Cl,{...s.inputProps}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})]})},oc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var c,i,a;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((c=l.tooltip)!=null&&c.label),children:e.jsx(me.Tooltip,{label:(i=l.tooltip)==null?void 0:i.label,arrowPosition:(a=l.tooltip)==null?void 0:a.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),l.inputProps.extended&&l.inputProps.extended]})},lc=({items:r,id:t,handleOnUpdate:o,width:n,toggleShow:l=!0,disabled:s=!1})=>{var y;const[c,i]=d.useState([]);d.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=c.find(b=>b.id===t))==null?void 0:y.isActive,h=d.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),o&&o(!a)},[t,o,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:n},children:l&&e.jsx(xr.Toggle,{disabled:s,checked:a,onChange:h,label:a?"Active":"Inactive"})})},nc={InputText:vs,InputDropdown:Cs,InputSingleFile:Us,CheckBoxOptions:Js,RadioOptions:Ys,InputTextArea:Xs,ToggleForm:$s,ActionButton:Ks,FormTitle:Rs,InputDate:ec,InputImgFile:tc,Custom:oc},xl=({customBottom:r})=>{const[t,o]=d.useState(!1),n=()=>{window.scrollY>window.screenY?o(!0):o(!1)},l=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.Box,{direction:"column",position:"absolute",style:{bottom:r||"1.6rem",right:"2rem",transform:t?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(j.Button,{secondary:!0,size:"xs",onClick:l,type:"button",iconLeft:e.jsx(M.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},qe="sa-sidepanel-item",wl="sa-sidepanel-item-styles",sc=`
|
|
57
|
+
`,document.head.appendChild(r)},Tr=r=>r==="right"?"right":r==="center"?"center":"left",us=/^(#|rgb|hsl|var\()/,Yr=r=>r?us.test(r)?r:`var(--sa-background-${r})`:void 0,gs=(r,t)=>{if(t)return r[t]},ys=(r,t)=>r==null&&t==null?0:r==null?-1:t==null?1:typeof r=="number"&&typeof t=="number"?r-t:String(r).localeCompare(String(t)),ps=({columns:r,data:t,getRowKey:o,rowBg:n,size:l="md",resizable:s=!1,layout:c="auto",widthStorageKey:i,columnState:a,onColumnStateChange:h,columnMenu:y=!1,sort:b,defaultSort:p,onSortChange:C,height:E,mobileLayout:w="cards",mobileBreakpoint:L="md",groupSeparator:F,summary:I,footer:B,stickyFooter:k=!1,emptyState:H,loading:W=!1,loadingRows:S=8,rowActions:z,selectable:O=!1,selectedKeys:Y,defaultSelectedKeys:X,onSelectionChange:q,isRowSelectable:Z})=>{fs();const te=!De.useMediaQuery(L)&&w!=="scroll",_=!!(z!=null&&z.length),[V,N]=d.useState(null);d.useEffect(()=>{if(!V)return;const v=()=>N(null),x=setTimeout(()=>document.addEventListener("click",v),0);return()=>{clearTimeout(x),document.removeEventListener("click",v)}},[V]);const[se,ve]=d.useState(()=>new Set),Ee=a!==void 0,[ue,Ce]=d.useState({}),xe=a??ue,we=v=>{h==null||h(v),Ee||Ce(v)},Ae=b!==void 0,[Fe,_e]=d.useState(p??null),$=Ae?b??null:Fe,ge=!C,We=v=>{C==null||C(v),Ae||_e(v)},{headerGroups:Ze,leafColumns:de,hasGroups:Ge}=d.useMemo(()=>{var ae;const v=new Set(xe.hidden??[]),x=(le,pe)=>le.key??(typeof le.accessor=="string"?le.accessor:`col-${pe}`),T=r.map((le,pe)=>{var Xe;if((Xe=le.children)!=null&&Xe.length){const Ar=le.children.map((rr,Wr)=>({col:rr,key:x(rr,`${pe}-${Wr}`)})).filter(rr=>!v.has(rr.key));return{col:le,key:le.key??`group-${pe}`,isGroup:!0,leaves:Ar}}const be={col:le,key:x(le,`${pe}`)};return{col:le,key:be.key,isGroup:!1,leaves:v.has(be.key)?[]:[be]}}).filter(le=>le.leaves.length>0),Q=T.some(le=>le.isGroup);let oe=T.flatMap(le=>le.leaves);if(!Q&&((ae=xe.order)!=null&&ae.length)){const le=new Map(xe.order.map((pe,be)=>[pe,be]));oe=[...oe].sort((pe,be)=>(le.get(pe.key)??1/0)-(le.get(be.key)??1/0))}return{headerGroups:T,leafColumns:oe,hasGroups:Q}},[r,xe]),lr=d.useMemo(()=>new Map(de.map((v,x)=>[v.key,x])),[de]),P=!Ge&&de.some(v=>(v.col.headerColSpan??1)>1),R=de.map(v=>v.key).join("|"),J=(v,x)=>{const T=v.sortKey??(typeof v.accessor=="string"?v.accessor:void 0);return T?x[T]:void 0},he=v=>v.sortable??(!!v.sortKey||typeof v.accessor=="string"),ce=d.useMemo(()=>{if(!ge||!$)return t;const v=de.find(T=>T.key===$.key);if(!v)return t;const x=$.direction==="asc"?1:-1;return[...t].sort((T,Q)=>ys(J(v.col,T),J(v.col,Q))*x)},[t,ge,$,de]),Me=!Ge&&!P,ze=!!i&&Me,[er,Qe]=U.useColumnWidths(i??""),Le=ze?er:void 0,Je=d.useRef(null),[Be,Ue]=d.useState();d.useLayoutEffect(()=>{Ue(void 0)},[R]),d.useLayoutEffect(()=>{if(!Me||Be||!Je.current)return;const v=Je.current.querySelectorAll("th.sa-tl-leaf");Ue(Array.from(v).map(x=>x.offsetWidth))},[Be,Me]);const[nr,gr]=d.useState(),[dr,hr]=d.useState(0);d.useLayoutEffect(()=>{if(!Ge||!Je.current)return;const v=Je.current.querySelector(":scope > tr");v&&hr(v.offsetHeight)},[Ge,R]);const Sr=(v,x)=>{if((Le==null?void 0:Le[x])!=null)return Le[x];if(v.width!=null)return v.width;if((Be==null?void 0:Be[x])!=null)return Be[x]},m=(v,x)=>typeof v.width=="number"?v.width:Be==null?void 0:Be[x],G=xe.frozenKey&&!Ge&&!P?de.findIndex(v=>v.key===xe.frozenKey):-1,re=v=>v<=G,Se=O?Ir:0,Oe=v=>{const x=nr??Be;if(!x)return Se;let T=Se;for(let Q=0;Q<v;Q++)T+=x[Q]??0;return T};d.useLayoutEffect(()=>{const v=Je.current;if(!v||G<0){gr(void 0);return}let x=0;const T=()=>{x=0;const oe=v.querySelectorAll("th.sa-tl-leaf"),ae=Array.from(oe).map(le=>le.getBoundingClientRect().width);gr(le=>le&&le.length===ae.length&&le.every((pe,be)=>Math.abs(pe-ae[be])<.5)?le:ae)},Q=new ResizeObserver(()=>{x||(x=requestAnimationFrame(T))});return Q.observe(v),v.querySelectorAll("th.sa-tl-leaf").forEach(oe=>Q.observe(oe)),T(),()=>{x&&cancelAnimationFrame(x),Q.disconnect()}},[R,G,O,Be,Le]);const Ye=d.useRef(null),[He,ke]=d.useState("100vh");d.useLayoutEffect(()=>{if(E!==void 0)return;const v=()=>{if(Ye.current){const x=Ye.current.getBoundingClientRect().top;ke(`calc(100vh - ${x}px - var(--sa-floating-footer-height, 0px) + 12px)`)}};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[E]);const Ie=(v,x)=>o?o(v,x):x,Ve=Y!==void 0,[Or,Nc]=d.useState(()=>new Set(X??[])),ir=d.useMemo(()=>Ve?new Set(Y):Or,[Ve,Y,Or]);d.useEffect(()=>{O&&!o&&process.env.NODE_ENV!=="production"&&console.warn("[@starasia/admin] TableLayout: `selectable` tanpa `getRowKey` — key default (index) membuat seleksi menempel ke POSISI baris, bukan datanya. Beri `getRowKey` yang stabil (mis. r => r.id).")},[O,!o]);const Il=v=>{if(Ve||Nc(v),q){const x=ce.filter((T,Q)=>v.has(Ie(T,Q)));q(Array.from(v),x)}},jt=(v,x)=>O&&(Z?Z(v,x):!0),Nt=v=>{const x=new Set(ir);x.has(v)?x.delete(v):x.add(v),Il(x)},Br=d.useMemo(()=>O?ce.map((v,x)=>({row:v,i:x,key:Ie(v,x)})).filter(({row:v,i:x})=>Z?Z(v,x):!0).map(({key:v})=>v):[],[O,ce,Z,o]),Tl=Br.filter(v=>ir.has(v)),_t=Br.length>0&&Tl.length===Br.length,Ll=Tl.length>0&&!_t,_c=()=>{const v=new Set(ir);_t?Br.forEach(x=>v.delete(x)):Br.forEach(x=>v.add(x)),Il(v)},qt=(v,x,T)=>v.render?v.render(x,T,ce):gs(x,v.accessor),Zt=de.length+(O?1:0)+(_?1:0),Ol=["80%","55%","70%","45%","90%","60%"],qc=(v,x)=>Ol[(v*7+x*3)%Ol.length],Zc=(v,x)=>e.jsx($e.Skeleton,{height:14,width:qc(v,x),borderRadius:"rounded-sm"}),Gc=Array.from({length:S},(v,x)=>e.jsxs(U.Tr,{children:[O&&e.jsx(U.Td,{style:{width:Ir,padding:0},children:e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx($e.Skeleton,{height:14,width:14,borderRadius:"rounded-sm"})})}),de.map(({col:T,key:Q},oe)=>e.jsx(U.Td,{style:{textAlign:Tr(T.align)},children:Zc(x,oe)},`sa-tl-sk-${x}-${Q}`)),_&&e.jsx(U.Td,{style:{width:1,padding:0,border:"none"}})]},`sa-tl-sk-${x}`)),Qc=(v,x)=>{x||we({...xe,hidden:[...xe.hidden??[],v]})},Uc=v=>we({...xe,frozenKey:xe.frozenKey===v?void 0:v}),lt=v=>(z??[]).filter(x=>{var T;return!((T=x.hidden)!=null&&T.call(x,v))}),Al={position:"absolute",right:0,top:0,bottom:0,display:"flex",alignItems:"center",gap:4,paddingRight:16,paddingLeft:40,background:"linear-gradient(to right, transparent, var(--sa-background-primary-inverse, #f8f8f8) 40px)"},nt=(v,x,T,Q)=>{var Xe;const oe=(Xe=v.disabled)==null?void 0:Xe.call(v,x),ae=(Q==null?void 0:Q.showLabel)??v.showLabel,le=(Q==null?void 0:Q.size)??"xs",pe=e.jsx(j.Button,{size:le,variant:v.variant??"tertiary",tone:v.tone??"neutral",disabled:oe,onClick:()=>v.onClick(x,T),iconLeft:v.icon?e.jsx(M.Icon,{name:v.icon,size:"sm"}):void 0,children:ae&&v.label}),be=v.tooltip;return be?e.jsx(me.Tooltip,{label:be,position:"top-end",children:pe}):pe},Jc=(v,x)=>{const T=lt(v);if(!T.length)return null;if(T.length>5){const oe=Ie(v,x),ae=(V==null?void 0:V.rowKey)===oe;return e.jsx("div",{className:"sa-tl-row-actions",style:Al,onClick:le=>le.stopPropagation(),children:e.jsx(me.Tooltip,{label:"Aksi lainnya",position:"top",children:e.jsx(j.Button,{size:"xs",variant:"tertiary",onClick:le=>{const pe=le.currentTarget.getBoundingClientRect();N(ae?null:{rowKey:oe,top:pe.bottom+4,right:window.innerWidth-pe.right})},children:e.jsx(M.Icon,{name:"MenuVertical",size:"sm"})})})})}return e.jsx("div",{className:"sa-tl-row-actions",style:Al,children:T.map(oe=>e.jsx(d.Fragment,{children:nt(oe,v,x)},oe.key))})},Yc=(v,x)=>{const T=lt(v);return T.length?e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingTop:8,marginTop:8,borderTop:Mr},children:T.map(Q=>e.jsx(d.Fragment,{children:nt(Q,v,x,{showLabel:!0,size:"sm"})},Q.key))}):null},Xc=(v,x)=>{const T=lt(v);return T.length?e.jsx("div",{style:{display:"flex",gap:4,paddingRight:8,flexShrink:0},children:T.map(Q=>e.jsx(d.Fragment,{children:nt(Q,v,x,{showLabel:!1})},Q.key))}):null},Gt=(v,x)=>{const{col:T,key:Q}=v,oe=lr.get(Q)??0,ae=re(oe),le=ae&&oe===G,pe=($==null?void 0:$.key)===Q?$.direction:null,be=y&&!T.disableMenu?e.jsx(ul,{active:!!pe||ae,canSort:he(T),canHide:!T.locked,sortDir:pe,frozen:ae,onSort:Wr=>We({key:Q,direction:Wr}),onClearSort:()=>We(null),onToggleFreeze:()=>Uc(Q),onHide:()=>Qc(Q,T.locked)}):null,Xe=T.align==="right",Ar=T.align==="right"?"flex-end":T.align==="center"?"center":"flex-start",rr=e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,justifyContent:Ar,overflow:"hidden"},children:[T.icon&&e.jsx(M.Icon,{name:T.icon,size:"sm",style:{flexShrink:0}}),e.jsx("span",{style:Jr,children:T.title})]});return e.jsx(U.Th,{className:`sa-tl-leaf${ae?" sa-tl-frozen":""}`,rowSpan:x==null?void 0:x.rowSpan,colSpan:x==null?void 0:x.colSpan,minWidth:T.minWidth,resizable:Me?T.resizable:!1,defaultWidth:m(T,oe),style:{textAlign:Tr(T.align),width:Sr(T,oe),position:"sticky",top:(x==null?void 0:x.top)??0,left:ae?Oe(oe):void 0,zIndex:ae?3:2,backgroundColor:Dr,boxShadow:le?gl:void 0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:Xe?e.jsxs(e.Fragment,{children:[be,rr]}):e.jsxs(e.Fragment,{children:[rr,be]})})},`th-${Q}`)},$c=()=>{const v=[];for(let x=0;x<de.length;){const T=de[x],Q=T.col.headerColSpan??1,oe=Math.max(1,Math.min(Q,de.length-x));v.push(Gt(T,oe>1?{colSpan:oe}:void 0)),x+=oe}return v},Wl=v=>e.jsx(U.Th,{rowSpan:v==null?void 0:v.rowSpan,style:{width:Ir,position:"sticky",top:0,left:0,zIndex:4,backgroundColor:Dr,padding:0},children:e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:x=>x.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",variant:Ll?"indeterminate":"select",checked:_t||Ll,disabled:Br.length===0,onChange:_c,"aria-label":"Pilih semua baris di halaman ini"})})},"th-select"),Kc=(v,x,T)=>{const Q=Ie(v,x);return e.jsx(U.Td,{className:"sa-tl-frozen",style:{width:Ir,padding:0,position:"sticky",left:0,zIndex:2,...T?{"--sa-tl-bg":T}:{}},children:jt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"},onClick:oe=>oe.stopPropagation(),children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(Q),onChange:()=>Nt(Q),"aria-label":"Pilih baris"})})},`tl-select-${x}`)},Qt=de.filter(v=>!v.col.hideOnMobile),Ut=Qt.find(v=>v.col.primary)??Qt[0],Rc=Qt.filter(v=>v!==Ut),ei=v=>ve(x=>{const T=new Set(x);return T.has(v)?T.delete(v):T.add(v),T}),zl=(v,x)=>Rc.map(({col:T,key:Q})=>{const oe=qt(T,v,x),ae=typeof oe=="string"||typeof oe=="number"?e.jsx(D.Text,{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:oe}):e.jsx("div",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",textAlign:"right"},children:oe});return e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"space-between",alignItems:"baseline"},children:[typeof T.title=="string"?e.jsx(D.Text,{color:"subtle",fontWeight:"medium",style:{color:hs,flexShrink:0},children:T.title}):e.jsx("div",{style:{flexShrink:0},children:T.title}),ae]},Q)}),Jt=(v,x)=>{const T=Ut?qt(Ut.col,v,x):null;return typeof T=="string"||typeof T=="number"?e.jsx(D.Text,{as:"span",style:Jr,children:T}):e.jsx("span",{style:Jr,children:T})},ri=e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:Array.from({length:S},(v,x)=>e.jsxs(f.Box,{style:{border:Mr,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[e.jsx($e.Skeleton,{height:16,width:"60%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"85%",borderRadius:"rounded-sm"}),e.jsx($e.Skeleton,{height:12,width:"70%",borderRadius:"rounded-sm"})]},`sa-tl-sk-card-${x}`))}),Hl=e.jsx(f.Box,{fullWidth:!0,style:{minHeight:(H==null?void 0:H.minHeight)??320,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:H==null?void 0:H.content}),ti=W?ri:ce.length===0?Hl:w==="expand"?e.jsx(f.Box,{style:{display:"flex",flexDirection:"column"},children:ce.map((v,x)=>{const T=Ie(v,x),Q=se.has(T),ae=O&&ir.has(T)?At:Yr(n==null?void 0:n(v,x));return e.jsxs("div",{style:{borderBottom:Mr,backgroundColor:ae},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jt(v,x)&&e.jsx("div",{style:{display:"flex",alignItems:"center",paddingLeft:12,flexShrink:0},children:e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(T),onChange:()=>Nt(T),"aria-label":"Pilih baris"})}),e.jsxs("button",{type:"button",onClick:()=>ei(T),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",background:"none",border:"none",font:"inherit",color:"inherit",cursor:"pointer",textAlign:"left"},children:[Jt(v,x),e.jsx(M.Icon,{name:Q?"ChevronUp":"ChevronDown",size:"sm",style:{flexShrink:0}})]}),_&&Xc(v,x)]}),Q&&e.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:6},children:zl(v,x)})]},T)})}):e.jsx(f.Box,{style:{display:"flex",flexDirection:"column",gap:8,padding:8},children:ce.map((v,x)=>{const T=Ie(v,x),Q=O&&ir.has(T);return e.jsxs(f.Box,{style:{border:Mr,borderRadius:"var(--sa-radii-sm, 6px)",padding:12,display:"flex",flexDirection:"column",gap:6,backgroundColor:Q?At:Yr(n==null?void 0:n(v,x))},children:[jt(v,x)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(tr.Checkbox,{size:"sm",checked:ir.has(T),onChange:()=>Nt(T),"aria-label":"Pilih baris"}),e.jsx("div",{style:{flex:1,minWidth:0},children:Jt(v,x)})]}):Jt(v,x),zl(v,x),_&&Yc(v,x)]},T)})}),oi=s&&Me&&Be!==void 0,Pl=c==="fixed"&&!s&&(Me?Be!==void 0:!0),li=Pl&&!Me,st=B&&B.length>0?B.map((v,x)=>e.jsx(U.Tr,{children:v.cells.map((T,Q)=>e.jsx(U.Td,{colSpan:T.colSpan,rowSpan:T.rowSpan,style:{textAlign:Tr(T.align)},children:T.content},`tl-foot-${x}-${Q}`))},`tl-foot-${x}`)):null,ni=e.jsxs(U.Table,{className:"sa-table-layout",fullWidth:!0,size:l,resizable:oi,style:Pl?{tableLayout:"fixed"}:void 0,onWidthsChange:ze?Qe:void 0,children:[li&&e.jsxs("colgroup",{children:[O&&e.jsx("col",{style:{width:Ir}}),de.map(({col:v,key:x},T)=>e.jsx("col",{style:{width:Sr(v,T)}},`col-${x}`)),_&&e.jsx("col",{style:{width:1}})]}),e.jsx(U.Thead,{ref:Je,children:Ge?e.jsxs(e.Fragment,{children:[e.jsxs(U.Tr,{children:[O&&Wl({rowSpan:2}),Ze.map(v=>v.isGroup?e.jsx(U.Th,{colSpan:v.leaves.length,style:{textAlign:"center",position:"sticky",top:0,zIndex:2,backgroundColor:Dr},children:e.jsx("span",{style:Jr,children:v.col.title})},`grp-${v.key}`):Gt(v.leaves[0],{rowSpan:2})),_&&e.jsx(U.Th,{rowSpan:2,style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]}),e.jsx(U.Tr,{children:Ze.flatMap(v=>v.isGroup?v.leaves.map(x=>Gt(x,{top:dr})):[])})]}):e.jsxs(U.Tr,{children:[O&&Wl(),$c(),_&&e.jsx(U.Th,{style:{position:"sticky",top:0,right:0,zIndex:3,width:1,padding:0,border:"none",backgroundColor:Dr}})]})}),e.jsx(U.Tbody,{children:W?Gc:ce.length===0?e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,children:Hl})}):e.jsxs(e.Fragment,{children:[ce.map((v,x)=>{const T=F==null?void 0:F(v,x,x>0?ce[x-1]:void 0),oe=O&&ir.has(Ie(v,x))?At:Yr(n==null?void 0:n(v,x));return e.jsxs(d.Fragment,{children:[T!=null&&T!==!1&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,style:{backgroundColor:Dr},children:T})}),e.jsxs(U.Tr,{children:[O&&Kc(v,x,oe),de.map(({col:ae,key:le},pe)=>{var jl;const be=(jl=ae.cellProps)==null?void 0:jl.call(ae,v,x,ce);if(be!=null&&be.hidden)return null;const Xe=re(pe),Ar=Xe&&pe===G,rr=qt(ae,v,x),Wr=typeof ae.bg=="function"?ae.bg(v,x,ce):ae.bg,Vl=Yr(Wr)??oe;return e.jsx(U.Td,{className:Xe?"sa-tl-frozen":void 0,colSpan:be==null?void 0:be.colSpan,rowSpan:be==null?void 0:be.rowSpan,style:{textAlign:Tr(ae.align),width:Sr(ae,pe),minWidth:ae.minWidth,position:Xe?"sticky":void 0,left:Xe?Oe(pe):void 0,zIndex:Xe?1:void 0,boxShadow:Ar?gl:void 0,...Vl?{"--sa-tl-bg":Vl}:{}},children:typeof rr=="string"?e.jsx(D.Text,{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:Tr(ae.align)},children:rr}):rr},`tl-cell-${x}-${le}`)}),_&&e.jsx(U.Td,{style:{position:"sticky",right:0,width:1,padding:0,overflow:"visible",zIndex:2,border:"none"},children:Jc(v,x)})]})]},Ie(v,x))}),I!=null&&e.jsx(U.Tr,{children:e.jsx(U.Td,{colSpan:Zt,children:I})})]})}),st&&e.jsx(U.Tfoot,{className:k?"sa-tl-sticky-foot":void 0,children:st})]}),Yt=V?ce.findIndex((v,x)=>Ie(v,x)===V.rowKey):-1,Xt=Yt>=0?ce[Yt]:null;return e.jsxs(e.Fragment,{children:[e.jsx(f.Box,{ref:Ye,fullWidth:!0,style:{overflow:"auto",height:E??He},children:te?e.jsxs(e.Fragment,{children:[ti,st&&!W&&ce.length>0&&e.jsx(f.Box,{style:{borderTop:Mr},children:e.jsx(U.Table,{fullWidth:!0,size:l,className:"sa-table-layout",children:e.jsx(U.Tbody,{children:st})})})]}):ni}),V&&Xt&&e.jsx("div",{className:"sa-tl-kebab-menu",style:{top:V.top,right:V.right},onClick:v=>v.stopPropagation(),children:lt(Xt).map(v=>e.jsx("div",{style:{padding:"2px 4px"},children:nt(v,Xt,Yt,{showLabel:!0,size:"sm"})},v.key))})]})},Wt=r=>r==="asc"||r==="desc",bs=(r={})=>{const{sortKeyParam:t="sortBy",sortOrderParam:o="sortOrder",pageKey:n="page",defaultSort:l=null,paramKeys:s,scopeId:c,storage:i=Et}=r,{searchParams:a,setSearchParams:h,searchQueries:y}=Ne(),b=a.toString(),p=c?wr.tableSort(c):void 0,C=d.useRef(!1);d.useEffect(()=>{if(C.current||(C.current=!0,!p)||a.has(t)||a.has(o))return;const B=i.get(p);!(B!=null&&B.key)||!Wt(B.direction)||h({...Object.fromEntries(a.entries()),[t]:B.key,[o]:B.direction},{replace:!0})},[]);const E=d.useMemo(()=>{const B=a.get(t),k=a.get(o);return B&&Wt(k)?{key:B,direction:k}:l},[b,t,o,l]);d.useEffect(()=>{if(!p)return;const B=a.get(t),k=a.get(o);B&&Wt(k)?i.set(p,{key:B,direction:k}):i.remove(p)},[b,p,t,o,i]);const w=(s==null?void 0:s.sortBy)??"sortBy",L=(s==null?void 0:s.sortOrder)??"sortOrder",F=d.useMemo(()=>E?{[w]:E.key,[L]:E.direction}:{},[E,w,L]),I=d.useCallback(B=>{const k={...y};B?(k[t]=B.key,k[o]=B.direction):(delete k[t],delete k[o]),delete k[n],h(k)},[y,t,o,n,h]);return{sort:E,setSort:I,params:F}},Xr=({of:r,render:t})=>d.Children.toArray(r==null?void 0:r.map((o,n,l)=>t(o,n,l))),fe=({condition:r,fallback:t,children:o,loading:n,isLoading:l})=>e.jsx(e.Fragment,{children:l?n:r?o:t}),ye=r=>e.jsx(D.Text,{...r,fontSize:r.fontSize||"md",fontWeight:r.fontWeight||"medium",color:r.color||"gray-700",children:r.children}),cr=r=>e.jsx(D.Text,{color:"red-600",fontSize:"sm",children:r.message}),vs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(ar.Input,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default",fullWidth:!0}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},Cs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(f.Box,{direction:"column",gap:"xs",fullWidth:l.inputProps.fullWidth||!1,children:[e.jsx(f.Box,{direction:"column",style:{width:l.inputProps.fullWidth?"100%":t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(br.Dropdown,{size:r,...l.inputProps,error:!!l.errorMessage})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage}),l.inputProps.extended&&l.inputProps.extended]})]})},xs=(r,t)=>typeof r=="string"&&r||t==="error"?"var(--sa-border-danger)":"var(--sa-border-subtle)",ws=r=>{var i;const[t,o]=d.useState(!1),n=a=>{a.preventDefault(),a.stopPropagation()},l=a=>{a.preventDefault(),a.stopPropagation(),a.dataTransfer&&r.handleOnFileChange(a.dataTransfer.files.item(0))},s=a=>{a.preventDefault(),o(!0)},c=a=>{a.preventDefault(),o(!1)};return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",direction:"row",gap:"sm",align:"center",onClick:r.handleOnClick,onDragOver:n,onDrop:l,onDragEnter:s,onDragLeave:c,paddingBlock:"md",borderRadius:"rounded-md",style:{border:t?"1px solid var(--sa-border-info)":`1px solid ${xs(r.errorMessage,r.status)}`},children:[e.jsx(M.Icon,{name:"Upload",size:"lg",style:{width:30,height:30}}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",children:[e.jsx(D.Text,{fontWeight:"medium",color:"gray-500",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"Click your upload"}),e.jsx(D.Text,{fontWeight:"medium",style:{textWrap:"nowrap"},fontSize:r.isDesktop?"md":"sm",children:"or Drag & Drop"})]}),e.jsx(D.Text,{fontSize:"sm",color:"gray-500",children:(i=r.fileSupports)==null?void 0:i.map(a=>a.toLocaleUpperCase()).join(", ")})]})]})};function Ds(r){return r.split(" ").map(t=>t[0]).join("").slice(0,2).toUpperCase()}const pl=r=>{const t={day:"2-digit",month:"short",year:"numeric"};return r.toLocaleDateString("id-ID",t)},Ss=r=>{const t={Jan:0,Feb:1,Mar:2,Apr:3,Mei:4,Jun:5,Jul:6,Agu:7,Sep:8,Okt:9,Nov:10,Des:11},o=r.split(" ");if(o.length!==3)return null;const n=parseInt(o[0],10),l=t[o[1]],s=parseInt(o[2],10);return isNaN(n)||isNaN(l)||isNaN(s)?null:new Date(s,l,n)};function Bs(r,t=!0){if(!r)return"Rp 0";const o=typeof r=="number"?r.toString():r;if(isNaN(Number(o)))return"Rp 0";const n=o.split("."),l=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),s=n.length===2?l+"."+n[1]:l;return t?"Rp"+s:s}String.prototype.toTitleCase=function(){return this.toLowerCase().split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")},String.prototype.toNumber=function(){return Number(this)};const ks=r=>{const t=r.split(" ");let o=t[0].charAt(0);return t.length>1&&(o+=""+t[1].charAt(0)),o.toUpperCase()};function Es(r){const t=typeof r=="string"?new Date(r):r;if(isNaN(t.getTime()))throw new Error("Invalid date format");const o=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),l=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${l}`}const ms="sa-admin",Re=r=>`var(--${ms}-${r})`,Fs={base:{borderColor:Re("base-border-color"),textColor:Re("base-text-color"),iconColor:Re("base-icon-color"),placeholderColor:Re("base-placeholder-color")},document:{bgColor:Re("document-bg-color")},sidebar:{bgColor:Re("sidebar-bg-color"),borderColor:Re("sidebar-border-color"),maxWidth:Re("sidebar-max-width"),width:Re("sidebar-width"),collapseWidth:Re("sidebar-collapse-width"),collapseV2Width:Re("sidebar-v2-collapse-width")}},Ms=24*60*60*1e3,Is=r=>{const t="14px poppins",n=document.createElement("canvas").getContext("2d");n.font=t;const l=n.measureText(r).width;return Number(Math.ceil(l))},Ts=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ls=/--+/,Os=/-$/;function As(r,t){return JSON.stringify(r)!==JSON.stringify(t)}function Ws(r){return/^(?:\+62|62|0)8[1-9][0-9]{7,10}$/.test(r)}function zs(r){return/^[A-Za-z\s]+$/.test(r)}const Hs=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&(r.key==="a"||r.key==="c"||r.key==="v")||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Ps=r=>{const t=/^[0-9]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},Vs=r=>{const t=/^[0-9.]$/,o=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab"];(r.ctrlKey||r.metaKey)&&r.key==="v"||!t.test(r.key)&&!o.includes(r.key)&&r.preventDefault()},js=r=>Ts.test(r);function Ns(r){return!(Ls.test(r)||Os.test(r))}const _s=r=>{const t=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Backspace","Delete","Enter","Tab","Home","End"];if((r.ctrlKey||r.metaKey)&&["a","c","v","x"].includes(r.key.toLowerCase()))return;const o=r.currentTarget.value;/^[0-9]$/.test(r.key)||r.key==="."&&!o.includes(".")||r.key==="-"&&o.length===0&&!o.includes("-")||t.includes(r.key)||r.preventDefault()},qs=r=>{const t=document.getElementById(r);if(t){const o=t.getBoundingClientRect(),n=window.scrollY+o.top-80;window.scrollTo({top:n,behavior:"smooth"})}};function Zs(r){const t=r.toLowerCase();if(["kb","mb","gb"].find(s=>t.endsWith(s)))return r;const l=Number(r);if(isNaN(l))throw new Error("Invalid size format");return l>=1e6?`${(l/1e6).toFixed(2)}MB`:l>=1e3?`${(l/1e3).toFixed(2)}KB`:`${l}B`}function Gs(r){const t=r.split("/");return t[t.length-1]}const Qs=r=>{var t,o;return e.jsxs(f.Box,{width:"width-full",paddingInline:"md",height:"height-full",direction:"row",justify:"space-between",align:"center",onClick:r.handleOnClickFile,fullHeight:!0,paddingBlock:"md",id:"file-item",borderRadius:"rounded-md",style:{border:"1px solid var(--sa-border-subtle)",cursor:"pointer"},children:[e.jsxs(ie.Flex,{direction:"row",align:"center",gap:"sm",style:{flex:1,minWidth:0},children:[e.jsx(M.Icon,{name:"DocumentFilled",size:"lg",style:{color:"var(--sa-icon-brand)",width:30,height:30,flexShrink:0}}),e.jsxs(ie.Flex,{direction:"column",style:{minWidth:0,flex:1},children:[e.jsx(D.Text,{fontWeight:"bold",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},children:r.defaultFile?Gs(r.defaultFile.url):(t=r.fileSelected)==null?void 0:t.name}),r.defaultFile?(r.defaultFile.size||r.defaultFile.date)&&e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[r.defaultFile.size&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:r.defaultFile.size}),r.defaultFile.size&&r.defaultFile.date&&e.jsx(M.Icon,{name:"Dot",size:"xs"}),r.defaultFile.date&&e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:r.defaultFile.date})]}):e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",children:Zs(((o=r.fileSelected)==null?void 0:o.size.toString())||"100000")}),e.jsx(M.Icon,{name:"Dot",size:"xs"}),e.jsx(D.Text,{fontSize:"sm",fontWeight:"medium",style:{textWrap:"nowrap"},children:pl(new Date)})]})]})]}),e.jsx(j.Button,{size:"xs",variant:"tertiary",tone:"error",type:"button",onClick:n=>{n.stopPropagation(),r.handleOnDeleteFile()},iconLeft:e.jsx(M.Icon,{name:"Trash1"})})]})},bl=({status:r="default",labelPosition:t="outside-top",...o})=>{var p;const n=d.useRef(null),l=()=>{if(o.defaultFile){window.open(o.defaultFile.url);return}n.current&&n.current.click()},s=De.useMediaQuery("md"),c=r==="error"||typeof o.errorMessage=="string"&&!!o.errorMessage,i=o.label?e.jsxs(ie.Flex,{direction:"row",align:"center",gap:"xs",children:[e.jsx(D.Text,{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-primary)"},children:o.label}),o.optional&&e.jsx("span",{style:{background:"var(--sa-background-neutral)",border:"1px solid var(--sa-border-subtle)",borderRadius:"4px",padding:"0 8px",fontSize:"10px",fontWeight:500,lineHeight:"18px",color:"var(--sa-text-primary)",display:"inline-flex",alignItems:"center"},children:"Optional"}),o.required&&e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--sa-text-error)"},children:"*"})]}):null,a=o.description?e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.description}):null,h=e.jsxs(e.Fragment,{children:[o.helperText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-subtlest, #6b6e76)",lineHeight:"18px"},children:o.helperText}),o.errorText&&r==="error"&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorText}),o.errorMessage&&!o.errorText&&e.jsx(D.Text,{style:{fontSize:"12px",fontWeight:400,color:"var(--sa-text-error, #a4133c)",lineHeight:"18px"},children:o.errorMessage})]}),y=e.jsx("input",{type:"file",style:{display:"none"},ref:n,onChange:C=>{var E;return o.handleOnChangeFile(((E=C.target.files)==null?void 0:E.item(0))||null)},accept:(p=o.fileSupportOption)==null?void 0:p.map(C=>"."+(C==null?void 0:C.toLowerCase())).join(", ")}),b=e.jsxs(f.Box,{direction:"column",fullWidth:!0,style:{minHeight:"69px"},borderRadius:"rounded-md",display:"flex",justify:"center",align:"center",cursor:"pointer",gap:"md",...o.containerProps,children:[y,(o.fileSelected||o.defaultFile)&&e.jsx(Qs,{fileSelected:o.fileSelected,defaultFile:o.defaultFile,handleOnDeleteFile:o.handleOnDeleteFile,handleOnClickFile:l}),!o.fileSelected&&!o.defaultFile&&e.jsx(ws,{fileSupports:o.fileSupportOption,isDesktop:s,errorMessage:c?o.errorText||o.errorMessage||" ":void 0,status:c?"error":"default",handleOnClick:l,handleOnFileChange:o.handleOnChangeFile})]});return t==="outside-left"?e.jsxs(ie.Flex,{direction:"row",align:"flex-start",gap:"sm",style:{width:"100%"},children:[e.jsxs(ie.Flex,{direction:"column",gap:"xs",style:{width:"40%",minWidth:"120px",paddingTop:"10px"},children:[i,a]}),e.jsxs(ie.Flex,{direction:"column",gap:"sm",style:{flex:1,minWidth:0},children:[b,h]})]}):e.jsxs(ie.Flex,{direction:"column",gap:"sm",style:{width:"100%"},children:[i,a,b,h]})},Us=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(bl,{...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},Js=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y,b;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"||t==="horizontal-inline"?"spacing-96":"sm",direction:t==="horizontal"||t==="horizontal-inline"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(Ke.Body3,{props:{color:"gray-500"},children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(me.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsx(f.Box,{gap:t==="horizontal-inline"?"xl":"md",direction:t==="horizontal-inline"?"row":"column",align:"flex-start",children:e.jsx(Xr,{of:(b=s.checkBoxesList)==null?void 0:b.map(p=>({...p,isChecked:s.checkBoxesAreChecked.includes(p.id)})),render:p=>p.renderBadge?e.jsxs(f.Box,{direction:"row",justify:"space-between",gap:"lg",...s.badgeContainerProps,children:[e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description}),p.renderBadge]}):e.jsx(tr.Checkbox,{name:p.name,value:p.id,checked:p.isChecked,onChange:C=>s.onChecked(C.target.value,p),label:p.name,description:p.description})})}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Ys=({position:r="vertical",size:t="md",fullWidth:o=!1,...n})=>{var s;const l=r==="horizontal-inline"||r==="horizontal-block"?t==="sm"?342:t==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:r==="horizontal-inline"||r==="horizontal-block"?"spacing-96":"sm",direction:r==="horizontal-inline"||r==="horizontal-block"?"row":"column",children:[e.jsx(fe,{condition:!!n.description||!!n.title,children:e.jsxs(f.Box,{direction:"column",customMaxWidth:l,fullWidth:o,children:[n.title&&e.jsx(ye,{children:n.title}),e.jsx(fe,{condition:!!n.description,children:e.jsx(D.Text,{color:"gray-500",children:n.description})})]})}),e.jsx(f.Box,{gap:"sm",direction:r==="horizontal"||r==="horizontal-inline"?"row":"column",align:"flex-start",flexWrap:"wrap",children:e.jsx(Xr,{of:(s=n.radioList)==null?void 0:s.map(c=>({...c,isChecked:n.radioIsChecked===c.id})),render:({value:c,id:i,isChecked:a,subInput:h,label:y,description:b})=>e.jsxs(f.Box,{direction:"column",gap:"xs",customMaxWidth:l,children:[e.jsx(at.Radio,{id:`${i.toString()}-${c}`,name:n.groupName||y,label:y,value:c,checked:a,onChange:p=>n.onChecked({id:i,label:p.target.name,value:p.target.value}),disabled:n.disableAll},i),b&&e.jsx(D.Text,{color:"gray-500",style:{marginLeft:28},children:b}),h]})})}),n.errorMessage&&e.jsx(cr,{message:n.errorMessage})]})},Xs=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(it.Textarea,{ref:l.inputRef,size:r,...l.inputProps,status:l.errorMessage?"error":"default"}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})},$s=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",required:n=!1,fullWidth:l=!1,...s})=>{var i,a,h;const c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:n,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:l,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=s.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=s.tooltip)==null?void 0:a.label,arrowPosition:(h=s.tooltip)==null?void 0:h.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.titleDescription,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.titleDescription})})]})}),e.jsx(xr.Toggle,{checked:s.checked,onChange:s.onChange,label:s.label,description:s.description}),s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})},Ks=({variant:r="primary",size:t="md",...o})=>{const n=Cr.useColor(),l=c=>{var a,h,y,b,p,C;if(!c)return;const i=o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary"?"var(--sa-text-subtle, #8c8f97)":r==="secondary-danger"?(h=(a=n==null?void 0:n.computed)==null?void 0:a.red)==null?void 0:h[600]:r==="secondary-primary"?(b=(y=n==null?void 0:n.computed)==null?void 0:y.blue)==null?void 0:b[700]:(C=(p=n==null?void 0:n.computed)==null?void 0:p.gray)==null?void 0:C[50];return e.jsx(M.Icon,{name:c,size:t,style:{color:i}})},s=()=>{var i,a,h,y;if(r!=="secondary-danger"&&r!=="secondary-primary")return o.title;const c={color:o.disabled?"var(--sa-text-disable, #181a198f)":r==="secondary-danger"?(a=(i=n==null?void 0:n.computed)==null?void 0:i.red)==null?void 0:a[600]:(y=(h=n==null?void 0:n.computed)==null?void 0:h.blue)==null?void 0:y[700]};switch(t){case"xs":return e.jsx(Ke.Body2,{props:{style:c},children:o.title});case"sm":case"md":return e.jsx(Ke.SubH3,{props:{style:c},children:o.title});case"lg":return e.jsx(Ke.SubH2,{props:{style:c},children:o.title});default:return o.title}};return e.jsx(j.Button,{fullWidth:!0,disabled:o.disabled,primary:r==="primary",secondary:r==="secondary"||r==="secondary-danger"||r==="secondary-primary",success:r==="success",onClick:o.onClick,type:o.type,iconLeft:l(o.iconLeft),iconRight:l(o.iconRight),size:t,children:s()})},Rs=r=>e.jsx(Ke.H5,{props:{...r},children:r.title}),ec=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var i,a,h;const s=l.hideMessageError||!1,c=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",onClick:l.onClickContainer,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:c,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((i=l.tooltip)!=null&&i.label),children:e.jsx(me.Tooltip,{label:(a=l.tooltip)==null?void 0:a.label,arrowPosition:(h=l.tooltip)==null?void 0:h.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(f.Box,{direction:"column",style:{width:t==="horizontal"&&l.customWidth?l.customWidth:t==="horizontal"?"343px":""},children:e.jsx(fr.StarasiaDate,{size:r,...l.inputProps,status:l.errorMessage?"error":void 0})}),!s&&l.errorMessage&&e.jsx(cr,{message:l.errorMessage})]})]})};async function rc(r,t){const o=new Image;o.src=r,await new Promise((s,c)=>{o.onload=s,o.onerror=c});const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const l=n.getContext("2d",{alpha:!0});if(!l)throw new Error("No 2D context");return l.drawImage(o,t.x,t.y,t.width,t.height,0,0,t.width,t.height),new Promise((s,c)=>{n.toBlob(i=>{if(!i)return c("Canvas is empty");const a=new File([i],"cropped.png",{type:"image/png"});s(a)},"image/png")})}const vl={"1:1":1,"4:3":4/3,"16:9":16/9,"3:4":3/4,"9:16":9/16,"2:3":2/3,"3:2":3/2,"32:9":32/9},Cl=d.forwardRef(({handleUpload:r,urlImage:t,isUploading:o,croppedImage:n,setCroppedImage:l,size:s="96",aspect:c="1:1",containerProps:i,maxFileSize:a=2,onError:h},y)=>{const b=De.useMediaQuery("md"),[p,C]=d.useState(!1),[E,w]=d.useState(null),[L,F]=d.useState(!1),[I,B]=d.useState({x:0,y:0}),[k,H]=d.useState(1),[W,S]=d.useState(null);d.useEffect(()=>{t===null&&l(null)},[t]);const z=d.useCallback((V,N)=>{S(N)},[]),O=V=>{var ve;const N=(ve=V.target.files)==null?void 0:ve[0];if(!N)return;const se=new FileReader;se.onload=()=>{w(se.result),F(!0)},se.readAsDataURL(N)},Y=async()=>{if(!(!E||!W))try{const V=await rc(E,W);if(a&&V.size>a*1024*1024){h==null||h(`Ukuran file maksimal ${a}MB`);return}r==null||r(V);const N=URL.createObjectURL(V);l(N,V),F(!1)}catch{h==null||h("Gagal memproses gambar")}},X=d.useRef(null),q=()=>{X.current&&X.current.click()};d.useImperativeHandle(y,()=>({openFileDialog:()=>{var V;(V=X.current)==null||V.click()}}));const Z=parseInt(s,10),K=vl[c];let te,_;return K>=1?(_=Z,te=Z*K):(te=Z,_=Z/K),e.jsxs(f.Box,{direction:"column",display:"flex",position:"relative",bg:(i==null?void 0:i.bg)||"gray-200",borderStyle:(i==null?void 0:i.borderStyle)||"border-none",borderColor:(i==null?void 0:i.borderColor)||"gray-200",borderWidth:(i==null?void 0:i.borderWidth)||"border-2",borderRadius:(i==null?void 0:i.borderRadius)||"rounded-md",overflow:"overflow-hidden",align:"center",justify:"center",style:{width:i!=null&&i.fullWidth?"100%":`${te}px`,height:i!=null&&i.fullWidth?"auto":`${_}px`,aspectRatio:K,flexShrink:0},onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[n||t?e.jsx("img",{src:n||t||void 0,alt:"Profile",style:{objectFit:"cover",width:"100%",height:"100%"}}):e.jsx(f.Box,{display:"flex",direction:"column",align:"center",justify:"center",padding:"spacing-4",children:e.jsx(M.Icon,{name:"Image",style:{color:"var(--sa-text-subtle, #8c8f97)",width:Number(s)/2<40?Number(s)/2:40,height:Number(s)/2<40?Number(s)/2:40}})}),e.jsxs(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",cursor:"pointer",style:{inset:0,backgroundColor:"var(--sa-color-black-alpha-a30, #080f214a)",opacity:p?1:0,transition:"opacity 0.3s ease-in-out"},onClick:q,children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",onChange:O,disabled:o,style:{display:"none"}}),e.jsxs(f.Box,{display:"flex",align:"center",gap:"spacing-2",direction:"row",children:[e.jsx(M.Icon,{name:"Edit3",style:{color:"var(--sa-background-primary, #ffffff)"}}),e.jsx(fe,{condition:s.toNumber()>80,children:e.jsx(D.Text,{color:"gray-50",fontSize:s.toNumber()>80?"sm":"md",fontWeight:"medium",children:"Edit Image"})})]})]}),o&&e.jsx(f.Box,{direction:"column",position:"absolute",display:"flex",align:"center",justify:"center",style:{inset:0,zIndex:20,backgroundColor:"var(--sa-color-white-alpha-a80, #e5e9f640)"},children:e.jsx(f.Box,{direction:"column",borderRadius:"rounded-full",style:{animation:"spin 1s linear infinite",border:"2px solid transparent",height:"2rem",width:"2rem"},borderColor:"info-600"})}),L&&Pr.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:19999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>F(!1),children:e.jsxs("div",{style:{backgroundColor:"var(--sa-background-primary)",borderRadius:"var(--sa-radii-md)",boxShadow:"0 20px 60px rgba(0,0,0,0.3)",overflow:"hidden",width:b?c==="1:1"?"min(90vw, 480px)":`min(90vw, ${te*2}px)`:"calc(100vw - 2rem)",display:"flex",flexDirection:"column"},onClick:V=>V.stopPropagation(),children:[e.jsx("div",{style:{position:"relative",width:"100%",height:"20rem",backgroundColor:"var(--sa-color-gray-100)"},children:E&&e.jsx(Nl,{image:E,crop:I,zoom:k,aspect:c?vl[c]:void 0,onCropChange:B,onZoomChange:H,onCropComplete:z,objectFit:"contain",minZoom:.5,restrictPosition:!1})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",padding:"0.75rem 1rem",borderTop:"1px solid var(--sa-border-subtle)"},children:[e.jsx(j.Button,{size:"sm",secondary:!0,onClick:()=>F(!1),children:"Cancel"}),e.jsx(j.Button,{size:"sm",primary:!0,onClick:Y,children:"Crop"})]})]})}),document.body)]})}),tc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,required:l=!1,...s})=>{var a,h,y;const c=s.hideMessageError||!1,i=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...s.containerProps,children:[s.title&&e.jsx(fe,{condition:!!l,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsx(ye,{children:s.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:i,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:s.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((a=s.tooltip)!=null&&a.label),children:e.jsx(me.Tooltip,{label:(h=s.tooltip)==null?void 0:h.label,arrowPosition:(y=s.tooltip)==null?void 0:y.arrowPosition,...s.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!s.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:s.description})})]})}),e.jsxs(ie.Flex,{direction:"column",gap:"xs",children:[e.jsx(Cl,{...s.inputProps}),!c&&s.errorMessage&&e.jsx(cr,{message:s.errorMessage})]})]})},oc=({size:r="md",direction:t="vertical",requiredTitle:o="(Required)",fullWidth:n=!1,...l})=>{var c,i,a;const s=t==="horizontal"?r==="sm"?342:r==="lg"?400:342:void 0;return e.jsxs(f.Box,{gap:t==="horizontal"?"spacing-96":"sm",direction:t==="horizontal"?"row":"column",...l.containerProps,children:[l.title&&e.jsx(fe,{condition:!!l.inputProps.required,fallback:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsx(ye,{children:l.title}),e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})]}),children:e.jsxs(f.Box,{direction:"column",customMaxWidth:s,fullWidth:n,children:[e.jsxs(ie.Flex,{direction:"row",gap:"xs",align:"center",children:[e.jsx(ye,{fontSize:r,children:l.title}),e.jsx(ye,{color:"error",fontSize:r,children:o}),e.jsx(fe,{condition:!!((c=l.tooltip)!=null&&c.label),children:e.jsx(me.Tooltip,{label:(i=l.tooltip)==null?void 0:i.label,arrowPosition:(a=l.tooltip)==null?void 0:a.arrowPosition,...l.tooltip,children:e.jsx(M.Icon,{name:"InfoCircle",size:r==="lg"?"sm":"xs",style:{color:"var(--sa-color-info-500, #00abeb)",marginTop:"6px"}})})})]}),e.jsx(fe,{condition:!!l.description,children:e.jsx(D.Text,{fontSize:r,color:"gray-500",children:l.description})})]})}),l.inputProps.extended&&l.inputProps.extended]})},lc=({items:r,id:t,handleOnUpdate:o,width:n,toggleShow:l=!0,disabled:s=!1})=>{var y;const[c,i]=d.useState([]);d.useEffect(()=>{r&&i([...r.map(b=>({id:b.id,isActive:b.isActive}))])},[r]);const a=(y=c.find(b=>b.id===t))==null?void 0:y.isActive,h=d.useCallback(()=>{i(b=>b.map(p=>p.id===t?{...p,isActive:!p.isActive}:p)),o&&o(!a)},[t,o,a]);return e.jsx(f.Box,{direction:"row",gap:"md",style:{width:n},children:l&&e.jsx(xr.Toggle,{disabled:s,checked:a,onChange:h,label:a?"Active":"Inactive"})})},nc={InputText:vs,InputDropdown:Cs,InputSingleFile:Us,CheckBoxOptions:Js,RadioOptions:Ys,InputTextArea:Xs,ToggleForm:$s,ActionButton:Ks,FormTitle:Rs,InputDate:ec,InputImgFile:tc,Custom:oc},xl=({customBottom:r})=>{const[t,o]=d.useState(!1),n=()=>{window.scrollY>window.screenY?o(!0):o(!1)},l=()=>{window.scrollTo({top:0,behavior:"smooth"})};return d.useEffect(()=>(window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}),[]),e.jsx(f.Box,{direction:"column",style:{position:"fixed",bottom:0,right:0},children:e.jsx(f.Box,{direction:"column",position:"absolute",style:{bottom:r||"1.6rem",right:"2rem",transform:t?"scale(1)":"scale(0)",transition:"transform 0.2s ease-in-out"},children:e.jsx(j.Button,{secondary:!0,size:"xs",onClick:l,type:"button",iconLeft:e.jsx(M.Icon,{width:16,size:"xs",name:"ArrowPullUp",style:{color:"var(--sa-background-brand, #04254f)"}})})})})},qe="sa-sidepanel-item",wl="sa-sidepanel-item-styles",sc=`
|
|
58
58
|
.${qe} {
|
|
59
59
|
display: block;
|
|
60
60
|
box-sizing: border-box;
|