"use strict";(()=>{var e={};e.id=7738,e.ids=[7738],e.modules={7849:e=>{e.exports=require("next/dist/client/components/action-async-storage.external")},2934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},5403:e=>{e.exports=require("next/dist/client/components/request-async-storage.external")},4580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},4749:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external")},5869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},7147:e=>{e.exports=require("fs")},1017:e=>{e.exports=require("path")},1745:(e,t,a)=>{a.r(t),a.d(t,{GlobalError:()=>i.a,__next_app__:()=>p,originalPathname:()=>x,pages:()=>o,routeModule:()=>m,tree:()=>d});var s=a(482),r=a(9108),n=a(2563),i=a.n(n),l=a(8300),c={};for(let e in l)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(c[e]=()=>l[e]);a.d(t,c);let d=["",{children:["(dashboard)",{children:["admin",{children:["licenses",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(a.bind(a,7789)),"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\(dashboard)\\admin\\licenses\\page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(a.bind(a,1824)),"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\(dashboard)\\layout.tsx"]}]},{layout:[()=>Promise.resolve().then(a.bind(a,1342)),"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\layout.tsx"],"not-found":[()=>Promise.resolve().then(a.bind(a,8206)),"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\not-found.tsx"]}],o=["C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\(dashboard)\\admin\\licenses\\page.tsx"],x="/(dashboard)/admin/licenses/page",p={require:a,loadChunk:()=>Promise.resolve()},m=new s.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/(dashboard)/admin/licenses/page",pathname:"/admin/licenses",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},7789:(e,t,a)=>{a.r(t),a.d(t,{default:()=>l});var s=a(5036),r=a(2509),n=a(9829),i=a(867);async function l(){let e=await (0,r.e)(),{data:{user:t}}=await e.auth.getUser();t||(0,i.redirect)("/login"),await (0,n.j)(t.id)||(0,i.redirect)("/dashboard");let a=(0,r.createAdminClient)(),{data:l,error:c}=await a.from("licenses").select(`
      id,
      license_key,
      customer_email,
      status,
      expires_at,
      created_at,
      tenant:tenants!licenses_tenant_id_fkey (
        id,
        name,
        slug
      )
    `).order("created_at",{ascending:!1});c&&console.error("Error fetching licenses:",c);let d=await Promise.all((l||[]).map(async e=>{let{count:t}=await a.from("sites").select("*",{count:"exact",head:!0}).eq("license_id",e.id),s={...e,tenant:Array.isArray(e.tenant)?e.tenant[0]:e.tenant,site_count:t||0};return s.customer_email||console.log("License missing customer_email:",{id:s.id,license_key:s.license_key,customer_email:s.customer_email}),s}));return(0,s.jsxs)("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:(0,s.jsxs)("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"All Licenses"}),s.jsx("p",{className:"text-gray-600 mt-1",children:"Manage all licenses across all tenants"})]})}),(0,s.jsxs)("div",{className:"card-modern overflow-hidden",children:[s.jsx("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[s.jsx("thead",{className:"bg-gray-50",children:(0,s.jsxs)("tr",{children:[s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"License Key"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Customer Email"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Tenant"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Sites"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Expires At"}),s.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"})]})}),s.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:d.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-gray-50",children:[s.jsx("td",{className:"px-6 py-4",children:s.jsx("code",{className:"text-sm font-mono text-gray-900 break-all",children:e.license_key})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("div",{className:"text-sm text-gray-900",children:e.customer_email?s.jsx("a",{href:`mailto:${e.customer_email}`,className:"text-indigo-600 hover:text-indigo-800 hover:underline",children:e.customer_email}):s.jsx("span",{className:"text-gray-400 italic",children:"No email"})})}),(0,s.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap",children:[s.jsx("div",{className:"text-sm font-medium text-gray-900",children:e.tenant?.name||"N/A"}),s.jsx("div",{className:"text-sm text-gray-500",children:e.tenant?.slug||""})]}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${"active"===e.status?"bg-green-100 text-green-800":"revoked"===e.status?"bg-red-100 text-red-800":"expired"===e.status?"bg-yellow-100 text-yellow-800":"bg-gray-100 text-gray-800"}`,children:e.status})}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:e.site_count}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.expires_at?new Date(e.expires_at).toLocaleDateString():"Never"}),s.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:new Date(e.created_at).toLocaleDateString()})]},e.id))})]})}),!d.length&&s.jsx("div",{className:"text-center py-12",children:s.jsx("p",{className:"text-gray-500",children:"No licenses found."})})]})]})}},9829:(e,t,a)=>{a.d(t,{j:()=>r});var s=a(2509);async function r(e){try{let t=(0,s.createAdminClient)(),{data:a,error:r}=await t.from("platform_users").select("role").eq("user_id",e).eq("role","super_admin").single();if(r||!a)return!1;return"super_admin"===a.role}catch(e){return console.error("Error checking super admin status:",e),!1}}}};var t=require("../../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),s=t.X(0,[1638,9989,665,1476,6040,867,9599],()=>a(1745));module.exports=s})();