import{r as o,s as h}from"./index-BH-cN4KT.js";const w=(...t)=>t.filter((e,s,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===s).join(" ").trim();const g=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const b=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,r)=>r?r.toUpperCase():s.toLowerCase());const C=t=>{const e=b(t);return e.charAt(0).toUpperCase()+e.slice(1)};var A={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const S=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const k=o.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:u="",children:n,iconNode:f,...d},l)=>o.createElement("svg",{ref:l,...A,width:e,height:e,stroke:t,strokeWidth:r?Number(s)*24/Number(e):s,className:w("lucide",u),...!n&&!S(d)&&{"aria-hidden":"true"},...d},[...f.map(([m,p])=>o.createElement(m,p)),...Array.isArray(n)?n:[n]]));const L=(t,e)=>{const s=o.forwardRef(({className:r,...u},n)=>o.createElement(k,{ref:n,iconNode:e,className:w(`lucide-${g(C(t))}`,`lucide-${t}`,r),...u}));return s.displayName=C(t),s};function v(){const[t,e]=o.useState(null),[s,r]=o.useState(null),[u,n]=o.useState([]),[f,d]=o.useState(!0),l=o.useCallback(async a=>{if(!a)return n([]);const{data:i}=await h.from("user_roles").select("role").eq("user_id",a);n((i??[]).map(c=>c.role))},[]);o.useEffect(()=>{const{data:{subscription:a}}=h.auth.onAuthStateChange((i,c)=>{e(c),r(c?.user??null),setTimeout(()=>l(c?.user?.id),0)});return h.auth.getSession().then(({data:i})=>{e(i.session),r(i.session?.user??null),l(i.session?.user?.id).finally(()=>d(!1))}),()=>a.unsubscribe()},[l]);const m=a=>u.includes(a),p=u.some(a=>a==="admin"||a==="editor"||a==="writer");return{session:t,user:s,roles:u,loading:f,hasRole:m,isStaff:p}}export{L as c,v as u};
