import{r as c,j as r}from"./sikshya-admin-sikshya-react-E_TY_un4.js";import{N as u}from"./sikshya-admin.js";import{ad as f}from"./sikshya-admin-sikshya-vendor-BVAk_Gwu.js";function m(s,a,o=!0){const t=c.useRef(a);t.current=a,c.useEffect(()=>{if(!o)return;const n=e=>{var d;const l=e.target;l instanceof Node&&((d=s.current)!=null&&d.contains(l)||t.current())},i=e=>{e.key==="Escape"&&t.current()};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n,{passive:!0}),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n),document.removeEventListener("keydown",i)}},[o,s])}const b="inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/40 focus-visible:ring-offset-1 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 dark:focus-visible:ring-offset-slate-900";function k({columns:s,visibility:a,onChange:o}){const[t,n]=c.useState(!1),i=c.useRef(null);return m(i,()=>n(!1),t),s.length===0?null:r.jsxs("div",{ref:i,className:"relative",children:[r.jsxs("button",{type:"button","aria-expanded":t,"aria-haspopup":"true",className:b,onClick:()=>n(e=>!e),children:[r.jsx(u,{name:"columns",className:"h-4 w-4 text-slate-500 dark:text-slate-400"}),f("Columns","sikshya"),r.jsx(u,{name:"chevronDown",className:"h-3.5 w-3.5 opacity-60"})]}),t?r.jsxs("div",{className:"absolute right-0 z-30 mt-1 w-56 rounded-xl border border-slate-200 bg-white p-2 shadow-lg ring-1 ring-black/5 dark:border-slate-700 dark:bg-slate-900 dark:ring-white/10",children:[r.jsx("p",{className:"px-2 pb-1 text-xs font-semibold uppercase tracking-wide text-slate-400",children:f("Visible columns","sikshya")}),r.jsx("ul",{className:"max-h-64 overflow-auto",children:s.map(e=>r.jsx("li",{children:r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-slate-50 dark:hover:bg-slate-800",children:[r.jsx("input",{type:"checkbox",className:"h-4 w-4 shrink-0 rounded border-slate-300 text-brand-600 focus:outline-none focus:ring-2 focus:ring-brand-500/40 focus:ring-offset-1 dark:border-slate-600 dark:bg-slate-700 dark:focus:ring-offset-slate-900",checked:a[e.id]??!0,onChange:l=>o(e.id,l.target.checked)}),r.jsx("span",{className:"text-sm text-slate-700 dark:text-slate-200",children:e.label})]})},e.id))})]}):null]})}const h="sikshya_cols_";function v(s){return`${h}${s}`}function y(s,a){const o={};for(const t of a)o[t.id]=!t.defaultHidden;try{const t=localStorage.getItem(s);if(!t)return o;const n=JSON.parse(t),i={...o};for(const e of a)typeof n[e.id]=="boolean"&&(i[e.id]=n[e.id]);return i}catch{return o}}function w(s,a){try{localStorage.setItem(s,JSON.stringify(a))}catch{}}export{k as C,v as c,y as l,w as s};
