import{u,a as h,b as p,r as g,j as e,L as m,O as j,s as f,t as y}from"./index-C-9v46qO.js";import{B as l}from"./button-B-2orO_-.js";import{c as i}from"./createLucideIcon-PnqOq2iY.js";import{S as N}from"./shopping-bag-Ql8Kfvna.js";import{P as b}from"./package-ZkUSb2Pi.js";import{T as w}from"./tags-CCeuQ4qa.js";import"./utils-BQHNewu7.js";const k=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],v=i("layout-dashboard",k);const _=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],L=i("log-out",_);const S=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],A=i("settings",S);const M=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],d=i("shield-alert",M);function P(){const a=u(),{user:s,loading:r,isStaff:n,roleLoading:x}=h(),o=p();g.useEffect(()=>{!r&&!s&&a({to:"/auth/login"})},[r,s,a]);const c=async()=>{await f.auth.signOut(),y.success("লগআউট সফল"),a({to:"/auth/login"})};return r||x?e.jsx("div",{className:"min-h-screen flex items-center justify-center text-muted-foreground",children:"লোড হচ্ছে..."}):s?n?e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsxs("header",{className:"bg-background border-b sticky top-0 z-30",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-4 h-14 flex items-center justify-between",children:[e.jsxs(m,{to:"/admin",className:"flex items-center gap-2",children:[o.logo_url?e.jsx("img",{src:o.logo_url,alt:o.site_name,className:"h-7 w-auto"}):e.jsx("span",{className:"font-script text-xl text-primary",children:o.site_name}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Admin"})]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:c,children:[e.jsx(L,{className:"h-4 w-4 mr-1"})," লগআউট"]})]}),e.jsxs("nav",{className:"max-w-7xl mx-auto px-4 flex gap-1 overflow-x-auto border-t",children:[e.jsx(t,{to:"/admin",icon:e.jsx(v,{className:"h-4 w-4"}),label:"ড্যাশবোর্ড",exact:!0}),e.jsx(t,{to:"/admin/orders",icon:e.jsx(N,{className:"h-4 w-4"}),label:"অর্ডার"}),e.jsx(t,{to:"/admin/products",icon:e.jsx(b,{className:"h-4 w-4"}),label:"প্রোডাক্ট"}),e.jsx(t,{to:"/admin/categories",icon:e.jsx(w,{className:"h-4 w-4"}),label:"ক্যাটাগরি"}),e.jsx(t,{to:"/admin/blacklist",icon:e.jsx(d,{className:"h-4 w-4"}),label:"ব্ল্যাকলিস্ট"}),e.jsx(t,{to:"/admin/settings",icon:e.jsx(A,{className:"h-4 w-4"}),label:"সেটিংস"})]})]}),e.jsx("main",{className:"max-w-7xl mx-auto px-4 py-6",children:e.jsx(j,{})})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",children:e.jsxs("div",{className:"max-w-md text-center space-y-4",children:[e.jsx(d,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsx("h1",{className:"text-2xl font-semibold",children:"অ্যাডমিন অ্যাক্সেস নেই"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"আপনার অ্যাকাউন্টে এখনো অ্যাডমিন বা স্টাফ রোল দেওয়া হয়নি। প্রথম অ্যাডমিনকে SQL এর মাধ্যমে রোল দিতে হবে।"}),e.jsxs("div",{className:"rounded-md bg-muted p-3 text-left font-mono text-xs",children:["INSERT INTO public.user_roles (user_id, role)",e.jsx("br",{}),"VALUES ('",s.id,"', 'admin');"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"আপনার ইউজার ID উপরে দেখানো হয়েছে।"}),e.jsx(l,{variant:"outline",onClick:c,children:"লগআউট"})]})}):null}function t({to:a,icon:s,label:r,exact:n}){return e.jsxs(m,{to:a,activeOptions:{exact:n},className:"flex items-center gap-2 px-3 py-2.5 text-sm font-medium text-muted-foreground hover:text-foreground border-b-2 border-transparent transition-colors whitespace-nowrap",activeProps:{className:"text-primary border-primary"},children:[s," ",r]})}export{P as component};
