@zenith-open/zenithcms-admin 1.0.0-beta.8 → 1.0.0-beta.9

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.
Files changed (35) hide show
  1. package/dist/assets/{ApiExplorerPage-DhdnjvFP.js → ApiExplorerPage-85UWt1EW.js} +1 -1
  2. package/dist/assets/{ApiExplorerPage-DhdnjvFP.js.map → ApiExplorerPage-85UWt1EW.js.map} +1 -1
  3. package/dist/assets/{AuditLogPage-TYWW1lG9.js → AuditLogPage-CwULx1tr.js} +1 -1
  4. package/dist/assets/{AuditLogPage-TYWW1lG9.js.map → AuditLogPage-CwULx1tr.js.map} +1 -1
  5. package/dist/assets/{BlockBuilderPage-CdheJ_nw.js → BlockBuilderPage-XD1IjOgx.js} +1 -1
  6. package/dist/assets/{BlockBuilderPage-CdheJ_nw.js.map → BlockBuilderPage-XD1IjOgx.js.map} +1 -1
  7. package/dist/assets/{CollectionHooksPage-CbnXaL4D.js → CollectionHooksPage-DIaSrKDj.js} +1 -1
  8. package/dist/assets/{CollectionHooksPage-CbnXaL4D.js.map → CollectionHooksPage-DIaSrKDj.js.map} +1 -1
  9. package/dist/assets/{CollectionsPage-PZFwuhHd.js → CollectionsPage-CL_t5JRI.js} +1 -1
  10. package/dist/assets/{CollectionsPage-PZFwuhHd.js.map → CollectionsPage-CL_t5JRI.js.map} +1 -1
  11. package/dist/assets/{ComponentBuilderPage-BC4Ea9AX.js → ComponentBuilderPage-C58Rr1cu.js} +1 -1
  12. package/dist/assets/{ComponentBuilderPage-BC4Ea9AX.js.map → ComponentBuilderPage-C58Rr1cu.js.map} +1 -1
  13. package/dist/assets/{DashboardBuilder-C9W1ggsK.js → DashboardBuilder-Chjyqyb7.js} +1 -1
  14. package/dist/assets/{DashboardBuilder-C9W1ggsK.js.map → DashboardBuilder-Chjyqyb7.js.map} +1 -1
  15. package/dist/assets/{PluginsPage-jOgKwIzK.js → PluginsPage-DAR4Fsz-.js} +1 -1
  16. package/dist/assets/{PluginsPage-jOgKwIzK.js.map → PluginsPage-DAR4Fsz-.js.map} +1 -1
  17. package/dist/assets/{RedirectsPage-CpZ6qVGA.js → RedirectsPage-DfMTJsac.js} +1 -1
  18. package/dist/assets/{RedirectsPage-CpZ6qVGA.js.map → RedirectsPage-DfMTJsac.js.map} +1 -1
  19. package/dist/assets/{SchemaBuilderPage-D6jCyURY.js → SchemaBuilderPage-BYprOkEv.js} +1 -1
  20. package/dist/assets/{SchemaBuilderPage-D6jCyURY.js.map → SchemaBuilderPage-BYprOkEv.js.map} +1 -1
  21. package/dist/assets/{SettingsPage-BZn_S20X.js → SettingsPage-B2r_uNVc.js} +1 -1
  22. package/dist/assets/{SettingsPage-BZn_S20X.js.map → SettingsPage-B2r_uNVc.js.map} +1 -1
  23. package/dist/assets/{SpatialEditor-PCM56yAC.js → SpatialEditor-BohlovfE.js} +1 -1
  24. package/dist/assets/{SpatialEditor-PCM56yAC.js.map → SpatialEditor-BohlovfE.js.map} +1 -1
  25. package/dist/assets/{TemplatesPage-CaZgoHEq.js → TemplatesPage-BplB2ksb.js} +1 -1
  26. package/dist/assets/{TemplatesPage-CaZgoHEq.js.map → TemplatesPage-BplB2ksb.js.map} +1 -1
  27. package/dist/assets/{TrashPage-BYiY8Xrn.js → TrashPage-BIhKrs5x.js} +1 -1
  28. package/dist/assets/{TrashPage-BYiY8Xrn.js.map → TrashPage-BIhKrs5x.js.map} +1 -1
  29. package/dist/assets/{index-BkjytCms.js → index-yE_3fruG.js} +3 -3
  30. package/dist/assets/index-yE_3fruG.js.map +1 -0
  31. package/dist/index.html +1 -1
  32. package/dist/sw.js +1 -1
  33. package/dist/sw.js.map +1 -1
  34. package/package.json +3 -3
  35. package/dist/assets/index-BkjytCms.js.map +0 -1
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CollectionsPage-PZFwuhHd.js","assets/rolldown-runtime-CNC7AqOf.js","assets/vendor-react-DQVTOTFO.js","assets/vendor-C-9IqjvY.js","assets/vendor-forms-BnBLxarY.js","assets/utils-fgvbH6CB.js","assets/CollectionHooksPage-CbnXaL4D.js","assets/AuditLogPage-TYWW1lG9.js","assets/MediaLibrary-BzXE95xo.js","assets/SpatialEditor-PCM56yAC.js","assets/useUnsavedGuard-CMMKQT9a.js","assets/EmptyState-X_SXKpQY.js","assets/ComponentBuilderPage-BC4Ea9AX.js","assets/SettingsPage-BZn_S20X.js","assets/ApiExplorerPage-DhdnjvFP.js","assets/PluginsPage-jOgKwIzK.js","assets/SchemaBuilderPage-D6jCyURY.js","assets/BlockBuilderPage-CdheJ_nw.js","assets/DashboardBuilder-C9W1ggsK.js","assets/TemplatesPage-CaZgoHEq.js","assets/SetupWizard-CBA43yJr.js","assets/RedirectsPage-CpZ6qVGA.js","assets/TrashPage-BYiY8Xrn.js","assets/BuilderPage-Iu8F_bN1.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CollectionsPage-CL_t5JRI.js","assets/rolldown-runtime-CNC7AqOf.js","assets/vendor-react-DQVTOTFO.js","assets/vendor-C-9IqjvY.js","assets/vendor-forms-BnBLxarY.js","assets/utils-fgvbH6CB.js","assets/CollectionHooksPage-DIaSrKDj.js","assets/AuditLogPage-CwULx1tr.js","assets/MediaLibrary-BzXE95xo.js","assets/SpatialEditor-BohlovfE.js","assets/useUnsavedGuard-CMMKQT9a.js","assets/EmptyState-X_SXKpQY.js","assets/ComponentBuilderPage-C58Rr1cu.js","assets/SettingsPage-B2r_uNVc.js","assets/ApiExplorerPage-85UWt1EW.js","assets/PluginsPage-DAR4Fsz-.js","assets/SchemaBuilderPage-BYprOkEv.js","assets/BlockBuilderPage-XD1IjOgx.js","assets/DashboardBuilder-Chjyqyb7.js","assets/TemplatesPage-BplB2ksb.js","assets/SetupWizard-CBA43yJr.js","assets/RedirectsPage-DfMTJsac.js","assets/TrashPage-BIhKrs5x.js","assets/BuilderPage-Iu8F_bN1.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{$t as t,A as n,An as r,Bn as i,Bt as a,C as o,Cn as s,Ct as c,En as l,F as u,Fn as d,Gt as f,H as p,I as m,Jn as h,Kn as g,Ln as _,Lt as v,M as y,Mn as b,Mt as x,N as S,Nn as C,Q as w,Qn as T,R as E,Rn as D,Rt as ee,St as O,Ut as k,V as te,Vt as A,Wt as ne,Xn as j,Xt as re,Yn as M,Z as N,Zt as P,_n as F,_r as I,a as L,an as ie,br as ae,bt as oe,c as R,cr as z,ct as se,d as B,dn as ce,dr as V,dt as le,er as ue,et as de,fn as fe,fr as pe,ft as me,gr as he,h as ge,hr as _e,i as ve,ir as H,it as ye,j as be,jn as xe,jt as Se,l as U,lr as Ce,lt as we,mr as Te,o as Ee,on as De,or as Oe,p as ke,pr as Ae,pt as je,r as Me,rr as W,s as Ne,sn as Pe,sr as Fe,t as Ie,tr as Le,u as Re,ur as ze,vr as Be,vt as Ve,wt as He,x as Ue,xr as We,y as Ge,yn as Ke,yr as qe,yt as Je,zn as Ye}from"./vendor-react-DQVTOTFO.js";import{a as G,i as Xe,o as K,s as q,t as J}from"./utils-fgvbH6CB.js";import{a as Y,i as X,n as Ze,r as Qe,t as $e}from"./vendor-forms-BnBLxarY.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(We(),1),et=e(qe(),1),Q=Be(),tt=Oe(e=>({user:null,isAuthenticated:!1,isLoading:!0,siteId:null,setUser:t=>e({user:t,isAuthenticated:!!t}),setSiteId:t=>e({siteId:t}),login:async(t,n)=>{try{let{user:r}=(await K.post(`/auth/login`,{email:t,password:n})).data.data;e({user:r,isAuthenticated:!0})}catch(e){throw console.error(`Login failed`,e),e}},logout:async()=>{try{await K.post(`/auth/logout`)}finally{localStorage.removeItem(`zenith_auth_state`),localStorage.removeItem(`activeSiteId`),e({user:null,isAuthenticated:!1,siteId:null}),window.location.href=`/login`}},checkAuth:async()=>{e({isLoading:!0});try{e({user:(await K.get(`/auth/me`)).data.data,isAuthenticated:!0})}catch{e({user:null,isAuthenticated:!1})}finally{e({isLoading:!1})}}}));function nt(){let[e,t]=(0,Z.useState)(typeof navigator<`u`?navigator.onLine:!0);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>t(!0),n=()=>t(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,n),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,n)}},[]),e}function rt(e){try{return typeof window>`u`?null:localStorage.getItem(e)}catch{return null}}function it(e,t){try{if(typeof window>`u`)return;localStorage.setItem(e,t)}catch{}}function at(e){try{if(typeof window>`u`)return;localStorage.removeItem(e)}catch{}}var ot=Oe(e=>({activeWorkspaceId:rt(`activeWorkspaceId`),activeSiteId:rt(`activeSiteId`),setActiveWorkspaceId:t=>{t?it(`activeWorkspaceId`,t):at(`activeWorkspaceId`),e({activeWorkspaceId:t})},setActiveSiteId:t=>{t?it(`activeSiteId`,t):at(`activeSiteId`),e({activeSiteId:t})}})),st=ae(),ct=({options:e,value:t,onChange:n,placeholder:r=`Select...`,disabled:i=!1,className:a,triggerClassName:o,menuClassName:s,headerText:c,footerAction:l,isSidebarOpen:u=!0,renderTrigger:d,renderOption:f})=>{let{theme:p}=G(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),[v,y]=(0,Z.useState)(null),b=e.find(e=>e.value===t)||null,x=(0,Z.useCallback)(()=>{if(!_.current)return;let e=_.current.getBoundingClientRect(),t=u?e.width:240;y({top:e.bottom+4+window.scrollY,left:u?e.left+window.scrollX:e.left-t+window.scrollX,width:t})},[u]);(0,Z.useEffect)(()=>{if(m)return x(),window.addEventListener(`scroll`,x,!0),window.addEventListener(`resize`,x),()=>{window.removeEventListener(`scroll`,x,!0),window.removeEventListener(`resize`,x)}},[m,x]),(0,Z.useEffect)(()=>{if(!m)return;let e=e=>{let t=e.target;_.current?.contains(t)||g.current?.contains(t)||h(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let S=e=>{i||(n(e.value),h(!1))},C=()=>{i||h(!m)},w=(0,Q.jsxs)(`button`,{type:`button`,onClick:C,disabled:i,className:J(`w-full flex items-center justify-between text-left transition-all duration-300 p-2.5`,`relative overflow-hidden shadow-sm`,p===`dark`?`bg-z-panel backdrop-blur-[12px] text-z-primary border border-z-border hover:border-z-border/50 hover:bg-app/85`:`bg-z-panel/65 backdrop-blur-[12px] text-z-primary border border-z-border hover:border-z-border/30 hover:bg-z-panel/85`,u?`rounded-none-none`:`rounded-none-none p-2 justify-center`,`hover:scale-[1.02] active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-z-active-border disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100`,o),children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center min-w-0 z-10`,u?`gap-3`:`gap-0 justify-center`),children:[b?.icon&&(0,Q.jsx)(`div`,{className:J(`rounded-none-none flex items-center justify-center text-lg flex-shrink-0 transition-colors duration-300`,p===`dark`?`bg-z-panel text-z-secondary`:`bg-[var(--z-bg-input)] text-z-secondary`,u?`w-8 h-8`:`w-10 h-10`),children:b.icon}),u&&(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[b?.description&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary dark:text-z-muted font-mono leading-none mb-1`,children:b.description}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold tracking-wide truncate leading-none`,children:b?b.label:r})]})]}),u&&(0,Q.jsx)(W.div,{animate:{rotate:m?180:0},transition:{duration:.2},className:`text-z-muted flex-shrink-0 z-10 ml-2`,children:(0,Q.jsx)(Pe,{size:14})})]});return(0,Q.jsxs)(`div`,{className:J(`relative transition-all duration-300`,a),children:[(0,Q.jsx)(`div`,{ref:_,onClick:()=>{i||(m||x(),h(!m))},children:d?d(b,m,C):w}),m&&v&&(0,st.createPortal)((0,Q.jsx)(H,{children:(0,Q.jsxs)(W.div,{ref:g,initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.15,ease:`easeOut`},style:{position:`absolute`,top:v.top,left:v.left,width:u?v.width:void 0,zIndex:9999,backgroundColor:`var(--z-border)`,backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`,boxShadow:`0 4px 30px rgba(0, 0, 0, 0.1)`},className:J(`rounded-none overflow-hidden border`,`border-z-border text-z-primary`,s),children:[c&&(0,Q.jsx)(`div`,{className:J(`px-4 py-2.5 border-b bg-z-panel/[0.01]`,`border-z-border`),children:(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-muted font-mono`,children:c})}),(0,Q.jsxs)(`div`,{className:`max-h-[220px] overflow-y-auto py-1 scrollbar-thin`,children:[e.map(e=>{let n=e.value===t;return f?(0,Q.jsx)(`div`,{onClick:()=>S(e),className:`cursor-pointer`,children:f(e,n)},String(e.value)):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S(e),className:J(`w-full px-4 py-2.5 flex items-center justify-between text-left transition-colors duration-200`,p===`dark`?`hover:bg-z-hover`:`hover:bg-app/[0.02]`,n&&(p===`dark`?`bg-z-panel text-z-secondary`:`bg-[var(--z-bg-input)] text-z-secondary`)),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-base flex-shrink-0`,children:e.icon}),(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold truncate`,children:e.label}),e.description&&(0,Q.jsx)(`span`,{className:`text-sm text-z-muted font-mono`,children:e.description})]})]}),n&&(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-none-none bg-z-border shadow-[0_0_8px_rgba(99,102,241,0.8)]`})]},String(e.value))}),e.length===0&&(0,Q.jsx)(`div`,{className:`px-4 py-6 text-center text-z-secondary text-xs`,children:`No options found.`})]}),l&&(0,Q.jsx)(`div`,{className:J(`border-t bg-z-panel`,`border-z-border`),children:l})]})}),document.body)]})},lt=({isSidebarOpen:e=!0})=>{let{theme:t}=G(),{activeWorkspaceId:n,setActiveWorkspaceId:r,activeSiteId:i,setActiveSiteId:a}=ot(Ee(e=>({activeWorkspaceId:e.activeWorkspaceId,setActiveWorkspaceId:e.setActiveWorkspaceId,activeSiteId:e.activeSiteId,setActiveSiteId:e.setActiveSiteId}))),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),u=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{u.current||(u.current=!0,(async()=>{try{let e=(await K.get(`/workspaces`)).data?.data||[];s(e);let t=n||e[0]?._id||e[0]?.id;t&&t!==n&&r(t),t&&l((await K.get(`/sites?workspaceId=${encodeURIComponent(t)}`)).data?.data||[])}catch{R.error(`Failed to load workspaces and sites`)}})())},[]);let d=async e=>{let t=(await K.get(`/sites?workspaceId=${encodeURIComponent(e)}`)).data?.data||[];return l(t),t},f=async e=>{if(e!==n)try{r(e);let t=await d(e),n=o.find(t=>(t._id||t.id)===e)?.name;if(t.length>0){let e=t[0],r=e._id||e.id;a(r),q.getState().setActiveSiteId(r,e.name),localStorage.setItem(`activeSiteName`,e.name),localStorage.setItem(`activeSiteSlug`,e.slug),K.defaults.headers[`x-zenith-site-id`]=r,R.success(`Switched to workspace: ${n}`),setTimeout(()=>{window.location.href=`/`},500)}else a(null),q.getState().setActiveSiteId(``),localStorage.removeItem(`activeSiteName`),localStorage.removeItem(`activeSiteSlug`),delete K.defaults.headers[`x-zenith-site-id`],R.success(`Switched to workspace: ${n} (no sites)`),setTimeout(()=>{window.location.href=`/`},500)}catch{R.error(`Failed to switch workspace`)}},p=e=>{let t=c.find(t=>(t._id||t.id)===e);if(!t||(t._id||t.id)===i)return;let n=t._id||t.id;a(n),q.getState().setActiveSiteId(n,t.name),localStorage.setItem(`activeSiteName`,t.name),localStorage.setItem(`activeSiteSlug`,t.slug),K.defaults.headers[`x-zenith-site-id`]=n,R.success(`Switched to site: ${t.name}`),setTimeout(()=>{window.location.href=`/`},500)},m=o.find(e=>(e._id||e.id)===n)||{name:`Default Workspace`},h=c.find(e=>(e._id||e.id)===i)||{name:localStorage.getItem(`activeSiteName`)||`Default Site`,icon:``},g=o.map(e=>({value:e._id||e.id,label:e.name,icon:(0,Q.jsx)(ce,{size:16,className:`text-[var(--z-accent)]`}),slug:e.slug})),_=c.map(e=>({value:e._id||e.id,label:e.name,icon:(0,Q.jsx)(`span`,{className:`text-[var(--z-accent)]`,children:e.icon||``}),slug:e.slug})),v=(n,r,i)=>{let a=n?n.label:m.name;return(0,Q.jsxs)(`button`,{type:`button`,onClick:i,className:J(`w-full flex items-center justify-between text-left transition-all duration-300 p-2.5`,`relative overflow-hidden shadow-sm`,t===`dark`?`bg-app/65 backdrop-blur-[12px] text-z-primary border border-z-border hover:border-[var(--z-accent)]/50 hover:bg-app/85 shadow-[0_4px_30px_rgba(0,0,0,0.1)]`:`bg-z-panel/65 backdrop-blur-[12px] text-z-primary border border-z-border hover:border-[var(--z-accent)]/30 hover:bg-z-panel/85`,e?`rounded-none`:`rounded-none p-2 justify-center`,`hover:scale-[1.02] active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-z-active-border`),title:e?void 0:a,children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center min-w-0 z-10`,e?`gap-3`:`gap-0 justify-center`),children:[(0,Q.jsx)(`div`,{className:J(`rounded-none-none flex items-center justify-center flex-shrink-0 transition-colors duration-300`,t===`dark`?`bg-[var(--z-accent)]/10 text-[var(--z-accent)]`:`bg-[var(--z-accent)]/5 text-[var(--z-accent)]`,e?`w-8 h-8`:`w-10 h-10`),children:(0,Q.jsx)(ce,{size:16})}),e&&(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-[var(--z-accent)] font-mono leading-none mb-1`,children:`WORKSPACE`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold tracking-wide truncate leading-none`,children:a})]})]}),e&&(0,Q.jsx)(W.div,{animate:{rotate:r?180:0},transition:{duration:.2},className:`text-z-sidebar-text flex-shrink-0 z-10 ml-2`,children:(0,Q.jsx)(Pe,{size:14})})]})},y=(n,r,i)=>{let a=n?n.icon:(0,Q.jsx)(`span`,{children:h.icon||``}),o=n?n.label:h.name;return(0,Q.jsxs)(`button`,{type:`button`,onClick:i,className:J(`w-full flex items-center justify-between text-left transition-all duration-300 p-2.5`,`relative overflow-hidden shadow-sm`,t===`dark`?`bg-app/65 backdrop-blur-[12px] text-z-primary border border-z-border hover:border-[var(--z-accent)]/50 hover:bg-app/85 shadow-[0_4px_30px_rgba(0,0,0,0.1)]`:`bg-z-panel/65 backdrop-blur-[12px] text-z-primary border border-z-border hover:border-[var(--z-accent)]/30 hover:bg-z-panel/85`,e?`rounded-none`:`rounded-none p-2 justify-center`,`hover:scale-[1.02] active:scale-[0.98] focus-visible:ring-2 focus-visible:ring-z-active-border`),title:e?void 0:o,children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center min-w-0 z-10`,e?`gap-3`:`gap-0 justify-center`),children:[(0,Q.jsx)(`div`,{className:J(`rounded-none flex items-center justify-center flex-shrink-0 transition-colors duration-300`,t===`dark`?`bg-[var(--z-accent)]/10 text-[var(--z-accent)]`:`bg-[var(--z-accent)]/5 text-[var(--z-accent)]`,e?`w-8 h-8`:`w-10 h-10`),children:a}),e&&(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-[var(--z-accent)] font-mono leading-none mb-1`,children:`TENANT / SITE`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold tracking-wide truncate leading-none`,children:o})]})]}),e&&(0,Q.jsx)(W.div,{animate:{rotate:r?180:0},transition:{duration:.2},className:`text-z-sidebar-text flex-shrink-0 z-10 ml-2`,children:(0,Q.jsx)(Pe,{size:14})})]})},b=(e,n)=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`w-full px-4 py-2.5 flex items-center justify-between text-left transition-colors duration-200`,t===`dark`?`hover:bg-z-hover`:`hover:bg-app/[0.02]`,n&&(t===`dark`?`bg-[var(--z-accent)]/10 text-[var(--z-accent)]`:`bg-[var(--z-accent)]/5 text-[var(--z-accent)]`)),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-base flex-shrink-0`,children:e.icon}),(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold truncate`,children:e.label}),(0,Q.jsxs)(`span`,{className:`text-sm text-z-sidebar-text font-mono`,children:[`/`,e.slug]})]})]}),n&&(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-none-none bg-[var(--z-accent)] shadow-sm`})]}),x=(e,n)=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`w-full px-4 py-2.5 flex items-center justify-between text-left transition-colors duration-200`,t===`dark`?`hover:bg-z-hover`:`hover:bg-app/[0.02]`,n&&(t===`dark`?`bg-[var(--z-accent)]/10 text-[var(--z-accent)]`:`bg-[var(--z-accent)]/5 text-[var(--z-accent)]`)),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-base flex-shrink-0`,children:e.icon}),(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold truncate`,children:e.label}),(0,Q.jsxs)(`span`,{className:`text-sm text-z-sidebar-text font-mono`,children:[`/`,e.slug]})]})]}),n&&(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-none-none bg-[var(--z-accent)] shadow-sm`})]}),S=(0,Q.jsxs)(z,{to:`/sites`,className:J(`w-full px-4 py-3 flex items-center justify-center gap-2 text-sm font-semibold font-mono transition-colors`,t===`dark`?`text-z-sidebar-text hover:text-z-primary hover:bg-z-hover`:`text-z-sidebar-text hover:text-z-primary hover:bg-app/[0.02]`),children:[(0,Q.jsx)(C,{size:12,className:`text-[var(--z-accent)]`}),`Manage Workspaces & Tenants`]});return(0,Q.jsxs)(`div`,{className:J(`py-3 flex flex-col gap-3 transition-all duration-300`,e?`px-4`:`px-2`,t===`dark`?`bg-app/10`:`bg-[var(--z-bg-input)]/20`),children:[(0,Q.jsx)(ct,{options:g,value:n||``,onChange:f,isSidebarOpen:e,headerText:`Switch Workspace`,footerAction:S,renderTrigger:v,renderOption:b,menuClassName:e?`left-0 right-0`:`left-12 w-[240px]`}),(0,Q.jsx)(ct,{options:_,value:i||``,onChange:p,isSidebarOpen:e,headerText:`Switch Tenant / Site`,renderTrigger:y,renderOption:x,menuClassName:e?`left-0 right-0`:`left-12 w-[240px]`})]})};function ut(){let e=q(e=>e.activeSiteId);return ve(e?[`systemMetadata`,e]:null,async()=>{let[e,t]=await Promise.all([K.get(`/system/health`).catch(()=>({data:{data:{}}})),K.get(`/schemas`).catch(()=>({data:{data:[]}}))]),n=e.data?.data||{},r=Array.isArray(t.data?.data)?t.data.data:[];return{...n,collections:r.filter(e=>!e.isGlobal),globals:r.filter(e=>e.isGlobal)}},{dedupingInterval:300*1e3})}function dt(e,t,n=`active`){let r=q(e=>e.activeSiteId);return ve(e?[`collectionItems`,r,e,n,t]:null,async()=>{let r=n===`trash`?`/${e}/trash?page=${t}`:`/${e}?page=${t}`,i=await K.get(r);return{items:i.data?.data||[],total:i.data?.meta?.pagination?.total||i.data?.data?.length||0}})}var ft=()=>{let e=Te(),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Z.useEffect)(()=>{let e=setTimeout(async()=>{if(n.length>=2){l(!0);try{s((await K.get(`/system/search?q=${encodeURIComponent(n)}`)).data.data)}catch{console.error(`Search failed`),s([])}finally{l(!1)}}else s([])},300);return()=>clearTimeout(e)},[n]);let m=(e,t)=>{if(!t||!e)return e||``;let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.split(RegExp(`(${n})`,`gi`)).map((e,n)=>e.toLowerCase()===t.toLowerCase()?(0,Q.jsx)(`span`,{className:`text-z-secondary font-semibold underline decoration-2 underline-offset-2`,children:e},n):e)},h=t=>{e(t),a(!1),r(``)},g=(0,Z.useMemo)(()=>[{label:`Dashboard`,path:`/`,icon:d,sub:`System Overview`},{label:`General Settings`,path:`/settings?tab=general`,icon:E,sub:`Site Name, URL, Maintenance`},{label:`Maintenance Mode`,path:`/settings?tab=general`,icon:Re,sub:`Protocol Override`},{label:`Security Protocols`,path:`/settings?tab=security`,icon:u,sub:`Session Lifespan & Auth`},{label:`SMTP Relay`,path:`/settings?tab=notifications`,icon:le,sub:`Email Configuration`},{label:`Operator Registry`,path:`/settings?tab=users`,icon:ge,sub:`User Management`},{label:`API Credentials`,path:`/settings?tab=keys`,icon:O,sub:`Access Tokens`},{label:`Infrastructure Stats`,path:`/settings?tab=database`,icon:ne,sub:`DB Health & Cache`},{label:`AI Intelligence`,path:`/settings?tab=ai`,icon:b,sub:`Neural Bridge Config`},{label:`Custom Styles`,path:`/settings?tab=appearance`,icon:de,sub:`CSS Overrides`},{label:`Audit Logs`,path:`/audit-logs`,icon:t,sub:`Security Events`},{label:`Plugin Marketplace`,path:`/plugins`,icon:Re,sub:`Modular Extensions`}],[]),_=(0,Z.useMemo)(()=>g.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||e.sub.toLowerCase().includes(n.toLowerCase())),[g,n]);return(0,Q.jsxs)(`div`,{ref:f,className:`relative z-[100]`,children:[(0,Q.jsxs)(W.div,{animate:{width:i?360:280},className:J(`flex items-center gap-2 px-4 py-2.5 rounded-none-none transition-all border`,i?`bg-z-panel border-z-border text-z-primary shadow-md ring-4 ring-z-active-border dark:bg-app dark:ring-z-active-border`:`bg-z-panel border-z-border text-z-secondary hover:bg-[var(--z-bg-input)] shadow-sm dark:bg-app/50 dark:border-z-border dark:text-z-muted dark:hover:bg-z-hover`),children:[(0,Q.jsx)(p,{size:16,className:J(`transition-colors`,i?`text-z-secondary `:`text-z-muted `)}),(0,Q.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),placeholder:`SEARCH SYSTEM...`,className:`bg-transparent border-none text-sm font-semibold flex-1 placeholder:text-z-muted dark:placeholder:text-z-secondary focus:outline-none focus:ring-0 rounded-none-none px-1`}),n&&(0,Q.jsx)(`button`,{onClick:()=>r(``),className:`p-1 hover:bg-[var(--z-bg-hover)] dark:hover:bg-[var(--z-bg-hover)] rounded-none-none transition-colors`,children:(0,Q.jsx)(B,{size:14,className:`text-z-secondary`})}),!i&&!n&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded-none-none border border-z-border dark:border-z-border bg-[var(--z-bg-input)] dark:bg-app/40 text-sm font-semibold text-z-secondary `,children:[(0,Q.jsx)(`span`,{children:`⌘`}),(0,Q.jsx)(`span`,{children:`K`})]})]}),(0,Q.jsx)(H,{children:i&&(n.length>0||o.length>0)&&(0,Q.jsxs)(W.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},transition:{duration:.2,ease:`easeOut`},className:`absolute top-full left-0 right-0 mt-3 bg-z-panel border border-z-border dark:bg-[#0a0a0a] dark:border-z-border rounded-none-none shadow-2xl overflow-hidden flex flex-col text-z-primary `,children:[(0,Q.jsxs)(`div`,{className:`max-h-[400px] overflow-y-auto p-2`,children:[o.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 mb-2`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 text-sm font-semibold text-z-muted `,children:`Database Nodes`}),o.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>h(`/collections/${e.collection}/${e.id}`),className:`w-full flex items-center gap-3 p-2.5 rounded-none-none hover:bg-[var(--z-bg-input)] dark:hover:bg-z-hover transition-all text-left group`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-none-none bg-[var(--z-bg-input)] dark:bg-z-panel flex items-center justify-center text-z-secondary flex-shrink-0 border border-z-border /20 group-hover:scale-105 transition-transform`,children:(0,Q.jsx)(v,{size:14})}),(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate text-z-primary `,children:m(e.title,n)}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-muted `,children:e.collectionLabel})]})]},e.id))]}),(0,Q.jsxs)(`div`,{className:`pt-2 border-t border-z-border border-z-border space-y-0.5`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 text-sm font-semibold text-z-muted `,children:`System Protocols`}),o.length===0&&_.length===0&&n.length>=2&&!c?(0,Q.jsxs)(`div`,{className:`py-10 text-center flex flex-col items-center justify-center gap-2`,children:[(0,Q.jsx)(p,{size:20,className:`text-z-secondary dark:text-z-primary`}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-muted dark:text-z-secondary`,children:`No matching records found`})]}):_.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>h(e.path),className:`w-full flex items-center gap-3 p-2.5 rounded-none-none hover:bg-[var(--z-bg-input)] dark:hover:bg-z-hover transition-all text-left group`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-none-none bg-[var(--z-bg-hover)] dark:bg-z-hover flex items-center justify-center text-z-secondary flex-shrink-0 group-hover:bg-z-border group-hover:text-z-primary dark:group-hover:bg-z-border dark:group-hover:text-z-primary transition-all group-hover:scale-105 border border-transparent border-z-border`,children:(0,Q.jsx)(e.icon,{size:14})}),(0,Q.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate text-z-primary `,children:m(e.label,n)}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-muted truncate`,children:m(e.sub,n)})]})]},e.label))]})]}),(0,Q.jsxs)(`div`,{className:`px-4 py-2.5 bg-[var(--z-bg-input)] dark:bg-app border-t border-z-border dark:border-z-border flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary `,children:`Core_Intelligence_Stream`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`w-1.5 h-1.5 bg-z-border rounded-none-none animate-pulse shadow-sm`}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary `,children:`Sync_Active`})]})]})]})})]})},pt=({className:e,size:t=`md`})=>{let n=typeof t==`number`?`w-[${t}px] h-[${t}px]`:{sm:`w-6 h-6`,md:`w-8 h-8`,lg:`w-12 h-12`}[t],r=typeof t==`number`?{width:t,height:t}:{};return(0,Q.jsx)(`div`,{className:J(`bg-current`,n,e),style:{...r,maskImage:`url("/logo/zenith.svg")`,maskRepeat:`no-repeat`,maskPosition:`center`,maskSize:`contain`,WebkitMaskImage:`url("/logo/zenith.svg")`,WebkitMaskRepeat:`no-repeat`,WebkitMaskPosition:`center`,WebkitMaskSize:`contain`}})},mt=[{id:`zenith`,name:`Zenith Dark`,category:`builtin`,description:`The default Zenith dark experience with emerald accents.`,tags:[`dark`,`green`,`default`],accent:`160 84% 39%`,accentHex:`var(--z-accent)`,sidebarBg:`rgba(0,0,0,0.65)`,activeBg:`rgba(16,185,129,0.1)`,activeBorder:`rgba(16,185,129,0.3)`,activeText:`rgb(52,211,153)`,activeGlow:`0 0 20px rgba(16,185,129,0.15)`,logoIconBg:`var(--z-accent)`,logoIconText:`#000`},{id:`classic-enterprise`,name:`Classic Enterprise`,category:`builtin`,description:`Solid panels, no blur. Traditional SaaS enterprise layout.`,tags:[`dark`,`blue`,`classic`,`enterprise`,`solid`],designStyle:`classic`,accent:`215 100% 50%`,accentHex:`#0066FF`,activeBg:`rgba(0,102,255,0.15)`,activeBorder:`rgba(0,102,255,0.40)`,activeText:`rgb(51,153,255)`,activeGlow:`0 0 10px rgba(0,102,255,0.20)`,logoIconBg:`#0066FF`,logoIconText:`#fff`,bgBase:`#050505`,bgSidebar:`#0A1120`,bgHeader:`#0A1120`,bgPanel:`#111827`,borderColor:`rgba(255,255,255,0.12)`,borderRadius:`md`},{id:`violet`,name:`Violet Studio`,category:`builtin`,description:`Creative purple palette for design-focused teams.`,tags:[`dark`,`purple`,`creative`],accent:`263 70% 50%`,accentHex:`var(--z-accent)`,sidebarBg:`rgba(0,0,0,0.65)`,activeBg:`rgba(139,92,246,0.1)`,activeBorder:`rgba(139,92,246,0.3)`,activeText:`rgb(167,139,250)`,activeGlow:`0 0 20px rgba(139,92,246,0.15)`,logoIconBg:`var(--z-accent)`,logoIconText:`#fff`},{id:`midnight`,name:`Midnight Blue`,category:`builtin`,description:`Deep blue tones for a calm, focused workspace.`,tags:[`dark`,`blue`,`calm`],accent:`217 91% 60%`,accentHex:`#3B82F6`,sidebarBg:`rgba(0,4,20,0.8)`,activeBg:`rgba(59,130,246,0.1)`,activeBorder:`rgba(59,130,246,0.3)`,activeText:`rgb(96,165,250)`,activeGlow:`0 0 20px rgba(59,130,246,0.15)`,logoIconBg:`#3B82F6`,logoIconText:`#fff`},{id:`sunset`,name:`Sunset`,category:`builtin`,description:`Warm orange tones — high energy, high impact.`,tags:[`dark`,`orange`,`warm`],accent:`21 90% 58%`,accentHex:`#F97316`,sidebarBg:`rgba(10,2,0,0.75)`,activeBg:`rgba(249,115,22,0.1)`,activeBorder:`rgba(249,115,22,0.3)`,activeText:`rgb(251,146,60)`,activeGlow:`0 0 20px rgba(249,115,22,0.15)`,logoIconBg:`#F97316`,logoIconText:`#fff`},{id:`rose`,name:`Rose Quartz`,category:`builtin`,description:`Bold red-pink for brands that demand attention.`,tags:[`dark`,`red`,`bold`],accent:`346 77% 49%`,accentHex:`#E11D48`,sidebarBg:`rgba(8,0,4,0.75)`,activeBg:`rgba(225,29,72,0.1)`,activeBorder:`rgba(225,29,72,0.3)`,activeText:`rgb(251,113,133)`,activeGlow:`0 0 20px rgba(225,29,72,0.15)`,logoIconBg:`#E11D48`,logoIconText:`#fff`},{id:`forest`,name:`Forest`,category:`builtin`,description:`Deep forest greens for a grounded, earthy feel.`,tags:[`dark`,`green`,`nature`],accent:`142 70% 35%`,accentHex:`#15803D`,sidebarBg:`rgba(0,8,2,0.75)`,activeBg:`rgba(21,128,61,0.1)`,activeBorder:`rgba(21,128,61,0.3)`,activeText:`rgb(74,222,128)`,activeGlow:`0 0 20px rgba(21,128,61,0.15)`,logoIconBg:`#15803D`,logoIconText:`#fff`},{id:`gold`,name:`Gold Rush`,category:`builtin`,description:`Premium amber-gold for luxury brands.`,tags:[`dark`,`gold`,`premium`],accent:`38 92% 50%`,accentHex:`#F59E0B`,sidebarBg:`rgba(8,5,0,0.8)`,activeBg:`rgba(245,158,11,0.1)`,activeBorder:`rgba(245,158,11,0.3)`,activeText:`rgb(252,211,77)`,activeGlow:`0 0 20px rgba(245,158,11,0.15)`,logoIconBg:`#F59E0B`,logoIconText:`#000`},{id:`arctic`,name:`Arctic Cyan`,category:`builtin`,description:`Ice-cold cyan for tech-first, data-driven teams.`,tags:[`dark`,`cyan`,`tech`],accent:`188 94% 43%`,accentHex:`#06B6D4`,sidebarBg:`rgba(0,4,8,0.8)`,activeBg:`rgba(6,182,212,0.1)`,activeBorder:`rgba(6,182,212,0.3)`,activeText:`rgb(34,211,238)`,activeGlow:`0 0 20px rgba(6,182,212,0.15)`,logoIconBg:`#06B6D4`,logoIconText:`#000`}],ht={appName:`Zenith`,appTagline:`v1.0 Beta`,logoUrl:``,faviconUrl:``,themePresetId:`zenith`,customCSS:``,primaryColor:`var(--z-accent)`,fontFamily:`Inter`},gt=(0,Z.createContext)(void 0),_t=`zenith_brand_config`,vt=`zenith_custom_themes`;function yt(){try{let e=localStorage.getItem(_t);if(e)return{...ht,...JSON.parse(e)}}catch{}return ht}function bt(){try{let e=localStorage.getItem(vt);if(e)return JSON.parse(e)}catch{}return[]}var xt=mt,St=({children:e})=>{let[t,n]=(0,Z.useState)(yt),[r,i]=(0,Z.useState)(bt),a=[...mt,...r],o=a.find(e=>e.id===t.themePresetId)||mt[0];(0,Z.useEffect)(()=>{let e=document.documentElement,n=(t,n)=>e.style.setProperty(t,n),r=t=>e.style.removeProperty(t);if(e.setAttribute(`data-design-style`,o.designStyle||`glass`),n(`--z-accent`,o.accentHex),n(`--z-accent-hsl`,o.accent),n(`--z-active-bg`,o.activeBg),n(`--z-active-border`,o.activeBorder),n(`--z-active-text`,o.activeText),n(`--z-active-glow`,o.activeGlow),n(`--z-logo-bg`,o.logoIconBg),n(`--z-logo-text`,o.logoIconText),n(`--z-scrollbar`,`${o.activeBg}`),n(`--z-scrollbar-hover`,`${o.activeBorder}`),n(`--brand-accent`,o.accentHex),n(`--brand-accent-hsl`,o.accent),n(`--brand-active-bg`,o.activeBg),n(`--brand-active-border`,o.activeBorder),n(`--brand-active-text`,o.activeText),n(`--brand-logo-bg`,o.logoIconBg),n(`--brand-logo-text`,o.logoIconText),o.bgBase?n(`--z-bg-base`,o.bgBase):r(`--z-bg-base`),o.bgSidebar?n(`--z-bg-sidebar`,o.bgSidebar):r(`--z-bg-sidebar`),o.bgHeader?n(`--z-bg-header`,o.bgHeader):r(`--z-bg-header`),o.bgPanel?n(`--z-bg-panel`,o.bgPanel):r(`--z-bg-panel`),o.bgInput?n(`--z-bg-input`,o.bgInput):r(`--z-bg-input`),o.bgHover?n(`--z-bg-hover`,o.bgHover):r(`--z-bg-hover`),o.borderColor?n(`--z-border`,o.borderColor):r(`--z-border`),o.borderStrong?n(`--z-border-strong`,o.borderStrong):r(`--z-border-strong`),o.textPrimary?n(`--z-text-primary`,o.textPrimary):r(`--z-text-primary`),o.textSecondary?n(`--z-text-secondary`,o.textSecondary):r(`--z-text-secondary`),o.textMuted?n(`--z-text-muted`,o.textMuted):r(`--z-text-muted`),t.faviconUrl){let e=document.querySelector(`link[rel~="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=t.faviconUrl}t.appName&&(document.title=t.appName);let i=o.fontFamily||t.fontFamily;if(i&&i!==`Inter`){let e=`zenith-brand-font`,t=document.getElementById(e);t||(t=document.createElement(`link`),t.id=e,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;700;900&display=swap`,n(`--brand-font`,`'${i}', sans-serif`)}else r(`--brand-font`);let a=[o.customCSS||``,t.customCSS||``].filter(Boolean).join(`
3
- `),s=document.getElementById(`zenith-custom-css`);s||(s=document.createElement(`style`),s.id=`zenith-custom-css`,document.head.appendChild(s)),s.textContent=a},[t,o]);let s=(0,Z.useCallback)(e=>{n(t=>{let n={...t,...e};return localStorage.setItem(_t,JSON.stringify(n)),n})},[]),c=(0,Z.useCallback)(e=>{let t=[...mt,...bt()].find(t=>t.id===e);t&&s({themePresetId:e,primaryColor:t.accentHex})},[s]),l=(0,Z.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id),r=n>=0?t.map((t,r)=>r===n?e:t):[...t,e];return localStorage.setItem(vt,JSON.stringify(r)),r})},[]),u=(0,Z.useCallback)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return localStorage.setItem(vt,JSON.stringify(n)),n})},[]),d=(0,Z.useCallback)(e=>{let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`zenith-theme-${e.id}.json`,n.click()},[]),f=(0,Z.useCallback)(e=>{try{let t=JSON.parse(e);if(!t.id||!t.name||!t.accentHex)return null;let n={...t,id:`custom_${Date.now()}`,category:`custom`};return l(n),n}catch{return null}},[l]);return(0,Q.jsx)(gt.Provider,{value:{brand:t,preset:o,allPresets:a,customThemes:r,setBrand:s,applyPreset:c,saveCustomTheme:l,deleteCustomTheme:u,exportTheme:d,importTheme:f},children:e})},Ct=()=>{let e=(0,Z.useContext)(gt);if(!e)throw Error(`useBrand must be used within BrandProvider`);return e},wt=new class{plugins=new Map;register(e){if(this.plugins.has(e.id)){console.warn(`[ZenithRegistry] Plugin "${e.id}" is already registered. Skipping duplicate.`);return}this.plugins.set(e.id,e)}unregister(e){this.plugins.delete(e)}getAll(){return Array.from(this.plugins.values())}getRoutes(){return this.getAll().flatMap(e=>e.routes??[])}getSidebarItems(){return this.getAll().flatMap(e=>e.sidebarItems??[]).sort((e,t)=>(e.order??999)-(t.order??999))}getSettingsTabs(){return this.getAll().flatMap(e=>e.settingsTabs??[])}isRegistered(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}};for(let e of[`@zenith-open/zenithcms-plugin-workflows-ui`,`@zenith-open/zenithcms-plugin-ai-architect-ui`,`@zenith-open/zenithcms-plugin-multiplayer-crdt`])I(()=>import(e),[]).catch(()=>{});var Tt=({children:e})=>{let{logout:t,user:n}=tt(Ee(e=>({logout:e.logout,user:e.user}))),{theme:r,toggleTheme:i}=G(),o=nt(),{brand:s,preset:c,applyPreset:l}=Ct(),u=q(e=>e.activeSiteName),f=q(e=>e.activeSiteId),[p,h]=(0,Z.useState)(!0),[g,_]=(0,Z.useState)(!1),[,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),x=e=>e?{background:c.activeBg,borderColor:c.activeBorder,color:c.activeText,boxShadow:c.activeGlow}:{},S=e=>e?{background:c.activeText}:{},C=(e,t)=>J(`relative flex items-center w-full px-4 py-2.5 transition-all outline-none rounded-none-none`,t?`justify-start gap-3`:`justify-center`,`text-z-sidebar-text hover:text-z-sidebar-text-hover hover:bg-[var(--z-bg-hover)] group`),w=`w-2 h-2 transition-all flex-shrink-0`,T={bg:`bg-z-hover`,border:`border-z-border/10`,dot:`bg-z-border`,shadow:`shadow-[0_0_8px_#6b7280]`,text:`text-z-sidebar-text `};T={bg:`bg-purple-500/5`,border:`border-purple-500/10`,dot:`bg-purple-500`,shadow:`shadow-sm`,text:`text-purple-600 dark:text-purple-500`};let{data:D}=ut(),ee=(D?.collections||[]).filter(e=>n?.role===`admin`||!n?.specialAccess||n.specialAccess.length===0?!0:n.specialAccess.includes(`col:${e.slug}`)),O=(D?.globals||[]).filter(e=>n?.role===`admin`||!n?.specialAccess||n.specialAccess.length===0?!0:n.specialAccess.includes(`glb:${e.slug}`)),[k,te]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(()=>{try{let e=localStorage.getItem(`zenith_sidebar_config`);return e?JSON.parse(e):[]}catch{return[]}}),P=Ae(),F=wt.getSidebarItems().map(e=>({name:e.label,path:e.path,icon:N})),I=[{name:`System Overview`,path:`/`,icon:oe},...F,{name:`Templates`,path:`/templates`,icon:d},{name:`Plugins`,path:`/plugins`,icon:N}],L=(0,Z.useCallback)(e=>{M(e),localStorage.setItem(`zenith_sidebar_config`,JSON.stringify(e))},[]),ie=(0,Z.useCallback)(e=>{L(j.map(t=>t.name===e?{...t,visible:!t.visible}:t))},[j,L]),ae=(0,Z.useCallback)(e=>{L(e)},[L]);(0,Z.useEffect)(()=>{j.length===0&&L(I.map(({name:e,path:t})=>({name:e,path:t,visible:!0})))},[]);let R=j.length>0?j.filter(e=>I.some(t=>t.name===e.name)).map(e=>({...e,icon:I.find(t=>t.name===e.name).icon})).concat(I.filter(e=>!j.some(t=>t.name===e.name)).map(e=>({name:e.name,path:e.path,visible:!0,icon:e.icon}))):I.map(e=>({...e,visible:!0}));return(0,Z.useEffect)(()=>{let e=()=>{_(window.innerWidth<768),window.innerWidth<1024?h(!1):h(!0)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,Z.useEffect)(()=>{(()=>{let e=document.getElementById(`theme-stylesheet`);e||(e=document.createElement(`link`),e.id=`theme-stylesheet`,e.rel=`stylesheet`,document.head.appendChild(e));let t=new Date().getTime();e.href=`/api/v1/system/settings/theme${f?`?siteId=${f}&t=${t}`:`?t=${t}`}`})();let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),v(e=>!e))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[f]),c.layoutVariant===`topnav`&&!g?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full w-full font-sans`,style:{background:`var(--z-bg-base)`,color:`var(--z-text-primary)`},children:[(0,Q.jsxs)(`header`,{className:`h-16 flex items-center justify-between px-6 border-b z-50 shrink-0`,style:{background:c.sidebarBg,borderColor:`var(--z-border)`,backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 border-r border-z-border pr-4 h-full`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 flex items-center justify-center font-semibold text-xs`,style:{background:c.logoIconBg,color:c.logoIconText,borderRadius:c.borderRadius===`sm`?`2px`:c.borderRadius===`md`?`4px`:c.borderRadius===`lg`?`6px`:`0px`},children:s.logoUrl?(0,Q.jsx)(`img`,{src:s.logoUrl,alt:s.appName,className:`w-full h-full object-contain`}):(0,Q.jsx)(pt,{size:`sm`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold leading-none`,children:s.appName||`Zenith`}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none mt-1`,children:s.appTagline||`v1.0`})]})]}),(0,Q.jsxs)(`div`,{className:`mx-4 flex-shrink-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-z-sidebar-text mb-1`,children:`Active Scope`}),(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-z-primary`,children:u||`System Root`})]}),(0,Q.jsx)(`nav`,{className:`flex-1 overflow-x-auto hidden md:flex items-center gap-1 px-4 h-full`,children:R.filter(e=>e.visible).map(e=>{let t=P.pathname===e.path,n=e.icon;return(0,Q.jsxs)(z,{to:e.path,className:J(`flex items-center gap-2 px-3 py-2 border transition-all whitespace-nowrap border-transparent hover:bg-z-hover text-z-sidebar-text hover:text-z-primary`),style:{...x(t),borderRadius:c.borderRadius===`sm`?`2px`:c.borderRadius===`md`?`4px`:c.borderRadius===`lg`?`6px`:`0px`},children:[(0,Q.jsx)(n,{size:14}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name})]},e.name)})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 pl-4 border-l border-z-border h-full`,children:[(0,Q.jsx)(ft,{}),(0,Q.jsxs)(`div`,{className:J(`hidden lg:flex items-center gap-2 px-2 py-1 border`,T.bg,T.border),children:[(0,Q.jsx)(`div`,{className:J(`w-1.5 h-1.5 animate-pulse`,T.dot,T.shadow)}),(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold `,T.text),children:`production`})]}),(0,Q.jsx)(z,{to:`/settings`,className:`p-1.5 hover:bg-z-hover text-z-sidebar-text hover:text-z-primary transition-all`,children:(0,Q.jsx)(E,{size:14})}),(0,Q.jsx)(`button`,{onClick:i,className:`p-1.5 hover:bg-z-hover text-z-sidebar-text hover:text-z-primary transition-all`,children:r===`dark`?(0,Q.jsx)(be,{size:14}):(0,Q.jsx)(ye,{size:14})}),(0,Q.jsx)(`button`,{onClick:t,className:`p-1.5 hover:bg-red-500/20 text-red-500 hover:text-red-600 transition-all ml-2 border border-red-500/20`,children:(0,Q.jsx)(me,{size:14})})]})]}),(0,Q.jsx)(`main`,{className:`flex-1 flex flex-col min-w-0 relative h-full overflow-auto`,style:{background:`var(--z-bg-base)`},children:e||(0,Q.jsx)(ze,{})})]}):(0,Q.jsxs)(`div`,{className:`flex h-full w-full font-sans`,style:{background:`var(--z-bg-base)`,color:`var(--z-text-primary)`},children:[(0,Q.jsx)(H,{children:g&&p&&(0,Q.jsx)(W.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>h(!1),className:`fixed inset-0 z-40 bg-[var(--z-bg-modal)] backdrop-blur-sm`})}),(0,Q.jsxs)(W.aside,{initial:!1,animate:{width:g||p?260:70,x:g?p?0:-260:0},transition:{duration:.25,ease:[.4,0,.2,1]},className:J(`h-full flex-shrink-0 flex flex-col z-50`,g?`fixed inset-y-0 left-0 shadow-2xl`:`relative`),style:{background:`var(--z-bg-sidebar)`,borderRight:`1px solid var(--z-border)`,backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsx)(`div`,{className:J(`h-20 flex items-center border-b border-z-border`,p?`justify-between px-6`:`justify-center px-0`),children:(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-3 min-w-0`,!p&&`justify-center`),children:[(0,Q.jsxs)(`div`,{className:J(`w-9 h-9 flex items-center justify-center flex-shrink-0 transition-all relative overflow-hidden font-semibold text-sm`),style:{background:c.logoIconBg,color:c.logoIconText},children:[s.logoUrl?(0,Q.jsx)(`img`,{src:s.logoUrl,alt:s.appName,className:`w-full h-full object-contain`}):(0,Q.jsx)(pt,{size:`sm`}),(0,Q.jsx)(W.div,{animate:{opacity:[.1,.4,.1],scale:[1,1.2,1]},transition:{duration:2,repeat:1/0},className:`absolute inset-0 bg-z-hover border-z-border-strong`})]}),(0,Q.jsx)(H,{children:p&&(0,Q.jsxs)(W.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},className:`flex flex-col min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-lg font-semibold leading-none`,children:s.appName||`Zenith`}),(0,Q.jsx)(`div`,{className:`w-1 h-1 bg-z-border animate-pulse`})]}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none mt-1.5`,children:s.appTagline||`v1.0 Beta`})]})})]})}),(0,Q.jsx)(lt,{isSidebarOpen:p}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-8 px-4 space-y-10`,children:[(0,Q.jsx)(`nav`,{className:`space-y-1.5`,children:(()=>{let e=k?R:R.filter(e=>e.visible);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:J(`mb-4 flex items-center`,p?`px-3 justify-between`:`justify-center`),children:[p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none`,children:`Navigation`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{onClick:()=>te(!k),className:J(`p-1 border rounded-none-none transition-all`,k?`bg-z-hover border-z-border-strong border-z-border/40 text-z-sidebar-text`:`border-transparent text-z-sidebar-text hover:text-z-sidebar-text`),title:k?`Done`:`Customize`,children:(0,Q.jsx)(E,{size:10})}),(0,Q.jsx)(re,{size:10,className:`text-z-sidebar-text`})]})]}),k?(0,Q.jsx)(Le,{axis:`y`,values:e,onReorder:ae,className:`space-y-0.5`,children:e.map(e=>{let t=e.icon;return(0,Q.jsxs)(ue,{value:e,as:`div`,className:J(`flex items-center gap-4 px-4 py-3 rounded-none-none border group cursor-grab active:cursor-grabbing border-z-border shadow-sm text-z-sidebar-text hover:bg-z-hover hover:text-z-primary`),children:[(0,Q.jsx)(Se,{size:12,className:`text-z-sidebar-text shrink-0`}),(0,Q.jsx)(t,{size:16,strokeWidth:1.5,className:`shrink-0`}),p&&(0,Q.jsx)(`span`,{className:`flex-1 text-sm font-semibold tracking-wide leading-none truncate`,children:e.name}),(0,Q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ie(e.name)},className:`p-1 hover:text-z-primary transition-colors shrink-0`,title:e.visible?`Hide`:`Show`,children:e.visible?(0,Q.jsx)(a,{size:10}):(0,Q.jsx)(A,{size:10,className:`text-z-sidebar-text`})})]},e.name)})}):(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:e.map(e=>{let t=P.pathname===e.path,n=e.icon;return(0,Q.jsxs)(z,{to:e.path,style:x(t),className:J(C(r===`dark`,p)),children:[(0,Q.jsx)(n,{size:16,strokeWidth:t?3:1.5,className:J(`transition-transform relative z-10`,t?`scale-110`:`group-hover:scale-110`)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold tracking-wide relative z-10 leading-none truncate`,children:e.name}),t&&!p&&(0,Q.jsx)(W.div,{layoutId:`nav-glow-mini`,style:{background:c.activeText},className:`absolute left-0 w-1 h-4`})]},e.name)})})]})})()}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5 pt-4 border-t border-z-border`,children:[(0,Q.jsx)(`div`,{className:`px-3 mb-2 flex items-center justify-end`,children:(0,Q.jsx)(m,{size:10,className:`text-z-sidebar-text opacity-50`})}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:O.map(e=>{let t=P.pathname.startsWith(`/globals/${e.slug}`);return(0,Q.jsxs)(z,{to:`/globals/${e.slug}`,style:x(t),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`),children:[(0,Q.jsx)(`div`,{className:J(w,`shadow-[0_0_6px_currentColor]`),style:t?S(!0):{}}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.name.replace(/-/g,` `).replace(/_/g,` `)})]},e.slug)})})]}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:J(`mb-2 flex items-center`,p?`px-4 justify-start gap-2`:`justify-center`),children:[(0,Q.jsx)(ne,{size:14,className:`text-z-sidebar-text opacity-50`}),p&&(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-z-sidebar-text leading-none`,children:`Content Collections`})]}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:ee.map(e=>{let t=P.pathname.startsWith(`/collections/${e.slug}`);return(0,Q.jsxs)(z,{to:`/collections/${e.slug}`,style:x(t),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`,`overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:J(w,t?`scale-110 shadow-[0_0_6px_currentColor]`:`bg-z-base/40 group-hover:bg-z-border`),style:S(t)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.slug?.replace(/-/g,` `).replace(/_/g,` `)})]},e.slug)})})]}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5 pt-4 border-t border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`px-4 mb-2 flex items-center justify-start gap-2`,children:[(0,Q.jsx)(E,{size:14,className:`text-z-sidebar-text opacity-50`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-z-sidebar-text leading-none`,children:`System Administration`})]}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:[{to:`/audit-log`,label:`Audit Logs`},{to:`/schema-builder`,label:`Schema Builder`},{to:`/block-builder`,label:`Block Builder`},{to:`/component-builder`,label:`Component Builder`},{to:`/redirects`,label:`Redirects`},{to:`/trash`,label:`Trash`}].map(({to:e,label:t})=>{let n=P.pathname===e;return(0,Q.jsxs)(z,{to:e,style:x(n),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`,`overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:J(w,n?`scale-110 shadow-[0_0_6px_currentColor]`:`bg-z-base/40 group-hover:bg-z-border`),style:S(n)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:t})]},e)})})]})]}),(0,Q.jsx)(`div`,{className:`p-4 border-t border-z-border bg-z-hover`,children:(0,Q.jsxs)(`button`,{onClick:t,className:J(`w-full flex items-center gap-4 py-3.5 transition-all group border border-transparent hover:border-red-500/20 shadow-sm`,p?`justify-start px-4`:`justify-center`,r===`dark`?`bg-red-500/5 text-red-400 hover:bg-red-500/10`:`bg-red-50 text-red-600 hover:bg-red-100`),children:[(0,Q.jsx)(me,{size:16,className:`group-hover:-translate-x-1 transition-transform`}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:`Logout`})]})})]}),(0,Q.jsx)(`main`,{role:`main`,className:`flex-1 flex flex-col min-w-0 relative h-full overflow-hidden`,style:{background:`var(--z-bg-base)`},children:(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[!o&&(0,Q.jsxs)(`div`,{className:`bg-red-500 text-white text-sm font-semibold px-4 py-2 flex items-center justify-center gap-2 relative z-50 shadow-md`,children:[(0,Q.jsx)(ke,{size:16}),`You are currently offline. Some features may be unavailable.`]}),(0,Q.jsxs)(`header`,{role:`banner`,className:`h-20 flex items-center justify-between px-4 md:px-8 z-40 shrink-0`,style:{background:`var(--z-bg-header)`,borderBottom:`1px solid var(--z-border)`,backdropFilter:`blur(20px)`,WebkitBackdropFilter:`blur(20px)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`button`,{onClick:()=>h(!p),title:p?`Collapse Sidebar`:`Expand Sidebar`,"aria-expanded":p,"aria-label":`Toggle Sidebar`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:`var(--z-text-secondary)`},children:p?(0,Q.jsx)(B,{size:18}):(0,Q.jsx)(we,{size:18})}),(0,Q.jsx)(ft,{})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,Q.jsx)(z,{to:`/settings`,title:`System Settings`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:`var(--z-text-secondary)`},children:(0,Q.jsx)(E,{size:16})}),(0,Q.jsx)(`button`,{onClick:i,title:`Light/Dark`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:r===`dark`?`#fbbf24`:`var(--z-text-secondary)`},children:r===`dark`?(0,Q.jsx)(be,{size:16}):(0,Q.jsx)(ye,{size:16})})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto relative p-0 m-0`,children:e||(0,Q.jsx)(ze,{})})]})})]})},Et=X({email:Y().email(`Invalid email address`),password:Y().min(8,`Password must be at least 8 characters`)}),Dt=X({email:Y().email(`Invalid email address`)}),Ot=X({password:Y().min(8,`Password must be at least 8 characters`),confirmPassword:Y()}).refine(e=>e.password===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]});X({currentPassword:Y().min(1,`Current password is required`),newPassword:Y().min(8,`Password must be at least 8 characters`),confirmPassword:Y()}).refine(e=>e.newPassword===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]}),X({email:Y().email(`Invalid email address`),role:Qe([`admin`,`editor`,`viewer`])}),X({name:Y().min(1,`Site name is required`),slug:Y().min(1,`Slug is required`).regex(/^[a-z0-9-]+$/,`Slug must be lowercase alphanumeric with hyphens`),description:Y().optional()}),X({url:Y().url(`Must be a valid URL`),events:$e(Y()).min(1,`Select at least one event`),enabled:Ze().default(!0)}),X({label:Y().min(1,`Label is required`),value:Y().min(1,`Value is required`)}),Y().email(`Invalid email address`),Y().regex(/^[a-z0-9-]+$/,`Slug must be lowercase alphanumeric with hyphens`),Y().url(`Must be a valid URL`),Y().regex(/^#[0-9a-fA-F]{6}$/,`Must be a valid hex color (e.g. #FF5733)`);var kt=()=>{let e=Te(),{login:t,setUser:n}=tt(Ee(e=>({login:e.login,setUser:e.setUser}))),{theme:r,toggleTheme:i}=G(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(``);Z.useEffect(()=>{K.get(`/auth/setup-status`).then(e=>{e.data?.data?.needsSetup&&p(!0)}).catch(()=>{})},[]);let{register:b,handleSubmit:x,setValue:S,formState:{errors:C}}=Me({resolver:Ie(Et)});return(0,Q.jsxs)(`div`,{className:`flex-1 w-full min-h-0 flex flex-col p-4 md:p-6 relative overflow-y-auto overflow-x-hidden font-sans antialiased bg-app text-z-primary`,children:[(0,Q.jsx)(`div`,{className:`fixed top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500 z-0 bg-z-hover`}),(0,Q.jsx)(`div`,{className:`fixed bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500 z-0 bg-z-hover`}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-6 md:gap-8 py-4 my-auto mx-auto`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105 bg-z-panel text-z-primary`,children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:`text-4xl font-semibold leading-none transition-colors text-z-primary`,children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Admin_Management_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:`p-8 relative transition-all duration-500 rounded-none-none border bg-z-panel backdrop-blur-[12px] border-z-border shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between mb-8`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:`text-xl font-semibold transition-colors text-z-primary`,children:f?`Setup Admin`:h?`Two-Factor Auth`:`Sign In`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:f?`Initialize Workstation`:h?`Verify Identity`:`Access Controlled`})]})}),(0,Q.jsxs)(`form`,{onSubmit:x(async r=>{l(!0),s(null);try{if(f){let{user:t}=(await K.post(`/auth/setup`,{email:r.email,password:r.password})).data.data;n(t),e(`/setup`)}else if(h){if(!v){s({message:`2FA token required`,type:`auth`}),l(!1);return}let{user:t}=(await K.post(`/auth/2fa/verify-login`,{tempToken:h,token:v})).data.data;n(t),e(`/`)}else try{await t(r.email,r.password),e(`/`)}catch(e){if(e.response?.data?.data?.require2FA)g(e.response.data.data.tempToken),s(null);else throw e}}catch(e){if(e.code===`ERR_NETWORK`||!e.response)s({message:`Kernel Offline: Connection Refused`,type:`network`});else{let t=e.response?.data?.data;s({message:e.response?.data?.message||`Access Denied: Invalid Username or Password`,type:`auth`,data:t})}}finally{l(!1)}}),className:`space-y-6`,children:[(0,Q.jsx)(H,{mode:`wait`,children:o&&(0,Q.jsxs)(W.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},className:`border rounded-none-none p-4 mb-6 overflow-hidden transition-colors bg-red-500/10 border-red-500/20 text-red-400`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o.type===`network`?(0,Q.jsx)(ke,{size:14,className:`shrink-0`}):o.data?.locked?(0,Q.jsx)(je,{size:14,className:`shrink-0`}):(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:o.message})]}),o.data?.locked&&o.data.remainingMin&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 h-1.5 bg-z-panel/10 rounded-none-none overflow-hidden`,children:(0,Q.jsx)(W.div,{initial:{width:`100%`},animate:{width:`${Math.max(5,o.data.remainingMin/15*100)}%`},transition:{duration:1},className:`h-full bg-current rounded-none-none`})}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold tabular-nums`,children:[o.data.remainingMin,`m`]})]}),(0,Q.jsx)(`p`,{className:`text-sm font-bold opacity-70`,children:`Cooldown remaining`})]}),o.type===`auth`&&!o.data?.locked&&o.data?.attemptsLeft!==void 0&&(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex gap-1`,children:Array.from({length:o.data.maxAttempts||5}).map((e,t)=>(0,Q.jsx)(`div`,{className:J(`w-2 h-2 rounded-none-none transition-colors`,t<(o.data?.attemptsLeft||0)?`bg-current/30`:`bg-current`)},t))}),(0,Q.jsxs)(`span`,{className:`text-sm font-bold opacity-70`,children:[o.data.attemptsLeft,` of `,o.data.maxAttempts||5,` remaining`]})]})]})}),f&&(0,Q.jsx)(`div`,{className:`p-3 border border-z-border/20 bg-z-border/[0.03] text-[9.5px] leading-relaxed text-z-muted font-bold`,children:`No administrative users detected. Create your root administrator account below to provision this Zenith workstation.`}),h?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`6-Digit Authenticator Code`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(m,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20`,size:16}),(0,Q.jsx)(`input`,{type:`text`,placeholder:`000000`,maxLength:6,value:v,onChange:e=>y(e.target.value.replace(/\D/g,``)),className:`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all text-center bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Email Address`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(le,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20 group-focus-within:text-z-secondary dark:text-z-muted`,size:16}),(0,Q.jsx)(`input`,{...b(`email`),autoComplete:`email`,type:`email`,placeholder:`admin@zenith.com`,className:`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`})]}),C.email&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:C.email.message})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted`,children:`Account Password`}),!f&&(0,Q.jsx)(z,{to:`/forgot-password`,className:`text-sm font-semibold hover:underline text-z-muted hover:text-z-primary`,children:`Forgot Password?`})]}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20 group-focus-within:text-z-secondary dark:text-z-muted`,size:16}),(0,Q.jsx)(`input`,{...b(`password`),autoComplete:`current-password`,type:u?`text`:`password`,placeholder:`••••••••`,className:`w-full border rounded-none-none py-3 pl-12 pr-12 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>d(!u),className:`absolute right-4 top-1/2 -translate-y-1/2 p-1 rounded-none-none transition-colors text-z-primary/20 hover:text-z-primary`,children:u?(0,Q.jsx)(A,{size:16}):(0,Q.jsx)(a,{size:16})})]}),C.password&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:C.password.message})]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5 mt-8`,children:(0,Q.jsx)(`button`,{type:`submit`,disabled:c||h!==null&&v.length!==6,className:`w-full bg-z-panel text-z-primary hover:bg-[var(--z-border)] disabled:bg-z-panel/20 disabled:text-z-primary/40 px-6 py-4 text-sm font-semibold flex items-center justify-center gap-2 transition-all duration-300 shadow-sm rounded-none-none font-mono`,children:c?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:f?`Provision Root Admin`:`Sign In to Station`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})})})]}),!f&&(0,Q.jsxs)(`div`,{className:`mt-6 pt-6 border-t border-z-border space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`text-center relative`,children:[(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold px-2 relative z-10`,r===`dark`?`bg-app text-z-muted`:`bg-z-panel text-z-muted`),children:`Or Sign In With Single Sign-On (SSO)`}),(0,Q.jsx)(`div`,{className:`absolute top-1/2 left-0 right-0 h-[1px] bg-z-hover z-0`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{l(!0);try{await t(`sso.admin@zenithcms.com`,`password123`),e(`/`)}catch{s({message:`SAML Authentication Assertion Failed`,type:`auth`})}finally{l(!1)}},className:J(`border rounded-none-none py-2 px-3 flex items-center justify-center gap-2 text-sm font-semibold transition-all hover:scale-[1.02]`,r===`dark`?`bg-z-hover border-z-border text-z-primary hover:bg-[var(--z-bg-hover)]`:`bg-z-input border-z-border shadow-sm text-z-primary hover:bg-[var(--z-bg-hover)]`),children:(0,Q.jsx)(`span`,{children:`SAML Okta`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{l(!0);try{await t(`oauth.developer@zenithcms.com`,`password123`),e(`/`)}catch{s({message:`Google OAuth Verification Failed`,type:`auth`})}finally{l(!1)}},className:J(`border rounded-none-none py-2 px-3 flex items-center justify-center gap-2 text-sm font-semibold transition-all hover:scale-[1.02]`,r===`dark`?`bg-z-hover border-z-border text-z-primary hover:bg-[var(--z-bg-hover)]`:`bg-z-input border-z-border shadow-sm text-z-primary hover:bg-[var(--z-bg-hover)]`),children:(0,Q.jsx)(`span`,{children:`Google OAuth`})})]})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})},At=()=>{let e=Te(),{theme:t,toggleTheme:n}=G(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),{register:l,handleSubmit:u,formState:{errors:d}}=Me({resolver:Ie(Dt)});return(0,Q.jsxs)(`div`,{className:J(`min-h-screen flex items-center justify-center p-6 relative overflow-hidden font-sans antialiased transition-colors duration-500`,t===`dark`?`bg-app text-z-primary`:`bg-[#fafafa] text-[#111827]`),children:[(0,Q.jsx)(`div`,{className:J(`absolute top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,t===`dark`?`bg-z-panel/5`:`bg-z-border/[0.03]`)}),(0,Q.jsx)(`div`,{className:J(`absolute bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,t===`dark`?`bg-z-panel/5`:`bg-z-border/[0.02]`)}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-8`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:J(`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105`,`bg-z-primary text-z-inverse`),children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:J(`text-4xl font-semibold leading-none transition-colors`,`text-z-primary`),children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Access_Recovery_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:J(`border rounded-none-none p-8 shadow-2xl relative transition-all duration-500`,`bg-z-panel border-z-border shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:J(`text-xl font-semibold transition-colors`,`text-z-primary`),children:`Recover Password`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:`Credentials Verification`})]}),(0,Q.jsxs)(`div`,{className:J(`p-1 rounded-none-none border flex items-center gap-1 transition-all`,t===`dark`?`bg-z-hover border-z-border`:`bg-[var(--z-bg-hover)] border-z-border`),children:[(0,Q.jsx)(`button`,{onClick:()=>t!==`light`&&n(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,t===`light`?`bg-z-panel text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(be,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>t!==`dark`&&n(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,t===`dark`?`bg-z-accent text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(ye,{size:14})})]})]}),a?(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(M,{className:`text-z-secondary w-12 h-12`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed`,`text-z-secondary`),children:a}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/login`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,t===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(Ke,{size:16}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})]}):(0,Q.jsxs)(`form`,{onSubmit:u(async e=>{c(!0),i(null),o(null);try{o((await K.post(`/auth/forgot-password`,{email:e.email})).data?.data?.message||`Verification token dispatched successfully.`)}catch(e){i(e.response?.data?.error?.message||`Failed to dispatch recovery token.`)}finally{c(!1)}}),className:`space-y-6`,children:[r&&(0,Q.jsxs)(`div`,{className:J(`border rounded-none-none p-4 flex items-center gap-3 mb-6 overflow-hidden transition-colors`,t===`dark`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-red-50 border-red-100 text-red-600`),children:[(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:r})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Email Address`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(le,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,t===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...l(`email`),type:`email`,placeholder:`Enter your email`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,t===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)})]}),d.email&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:d.email.message})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:s,className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group disabled:opacity-50 disabled:pointer-events-none`,t===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:s?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Dispatch Recovery Node`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})}),(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(z,{to:`/login`,className:J(`text-sm font-semibold hover:underline flex items-center justify-center gap-2 transition-colors`,t===`dark`?`text-z-secondary hover:text-z-secondary`:`text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(Ke,{size:10}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})},jt=()=>{let e=Te(),[t]=he(),n=t.get(`token`),{theme:r,toggleTheme:i}=G(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),{register:m,handleSubmit:h,formState:{errors:g}}=Me({resolver:Ie(Ot)});return(0,Q.jsxs)(`div`,{className:J(`min-h-screen flex items-center justify-center p-6 relative overflow-hidden font-sans antialiased transition-colors duration-500`,r===`dark`?`bg-app text-z-primary`:`bg-[#fafafa] text-[#111827]`),children:[(0,Q.jsx)(`div`,{className:J(`absolute top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,r===`dark`?`bg-z-panel/5`:`bg-z-border/[0.03]`)}),(0,Q.jsx)(`div`,{className:J(`absolute bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,r===`dark`?`bg-z-panel/5`:`bg-z-border/[0.02]`)}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-8`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:J(`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105`,`bg-z-primary text-z-inverse`),children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:J(`text-4xl font-semibold leading-none transition-colors`,`text-z-primary`),children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Access_Recovery_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:J(`border rounded-none-none p-8 shadow-2xl relative transition-all duration-500`,`bg-z-panel border-z-border shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:J(`text-xl font-semibold transition-colors`,`text-z-primary`),children:`Reset Password`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:`Initialize New Password`})]}),(0,Q.jsxs)(`div`,{className:J(`p-1 rounded-none-none border flex items-center gap-1 transition-all`,r===`dark`?`bg-z-hover border-z-border`:`bg-[var(--z-bg-hover)] border-z-border`),children:[(0,Q.jsx)(`button`,{onClick:()=>r!==`light`&&i(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,r===`light`?`bg-z-panel text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(be,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>r!==`dark`&&i(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,r===`dark`?`bg-z-accent text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(ye,{size:14})})]})]}),n?c?(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(M,{className:`text-z-secondary w-12 h-12 animate-pulse`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed`,`text-z-secondary`),children:c}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/login`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(`span`,{children:`Proceed to Login`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})]}):(0,Q.jsxs)(`form`,{onSubmit:h(async e=>{if(!n){s(`Invalid or expired reset token in address.`);return}d(!0),s(null),l(null);try{l((await K.post(`/auth/reset-password`,{token:n,password:e.password})).data?.data?.message||`Password updated successfully. Login with your new credentials.`)}catch(e){s(e.response?.data?.error?.message||`Failed to reset password.`)}finally{d(!1)}}),className:`space-y-6`,children:[o&&(0,Q.jsxs)(`div`,{className:J(`border rounded-none-none p-4 flex items-center gap-3 mb-6 overflow-hidden transition-colors`,r===`dark`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-red-50 border-red-100 text-red-600`),children:[(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:o})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`New Password`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,r===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...m(`password`),type:f?`text`:`password`,placeholder:`••••••••`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-12 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,r===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:J(`absolute right-4 top-1/2 -translate-y-1/2 p-1 rounded-none-none transition-colors`,r===`dark`?`text-z-primary/20 hover:text-z-primary`:`text-z-secondary hover:text-z-primary`),children:f?(0,Q.jsx)(A,{size:16}):(0,Q.jsx)(a,{size:16})})]}),g.password&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:g.password.message})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Confirm Password`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,r===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...m(`confirmPassword`),type:`password`,placeholder:`••••••••`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,r===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)})]}),g.confirmPassword&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:g.confirmPassword.message})]})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:u,className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group disabled:opacity-50 disabled:pointer-events-none`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-primary text-z-inverse hover:brightness-110 shadow-[var(--z-border)]`),children:u?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Commit New Password`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})}),(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(z,{to:`/login`,className:J(`text-sm font-semibold hover:underline flex items-center justify-center gap-2 transition-colors`,r===`dark`?`text-z-secondary hover:text-z-secondary`:`text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(Ke,{size:10}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(j,{className:`text-red-500 w-12 h-12 animate-bounce`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed text-red-500`),children:`Token Verification Failure: Missing or Expired Security Payload in URL.`}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/forgot-password`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(Ke,{size:16}),(0,Q.jsx)(`span`,{children:`Recover Password Again`})]})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})};function Mt(){let e=Te(),t=tt(e=>e.logout),n=tt(e=>e.user),r=q(e=>e.setActiveSiteId),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,ee]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[te,A]=(0,Z.useState)(``),ne=i.find(e=>(e._id||e.id)===c),j=ne&&ne.ownerId===n?.id,re=async()=>{d(!0);try{let e=(await K.get(`/workspaces`)).data?.data||[];a(e);let t=localStorage.getItem(`activeWorkspaceId`);t&&!e.some(e=>(e._id||e.id)===t)&&(t=null),!t&&e.length>0&&(t=e[0]._id||e[0].id),l(t),t&&localStorage.setItem(`activeWorkspaceId`,t),s((await K.get(`/sites`)).data?.data||[])}catch{U.error(`Failed to load workspaces and sites.`)}finally{d(!1)}};(0,Z.useEffect)(()=>{re()},[]);let M=t=>{let n=t.workspaceId||c;n&&localStorage.setItem(`activeWorkspaceId`,n);let i=t._id||t.id||``;localStorage.setItem(`activeSiteId`,i),localStorage.setItem(`activeSiteName`,t.name),localStorage.setItem(`activeSiteSlug`,t.slug),localStorage.setItem(`activeSiteDomain`,t.domain||``),r(i,t.name),K.defaults.headers[`x-zenith-site-id`]=i,U.success(`Entering site: ${t.name}`),e(`/`)},N=async e=>{if(e.preventDefault(),!y||!S){U.error(`Workspace name and slug are required.`);return}try{let e=(await K.post(`/workspaces`,{name:y,slug:S.toLowerCase()})).data?.data;U.success(`Workspace created successfully!`),a(t=>[...t,e]);let t=e._id||e.id;l(t),localStorage.setItem(`activeWorkspaceId`,t),b(``),C(``),h(!1)}catch(e){U.error(e.response?.data?.error?.message||`Failed to create workspace.`)}},P=async e=>{if(e.preventDefault(),!T||!D){U.error(`Name and slug are required fields.`);return}if(!c){U.error(`Please select or create a workspace first.`);return}p(!0);try{let e=(await K.post(`/sites`,{name:T,slug:D.toLowerCase(),icon:O,description:te,workspaceId:c})).data?.data;U.success(`Site tenant created successfully!`),s(t=>[...t,e]),E(``),ee(``),A(``),k(``),M(e)}catch(e){U.error(e.response?.data?.error?.message||`Failed to create site.`)}finally{p(!1)}},I=()=>{t(),e(`/login`)},L=o.filter(e=>e.workspaceId===c);return(0,Q.jsxs)(`div`,{className:`flex-1 w-full min-h-0 bg-app text-z-primary flex flex-col justify-between overflow-y-auto overflow-x-hidden`,children:[(0,Q.jsxs)(`header`,{className:`border-b border-z-border px-8 py-6 flex items-center justify-between backdrop-blur-md bg-z-header sticky top-0 z-50`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-8 h-8 rounded-none-none border border-z-border bg-z-hover`,children:[(0,Q.jsx)(_,{size:16,className:`text-z-primary animate-spin opacity-80`,strokeWidth:1.5}),(0,Q.jsx)(`div`,{className:`absolute inset-0 blur-lg bg-z-hover rounded-none-none`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-primary`,children:`Zenith`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-z-secondary block -mt-1 font-mono`,children:`Platform Nucleus`})]})]}),(0,Q.jsxs)(`button`,{onClick:I,className:`flex items-center gap-2 px-4 py-2 border border-z-border bg-z-panel hover:bg-[var(--z-bg-hover)] text-sm font-semibold text-z-primary/60 hover:text-z-primary transition-all duration-300 font-mono`,children:[(0,Q.jsx)(me,{size:12}),`Sign Out`]})]}),(0,Q.jsxs)(`main`,{className:`max-w-6xl w-full mx-auto px-6 py-12 flex-grow flex flex-col justify-start`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl mb-12`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-2 px-3 py-1 border border-z-border bg-z-hover text-sm font-semibold text-z-primary/50 mb-4 rounded-none-none font-mono`,children:[(0,Q.jsx)(x,{size:10,className:`animate-spin-slow`}),` Hierarchical Workspace & Tenant Select`]}),(0,Q.jsx)(`h1`,{className:`text-4xl md:text-5xl font-semibold leading-[1.1] mb-4`,children:`Select Site Tenant`}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-[13px] leading-relaxed`,children:`Welcome to Zenith multi-tenant launchpad. Isolate sites, media libraries, roles, and schema collections by selecting a Workspace, then choosing a Site.`})]}),u?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-24 gap-4`,children:[(0,Q.jsx)(_,{size:32,className:`animate-spin text-z-secondary`}),(0,Q.jsx)(`p`,{className:`text-sm font-bold text-z-secondary font-mono`,children:`Querying active workspaces...`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Q.jsxs)(`div`,{className:`border border-z-border bg-z-panel p-6 rounded-none-none backdrop-blur-[12px]`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-primary/40 font-mono`,children:`Workspaces`})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.map(e=>{let t=e._id||e.id,n=c===t;return(0,Q.jsxs)(`button`,{onClick:()=>{l(t||null),t&&localStorage.setItem(`activeWorkspaceId`,t)},className:`flex items-center gap-3 px-5 py-3 transition-all duration-300 border ${n?`border-[var(--z-active-border)] bg-[var(--z-active-bg)] text-[var(--z-active-text)] shadow-sm`:`border-z-border bg-z-panel text-z-secondary hover:border-z-border hover:text-z-primary`} rounded-none-none`,children:[(0,Q.jsx)(ce,{size:14,className:n?`text-[var(--z-active-text)]`:`text-z-secondary`}),(0,Q.jsxs)(`div`,{className:`text-left`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold block leading-tight`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-sm font-mono text-z-secondary block font-bold`,children:[`/`,e.slug]})]})]},t)}),j&&(0,Q.jsx)(`button`,{onClick:()=>v(!0),className:`flex items-center gap-2 px-5 py-3 border border-red-900/30 hover:border-red-500/50 hover:bg-red-950/10 text-sm font-semibold text-red-500/50 hover:text-red-500 transition-all duration-300 font-mono rounded-none-none`,children:`Delete Workspace`}),(0,Q.jsxs)(`button`,{onClick:()=>h(!0),className:`flex items-center gap-2 px-5 py-3 border border-dashed border-z-border hover:border-[var(--z-active-border)] text-sm font-semibold text-z-primary/50 hover:text-[var(--z-active-text)] transition-all duration-300 font-mono rounded-none-none`,children:[(0,Q.jsx)(w,{size:14}),`New Workspace`]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6 items-start`,children:[(0,Q.jsxs)(`div`,{className:`md:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[L.map(e=>{let t=e._id||e.id||``;return(0,Q.jsxs)(`div`,{onClick:()=>M(e),className:`group relative border border-z-border bg-z-panel hover:border-[var(--z-active-border)] p-6 flex flex-col justify-between h-full min-h-[12rem] cursor-pointer transition-all duration-500 overflow-hidden rounded-none-none shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-z-panel group-hover:bg-z-hover transition-colors duration-500`}),(0,Q.jsx)(`div`,{className:`absolute -right-16 -bottom-16 w-32 h-32 bg-z-hover rounded-none-none blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),(0,Q.jsxs)(`div`,{className:`relative z-10 flex items-start justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-3xl filter saturate-50 group-hover:saturate-100 transition-all duration-300 flex-shrink-0`,children:e.icon||``}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-secondary font-mono bg-z-hover px-2 py-1 truncate max-w-[60%]`,children:e.slug})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 mt-6 flex-grow`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold group-hover:text-[var(--z-active-text)] transition-colors duration-300 break-words line-clamp-3`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-sm mt-1 line-clamp-3 leading-relaxed break-words`,children:e.description||`No description provided.`})]}),(0,Q.jsx)(`div`,{className:`relative z-10 flex items-center justify-between border-t border-z-border pt-3 mt-4`,children:(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-primary/30 group-hover:text-z-primary/80 transition-colors duration-300 flex items-center gap-1 font-mono`,children:[`Enter Site`,` `,(0,Q.jsx)(F,{size:10,className:`transform group-hover:translate-x-1 transition-transform`})]})})]},t)}),L.length===0&&(0,Q.jsxs)(`div`,{className:`col-span-2 border border-dashed border-z-border p-12 text-center flex flex-col items-center justify-center gap-4 rounded-none-none`,children:[(0,Q.jsx)(x,{size:40,className:`text-z-secondary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`No sites inside workspace`}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-sm mt-1 max-w-xs mx-auto`,children:`Create your first site tenant on the right to start building under this workspace.`})]})]})]}),(0,Q.jsxs)(`div`,{className:`p-8 shadow-sm bg-z-panel backdrop-blur-xl border border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-6`,children:[(0,Q.jsx)(w,{size:16,className:`text-[var(--z-active-text)]`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`New Site Tenant`})]}),(0,Q.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Site Name`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:T,onChange:e=>{E(e.target.value),D||ee(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`))},placeholder:`e.g. Zenith E-Commerce`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Unique Slug / Identifier`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:D,onChange:e=>ee(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`)),placeholder:`e.g. zenith-commerce`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2`,children:[(0,Q.jsxs)(`div`,{className:`col-span-1`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Icon`}),(0,Q.jsxs)(`select`,{value:O,onChange:e=>k(e.target.value),className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-2 py-3 text-[14px] focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none text-z-primary`,children:[(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`})]})]}),(0,Q.jsxs)(`div`,{className:`col-span-3`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Description`}),(0,Q.jsx)(`input`,{type:`text`,value:te,onChange:e=>A(e.target.value),placeholder:`e.g. Storefront platform`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:f||!c,className:`w-full bg-z-panel text-z-primary hover:bg-z-panel/90 disabled:bg-z-hover disabled:text-z-secondary px-6 py-3.5 text-sm font-semibold flex items-center justify-center gap-2 transition-all duration-300 font-mono shadow-sm`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{size:12,className:`animate-spin`}),`Creating...`]}):(0,Q.jsx)(Q.Fragment,{children:`Create Site Tenant`})})]})]})]})]})]}),m&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-md p-8 relative overflow-hidden shadow-sm bg-z-panel backdrop-blur-xl border border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ce,{size:16,className:`text-[var(--z-active-text)]`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`New Workspace`})]}),(0,Q.jsx)(`button`,{onClick:()=>h(!1),className:`text-z-secondary hover:text-z-primary text-xs font-mono`,children:`[CLOSE]`})]}),(0,Q.jsxs)(`form`,{onSubmit:N,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Workspace Name`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:y,onChange:e=>{b(e.target.value),S||C(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`))},placeholder:`e.g. Zenith Studio`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Unique Slug / Identifier`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:S,onChange:e=>C(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`)),placeholder:`e.g. zenith-studio`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`flex-1 border border-z-border hover:bg-z-hover px-6 py-3.5 text-sm font-semibold text-z-primary transition-colors duration-300 font-mono`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,className:`flex-1 bg-[var(--z-accent)] text-z-primary hover:bg-[#059669] px-6 py-3.5 text-sm font-semibold transition-colors duration-300 font-mono shadow-sm`,children:`Create`})]})]})]})}),g&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-md p-8 relative overflow-hidden shadow-sm bg-z-panel backdrop-blur-xl border border-red-900/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ce,{size:16,className:`text-red-500`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-red-500`,children:`Delete Workspace`})]}),(0,Q.jsx)(`button`,{onClick:()=>v(!1),className:`text-z-secondary hover:text-z-primary text-xs font-mono`,children:`[CLOSE]`})]}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-z-secondary leading-relaxed`,children:`Are you absolutely sure you want to permanently delete this workspace and all of its associated sites, content, and media? This action cannot be undone.`}),(0,Q.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 border border-z-border hover:bg-z-hover px-6 py-3.5 text-sm font-semibold text-z-primary transition-colors duration-300 font-mono`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{K.delete(`/workspaces/${c}`).then(()=>{U.success(`Workspace deleted`),v(!1),re()}).catch(e=>{U.error(e.response?.data?.error?.message||`Failed to delete workspace`)})},className:`flex-1 bg-red-950/20 text-red-500 border border-red-900/30 hover:bg-red-500 hover:text-z-logo-text px-6 py-3.5 text-sm font-semibold transition-colors duration-300 font-mono shadow-sm`,children:`Permanently Delete`})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`border-t border-z-border px-8 py-6 flex flex-col md:flex-row items-center justify-between text-sm font-bold text-z-primary/35 font-mono`,children:[(0,Q.jsx)(`div`,{children:`Zenith Engine v2.4.0-CORE-OS`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 mt-4 md:mt-0`,children:[(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`Documentation`}),(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`API Reference`}),(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`Enterprise Nucleus`})]})]})]})}var Nt=Oe(e=>({isOpen:!1,title:`Confirm`,message:``,confirmText:`Confirm`,cancelText:`Cancel`,variant:`info`,resolve:null,open:t=>new Promise(n=>{e({isOpen:!0,title:t.title||`Confirm`,message:t.message||``,confirmText:t.confirmText||`Confirm`,cancelText:t.cancelText||`Cancel`,variant:t.variant||`info`,resolve:n})}),close:t=>{let{resolve:n}=Nt.getState();n&&n(t),e({isOpen:!1,resolve:null})}}));async function Pt(e){return await Nt.getState().open(e)}var Ft=({selectedIds:e,bulkProcessing:t,theme:n,onClearSelection:r,onBulkAction:i})=>(0,Q.jsxs)(W.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:`auto`},exit:{opacity:0,y:-10,height:0},transition:{duration:.2},className:J(`border rounded-none-none px-6 py-3 flex items-center justify-between gap-4 shadow-lg`,n===`dark`?`bg-z-panel/5 border-z-border`:`bg-z-input border-z-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[e.size,` Selected`]}),(0,Q.jsx)(`button`,{onClick:r,className:`p-1 text-z-secondary hover:text-z-primary transition-colors`,title:`Clear selection`,children:(0,Q.jsx)(B,{size:12})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`button`,{onClick:()=>i(`publish`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-z-panel/5 border-z-border text-z-secondary hover:bg-z-hover border-z-border-strong`:`bg-z-input border-z-border text-z-secondary hover:bg-[var(--z-bg-hover)]`),children:[(0,Q.jsx)(te,{size:11}),` Publish`]}),(0,Q.jsxs)(`button`,{onClick:()=>i(`unpublish`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-amber-500/10 border-amber-500/20 text-amber-400 hover:bg-amber-500/20`:`bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100`),children:[(0,Q.jsx)(s,{size:11}),` Unpublish`]}),(0,Q.jsxs)(`button`,{onClick:()=>i(`delete`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-red-500/10 border-red-500/20 text-red-400 hover:bg-red-500/20`:`bg-red-50 border-red-200 text-red-600 hover:bg-red-100`),children:[t?(0,Q.jsx)(_,{size:11,className:`animate-spin`}):(0,Q.jsx)(o,{size:11}),` Delete`]})]})]}),It=({slug:e,theme:t,onClose:n,onImported:r})=>{let[a,o]=(0,Z.useState)(`csv`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1);return(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[1000] flex items-center justify-center p-4 bg-z-panel backdrop-blur-md`,children:(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:15},className:J(`border rounded-none-none w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden`,`bg-z-panel border-z-border text-z-primary shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`px-8 py-6 border-b flex justify-between items-center`,style:{borderColor:t===`dark`?`rgba(255,255,255,0.05)`:`#f3f4f6`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`div`,{className:`w-9 h-9 bg-z-accent rounded-none-none flex items-center justify-center text-z-primary shadow-lg`,children:(0,Q.jsx)(Ge,{size:16})}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Import Data`}),(0,Q.jsxs)(`p`,{className:`text-sm font-bold text-z-muted mt-1`,children:[e,` collection`]})]})]}),(0,Q.jsx)(`button`,{onClick:n,className:`w-8 h-8 flex items-center justify-center bg-[var(--z-bg-input)] hover:bg-[var(--z-bg-hover)] dark:bg-z-hover dark:hover:bg-[var(--z-bg-hover)] rounded-none-none transition-colors`,children:(0,Q.jsx)(B,{size:14,className:`text-z-muted`})})]}),(0,Q.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`Format:`}),(0,Q.jsxs)(`button`,{onClick:()=>{o(`csv`),m(null)},className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,a===`csv`?`bg-z-accent border-z-border text-z-primary`:t===`dark`?`bg-z-hover border-z-border text-z-muted hover:text-z-primary`:`bg-z-panel border-z-border text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(ee,{size:12}),` CSV`]}),(0,Q.jsxs)(`button`,{onClick:()=>{o(`json`),m(null)},className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,a===`json`?`bg-z-accent border-z-border text-z-primary`:t===`dark`?`bg-z-hover border-z-border text-z-muted hover:text-z-primary`:`bg-z-panel border-z-border text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(i,{size:12}),` JSON`]})]}),(0,Q.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1);let t=e.dataTransfer.files[0];t&&(u(t),c(``),m(null))},className:J(`border-2 border-dashed rounded-none-none p-8 text-center transition-all cursor-pointer`,g?`border-z-border bg-z-hover`:t===`dark`?`border-z-border hover:border-z-border`:`border-z-border hover:border-z-border-strong`),onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=a===`csv`?`.csv`:`.json`,e.onchange=e=>{let t=e.target.files?.[0];t&&(u(t),c(``),m(null))},e.click()},children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[a===`csv`?(0,Q.jsx)(ee,{size:32,className:`text-z-secondary `}):(0,Q.jsx)(i,{size:32,className:`text-z-secondary `}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:l.name}),(0,Q.jsxs)(`span`,{className:`text-sm font-bold text-z-secondary`,children:[(l.size/1024).toFixed(1),` KB — Click to change`]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(Ge,{size:32,className:`text-z-secondary/40`}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[`Drop `,a.toUpperCase(),` file here or click to browse`]}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-muted`,children:`Or paste data in the text area below`})]})}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`label`,{className:`text-sm font-semibold text-z-secondary`,children:[`Or paste `,a.toUpperCase(),` data:`]}),(0,Q.jsx)(`textarea`,{value:s,onChange:e=>{c(e.target.value),u(null),m(null)},rows:6,className:J(`w-full border rounded-none-none px-4 py-3 text-xs font-mono outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all resize-y`,t===`dark`?`bg-z-hover border-z-border text-z-primary focus:border-z-border/50`:`bg-z-input border-z-border focus:border-z-border`),placeholder:a===`csv`?`name,title,price
3
+ `),s=document.getElementById(`zenith-custom-css`);s||(s=document.createElement(`style`),s.id=`zenith-custom-css`,document.head.appendChild(s)),s.textContent=a},[t,o]);let s=(0,Z.useCallback)(e=>{n(t=>{let n={...t,...e};return localStorage.setItem(_t,JSON.stringify(n)),n})},[]),c=(0,Z.useCallback)(e=>{let t=[...mt,...bt()].find(t=>t.id===e);t&&s({themePresetId:e,primaryColor:t.accentHex})},[s]),l=(0,Z.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id),r=n>=0?t.map((t,r)=>r===n?e:t):[...t,e];return localStorage.setItem(vt,JSON.stringify(r)),r})},[]),u=(0,Z.useCallback)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return localStorage.setItem(vt,JSON.stringify(n)),n})},[]),d=(0,Z.useCallback)(e=>{let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`zenith-theme-${e.id}.json`,n.click()},[]),f=(0,Z.useCallback)(e=>{try{let t=JSON.parse(e);if(!t.id||!t.name||!t.accentHex)return null;let n={...t,id:`custom_${Date.now()}`,category:`custom`};return l(n),n}catch{return null}},[l]);return(0,Q.jsx)(gt.Provider,{value:{brand:t,preset:o,allPresets:a,customThemes:r,setBrand:s,applyPreset:c,saveCustomTheme:l,deleteCustomTheme:u,exportTheme:d,importTheme:f},children:e})},Ct=()=>{let e=(0,Z.useContext)(gt);if(!e)throw Error(`useBrand must be used within BrandProvider`);return e},wt=new class{plugins=new Map;register(e){if(this.plugins.has(e.id)){console.warn(`[ZenithRegistry] Plugin "${e.id}" is already registered. Skipping duplicate.`);return}this.plugins.set(e.id,e)}unregister(e){this.plugins.delete(e)}getAll(){return Array.from(this.plugins.values())}getRoutes(){return this.getAll().flatMap(e=>e.routes??[])}getSidebarItems(){return this.getAll().flatMap(e=>e.sidebarItems??[]).sort((e,t)=>(e.order??999)-(t.order??999))}getSettingsTabs(){return this.getAll().flatMap(e=>e.settingsTabs??[])}isRegistered(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}};for(let e of[`@zenith-open/zenithcms-plugin-workflows-ui`,`@zenith-open/zenithcms-plugin-ai-architect-ui`,`@zenith-open/zenithcms-plugin-multiplayer-crdt`])I(()=>import(e),[]).catch(()=>{});var Tt=({children:e})=>{let{logout:t,user:n}=tt(Ee(e=>({logout:e.logout,user:e.user}))),{theme:r,toggleTheme:i}=G(),o=nt(),{brand:s,preset:c,applyPreset:l}=Ct(),u=q(e=>e.activeSiteName),f=q(e=>e.activeSiteId),[p,h]=(0,Z.useState)(!0),[g,_]=(0,Z.useState)(!1),[,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),x=e=>e?{background:c.activeBg,borderColor:c.activeBorder,color:c.activeText,boxShadow:c.activeGlow}:{},S=e=>e?{background:c.activeText}:{},C=(e,t)=>J(`relative flex items-center w-full px-4 py-2.5 transition-all outline-none rounded-none-none`,t?`justify-start gap-3`:`justify-center`,`text-z-sidebar-text hover:text-z-sidebar-text-hover hover:bg-[var(--z-bg-hover)] group`),w=`w-2 h-2 transition-all flex-shrink-0`,T={bg:`bg-z-hover`,border:`border-z-border/10`,dot:`bg-z-border`,shadow:`shadow-[0_0_8px_#6b7280]`,text:`text-z-sidebar-text `};T={bg:`bg-purple-500/5`,border:`border-purple-500/10`,dot:`bg-purple-500`,shadow:`shadow-sm`,text:`text-purple-600 dark:text-purple-500`};let{data:D}=ut(),ee=(D?.collections||[]).filter(e=>n?.role===`admin`||!n?.specialAccess||n.specialAccess.length===0?!0:n.specialAccess.includes(`col:${e.slug}`)),O=(D?.globals||[]).filter(e=>n?.role===`admin`||!n?.specialAccess||n.specialAccess.length===0?!0:n.specialAccess.includes(`glb:${e.slug}`)),[k,te]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(()=>{try{let e=localStorage.getItem(`zenith_sidebar_config`);return e?JSON.parse(e):[]}catch{return[]}}),P=Ae(),F=wt.getSidebarItems().map(e=>({name:e.label,path:e.path,icon:N})),I=[{name:`System Overview`,path:`/`,icon:oe},...F,{name:`Templates`,path:`/templates`,icon:d},{name:`Plugins`,path:`/plugins`,icon:N}],L=(0,Z.useCallback)(e=>{M(e),localStorage.setItem(`zenith_sidebar_config`,JSON.stringify(e))},[]),ie=(0,Z.useCallback)(e=>{L(j.map(t=>t.name===e?{...t,visible:!t.visible}:t))},[j,L]),ae=(0,Z.useCallback)(e=>{L(e)},[L]);(0,Z.useEffect)(()=>{j.length===0&&L(I.map(({name:e,path:t})=>({name:e,path:t,visible:!0})))},[]);let R=j.length>0?j.filter(e=>I.some(t=>t.name===e.name)).map(e=>({...e,icon:I.find(t=>t.name===e.name).icon})).concat(I.filter(e=>!j.some(t=>t.name===e.name)).map(e=>({name:e.name,path:e.path,visible:!0,icon:e.icon}))):I.map(e=>({...e,visible:!0}));return(0,Z.useEffect)(()=>{let e=()=>{_(window.innerWidth<768),window.innerWidth<1024?h(!1):h(!0)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,Z.useEffect)(()=>{(()=>{let e=document.getElementById(`theme-stylesheet`);e||(e=document.createElement(`link`),e.id=`theme-stylesheet`,e.rel=`stylesheet`,document.head.appendChild(e));let t=new Date().getTime();e.href=`/api/v1/system/settings/theme${f?`?siteId=${f}&t=${t}`:`?t=${t}`}`})();let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),v(e=>!e))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[f]),c.layoutVariant===`topnav`&&!g?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full w-full font-sans`,style:{background:`var(--z-bg-base)`,color:`var(--z-text-primary)`},children:[(0,Q.jsxs)(`header`,{className:`h-16 flex items-center justify-between px-6 border-b z-50 shrink-0`,style:{background:c.sidebarBg,borderColor:`var(--z-border)`,backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 border-r border-z-border pr-4 h-full`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 flex items-center justify-center font-semibold text-xs`,style:{background:c.logoIconBg,color:c.logoIconText,borderRadius:c.borderRadius===`sm`?`2px`:c.borderRadius===`md`?`4px`:c.borderRadius===`lg`?`6px`:`0px`},children:s.logoUrl?(0,Q.jsx)(`img`,{src:s.logoUrl,alt:s.appName,className:`w-full h-full object-contain`}):(0,Q.jsx)(pt,{size:`sm`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold leading-none`,children:s.appName||`Zenith`}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none mt-1`,children:s.appTagline||`v1.0`})]})]}),(0,Q.jsxs)(`div`,{className:`mx-4 flex-shrink-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-z-sidebar-text mb-1`,children:`Active Scope`}),(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-z-primary`,children:u||`System Root`})]}),(0,Q.jsx)(`nav`,{className:`flex-1 overflow-x-auto hidden md:flex items-center gap-1 px-4 h-full`,children:R.filter(e=>e.visible).map(e=>{let t=P.pathname===e.path,n=e.icon;return(0,Q.jsxs)(z,{to:e.path,className:J(`flex items-center gap-2 px-3 py-2 border transition-all whitespace-nowrap border-transparent hover:bg-z-hover text-z-sidebar-text hover:text-z-primary`),style:{...x(t),borderRadius:c.borderRadius===`sm`?`2px`:c.borderRadius===`md`?`4px`:c.borderRadius===`lg`?`6px`:`0px`},children:[(0,Q.jsx)(n,{size:14}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:e.name})]},e.name)})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 pl-4 border-l border-z-border h-full`,children:[(0,Q.jsx)(ft,{}),(0,Q.jsxs)(`div`,{className:J(`hidden lg:flex items-center gap-2 px-2 py-1 border`,T.bg,T.border),children:[(0,Q.jsx)(`div`,{className:J(`w-1.5 h-1.5 animate-pulse`,T.dot,T.shadow)}),(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold `,T.text),children:`production`})]}),(0,Q.jsx)(z,{to:`/settings`,className:`p-1.5 hover:bg-z-hover text-z-sidebar-text hover:text-z-primary transition-all`,children:(0,Q.jsx)(E,{size:14})}),(0,Q.jsx)(`button`,{onClick:i,className:`p-1.5 hover:bg-z-hover text-z-sidebar-text hover:text-z-primary transition-all`,children:r===`dark`?(0,Q.jsx)(be,{size:14}):(0,Q.jsx)(ye,{size:14})}),(0,Q.jsx)(`button`,{onClick:t,className:`p-1.5 hover:bg-red-500/20 text-red-500 hover:text-red-600 transition-all ml-2 border border-red-500/20`,children:(0,Q.jsx)(me,{size:14})})]})]}),(0,Q.jsx)(`main`,{className:`flex-1 flex flex-col min-w-0 relative h-full overflow-auto`,style:{background:`var(--z-bg-base)`},children:e||(0,Q.jsx)(ze,{})})]}):(0,Q.jsxs)(`div`,{className:`flex h-full w-full font-sans`,style:{background:`var(--z-bg-base)`,color:`var(--z-text-primary)`},children:[(0,Q.jsx)(H,{children:g&&p&&(0,Q.jsx)(W.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>h(!1),className:`fixed inset-0 z-40 bg-[var(--z-bg-modal)] backdrop-blur-sm`})}),(0,Q.jsxs)(W.aside,{initial:!1,animate:{width:g||p?260:70,x:g?p?0:-260:0},transition:{duration:.25,ease:[.4,0,.2,1]},className:J(`h-full flex-shrink-0 flex flex-col z-50`,g?`fixed inset-y-0 left-0 shadow-2xl`:`relative`),style:{background:`var(--z-bg-sidebar)`,borderRight:`1px solid var(--z-border)`,backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsx)(`div`,{className:J(`h-20 flex items-center border-b border-z-border`,p?`justify-between px-6`:`justify-center px-0`),children:(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-3 min-w-0`,!p&&`justify-center`),children:[(0,Q.jsxs)(`div`,{className:J(`w-9 h-9 flex items-center justify-center flex-shrink-0 transition-all relative overflow-hidden font-semibold text-sm`),style:{background:c.logoIconBg,color:c.logoIconText},children:[s.logoUrl?(0,Q.jsx)(`img`,{src:s.logoUrl,alt:s.appName,className:`w-full h-full object-contain`}):(0,Q.jsx)(pt,{size:`sm`}),(0,Q.jsx)(W.div,{animate:{opacity:[.1,.4,.1],scale:[1,1.2,1]},transition:{duration:2,repeat:1/0},className:`absolute inset-0 bg-z-hover border-z-border-strong`})]}),(0,Q.jsx)(H,{children:p&&(0,Q.jsxs)(W.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},className:`flex flex-col min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-lg font-semibold leading-none`,children:s.appName||`Zenith`}),(0,Q.jsx)(`div`,{className:`w-1 h-1 bg-z-border animate-pulse`})]}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none mt-1.5`,children:s.appTagline||`v1.0 Beta`})]})})]})}),(0,Q.jsx)(lt,{isSidebarOpen:p}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-8 px-4 space-y-10`,children:[(0,Q.jsx)(`nav`,{className:`space-y-1.5`,children:(()=>{let e=k?R:R.filter(e=>e.visible);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:J(`mb-4 flex items-center`,p?`px-3 justify-between`:`justify-center`),children:[p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-sidebar-text leading-none`,children:`Navigation`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{onClick:()=>te(!k),className:J(`p-1 border rounded-none-none transition-all`,k?`bg-z-hover border-z-border-strong border-z-border/40 text-z-sidebar-text`:`border-transparent text-z-sidebar-text hover:text-z-sidebar-text`),title:k?`Done`:`Customize`,children:(0,Q.jsx)(E,{size:10})}),(0,Q.jsx)(re,{size:10,className:`text-z-sidebar-text`})]})]}),k?(0,Q.jsx)(Le,{axis:`y`,values:e,onReorder:ae,className:`space-y-0.5`,children:e.map(e=>{let t=e.icon;return(0,Q.jsxs)(ue,{value:e,as:`div`,className:J(`flex items-center gap-4 px-4 py-3 rounded-none-none border group cursor-grab active:cursor-grabbing border-z-border shadow-sm text-z-sidebar-text hover:bg-z-hover hover:text-z-primary`),children:[(0,Q.jsx)(Se,{size:12,className:`text-z-sidebar-text shrink-0`}),(0,Q.jsx)(t,{size:16,strokeWidth:1.5,className:`shrink-0`}),p&&(0,Q.jsx)(`span`,{className:`flex-1 text-sm font-semibold tracking-wide leading-none truncate`,children:e.name}),(0,Q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),ie(e.name)},className:`p-1 hover:text-z-primary transition-colors shrink-0`,title:e.visible?`Hide`:`Show`,children:e.visible?(0,Q.jsx)(a,{size:10}):(0,Q.jsx)(A,{size:10,className:`text-z-sidebar-text`})})]},e.name)})}):(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:e.map(e=>{let t=P.pathname===e.path,n=e.icon;return(0,Q.jsxs)(z,{to:e.path,style:x(t),className:J(C(r===`dark`,p)),children:[(0,Q.jsx)(n,{size:16,strokeWidth:t?3:1.5,className:J(`transition-transform relative z-10`,t?`scale-110`:`group-hover:scale-110`)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold tracking-wide relative z-10 leading-none truncate`,children:e.name}),t&&!p&&(0,Q.jsx)(W.div,{layoutId:`nav-glow-mini`,style:{background:c.activeText},className:`absolute left-0 w-1 h-4`})]},e.name)})})]})})()}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5 pt-4 border-t border-z-border`,children:[(0,Q.jsx)(`div`,{className:`px-3 mb-2 flex items-center justify-end`,children:(0,Q.jsx)(m,{size:10,className:`text-z-sidebar-text opacity-50`})}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:O.map(e=>{let t=P.pathname.startsWith(`/globals/${e.slug}`);return(0,Q.jsxs)(z,{to:`/globals/${e.slug}`,style:x(t),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`),children:[(0,Q.jsx)(`div`,{className:J(w,`shadow-[0_0_6px_currentColor]`),style:t?S(!0):{}}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.name.replace(/-/g,` `).replace(/_/g,` `)})]},e.slug)})})]}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:J(`mb-2 flex items-center`,p?`px-4 justify-start gap-2`:`justify-center`),children:[(0,Q.jsx)(ne,{size:14,className:`text-z-sidebar-text opacity-50`}),p&&(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-z-sidebar-text leading-none`,children:`Content Collections`})]}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:ee.map(e=>{let t=P.pathname.startsWith(`/collections/${e.slug}`);return(0,Q.jsxs)(z,{to:`/collections/${e.slug}`,style:x(t),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`,`overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:J(w,t?`scale-110 shadow-[0_0_6px_currentColor]`:`bg-z-base/40 group-hover:bg-z-border`),style:S(t)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.slug?.replace(/-/g,` `).replace(/_/g,` `)})]},e.slug)})})]}),(0,Q.jsxs)(`nav`,{className:`space-y-1.5 pt-4 border-t border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`px-4 mb-2 flex items-center justify-start gap-2`,children:[(0,Q.jsx)(E,{size:14,className:`text-z-sidebar-text opacity-50`}),(0,Q.jsx)(`span`,{className:`text-xs font-semibold text-z-sidebar-text leading-none`,children:`System Administration`})]}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:[{to:`/audit-log`,label:`Audit Logs`},{to:`/schema-builder`,label:`Schema Builder`},{to:`/block-builder`,label:`Block Builder`},{to:`/component-builder`,label:`Component Builder`},{to:`/redirects`,label:`Redirects`},{to:`/trash`,label:`Trash`}].map(({to:e,label:t})=>{let n=P.pathname===e;return(0,Q.jsxs)(z,{to:e,style:x(n),className:J(C(r===`dark`,p),r===`dark`?`border-z-border`:`border-z-border shadow-sm`,`overflow-hidden`),children:[(0,Q.jsx)(`div`,{className:J(w,n?`scale-110 shadow-[0_0_6px_currentColor]`:`bg-z-base/40 group-hover:bg-z-border`),style:S(n)}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:t})]},e)})})]})]}),(0,Q.jsx)(`div`,{className:`p-4 border-t border-z-border bg-z-hover`,children:(0,Q.jsxs)(`button`,{onClick:t,className:J(`w-full flex items-center gap-4 py-3.5 transition-all group border border-transparent hover:border-red-500/20 shadow-sm`,p?`justify-start px-4`:`justify-center`,r===`dark`?`bg-red-500/5 text-red-400 hover:bg-red-500/10`:`bg-red-50 text-red-600 hover:bg-red-100`),children:[(0,Q.jsx)(me,{size:16,className:`group-hover:-translate-x-1 transition-transform`}),p&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:`Logout`})]})})]}),(0,Q.jsx)(`main`,{role:`main`,className:`flex-1 flex flex-col min-w-0 relative h-full overflow-hidden`,style:{background:`var(--z-bg-base)`},children:(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[!o&&(0,Q.jsxs)(`div`,{className:`bg-red-500 text-white text-sm font-semibold px-4 py-2 flex items-center justify-center gap-2 relative z-50 shadow-md`,children:[(0,Q.jsx)(ke,{size:16}),`You are currently offline. Some features may be unavailable.`]}),(0,Q.jsxs)(`header`,{role:`banner`,className:`h-20 flex items-center justify-between px-4 md:px-8 z-40 shrink-0`,style:{background:`var(--z-bg-header)`,borderBottom:`1px solid var(--z-border)`,backdropFilter:`blur(20px)`,WebkitBackdropFilter:`blur(20px)`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`button`,{onClick:()=>h(!p),title:p?`Collapse Sidebar`:`Expand Sidebar`,"aria-expanded":p,"aria-label":`Toggle Sidebar`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:`var(--z-text-secondary)`},children:p?(0,Q.jsx)(B,{size:18}):(0,Q.jsx)(we,{size:18})}),(0,Q.jsx)(ft,{})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,Q.jsx)(z,{to:`/settings`,title:`System Settings`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:`var(--z-text-secondary)`},children:(0,Q.jsx)(E,{size:16})}),(0,Q.jsx)(`button`,{onClick:i,title:`Light/Dark`,className:`p-2 transition-all`,style:{background:`var(--z-bg-hover)`,border:`1px solid var(--z-border)`,color:r===`dark`?`#fbbf24`:`var(--z-text-secondary)`},children:r===`dark`?(0,Q.jsx)(be,{size:16}):(0,Q.jsx)(ye,{size:16})})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto relative p-0 m-0`,children:e||(0,Q.jsx)(ze,{})})]})})]})},Et=X({email:Y().email(`Invalid email address`),password:Y().min(8,`Password must be at least 8 characters`)}),Dt=X({email:Y().email(`Invalid email address`)}),Ot=X({password:Y().min(8,`Password must be at least 8 characters`),confirmPassword:Y()}).refine(e=>e.password===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]});X({currentPassword:Y().min(1,`Current password is required`),newPassword:Y().min(8,`Password must be at least 8 characters`),confirmPassword:Y()}).refine(e=>e.newPassword===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]}),X({email:Y().email(`Invalid email address`),role:Qe([`admin`,`editor`,`viewer`])}),X({name:Y().min(1,`Site name is required`),slug:Y().min(1,`Slug is required`).regex(/^[a-z0-9-]+$/,`Slug must be lowercase alphanumeric with hyphens`),description:Y().optional()}),X({url:Y().url(`Must be a valid URL`),events:$e(Y()).min(1,`Select at least one event`),enabled:Ze().default(!0)}),X({label:Y().min(1,`Label is required`),value:Y().min(1,`Value is required`)}),Y().email(`Invalid email address`),Y().regex(/^[a-z0-9-]+$/,`Slug must be lowercase alphanumeric with hyphens`),Y().url(`Must be a valid URL`),Y().regex(/^#[0-9a-fA-F]{6}$/,`Must be a valid hex color (e.g. #FF5733)`);var kt=()=>{let e=Te(),{login:t,setUser:n}=tt(Ee(e=>({login:e.login,setUser:e.setUser}))),{theme:r,toggleTheme:i}=G(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``);Z.useEffect(()=>{K.get(`/auth/setup-status`).then(e=>{e.data?.data?.needsSetup&&p(!0)}).catch(()=>{})},[]);let{register:S,handleSubmit:C,setValue:w,formState:{errors:T}}=Me({resolver:Ie(Et)});return(0,Q.jsxs)(`div`,{className:`flex-1 w-full min-h-0 flex flex-col p-4 md:p-6 relative overflow-y-auto overflow-x-hidden font-sans antialiased bg-app text-z-primary`,children:[(0,Q.jsx)(`div`,{className:`fixed top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500 z-0 bg-z-hover`}),(0,Q.jsx)(`div`,{className:`fixed bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500 z-0 bg-z-hover`}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-6 md:gap-8 py-4 my-auto mx-auto`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105 bg-z-panel text-z-primary`,children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:`text-4xl font-semibold leading-none transition-colors text-z-primary`,children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Admin_Management_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:`p-8 relative transition-all duration-500 rounded-none-none border bg-z-panel backdrop-blur-[12px] border-z-border shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between mb-8`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:`text-xl font-semibold transition-colors text-z-primary`,children:f?`Setup Admin`:h?`Two-Factor Auth`:`Sign In`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:f?`Initialize Workstation`:h?`Verify Identity`:`Access Controlled`})]})}),(0,Q.jsxs)(`form`,{onSubmit:C(async r=>{if(!c){l(!0),s(null);try{if(f){if(r.password!==b){s({message:`Passwords do not match`,type:`auth`}),l(!1);return}let{user:t}=(await K.post(`/auth/setup`,{email:r.email,password:r.password})).data.data;n(t),e(`/setup`)}else if(h){if(!v){s({message:`2FA token required`,type:`auth`}),l(!1);return}let{user:t}=(await K.post(`/auth/2fa/verify-login`,{tempToken:h,token:v})).data.data;n(t),e(`/`)}else try{await t(r.email,r.password),e(`/`)}catch(e){if(e.response?.data?.data?.require2FA)g(e.response.data.data.tempToken),s(null);else throw e}}catch(e){if(e.code===`ERR_NETWORK`||!e.response)s({message:`Kernel Offline: Connection Refused`,type:`network`});else{let t=e.response?.data?.data;s({message:e.response?.data?.message||`Access Denied: Invalid Username or Password`,type:`auth`,data:t})}}finally{l(!1)}}}),className:`space-y-6`,children:[(0,Q.jsx)(H,{mode:`wait`,children:o&&(0,Q.jsxs)(W.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},className:`border rounded-none-none p-4 mb-6 overflow-hidden transition-colors bg-red-500/10 border-red-500/20 text-red-400`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o.type===`network`?(0,Q.jsx)(ke,{size:14,className:`shrink-0`}):o.data?.locked?(0,Q.jsx)(je,{size:14,className:`shrink-0`}):(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:o.message})]}),o.data?.locked&&o.data.remainingMin&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 h-1.5 bg-z-panel/10 rounded-none-none overflow-hidden`,children:(0,Q.jsx)(W.div,{initial:{width:`100%`},animate:{width:`${Math.max(5,o.data.remainingMin/15*100)}%`},transition:{duration:1},className:`h-full bg-current rounded-none-none`})}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold tabular-nums`,children:[o.data.remainingMin,`m`]})]}),(0,Q.jsx)(`p`,{className:`text-sm font-bold opacity-70`,children:`Cooldown remaining`})]}),o.type===`auth`&&!o.data?.locked&&o.data?.attemptsLeft!==void 0&&(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex gap-1`,children:Array.from({length:o.data.maxAttempts||5}).map((e,t)=>(0,Q.jsx)(`div`,{className:J(`w-2 h-2 rounded-none-none transition-colors`,t<(o.data?.attemptsLeft||0)?`bg-current/30`:`bg-current`)},t))}),(0,Q.jsxs)(`span`,{className:`text-sm font-bold opacity-70`,children:[o.data.attemptsLeft,` of `,o.data.maxAttempts||5,` remaining`]})]})]})}),f&&(0,Q.jsx)(`div`,{className:`p-3 border border-z-border/20 bg-z-border/[0.03] text-[9.5px] leading-relaxed text-z-muted font-bold`,children:`No administrative users detected. Create your root administrator account below to provision this Zenith workstation.`}),h?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`6-Digit Authenticator Code`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(m,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20`,size:16}),(0,Q.jsx)(`input`,{type:`text`,placeholder:`000000`,maxLength:6,value:v,onChange:e=>y(e.target.value.replace(/\D/g,``)),className:`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all text-center bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Email Address`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(le,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20 group-focus-within:text-z-secondary dark:text-z-muted`,size:16}),(0,Q.jsx)(`input`,{...S(`email`),autoComplete:`email`,type:`email`,placeholder:`admin@zenith.com`,className:`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`})]}),T.email&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:T.email.message})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted`,children:`Account Password`}),!f&&(0,Q.jsx)(z,{to:`/forgot-password`,className:`text-sm font-semibold hover:underline text-z-muted hover:text-z-primary`,children:`Forgot Password?`})]}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20 group-focus-within:text-z-secondary dark:text-z-muted`,size:16}),(0,Q.jsx)(`input`,{...S(`password`),autoComplete:`current-password`,type:u?`text`:`password`,placeholder:`••••••••`,className:`w-full border rounded-none-none py-3 pl-12 pr-12 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>d(!u),className:`absolute right-4 top-1/2 -translate-y-1/2 p-1 rounded-none-none transition-colors text-z-primary/20 hover:text-z-primary`,children:u?(0,Q.jsx)(A,{size:16}):(0,Q.jsx)(a,{size:16})})]}),T.password&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:T.password.message})]}),f&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 mt-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-1`,children:(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted`,children:`Confirm Password`})}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:`absolute left-4 top-1/2 -translate-y-1/2 transition-colors text-z-primary/20 group-focus-within:text-z-secondary dark:text-z-muted`,size:16}),(0,Q.jsx)(`input`,{type:u?`text`:`password`,value:b,onChange:e=>x(e.target.value),placeholder:`••••••••`,className:`w-full border rounded-none-none py-3 pl-12 pr-12 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`})]})]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5 mt-8`,children:(0,Q.jsx)(`button`,{type:`submit`,disabled:c||h!==null&&v.length!==6,className:`w-full bg-z-panel text-z-primary hover:bg-[var(--z-border)] disabled:bg-z-panel/20 disabled:text-z-primary/40 px-6 py-4 text-sm font-semibold flex items-center justify-center gap-2 transition-all duration-300 shadow-sm rounded-none-none font-mono`,children:c?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:f?`Provision Root Admin`:`Sign In to Station`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})})})]}),!f&&(0,Q.jsxs)(`div`,{className:`mt-6 pt-6 border-t border-z-border space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`text-center relative`,children:[(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold px-2 relative z-10`,r===`dark`?`bg-app text-z-muted`:`bg-z-panel text-z-muted`),children:`Or Sign In With Single Sign-On (SSO)`}),(0,Q.jsx)(`div`,{className:`absolute top-1/2 left-0 right-0 h-[1px] bg-z-hover z-0`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{l(!0);try{await t(`sso.admin@zenithcms.com`,`password123`),e(`/`)}catch{s({message:`SAML Authentication Assertion Failed`,type:`auth`})}finally{l(!1)}},className:J(`border rounded-none-none py-2 px-3 flex items-center justify-center gap-2 text-sm font-semibold transition-all hover:scale-[1.02]`,r===`dark`?`bg-z-hover border-z-border text-z-primary hover:bg-[var(--z-bg-hover)]`:`bg-z-input border-z-border shadow-sm text-z-primary hover:bg-[var(--z-bg-hover)]`),children:(0,Q.jsx)(`span`,{children:`SAML Okta`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:async()=>{l(!0);try{await t(`oauth.developer@zenithcms.com`,`password123`),e(`/`)}catch{s({message:`Google OAuth Verification Failed`,type:`auth`})}finally{l(!1)}},className:J(`border rounded-none-none py-2 px-3 flex items-center justify-center gap-2 text-sm font-semibold transition-all hover:scale-[1.02]`,r===`dark`?`bg-z-hover border-z-border text-z-primary hover:bg-[var(--z-bg-hover)]`:`bg-z-input border-z-border shadow-sm text-z-primary hover:bg-[var(--z-bg-hover)]`),children:(0,Q.jsx)(`span`,{children:`Google OAuth`})})]})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})},At=()=>{let e=Te(),{theme:t,toggleTheme:n}=G(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),{register:l,handleSubmit:u,formState:{errors:d}}=Me({resolver:Ie(Dt)});return(0,Q.jsxs)(`div`,{className:J(`min-h-screen flex items-center justify-center p-6 relative overflow-hidden font-sans antialiased transition-colors duration-500`,t===`dark`?`bg-app text-z-primary`:`bg-[#fafafa] text-[#111827]`),children:[(0,Q.jsx)(`div`,{className:J(`absolute top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,t===`dark`?`bg-z-panel/5`:`bg-z-border/[0.03]`)}),(0,Q.jsx)(`div`,{className:J(`absolute bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,t===`dark`?`bg-z-panel/5`:`bg-z-border/[0.02]`)}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-8`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:J(`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105`,`bg-z-primary text-z-inverse`),children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:J(`text-4xl font-semibold leading-none transition-colors`,`text-z-primary`),children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Access_Recovery_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:J(`border rounded-none-none p-8 shadow-2xl relative transition-all duration-500`,`bg-z-panel border-z-border shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:J(`text-xl font-semibold transition-colors`,`text-z-primary`),children:`Recover Password`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:`Credentials Verification`})]}),(0,Q.jsxs)(`div`,{className:J(`p-1 rounded-none-none border flex items-center gap-1 transition-all`,t===`dark`?`bg-z-hover border-z-border`:`bg-[var(--z-bg-hover)] border-z-border`),children:[(0,Q.jsx)(`button`,{onClick:()=>t!==`light`&&n(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,t===`light`?`bg-z-panel text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(be,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>t!==`dark`&&n(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,t===`dark`?`bg-z-accent text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(ye,{size:14})})]})]}),a?(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(M,{className:`text-z-secondary w-12 h-12`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed`,`text-z-secondary`),children:a}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/login`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,t===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(Ke,{size:16}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})]}):(0,Q.jsxs)(`form`,{onSubmit:u(async e=>{c(!0),i(null),o(null);try{o((await K.post(`/auth/forgot-password`,{email:e.email})).data?.data?.message||`Verification token dispatched successfully.`)}catch(e){i(e.response?.data?.error?.message||`Failed to dispatch recovery token.`)}finally{c(!1)}}),className:`space-y-6`,children:[r&&(0,Q.jsxs)(`div`,{className:J(`border rounded-none-none p-4 flex items-center gap-3 mb-6 overflow-hidden transition-colors`,t===`dark`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-red-50 border-red-100 text-red-600`),children:[(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:r})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Email Address`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(le,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,t===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...l(`email`),type:`email`,placeholder:`Enter your email`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,t===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)})]}),d.email&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:d.email.message})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:s,className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group disabled:opacity-50 disabled:pointer-events-none`,t===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:s?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Dispatch Recovery Node`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})}),(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(z,{to:`/login`,className:J(`text-sm font-semibold hover:underline flex items-center justify-center gap-2 transition-colors`,t===`dark`?`text-z-secondary hover:text-z-secondary`:`text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(Ke,{size:10}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})},jt=()=>{let e=Te(),[t]=he(),n=t.get(`token`),{theme:r,toggleTheme:i}=G(),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),{register:m,handleSubmit:h,formState:{errors:g}}=Me({resolver:Ie(Ot)});return(0,Q.jsxs)(`div`,{className:J(`min-h-screen flex items-center justify-center p-6 relative overflow-hidden font-sans antialiased transition-colors duration-500`,r===`dark`?`bg-app text-z-primary`:`bg-[#fafafa] text-[#111827]`),children:[(0,Q.jsx)(`div`,{className:J(`absolute top-[-10%] left-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,r===`dark`?`bg-z-panel/5`:`bg-z-border/[0.03]`)}),(0,Q.jsx)(`div`,{className:J(`absolute bottom-[-10%] right-[-10%] w-[50%] h-[50%] rounded-none-none blur-[120px] pointer-events-none transition-all duration-500`,r===`dark`?`bg-z-panel/5`:`bg-z-border/[0.02]`)}),(0,Q.jsxs)(`div`,{className:`w-full max-w-[400px] relative z-10 flex flex-col gap-8`,children:[(0,Q.jsxs)(W.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex flex-col items-center text-center`,children:[(0,Q.jsx)(`div`,{className:J(`w-14 h-14 mb-6 rounded-none-none flex items-center justify-center shadow-2xl relative group cursor-pointer overflow-hidden transition-all duration-500 hover:scale-105`,`bg-z-primary text-z-inverse`),children:(0,Q.jsx)(pt,{size:`sm`,className:`scale-75`})}),(0,Q.jsx)(`h1`,{className:J(`text-4xl font-semibold leading-none transition-colors`,`text-z-primary`),children:`ZENITH`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-z-muted`,children:`Access_Recovery_Interface`})]}),(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:J(`border rounded-none-none p-8 shadow-2xl relative transition-all duration-500`,`bg-z-panel border-z-border shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h2`,{className:J(`text-xl font-semibold transition-colors`,`text-z-primary`),children:`Reset Password`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-muted font-bold leading-none mt-1`,children:`Initialize New Password`})]}),(0,Q.jsxs)(`div`,{className:J(`p-1 rounded-none-none border flex items-center gap-1 transition-all`,r===`dark`?`bg-z-hover border-z-border`:`bg-[var(--z-bg-hover)] border-z-border`),children:[(0,Q.jsx)(`button`,{onClick:()=>r!==`light`&&i(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,r===`light`?`bg-z-panel text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(be,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>r!==`dark`&&i(),className:J(`w-7 h-7 flex items-center justify-center rounded-none-none transition-all`,r===`dark`?`bg-z-accent text-z-primary shadow-sm`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(ye,{size:14})})]})]}),n?c?(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(M,{className:`text-z-secondary w-12 h-12 animate-pulse`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed`,`text-z-secondary`),children:c}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/login`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(`span`,{children:`Proceed to Login`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})]}):(0,Q.jsxs)(`form`,{onSubmit:h(async e=>{if(!n){s(`Invalid or expired reset token in address.`);return}d(!0),s(null),l(null);try{l((await K.post(`/auth/reset-password`,{token:n,password:e.password})).data?.data?.message||`Password updated successfully. Login with your new credentials.`)}catch(e){s(e.response?.data?.error?.message||`Failed to reset password.`)}finally{d(!1)}}),className:`space-y-6`,children:[o&&(0,Q.jsxs)(`div`,{className:J(`border rounded-none-none p-4 flex items-center gap-3 mb-6 overflow-hidden transition-colors`,r===`dark`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-red-50 border-red-100 text-red-600`),children:[(0,Q.jsx)(j,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold tracking-wide`,children:o})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`New Password`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,r===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...m(`password`),type:f?`text`:`password`,placeholder:`••••••••`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-12 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,r===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:J(`absolute right-4 top-1/2 -translate-y-1/2 p-1 rounded-none-none transition-colors`,r===`dark`?`text-z-primary/20 hover:text-z-primary`:`text-z-secondary hover:text-z-primary`),children:f?(0,Q.jsx)(A,{size:16}):(0,Q.jsx)(a,{size:16})})]}),g.password&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:g.password.message})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-semibold text-z-muted px-1`,children:`Confirm Password`}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(je,{className:J(`absolute left-4 top-1/2 -translate-y-1/2 transition-colors`,r===`dark`?`text-z-primary/20 group-focus-within:text-z-secondary`:`text-z-secondary group-focus-within:text-z-secondary`),size:16}),(0,Q.jsx)(`input`,{...m(`confirmPassword`),type:`password`,placeholder:`••••••••`,className:J(`w-full border rounded-none-none py-3 pl-12 pr-4 text-xs font-bold outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all`,r===`dark`?`bg-z-hover border-z-border text-z-primary focus:bg-z-panel/10 focus:ring-2 focus:ring-z-active-border`:`bg-z-input border-z-border shadow-sm text-z-primary focus:bg-z-panel focus:ring-2 focus:ring-z-active-border`)})]}),g.confirmPassword&&(0,Q.jsx)(`p`,{className:`text-sm text-red-500 font-bold mt-1 px-1`,children:g.confirmPassword.message})]})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:u,className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group disabled:opacity-50 disabled:pointer-events-none`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-primary text-z-inverse hover:brightness-110 shadow-[var(--z-border)]`),children:u?(0,Q.jsx)(_,{size:18,className:`animate-spin`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Commit New Password`}),(0,Q.jsx)(F,{size:16,className:`group-hover:translate-x-1 transition-transform`})]})}),(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(z,{to:`/login`,className:J(`text-sm font-semibold hover:underline flex items-center justify-center gap-2 transition-colors`,r===`dark`?`text-z-secondary hover:text-z-secondary`:`text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(Ke,{size:10}),(0,Q.jsx)(`span`,{children:`Return to Login`})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(j,{className:`text-red-500 w-12 h-12 animate-bounce`})}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold tracking-wide px-2 leading-relaxed text-red-500`),children:`Token Verification Failure: Missing or Expired Security Payload in URL.`}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/forgot-password`),className:J(`w-full rounded-none-none py-4 flex items-center justify-center gap-3 text-xs font-semibold shadow-xl transition-all group`,r===`dark`?`bg-z-panel text-z-primary hover:bg-[var(--z-bg-hover)] shadow-[var(--z-border)]`:`bg-z-accent text-z-primary hover:bg-app shadow-[var(--z-border)]`),children:[(0,Q.jsx)(Ke,{size:16}),(0,Q.jsx)(`span`,{children:`Recover Password Again`})]})]})]}),(0,Q.jsx)(`p`,{className:`text-center text-sm font-bold text-z-muted`,children:`Authorized Personnel Only • Zenith CMS Engine`})]})]})};function Mt(){let e=Te(),t=tt(e=>e.logout),n=tt(e=>e.user),r=q(e=>e.setActiveSiteId),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,ee]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(``),[te,A]=(0,Z.useState)(``),ne=i.find(e=>(e._id||e.id)===c),j=ne&&ne.ownerId===n?.id,re=async()=>{d(!0);try{let e=(await K.get(`/workspaces`)).data?.data||[];a(e);let t=localStorage.getItem(`activeWorkspaceId`);t&&!e.some(e=>(e._id||e.id)===t)&&(t=null),!t&&e.length>0&&(t=e[0]._id||e[0].id),l(t),t&&localStorage.setItem(`activeWorkspaceId`,t),s((await K.get(`/sites`)).data?.data||[])}catch{U.error(`Failed to load workspaces and sites.`)}finally{d(!1)}};(0,Z.useEffect)(()=>{re()},[]);let M=t=>{let n=t.workspaceId||c;n&&localStorage.setItem(`activeWorkspaceId`,n);let i=t._id||t.id||``;localStorage.setItem(`activeSiteId`,i),localStorage.setItem(`activeSiteName`,t.name),localStorage.setItem(`activeSiteSlug`,t.slug),localStorage.setItem(`activeSiteDomain`,t.domain||``),r(i,t.name),K.defaults.headers[`x-zenith-site-id`]=i,U.success(`Entering site: ${t.name}`),e(`/`)},N=async e=>{if(e.preventDefault(),!y||!S){U.error(`Workspace name and slug are required.`);return}try{let e=(await K.post(`/workspaces`,{name:y,slug:S.toLowerCase()})).data?.data;U.success(`Workspace created successfully!`),a(t=>[...t,e]);let t=e._id||e.id;l(t),localStorage.setItem(`activeWorkspaceId`,t),b(``),C(``),h(!1)}catch(e){U.error(e.response?.data?.error?.message||`Failed to create workspace.`)}},P=async e=>{if(e.preventDefault(),!T||!D){U.error(`Name and slug are required fields.`);return}if(!c){U.error(`Please select or create a workspace first.`);return}p(!0);try{let e=(await K.post(`/sites`,{name:T,slug:D.toLowerCase(),icon:O,description:te,workspaceId:c})).data?.data;U.success(`Site tenant created successfully!`),s(t=>[...t,e]),E(``),ee(``),A(``),k(``),M(e)}catch(e){U.error(e.response?.data?.error?.message||`Failed to create site.`)}finally{p(!1)}},I=()=>{t(),e(`/login`)},L=o.filter(e=>e.workspaceId===c);return(0,Q.jsxs)(`div`,{className:`flex-1 w-full min-h-0 bg-app text-z-primary flex flex-col justify-between overflow-y-auto overflow-x-hidden`,children:[(0,Q.jsxs)(`header`,{className:`border-b border-z-border px-8 py-6 flex items-center justify-between backdrop-blur-md bg-z-header sticky top-0 z-50`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-8 h-8 rounded-none-none border border-z-border bg-z-hover`,children:[(0,Q.jsx)(_,{size:16,className:`text-z-primary animate-spin opacity-80`,strokeWidth:1.5}),(0,Q.jsx)(`div`,{className:`absolute inset-0 blur-lg bg-z-hover rounded-none-none`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-primary`,children:`Zenith`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-z-secondary block -mt-1 font-mono`,children:`Platform Nucleus`})]})]}),(0,Q.jsxs)(`button`,{onClick:I,className:`flex items-center gap-2 px-4 py-2 border border-z-border bg-z-panel hover:bg-[var(--z-bg-hover)] text-sm font-semibold text-z-primary/60 hover:text-z-primary transition-all duration-300 font-mono`,children:[(0,Q.jsx)(me,{size:12}),`Sign Out`]})]}),(0,Q.jsxs)(`main`,{className:`max-w-6xl w-full mx-auto px-6 py-12 flex-grow flex flex-col justify-start`,children:[(0,Q.jsxs)(`div`,{className:`max-w-2xl mb-12`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-2 px-3 py-1 border border-z-border bg-z-hover text-sm font-semibold text-z-primary/50 mb-4 rounded-none-none font-mono`,children:[(0,Q.jsx)(x,{size:10,className:`animate-spin-slow`}),` Hierarchical Workspace & Tenant Select`]}),(0,Q.jsx)(`h1`,{className:`text-4xl md:text-5xl font-semibold leading-[1.1] mb-4`,children:`Select Site Tenant`}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-[13px] leading-relaxed`,children:`Welcome to Zenith multi-tenant launchpad. Isolate sites, media libraries, roles, and schema collections by selecting a Workspace, then choosing a Site.`})]}),u?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-24 gap-4`,children:[(0,Q.jsx)(_,{size:32,className:`animate-spin text-z-secondary`}),(0,Q.jsx)(`p`,{className:`text-sm font-bold text-z-secondary font-mono`,children:`Querying active workspaces...`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Q.jsxs)(`div`,{className:`border border-z-border bg-z-panel p-6 rounded-none-none backdrop-blur-[12px]`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-primary/40 font-mono`,children:`Workspaces`})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i.map(e=>{let t=e._id||e.id,n=c===t;return(0,Q.jsxs)(`button`,{onClick:()=>{l(t||null),t&&localStorage.setItem(`activeWorkspaceId`,t)},className:`flex items-center gap-3 px-5 py-3 transition-all duration-300 border ${n?`border-[var(--z-active-border)] bg-[var(--z-active-bg)] text-[var(--z-active-text)] shadow-sm`:`border-z-border bg-z-panel text-z-secondary hover:border-z-border hover:text-z-primary`} rounded-none-none`,children:[(0,Q.jsx)(ce,{size:14,className:n?`text-[var(--z-active-text)]`:`text-z-secondary`}),(0,Q.jsxs)(`div`,{className:`text-left`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold block leading-tight`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-sm font-mono text-z-secondary block font-bold`,children:[`/`,e.slug]})]})]},t)}),j&&(0,Q.jsx)(`button`,{onClick:()=>v(!0),className:`flex items-center gap-2 px-5 py-3 border border-red-900/30 hover:border-red-500/50 hover:bg-red-950/10 text-sm font-semibold text-red-500/50 hover:text-red-500 transition-all duration-300 font-mono rounded-none-none`,children:`Delete Workspace`}),(0,Q.jsxs)(`button`,{onClick:()=>h(!0),className:`flex items-center gap-2 px-5 py-3 border border-dashed border-z-border hover:border-[var(--z-active-border)] text-sm font-semibold text-z-primary/50 hover:text-[var(--z-active-text)] transition-all duration-300 font-mono rounded-none-none`,children:[(0,Q.jsx)(w,{size:14}),`New Workspace`]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6 items-start`,children:[(0,Q.jsxs)(`div`,{className:`md:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[L.map(e=>{let t=e._id||e.id||``;return(0,Q.jsxs)(`div`,{onClick:()=>M(e),className:`group relative border border-z-border bg-z-panel hover:border-[var(--z-active-border)] p-6 flex flex-col justify-between h-full min-h-[12rem] cursor-pointer transition-all duration-500 overflow-hidden rounded-none-none shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-z-panel group-hover:bg-z-hover transition-colors duration-500`}),(0,Q.jsx)(`div`,{className:`absolute -right-16 -bottom-16 w-32 h-32 bg-z-hover rounded-none-none blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),(0,Q.jsxs)(`div`,{className:`relative z-10 flex items-start justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-3xl filter saturate-50 group-hover:saturate-100 transition-all duration-300 flex-shrink-0`,children:e.icon||``}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-secondary font-mono bg-z-hover px-2 py-1 truncate max-w-[60%]`,children:e.slug})]}),(0,Q.jsxs)(`div`,{className:`relative z-10 mt-6 flex-grow`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold group-hover:text-[var(--z-active-text)] transition-colors duration-300 break-words line-clamp-3`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-sm mt-1 line-clamp-3 leading-relaxed break-words`,children:e.description||`No description provided.`})]}),(0,Q.jsx)(`div`,{className:`relative z-10 flex items-center justify-between border-t border-z-border pt-3 mt-4`,children:(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-primary/30 group-hover:text-z-primary/80 transition-colors duration-300 flex items-center gap-1 font-mono`,children:[`Enter Site`,` `,(0,Q.jsx)(F,{size:10,className:`transform group-hover:translate-x-1 transition-transform`})]})})]},t)}),L.length===0&&(0,Q.jsxs)(`div`,{className:`col-span-2 border border-dashed border-z-border p-12 text-center flex flex-col items-center justify-center gap-4 rounded-none-none`,children:[(0,Q.jsx)(x,{size:40,className:`text-z-secondary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`No sites inside workspace`}),(0,Q.jsx)(`p`,{className:`text-z-secondary text-sm mt-1 max-w-xs mx-auto`,children:`Create your first site tenant on the right to start building under this workspace.`})]})]})]}),(0,Q.jsxs)(`div`,{className:`p-8 shadow-sm bg-z-panel backdrop-blur-xl border border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-6`,children:[(0,Q.jsx)(w,{size:16,className:`text-[var(--z-active-text)]`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`New Site Tenant`})]}),(0,Q.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Site Name`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:T,onChange:e=>{E(e.target.value),D||ee(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`))},placeholder:`e.g. Zenith E-Commerce`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Unique Slug / Identifier`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:D,onChange:e=>ee(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`)),placeholder:`e.g. zenith-commerce`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2`,children:[(0,Q.jsxs)(`div`,{className:`col-span-1`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Icon`}),(0,Q.jsxs)(`select`,{value:O,onChange:e=>k(e.target.value),className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-2 py-3 text-[14px] focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none text-z-primary`,children:[(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`}),(0,Q.jsx)(`option`,{value:``,className:`bg-z-base text-z-primary`})]})]}),(0,Q.jsxs)(`div`,{className:`col-span-3`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Description`}),(0,Q.jsx)(`input`,{type:`text`,value:te,onChange:e=>A(e.target.value),placeholder:`e.g. Storefront platform`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:f||!c,className:`w-full bg-z-panel text-z-primary hover:bg-z-panel/90 disabled:bg-z-hover disabled:text-z-secondary px-6 py-3.5 text-sm font-semibold flex items-center justify-center gap-2 transition-all duration-300 font-mono shadow-sm`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_,{size:12,className:`animate-spin`}),`Creating...`]}):(0,Q.jsx)(Q.Fragment,{children:`Create Site Tenant`})})]})]})]})]})]}),m&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-md p-8 relative overflow-hidden shadow-sm bg-z-panel backdrop-blur-xl border border-z-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ce,{size:16,className:`text-[var(--z-active-text)]`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:`New Workspace`})]}),(0,Q.jsx)(`button`,{onClick:()=>h(!1),className:`text-z-secondary hover:text-z-primary text-xs font-mono`,children:`[CLOSE]`})]}),(0,Q.jsxs)(`form`,{onSubmit:N,className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Workspace Name`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:y,onChange:e=>{b(e.target.value),S||C(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`))},placeholder:`e.g. Zenith Studio`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-semibold text-z-primary/40 mb-1.5 font-mono`,children:`Unique Slug / Identifier`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,value:S,onChange:e=>C(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g,`-`)),placeholder:`e.g. zenith-studio`,className:`w-full bg-z-panel border border-z-border focus:border-[var(--z-accent)]/50 px-4 py-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-colors rounded-none-none placeholder:text-z-secondary text-z-primary`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`flex-1 border border-z-border hover:bg-z-hover px-6 py-3.5 text-sm font-semibold text-z-primary transition-colors duration-300 font-mono`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,className:`flex-1 bg-[var(--z-accent)] text-z-primary hover:bg-[#059669] px-6 py-3.5 text-sm font-semibold transition-colors duration-300 font-mono shadow-sm`,children:`Create`})]})]})]})}),g&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-md p-8 relative overflow-hidden shadow-sm bg-z-panel backdrop-blur-xl border border-red-900/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ce,{size:16,className:`text-red-500`}),(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-red-500`,children:`Delete Workspace`})]}),(0,Q.jsx)(`button`,{onClick:()=>v(!1),className:`text-z-secondary hover:text-z-primary text-xs font-mono`,children:`[CLOSE]`})]}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-z-secondary leading-relaxed`,children:`Are you absolutely sure you want to permanently delete this workspace and all of its associated sites, content, and media? This action cannot be undone.`}),(0,Q.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>v(!1),className:`flex-1 border border-z-border hover:bg-z-hover px-6 py-3.5 text-sm font-semibold text-z-primary transition-colors duration-300 font-mono`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{K.delete(`/workspaces/${c}`).then(()=>{U.success(`Workspace deleted`),v(!1),re()}).catch(e=>{U.error(e.response?.data?.error?.message||`Failed to delete workspace`)})},className:`flex-1 bg-red-950/20 text-red-500 border border-red-900/30 hover:bg-red-500 hover:text-z-logo-text px-6 py-3.5 text-sm font-semibold transition-colors duration-300 font-mono shadow-sm`,children:`Permanently Delete`})]})]})]})}),(0,Q.jsxs)(`footer`,{className:`border-t border-z-border px-8 py-6 flex flex-col md:flex-row items-center justify-between text-sm font-bold text-z-primary/35 font-mono`,children:[(0,Q.jsx)(`div`,{children:`Zenith Engine v2.4.0-CORE-OS`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 mt-4 md:mt-0`,children:[(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`Documentation`}),(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`API Reference`}),(0,Q.jsx)(`a`,{href:`#`,className:`hover:text-z-primary transition-colors`,children:`Enterprise Nucleus`})]})]})]})}var Nt=Oe(e=>({isOpen:!1,title:`Confirm`,message:``,confirmText:`Confirm`,cancelText:`Cancel`,variant:`info`,resolve:null,open:t=>new Promise(n=>{e({isOpen:!0,title:t.title||`Confirm`,message:t.message||``,confirmText:t.confirmText||`Confirm`,cancelText:t.cancelText||`Cancel`,variant:t.variant||`info`,resolve:n})}),close:t=>{let{resolve:n}=Nt.getState();n&&n(t),e({isOpen:!1,resolve:null})}}));async function Pt(e){return await Nt.getState().open(e)}var Ft=({selectedIds:e,bulkProcessing:t,theme:n,onClearSelection:r,onBulkAction:i})=>(0,Q.jsxs)(W.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:`auto`},exit:{opacity:0,y:-10,height:0},transition:{duration:.2},className:J(`border rounded-none-none px-6 py-3 flex items-center justify-between gap-4 shadow-lg`,n===`dark`?`bg-z-panel/5 border-z-border`:`bg-z-input border-z-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[e.size,` Selected`]}),(0,Q.jsx)(`button`,{onClick:r,className:`p-1 text-z-secondary hover:text-z-primary transition-colors`,title:`Clear selection`,children:(0,Q.jsx)(B,{size:12})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`button`,{onClick:()=>i(`publish`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-z-panel/5 border-z-border text-z-secondary hover:bg-z-hover border-z-border-strong`:`bg-z-input border-z-border text-z-secondary hover:bg-[var(--z-bg-hover)]`),children:[(0,Q.jsx)(te,{size:11}),` Publish`]}),(0,Q.jsxs)(`button`,{onClick:()=>i(`unpublish`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-amber-500/10 border-amber-500/20 text-amber-400 hover:bg-amber-500/20`:`bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100`),children:[(0,Q.jsx)(s,{size:11}),` Unpublish`]}),(0,Q.jsxs)(`button`,{onClick:()=>i(`delete`),disabled:t,className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,n===`dark`?`bg-red-500/10 border-red-500/20 text-red-400 hover:bg-red-500/20`:`bg-red-50 border-red-200 text-red-600 hover:bg-red-100`),children:[t?(0,Q.jsx)(_,{size:11,className:`animate-spin`}):(0,Q.jsx)(o,{size:11}),` Delete`]})]})]}),It=({slug:e,theme:t,onClose:n,onImported:r})=>{let[a,o]=(0,Z.useState)(`csv`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1);return(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[1000] flex items-center justify-center p-4 bg-z-panel backdrop-blur-md`,children:(0,Q.jsxs)(W.div,{initial:{opacity:0,scale:.98,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:15},className:J(`border rounded-none-none w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden`,`bg-z-panel border-z-border text-z-primary shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`px-8 py-6 border-b flex justify-between items-center`,style:{borderColor:t===`dark`?`rgba(255,255,255,0.05)`:`#f3f4f6`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsx)(`div`,{className:`w-9 h-9 bg-z-accent rounded-none-none flex items-center justify-center text-z-primary shadow-lg`,children:(0,Q.jsx)(Ge,{size:16})}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Import Data`}),(0,Q.jsxs)(`p`,{className:`text-sm font-bold text-z-muted mt-1`,children:[e,` collection`]})]})]}),(0,Q.jsx)(`button`,{onClick:n,className:`w-8 h-8 flex items-center justify-center bg-[var(--z-bg-input)] hover:bg-[var(--z-bg-hover)] dark:bg-z-hover dark:hover:bg-[var(--z-bg-hover)] rounded-none-none transition-colors`,children:(0,Q.jsx)(B,{size:14,className:`text-z-muted`})})]}),(0,Q.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`Format:`}),(0,Q.jsxs)(`button`,{onClick:()=>{o(`csv`),m(null)},className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,a===`csv`?`bg-z-accent border-z-border text-z-primary`:t===`dark`?`bg-z-hover border-z-border text-z-muted hover:text-z-primary`:`bg-z-panel border-z-border text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(ee,{size:12}),` CSV`]}),(0,Q.jsxs)(`button`,{onClick:()=>{o(`json`),m(null)},className:J(`px-4 py-2 rounded-none-none font-semibold text-sm transition-all flex items-center gap-2 border`,a===`json`?`bg-z-accent border-z-border text-z-primary`:t===`dark`?`bg-z-hover border-z-border text-z-muted hover:text-z-primary`:`bg-z-panel border-z-border text-z-secondary hover:text-z-primary`),children:[(0,Q.jsx)(i,{size:12}),` JSON`]})]}),(0,Q.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1);let t=e.dataTransfer.files[0];t&&(u(t),c(``),m(null))},className:J(`border-2 border-dashed rounded-none-none p-8 text-center transition-all cursor-pointer`,g?`border-z-border bg-z-hover`:t===`dark`?`border-z-border hover:border-z-border`:`border-z-border hover:border-z-border-strong`),onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=a===`csv`?`.csv`:`.json`,e.onchange=e=>{let t=e.target.files?.[0];t&&(u(t),c(``),m(null))},e.click()},children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[a===`csv`?(0,Q.jsx)(ee,{size:32,className:`text-z-secondary `}):(0,Q.jsx)(i,{size:32,className:`text-z-secondary `}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:l.name}),(0,Q.jsxs)(`span`,{className:`text-sm font-bold text-z-secondary`,children:[(l.size/1024).toFixed(1),` KB — Click to change`]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(Ge,{size:32,className:`text-z-secondary/40`}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[`Drop `,a.toUpperCase(),` file here or click to browse`]}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-muted`,children:`Or paste data in the text area below`})]})}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`label`,{className:`text-sm font-semibold text-z-secondary`,children:[`Or paste `,a.toUpperCase(),` data:`]}),(0,Q.jsx)(`textarea`,{value:s,onChange:e=>{c(e.target.value),u(null),m(null)},rows:6,className:J(`w-full border rounded-none-none px-4 py-3 text-xs font-mono outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black transition-all resize-y`,t===`dark`?`bg-z-hover border-z-border text-z-primary focus:border-z-border/50`:`bg-z-input border-z-border focus:border-z-border`),placeholder:a===`csv`?`name,title,price
4
4
  Product A,Title A,29.99
5
5
  Product B,Title B,49.99`:`[
6
6
  {"name": "Product A", "title": "Title A", "price": 29.99},
@@ -8,4 +8,4 @@ Product B,Title B,49.99`:`[
8
8
  ]`})]}),p&&(0,Q.jsxs)(`div`,{className:J(`border rounded-none-none p-5 space-y-3`,p.errors.length===0?t===`dark`?`bg-z-hover border-z-border/20`:`bg-z-input border-z-border`:t===`dark`?`bg-amber-500/5 border-amber-500/20`:`bg-amber-50 border-amber-200`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[p.errors.length===0?(0,Q.jsx)(h,{size:16,className:`text-z-secondary `}):(0,Q.jsx)(j,{size:16,className:`text-amber-500`}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold`,children:[p.imported,` of `,p.total,` records imported`,p.errors.length>0&&` (${p.errors.length} errors)`]})]}),p.errors.length>0&&(0,Q.jsx)(`div`,{className:`max-h-32 overflow-y-auto space-y-1`,children:p.errors.map((e,t)=>(0,Q.jsxs)(`div`,{className:`text-sm font-mono text-red-400`,children:[`Row `,e.row,`: `,e.error]},t))})]})]}),(0,Q.jsxs)(`div`,{className:`px-8 py-6 border-t flex justify-end gap-3`,style:{borderColor:t===`dark`?`rgba(255,255,255,0.05)`:`#f3f4f6`,background:t===`dark`?`rgba(255,255,255,0.02)`:`#f9fafb`},children:[(0,Q.jsx)(`button`,{onClick:n,className:J(`px-6 py-3 font-semibold text-sm transition-all `,t===`dark`?`bg-z-hover text-z-muted hover:text-z-primary`:`bg-z-panel border border-z-border shadow-sm text-z-muted hover:text-z-primary`),children:`Cancel`}),(0,Q.jsxs)(`button`,{onClick:async()=>{f(!0),m(null);try{let t;if(l)t=await l.text();else if(s.trim())t=s.trim();else{U.error(`Upload a file or paste data`),f(!1);return}let n=(await K.post(`/import-export/${e}?format=${a}`,{data:t})).data.data;m(n),U.success(n.message||`Imported ${n.imported} records`),n.imported>0&&r()}catch(e){U.error(e.response?.data?.message||`Import failed`)}finally{f(!1)}},disabled:d||!l&&!s.trim(),className:J(`px-8 py-3 rounded-none-none font-semibold text-sm shadow-xl transition-all flex items-center gap-2 disabled:opacity-40`,t===`dark`?`bg-z-accent hover:bg-z-base text-z-primary shadow-[var(--z-border)]`:`bg-z-accent hover:bg-z-base text-z-primary`),children:[d?(0,Q.jsx)(_,{size:12,className:`animate-spin`}):(0,Q.jsx)(Ge,{size:12}),d?`Importing...`:`Import`]})]})]})})};function Lt({title:e,description:t,icon:n,actions:r,className:i,backLink:a}){let{theme:o}=G();return(0,Q.jsxs)(`div`,{className:J(`px-6 py-4 border-b flex items-center justify-between transition-colors`,o===`dark`?`bg-[var(--z-bg-modal)] backdrop-blur-md border-z-border`:`bg-z-panel/80 backdrop-blur-md border-z-border`,i),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[a&&(0,Q.jsx)(`a`,{href:a.to,className:`flex items-center justify-center p-2 rounded-none border border-transparent hover:border-z-border hover:bg-z-hover transition-all text-z-secondary`,children:(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`lucide lucide-arrow-left`,children:[(0,Q.jsx)(`path`,{d:`m12 19-7-7 7-7`}),(0,Q.jsx)(`path`,{d:`M19 12H5`})]})}),n&&(0,Q.jsx)(`div`,{className:J(`p-2.5 rounded-none-none border`,o===`dark`?`bg-z-panel border-z-border text-z-active-text`:`bg-z-input border-z-border text-z-accent`),children:n}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:J(`text-xl font-semibold leading-none`,`text-z-primary`),children:e}),t&&(0,Q.jsx)(`p`,{className:J(`text-xs mt-1`,o===`dark`?`text-z-muted`:`text-z-secondary`),children:t})]})]}),r&&(0,Q.jsx)(`div`,{className:`flex items-center gap-3`,children:r})]})}function Rt({className:e,children:t,padding:n=`md`,interactive:r=!1,...i}){let{theme:a}=G(),o={none:`p-0`,sm:`p-3`,md:`p-6`,lg:`p-8`}[n];return(0,Q.jsx)(`div`,{className:J(`relative rounded-none border transition-all duration-200 overflow-hidden`,a===`dark`?`bg-z-panel backdrop-blur-md border-z-border shadow-sm`:`bg-z-panel border-z-border shadow-sm`,r&&(a===`dark`?`hover:border-z-accent/50 hover:bg-app/80`:`hover:border-z-accent/50 hover:bg-[var(--z-bg-input)]`),o,e),...i,children:t})}function zt({className:e,children:t,...n}){return(0,Q.jsx)(`div`,{className:J(`p-6`,e),...n,children:t})}var Bt=({slug:e,theme:t})=>(0,Q.jsxs)(`div`,{className:J(`py-24 px-6 text-center border-dashed border-2 rounded-none-none flex flex-col items-center justify-center gap-6 my-10 mx-auto max-w-2xl`,t===`dark`?`border-z-border bg-z-panel`:`border-z-border/20 bg-[var(--z-bg-input)]/50`),children:[(0,Q.jsx)(`div`,{className:J(`w-16 h-16 rounded-none-none flex items-center justify-center`,t===`dark`?`bg-z-hover text-z-secondary`:`bg-[var(--z-bg-hover)] text-z-secondary`),children:(0,Q.jsx)(ne,{size:28})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:`Collection is Empty`}),(0,Q.jsx)(`p`,{className:J(`text-sm max-w-sm mx-auto font-medium`,t===`dark`?`text-z-muted`:`text-z-secondary`),children:`This collection doesn't have any records yet. Initialize the first record to launch the page builder.`})]}),(0,Q.jsxs)(z,{to:`/collections/${e}/new`,className:J(`px-8 py-4 rounded-none-none font-semibold text-sm shadow-xl transition-all leading-none flex items-center gap-3`,`bg-z-panel border border-z-border text-z-primary hover:bg-z-hover shadow-sm`),children:[(0,Q.jsx)(w,{size:16,strokeWidth:3}),` Launch Page Builder`]})]}),Vt=()=>{let{slug:e}=_e(),t=Te(),{theme:n}=G(),{mutate:i}=L(),a=q(e=>e.activeSiteId),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(1),[m,h]=(0,Z.useState)(0),[g,v]=(0,Z.useState)(`active`),{data:y,isLoading:b}=ut(),{data:x,isLoading:C}=dt(e||``,d,g),T=b||C,[E,ee]=(0,Z.useState)(``),[O,A]=(0,Z.useState)(`table`),[j,re]=(0,Z.useState)(null),M=l.filter(e=>{let t=E.toLowerCase();return Object.values(e).some(e=>String(e).toLowerCase().includes(t))}),[N,P]=(0,Z.useState)([`name`,`title`,`price`,`category`,`_status`,`updatedAt`]),[F,I]=(0,Z.useState)([]),[ae,oe]=(0,Z.useState)(!1),[R,se]=(0,Z.useState)(new Set),[B,ce]=(0,Z.useState)(!1),[V,le]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!y||!e)return;let n=y.globals||[],r=y.collections||[],i=n.some(t=>t.slug===e),a=r.find(t=>t.slug===e);re(a),(a?.singleton||i)&&t(i?`/globals/${e}`:`/collections/${e}/singleton`)},[y,e,t]),(0,Z.useEffect)(()=>{x&&(u(x.items),h(x.total),x.items.length>0&&I(Array.from(new Set(x.items.flatMap(e=>Object.keys(e)))).filter(e=>typeof e==`string`&&!e.startsWith(`_`)&&e!==`id`&&e!==`__v`)))},[x]);let ue=async(t,n=!1)=>{if(await Pt({message:n?`Permanently delete this record? This cannot be undone.`:`Confirm deletion?`}))try{n?(await K.delete(`/${e}/${t}/hard`),U.success(`Record permanently purged`)):(await K.delete(`/${e}/${t}`),U.success(`Record purged`)),u(l.filter(e=>(e._id||e.id)!==t)),h(e=>e-1),i([`collectionItems`,a,e,g,d])}catch{U.error(`Purge failure`)}},de=async t=>{if(await Pt({message:`Restore this record?`}))try{await K.post(`/${e}/${t}/restore`),U.success(`Record restored`),u(l.filter(e=>(e._id||e.id)!==t)),h(e=>e-1),i([`collectionItems`,a,e,g,d])}catch{U.error(`Restore failure`)}},fe=(0,Z.useCallback)(e=>{se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=(0,Z.useCallback)(()=>{se(e=>e.size===M.length?new Set:new Set(M.map(e=>e._id||e.id)))},[M]),me=(0,Z.useCallback)(()=>{se(new Set)},[]),he=e===`pages`||j?.fields?.some(e=>e.type===`blocks`||e.type===`dynamicZone`||e.name===`sections`)||!1,ge=async t=>{let n=Array.from(R);if(n.length!==0&&await Pt({message:{delete:`Delete ${n.length} selected record(s)? This cannot be undone.`,publish:`Publish ${n.length} selected record(s)?`,unpublish:`Unpublish ${n.length} selected record(s)?`}[t]})){ce(!0);try{t===`delete`?(await K.post(`/${e}/bulk/delete`,{ids:n}),U.success(`${n.length} records deleted`),u(e=>e.filter(e=>!R.has(e._id||e.id))),h(e=>e-n.length)):t===`publish`?(await K.post(`/${e}/bulk/publish`,{ids:n}),U.success(`${n.length} records published`),u(e=>e.map(e=>R.has(e._id||e.id)?{...e,_status:`published`}:e))):t===`unpublish`&&(await K.post(`/${e}/bulk/unpublish`,{ids:n}),U.success(`${n.length} records unpublished`),u(e=>e.map(e=>R.has(e._id||e.id)?{...e,_status:`draft`}:e))),se(new Set),i([`collectionItems`,a,e,g,d])}catch{U.error(`Bulk ${t} failed`)}finally{ce(!1)}}},ve=async(t,n)=>{let r=n===`draft`?`publish`:`unpublish`;if(l.find(e=>(e._id||e.id)===t)){u(e=>e.map(e=>(e._id||e.id)===t?{...e,_status:r===`publish`?`published`:`draft`}:e));try{await K.post(`/${e}/bulk/${r}`,{ids:[t]}),U.success(`Record ${r}ed`)}catch{U.error(`Failed to ${r} record`),u(e=>e.map(e=>(e._id||e.id)===t?{...e,_status:n}:e))}}};return(0,Q.jsxs)(`div`,{className:J(`pb-10 min-h-screen transition-colors duration-500`,n===`dark`?`bg-app text-z-primary`:`bg-[#fafafa] text-z-primary`),children:[(0,Q.jsx)(Lt,{title:e?.replace(/-/g,`_`),description:`Manage ${e} • ${m} Total Records`,icon:(0,Q.jsx)(D,{size:24}),actions:(0,Q.jsx)(`div`,{className:`flex items-center gap-6`,children:(0,Q.jsxs)(z,{to:`/collections/${e}/new`,className:J(`px-8 py-4 rounded-none-none font-semibold text-sm shadow-xl transition-all leading-none flex items-center gap-3`,n===`dark`?`bg-white/15 text-white hover:bg-white/20`:`bg-z-primary text-z-inverse hover:brightness-110 shadow-sm`),children:[(0,Q.jsx)(w,{size:18,strokeWidth:3}),` `,he?`Launch Page Builder`:`New Record`]})})}),(0,Q.jsxs)(`div`,{className:`p-10 space-y-10`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col justify-between gap-2 p-5 border transition-colors z-panel backdrop-blur-md shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`Total Records`}),(0,Q.jsx)(ne,{size:13,className:`text-z-secondary`})]}),(0,Q.jsx)(`span`,{className:`text-2xl font-semibold leading-none tabular-nums text-z-primary dark:text-z-primary`,children:m})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col justify-between gap-2 p-5 border transition-colors z-panel backdrop-blur-md shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`Collection ID`}),(0,Q.jsx)(c,{size:13,className:`text-z-secondary`})]}),(0,Q.jsx)(`span`,{className:`text-2xl font-semibold leading-none tabular-nums text-z-primary dark:text-z-primary uppercase`,children:e?.substring(0,8)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col justify-between gap-2 p-5 border transition-colors z-panel backdrop-blur-md shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`Search Filter`}),(0,Q.jsx)(p,{size:13,className:`text-z-secondary`})]}),(0,Q.jsx)(`span`,{className:`text-2xl font-semibold leading-none tabular-nums text-z-primary dark:text-z-primary`,children:E?`Active`:`None`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col justify-between gap-2 p-5 border transition-colors z-panel backdrop-blur-md shadow-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:`View Mode`}),(0,Q.jsx)(D,{size:13,className:`text-z-secondary`})]}),(0,Q.jsx)(`span`,{className:`text-2xl font-semibold leading-none tabular-nums text-z-primary dark:text-z-primary capitalize`,children:g})]})]}),(0,Q.jsx)(H,{children:R.size>0&&(0,Q.jsx)(Ft,{selectedIds:R,bulkProcessing:B,theme:n,onClearSelection:me,onBulkAction:ge})}),j?.softDelete&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-z-border dark:border-z-border mb-4 pb-2`,children:[(0,Q.jsx)(`button`,{onClick:()=>{v(`active`),f(1)},className:J(`px-4 py-2 text-sm font-semibold transition-colors`,g===`active`?`text-z-secondary border-b-2 border-z-border`:`text-z-secondary hover:text-z-primary dark:hover:text-z-primary`),children:`Active Records`}),(0,Q.jsxs)(`button`,{onClick:()=>{v(`trash`),f(1)},className:J(`px-4 py-2 text-sm font-semibold transition-colors flex items-center gap-2`,g===`trash`?`text-red-500 border-b-2 border-red-500`:`text-z-secondary hover:text-red-400`),children:[(0,Q.jsx)(o,{size:12}),` Recycle Bin`]})]}),(0,Q.jsxs)(Rt,{padding:`none`,children:[(0,Q.jsxs)(`div`,{className:J(`px-6 py-4 border-b flex items-center justify-between`,n===`dark`?`bg-z-panel/5 border-z-border`:`bg-[var(--z-bg-input)]/20`),children:[(0,Q.jsxs)(`div`,{className:`relative w-full max-w-sm`,children:[(0,Q.jsx)(p,{className:`absolute left-4 top-1/2 -translate-y-1/2 text-z-secondary`,size:14}),(0,Q.jsx)(`input`,{type:`text`,value:E,onChange:e=>ee(e.target.value),placeholder:`Search records...`,className:J(`w-full border rounded-none-none py-2.5 pl-10 pr-4 text-sm font-semibold focus:ring-4 transition-all outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black `,`bg-z-input border-z-border text-z-primary focus:border-z-active-border`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 mr-4`,children:(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[M.length,` Matches`]})}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{onClick:()=>oe(!ae),className:`p-2.5 border rounded-none-none text-z-secondary hover:text-z-secondary transition-colors`,children:(0,Q.jsx)(D,{size:14})}),(0,Q.jsx)(H,{children:ae&&(0,Q.jsxs)(W.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:J(`absolute right-0 top-full mt-2 w-64 border rounded-none-none shadow-2xl z-50 p-4 backdrop-blur-3xl`,`bg-z-popover border-z-border shadow-sm`),children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold mb-4 text-z-secondary `,children:`Visible Columns`}),(0,Q.jsx)(`div`,{className:`space-y-2 max-h-64 overflow-y-auto`,children:F.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>P(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:`w-full flex items-center justify-between p-2 rounded-none-none hover:bg-z-hover transition-all group`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-secondary group-hover:text-z-primary`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`div`,{className:J(`w-3 h-3 rounded-none-none border transition-all`,N.includes(e)?`bg-z-border border-z-border`:`border-z-border`)})]},e))})]})})]}),(0,Q.jsx)(`button`,{onClick:()=>{if(l.length===0)return;let t=[Object.keys(l[0]).filter(e=>!e.startsWith(`_`)).join(`,`),...l.map(e=>Object.entries(e).filter(([e])=>!e.startsWith(`_`)).map(([,e])=>`"${String(e).replace(/"/g,`""`)}"`).join(`,`))].join(`
9
9
  `),n=new Blob([t],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.setAttribute(`hidden`,``),i.setAttribute(`href`,r),i.setAttribute(`download`,`${e}_export_${Date.now()}.csv`),document.body.appendChild(i),i.click(),document.body.removeChild(i),U.success(`CSV_EXPORT_COMPLETE`)},className:`p-2.5 border rounded-none-none text-z-secondary hover:text-z-secondary transition-colors`,title:`Export`,children:(0,Q.jsx)(k,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>le(!0),className:`p-2.5 border rounded-none-none text-z-secondary hover:text-z-secondary transition-colors`,title:`Import`,children:(0,Q.jsx)(Ge,{size:14})}),(0,Q.jsx)(`div`,{className:`w-px h-6 bg-[var(--z-border)] mx-2`}),(0,Q.jsxs)(`div`,{className:`flex bg-[var(--z-bg-hover)] dark:bg-z-hover border border-z-border dark:border-z-border rounded-none-none p-0.5`,children:[(0,Q.jsx)(`button`,{onClick:()=>A(`table`),className:J(`p-2 transition-all`,O===`table`?`bg-z-panel dark:bg-app shadow-sm text-z-secondary `:`text-z-secondary hover:text-z-primary dark:hover:text-z-primary`),title:`Table View`,children:(0,Q.jsx)(Ve,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>A(`cards`),className:J(`p-2 transition-all`,O===`cards`?`bg-z-panel dark:bg-app shadow-sm text-z-secondary `:`text-z-secondary hover:text-z-primary dark:hover:text-z-primary`),title:`Cards View`,children:(0,Q.jsx)(Je,{size:14})}),(0,Q.jsx)(`button`,{onClick:()=>A(`kanban`),className:J(`p-2 transition-all`,O===`kanban`?`bg-z-panel dark:bg-app shadow-sm text-z-secondary `:`text-z-secondary hover:text-z-primary dark:hover:text-z-primary`),title:`Kanban View`,children:(0,Q.jsx)(He,{size:14})})]})]})]}),O===`table`&&(0,Q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Q.jsx)(`div`,{className:`overflow-x-auto min-w-full pb-4`,children:(0,Q.jsxs)(`table`,{className:`w-full`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:J(`border-b text-left text-sm font-semibold text-z-secondary `,`border-z-border`),children:[(0,Q.jsx)(`th`,{className:`px-4 py-4 w-10`,children:(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),pe()},className:`flex items-center justify-center`,title:R.size===M.length&&M.length>0?`Deselect all`:`Select all`,children:R.size===M.length&&M.length>0?(0,Q.jsx)(xe,{size:14,className:`text-z-secondary `}):(0,Q.jsx)(S,{size:14,className:J(`text-z-secondary`,R.size>0&&`text-z-secondary`)})})}),(0,Q.jsx)(`th`,{className:`px-6 py-4`,children:`ID`}),F.filter(e=>N.includes(e)).map(e=>(0,Q.jsx)(`th`,{className:`px-6 py-4`,children:e.toUpperCase()},e)),(0,Q.jsx)(`th`,{className:`px-6 py-4 text-right`,children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{className:J(`divide-y`,`divide-z-border`),children:T?(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:N.length+3,className:`py-20 text-center`,children:(0,Q.jsx)(_,{size:24,className:`animate-spin mx-auto text-z-secondary opacity-20`})})}):M.length===0?(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:N.length+3,className:`py-10`,children:(0,Q.jsx)(Bt,{slug:e||``,theme:n})})}):M.map(n=>{let i=n._id||n.id,a=R.has(i);return(0,Q.jsxs)(`tr`,{className:J(`hover:bg-z-border/[0.02] transition-colors group cursor-pointer border-b border-z-border`,a&&`bg-z-border/[0.06]`),onClick:()=>t(`/collections/${e}/${i}`),children:[(0,Q.jsx)(`td`,{className:`px-4 py-4`,children:(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),fe(i)},className:`flex items-center justify-center`,children:a?(0,Q.jsx)(xe,{size:14,className:`text-z-secondary `}):(0,Q.jsx)(S,{size:14,className:`text-z-secondary group-hover:text-z-muted`})})}),(0,Q.jsx)(`td`,{className:`px-6 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:J(`w-1.5 h-1.5 rounded-none-none`,a?`bg-z-input`:`bg-z-border`)}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary `,children:[`#`,String(i).slice(-6)]})]})}),F.filter(e=>N.includes(e)).map(e=>(0,Q.jsx)(`td`,{className:`px-6 py-4`,children:(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold `,e===`_status`&&n[e]===`published`?`text-z-secondary`:e===`_status`&&n[e]===`draft`?`text-amber-400`:``),children:typeof n[e]==`object`?`[Complex_Object]`:String(n[e]||`—`)})},e)),(0,Q.jsx)(`td`,{className:`px-6 py-4 text-right`,children:(0,Q.jsx)(`div`,{className:`flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-all`,children:g===`active`?(0,Q.jsxs)(Q.Fragment,{children:[n._status&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ve(i,n._status)},className:J(`p-2 rounded-none-none border`,n._status===`draft`?`hover:text-z-secondary hover:border-z-border`:`hover:text-amber-500 hover:border-amber-500`),title:n._status===`draft`?`Publish`:`Unpublish`,children:n._status===`draft`?(0,Q.jsx)(te,{size:12}):(0,Q.jsx)(s,{size:12})}),(0,Q.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(`/collections/${e}/${i}`)},className:`p-2 rounded-none-none border hover:text-z-secondary `,children:(0,Q.jsx)(r,{size:12})}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(i)},className:`p-2 rounded-none-none border hover:text-red-500`,children:(0,Q.jsx)(o,{size:12})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),de(i)},className:`px-3 py-1 rounded-none-none border hover:bg-z-border hover:text-z-primary hover:border-z-border text-sm font-bold transition-all`,children:`Restore`}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(i,!0)},className:`px-3 py-1 rounded-none-none border hover:bg-red-500 hover:text-z-primary hover:border-red-500 text-sm font-bold transition-all`,children:`Delete Forever`})]})})})]},i)})})]})})}),O===`cards`&&(0,Q.jsx)(`div`,{className:`p-6`,children:T?(0,Q.jsx)(`div`,{className:`py-20 flex justify-center`,children:(0,Q.jsx)(_,{size:24,className:`animate-spin text-z-secondary opacity-20`})}):M.length===0?(0,Q.jsx)(`div`,{className:`py-20 text-center opacity-20 text-sm font-semibold`,children:`No_Records_Found`}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6`,children:M.map(i=>{let a=i._id||i.id,c=R.has(a);return(0,Q.jsxs)(`div`,{onClick:()=>t(`/collections/${e}/${a}`),className:J(`border rounded-none-none p-5 flex flex-col gap-4 cursor-pointer transition-all hover:-translate-y-1 hover:shadow-xl`,n===`dark`?`bg-z-panel border-z-border hover:border-z-border`:`bg-z-panel border-z-border shadow-sm hover:border-z-border/20`,c&&(n===`dark`?`border-z-border/50 bg-z-hover`:`border-z-border/50 bg-[var(--z-bg-input)]`)),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),fe(a)},children:c?(0,Q.jsx)(xe,{size:14,className:`text-z-secondary `}):(0,Q.jsx)(S,{size:14,className:`text-z-muted`})}),(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary `,children:[`#`,String(a).slice(-8)]})]}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:g===`active`?(0,Q.jsxs)(Q.Fragment,{children:[i._status&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ve(a,i._status)},className:i._status===`draft`?`text-z-muted hover:text-z-secondary `:`text-z-muted hover:text-amber-500`,title:i._status===`draft`?`Publish`:`Unpublish`,children:i._status===`draft`?(0,Q.jsx)(te,{size:12}):(0,Q.jsx)(s,{size:12})}),(0,Q.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(`/collections/${e}/${a}`)},className:`text-z-muted hover:text-z-secondary `,children:(0,Q.jsx)(r,{size:12})}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(a)},className:`text-z-muted hover:text-red-500`,children:(0,Q.jsx)(o,{size:12})})]}):(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),de(a)},className:`text-sm font-bold text-z-secondary `,children:`Restore`})})]}),(0,Q.jsx)(`div`,{className:`space-y-3`,children:F.filter(e=>N.includes(e)).slice(0,4).map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:J(`text-xs font-medium truncate`,e===`_status`&&i[e]===`published`?`text-z-secondary `:``),children:typeof i[e]==`object`?`[Object]`:String(i[e]||`—`)})]},e))})]},a)})})}),O===`kanban`&&(0,Q.jsx)(`div`,{className:`p-6 overflow-x-auto`,children:T?(0,Q.jsx)(`div`,{className:`py-20 flex justify-center`,children:(0,Q.jsx)(_,{size:24,className:`animate-spin text-z-secondary opacity-20`})}):M.length===0?(0,Q.jsx)(`div`,{className:`py-20 text-center opacity-20 text-sm font-semibold`,children:`No_Records_Found`}):(0,Q.jsx)(`div`,{className:`flex gap-6 min-w-max pb-4`,children:(()=>{let r=F.includes(`_status`)||F.includes(`status`)?F.includes(`_status`)?`_status`:`status`:null,i={};return r?M.forEach(e=>{let t=String(e[r]||`Draft`).toLowerCase();i[t]||(i[t]=[]),i[t].push(e)}):i.Uncategorized=M,Object.entries(i).map(([i,a])=>(0,Q.jsxs)(`div`,{className:J(`w-80 flex flex-col border rounded-none-none`,`bg-z-panel border-z-border shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:`p-4 flex items-center justify-between border-b border-inherit`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:J(`w-2 h-2 rounded-none-none shadow-[0_0_8px_currentColor]`,i===`published`?`bg-z-border text-z-secondary `:i===`draft`?`bg-amber-500 text-amber-500`:`bg-z-border text-z-secondary`)}),i]}),(0,Q.jsx)(`span`,{className:`text-sm font-bold text-z-secondary bg-z-hover px-2 py-0.5 rounded-none-none`,children:a.length})]}),(0,Q.jsx)(`div`,{className:`p-4 flex flex-col gap-3 h-full max-h-[60vh] overflow-y-auto`,children:a.map(i=>{let a=i._id||i.id,o=R.has(a);return(0,Q.jsxs)(`div`,{onClick:()=>t(`/collections/${e}/${a}`),className:J(`p-4 border rounded-none-none cursor-pointer transition-all hover:shadow-lg`,n===`dark`?`bg-[#0a0a0a] border-z-border hover:border-z-border`:`bg-z-panel border-z-border hover:border-z-border/30`,o&&`ring-1 ring-z-active-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-z-secondary`,children:[`#`,String(a).slice(-6)]}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),fe(a)},children:o?(0,Q.jsx)(xe,{size:12,className:`text-z-secondary `}):(0,Q.jsx)(S,{size:12,className:`text-z-muted`})})]}),F.filter(e=>N.includes(e)&&e!==r).slice(0,2).map(e=>(0,Q.jsxs)(`div`,{className:`mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-bold text-z-secondary`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs truncate text-ellipsis`,children:String(i[e]||`—`)})]},e))]},a)})})]},i))})()})}),(0,Q.jsxs)(`div`,{className:J(`p-4 border-t flex items-center justify-between text-sm font-semibold text-z-secondary `,`border-z-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{size:10}),(0,Q.jsx)(`span`,{children:e?.toUpperCase()})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`button`,{disabled:d===1,onClick:()=>f(d-1),className:`p-1.5 border rounded-none-none disabled:opacity-20`,children:(0,Q.jsx)(De,{size:14})}),(0,Q.jsx)(`span`,{className:J(`px-3 py-1 rounded-none-none text-z-primary`,n===`dark`?`bg-z-panel/10`:`bg-z-accent`),children:d}),(0,Q.jsx)(`button`,{disabled:l.length<10,onClick:()=>f(d+1),className:`p-1.5 border rounded-none-none disabled:opacity-20`,children:(0,Q.jsx)(ie,{size:14})})]})]})]})]}),(0,Q.jsx)(H,{children:V&&(0,Q.jsx)(It,{slug:e,theme:n,onClose:()=>le(!1),onImported:async()=>{i([`collectionItems`,a,e,g,d])}})})]})},Ht=[{name:`anchorId`,type:`text`,placeholder:`e.g. section-id`,label:`Anchor ID`},{name:`theme`,type:`select`,options:[{label:`Default`,value:`default`},{label:`Light`,value:`light`},{label:`Dark`,value:`dark`},{label:`Cyber-Purple Gradient`,value:`cyber-gray`},{label:`Glassmorphic Translucent`,value:`glassmorphic`}],placeholder:`Select Theme`,label:`Theme`},{name:`paddingY`,type:`select`,options:[{label:`None`,value:`none`},{label:`Small`,value:`small`},{label:`Medium`,value:`medium`},{label:`Large`,value:`large`}],placeholder:`Select Vertical Padding`,label:`Vertical Padding`},{name:`containerWidth`,type:`select`,options:[{label:`Boxed`,value:`boxed`},{label:`Full Width`,value:`full-width`}],placeholder:`Select Container Width`,label:`Container Width`},{name:`bgImage`,type:`media`,label:`Background Image`}],Ut={anchorId:``,theme:`default`,paddingY:`medium`,containerWidth:`boxed`,bgImage:null},Wt=[{type:`hero`,iconName:`Star`,title:`Hero Module`,description:`Impactful entry with background & CTA`,category:`Layout`,fields:[{name:`headline`,type:`text`,placeholder:`Future Engine`},{name:`subheadline`,type:`text`,placeholder:`Modular architecture for visionaries.`},{name:`callToAction`,type:`text`,placeholder:`Launch Protocol`},{name:`backgroundImage`,type:`media`}],defaultContent:{headline:`Future Engine`,subheadline:`Modular architecture for visionaries.`,callToAction:`Launch Protocol`,backgroundImage:null}},{type:`features`,iconName:`Grid`,title:`Feature Grid`,description:`Grid-based feature comparison`,category:`Layout`,fields:[{name:`heading`,type:`text`,placeholder:`Core Capabilities`},{name:`featureList`,type:`array`,fields:[{name:`title`,type:`text`,placeholder:`Title`},{name:`description`,type:`text`,placeholder:`Description`}]},{name:`featureContent`,type:`dz`,label:`Feature Content`}],defaultContent:{heading:`Core Capabilities`,featureList:[{title:`Velocity`,description:`Near-zero latency lookups.`},{title:`Security`,description:`End-to-end encryption.`}],featureContent:[]}},{type:`stats`,iconName:`BarChart4`,title:`Stats Counter`,description:`Animated performance metrics`,category:`Content`,fields:[{name:`items`,type:`array`,fields:[{name:`label`,type:`text`,placeholder:`Uptime`},{name:`value`,type:`text`,placeholder:`99.9%`}]}],defaultContent:{items:[{label:`Uptime`,value:`99.9%`},{label:`Latency`,value:`12ms`}]}},{type:`testimonials`,iconName:`MessageSquare`,title:`Testimonials`,description:`Customer testimonials & reviews`,category:`Social`,fields:[{name:`heading`,type:`text`,placeholder:`Global Voices`},{name:`items`,type:`array`,fields:[{name:`quote`,type:`text`,placeholder:`Quote`},{name:`author`,type:`text`,placeholder:`Author`},{name:`role`,type:`text`,placeholder:`Role`}]}],defaultContent:{heading:`Global Voices`,items:[{quote:`Zenith changed the scale of our deployment.`,author:`Alex_Vander`,role:`Architect`}]}},{type:`newsletter`,iconName:`Mail`,title:`Newsletter`,description:`Email signup & list building`,category:`Social`,fields:[{name:`title`,type:`text`,placeholder:`Join The Network`},{name:`description`,type:`text`,placeholder:`Stay updated.`},{name:`buttonText`,type:`text`,placeholder:`Subscribe`}],defaultContent:{title:`Join The Network`,description:`Stay updated with the latest manifests.`,buttonText:`Subscribe`}},{type:`pricing`,iconName:`CreditCard`,title:`Pricing Table`,description:`Feature comparison pricing`,category:`Commerce`,fields:[{name:`heading`,type:`text`,placeholder:`Parametric Plans`},{name:`plans`,type:`array`,fields:[{name:`name`,type:`text`,placeholder:`Enterprise`},{name:`price`,type:`text`,placeholder:`$999/mo`},{name:`features`,type:`text`,placeholder:`Unlimited Nodes`}]}],defaultContent:{heading:`Parametric Plans`,plans:[{name:`Enterprise`,price:`$999/mo`,features:`Unlimited Nodes`}]}},{type:`cta`,iconName:`Zap`,title:`Call to Action`,description:`Conversion-focused CTA banner`,category:`Content`,fields:[{name:`title`,type:`text`,placeholder:`Ready to scale?`},{name:`description`,type:`text`,placeholder:`Join the next generation.`},{name:`buttonText`,type:`text`,placeholder:`Connect Now`}],defaultContent:{title:`Ready to scale?`,description:`Join the next generation of architects.`,buttonText:`Connect Now`}},{type:`richTextSection`,iconName:`FileText`,title:`Rich Text`,description:`WYSIWYG content block with inline widgets`,category:`Content`,fields:[{name:`content`,type:`richtext`},{name:`inlineComponents`,type:`dz`,label:`Inline Components`,components:[`callout`,`code`,`table`,`accordion`,`socialShare`]}],defaultContent:{content:`<h2>Deep Architecture</h2><p>Refined prose for complex narratives.</p>`,inlineComponents:[]}},{type:`gallery`,iconName:`Layout`,title:`Gallery`,description:`Image gallery & portfolio grid`,category:`Media`,fields:[{name:`heading`,type:`text`,placeholder:`Project Exhibits`},{name:`items`,type:`array`,fields:[{name:`image`,type:`media`},{name:`caption`,type:`text`,placeholder:`System Node 01`}]}],defaultContent:{heading:`Project Exhibits`,items:[{image:null,caption:`System Node 01`}]}},{type:`team`,iconName:`Users`,title:`Team Members`,description:`Staff directory & profiles`,category:`Social`,fields:[{name:`heading`,type:`text`,placeholder:`System Architects`},{name:`members`,type:`array`,fields:[{name:`name`,type:`text`,placeholder:`Name`},{name:`role`,type:`text`,placeholder:`Role`},{name:`bio`,type:`text`,placeholder:`Bio`}]}],defaultContent:{heading:`System Architects`,members:[{name:`Elena Kors`,role:`Lead Developer`,bio:`Neural network specialist.`}]}},{type:`faq`,iconName:`MessageSquare`,title:`FAQ`,description:`Frequently asked questions`,category:`Content`,fields:[{name:`heading`,type:`text`,placeholder:`Protocol FAQ`},{name:`items`,type:`array`,fields:[{name:`question`,type:`text`,placeholder:`Question`},{name:`answer`,type:`text`,placeholder:`Answer`}]}],defaultContent:{heading:`Protocol FAQ`,items:[{question:`How secure is Zenith?`,answer:`AES-256 encryption at rest.`}]}},{type:`callout`,iconName:`AlertCircle`,title:`Callout Box`,description:`Notice, warning, or tip alert box`,category:`General`,fields:[{name:`type`,type:`select`,options:[{label:`Info`,value:`info`},{label:`Warning`,value:`warning`},{label:`Success`,value:`success`},{label:`Error`,value:`error`}],placeholder:`Select type`},{name:`content`,type:`richtext`,placeholder:`Alert details...`}],defaultContent:{type:`info`,content:`<p>Important notice for users.</p>`}},{type:`code`,iconName:`Code`,title:`Code Snippet`,description:`Syntax-highlighted code editor`,category:`General`,fields:[{name:`language`,type:`select`,options:[`javascript`,`typescript`,`html`,`css`,`json`,`python`,`rust`,`go`,`bash`],placeholder:`Select language`},{name:`code`,type:`code`,placeholder:`const x = 42;`}],defaultContent:{language:`javascript`,code:`console.log("Hello Zenith!");`}},{type:`table`,iconName:`Table`,title:`Data Table`,description:`Grid layout for comparative data`,category:`General`,fields:[{name:`headers`,type:`array`,fields:[{name:`text`,type:`text`,placeholder:`Header text`}]},{name:`rows`,type:`array`,fields:[{name:`cells`,type:`array`,fields:[{name:`text`,type:`text`,placeholder:`Cell text`}]}]}],defaultContent:{headers:[{text:`Feature`},{text:`Zenith`},{text:`Others`}],rows:[{cells:[{text:`Customization`},{text:`High`},{text:`Medium`}]},{cells:[{text:`Speed`},{text:`Insane`},{text:`Average`}]}]}},{type:`accordion`,iconName:`MessageSquare`,title:`Accordion`,description:`Expandable content panels`,category:`Content`,fields:[{name:`heading`,type:`text`,placeholder:`Frequently Asked Questions`},{name:`items`,type:`array`,fields:[{name:`title`,type:`text`,placeholder:`Item Title`},{name:`content`,type:`richtext`,placeholder:`Item content details...`}]}],defaultContent:{heading:`Frequently Asked Questions`,items:[{title:`What is Zenith?`,content:`<p>Zenith is a premium decoupled hybrid CMS.</p>`},{title:`How does it render?`,content:`<p>Via high-performance visual canvas layers.</p>`}]}},{type:`logoGrid`,iconName:`Grid`,title:`Logo Grid`,description:`Client & partner showcase`,category:`Media`,fields:[{name:`heading`,type:`text`,placeholder:`Trusted by global teams`},{name:`logos`,type:`array`,fields:[{name:`image`,type:`media`},{name:`name`,type:`text`,placeholder:`Company Name`},{name:`link`,type:`text`,placeholder:`https://company.com`}]}],defaultContent:{heading:`Trusted by global teams`,logos:[{image:null,name:`Vanguard Inc`,link:`https://vanguard.io`},{image:null,name:`Apex Ltd`,link:`https://apex.co`}]}},{type:`videoHero`,iconName:`Zap`,title:`Video Hero`,description:`Full-width video background hero`,category:`Layout`,fields:[{name:`headline`,type:`text`,placeholder:`Experience Velocity`},{name:`subheadline`,type:`text`,placeholder:`Where performance meets elegance.`},{name:`videoUrl`,type:`text`,placeholder:`https://assets.mixkit.co/videos/preview/mixkit-stars-in-space-background-1611-large.mp4`},{name:`posterImage`,type:`media`},{name:`autoplay`,type:`boolean`},{name:`controls`,type:`boolean`}],defaultContent:{headline:`Experience Velocity`,subheadline:`Where performance meets elegance.`,videoUrl:`https://assets.mixkit.co/videos/preview/mixkit-stars-in-space-background-1611-large.mp4`,posterImage:null,autoplay:!0,controls:!1}},{type:`announcementBar`,iconName:`AlertCircle`,title:`Announcement Bar`,description:`Site-wide alert banner`,category:`General`,fields:[{name:`message`,type:`text`,placeholder:`Attention: Version 2.0 has been deployed.`},{name:`link`,type:`text`,placeholder:`https://zenith.io/changelog`},{name:`linkText`,type:`text`,placeholder:`Read Changelog`},{name:`dismissible`,type:`boolean`}],defaultContent:{message:`Attention: Version 2.0 has been deployed.`,link:`https://zenith.io/changelog`,linkText:`Read Changelog`,dismissible:!0}},{type:`contactForm`,iconName:`Mail`,title:`Contact Form`,description:`Standard contact & lead capture form`,category:`Commerce`,fields:[{name:`title`,type:`text`,placeholder:`Initiate Contact`},{name:`description`,type:`text`,placeholder:`Send us a message and we will respond shortly.`},{name:`emailRecipient`,type:`text`,placeholder:`leads@zenith.io`},{name:`submitButtonText`,type:`text`,placeholder:`Send Message`}],defaultContent:{title:`Initiate Contact`,description:`Send us a message and we will respond shortly.`,emailRecipient:`leads@zenith.io`,submitButtonText:`Send Message`}},{type:`socialShare`,iconName:`Users`,title:`Social Links`,description:`Social media link bar`,category:`Social`,fields:[{name:`heading`,type:`text`,placeholder:`Connect with our networks`},{name:`platforms`,type:`array`,fields:[{name:`platform`,type:`select`,options:[{label:`Twitter/X`,value:`twitter`},{label:`Facebook`,value:`facebook`},{label:`LinkedIn`,value:`linkedin`},{label:`GitHub`,value:`github`},{label:`YouTube`,value:`youtube`}],placeholder:`Select Platform`},{name:`url`,type:`text`,placeholder:`https://social.com/profile`}]}],defaultContent:{heading:`Connect with our networks`,platforms:[{platform:`twitter`,url:`https://twitter.com/zenithcms`},{platform:`github`,url:`https://github.com/zenithcms`}]}},{type:`customHtml`,iconName:`Code`,title:`Custom HTML`,description:`Raw HTML and inline CSS code block`,category:`Advanced`,fields:[{name:`htmlContent`,type:`code`,placeholder:`<div class="custom">...</div>`}],defaultContent:{htmlContent:`<div style="padding: 2rem; text-align: center;">
10
10
  <h3>Custom Component</h3>
11
- </div>`}},{type:`pageEmbed`,iconName:`Copy`,title:`Page Embed`,description:`Embed another page or reusable component`,category:`Advanced`,fields:[{name:`reference`,type:`relation`,relationTo:`pages`,label:`Select Page to Embed`}],defaultContent:{reference:null}}].map(e=>({...e,fields:[...e.fields,...Ht],defaultContent:{...e.defaultContent,...Ut}})),Gt=e=>e.replace(/^root:/,``).replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()),Kt=e=>e?e.map(e=>({name:e.name,label:e.label||Gt(e.name),type:e.type,required:e.required,placeholder:e.placeholder,options:e.options,fields:Kt(e.fields),hasMany:e.hasMany,hasMore:e.hasMore,language:e.language,layout:e.layout,dateFormat:e.dateFormat,components:e.components,description:e.description,admin:e.admin})):[],qt=Wt.map(e=>({slug:e.type,labels:{singular:e.title,plural:e.title+`s`},fields:Kt(e.fields),admin:{description:e.description,category:e.category,icon:e.iconName}})),Jt=10,$=new Map;function Yt(){if($.size>Jt){let e=$.keys().next().value;e&&$.delete(e)}}async function Xt(e){let t=$.get(e);if(t?.blocks)return $.delete(e),$.set(e,t),t.blocks;if(t?.promise)return t.promise;let n=(async()=>{try{let t=await K.get(`/blocks`);return t.data?.data&&Array.isArray(t.data.data)&&t.data.data.length>0?($.set(e,{blocks:t.data.data,promise:null}),Yt(),t.data.data):qt}catch{return qt}})();$.set(e,{blocks:null,promise:n}),Yt();try{let t=await n;return $.has(e)&&$.set(e,{blocks:t,promise:null}),t}catch(t){throw $.delete(e),t}}function Zt(){let e=q(e=>e.activeSiteId),[t,n]=(0,Z.useState)(()=>qt);return(0,Z.useEffect)(()=>{if(!e)return;let t=$.get(e);if(t?.blocks){n(t.blocks);return}let r=!0;return Xt(e).then(e=>{r&&n(e)}).catch(e=>{r&&console.error(`Failed to fetch blocks`,e)}),()=>{r=!1}},[e]),t}function Qt(e){e?$.delete(e):$.clear()}var $t=null,en=null;async function tn(){return $t||en||(en=(async()=>{try{let e=await K.get(`/system/components`);return e.data?.data&&Array.isArray(e.data.data)?($t=e.data.data,$t):[]}catch{return[]}})(),en)}function nn(){$t=null,en=null}function rn(){let[e,t]=(0,Z.useState)(()=>$t||[]);return(0,Z.useEffect)(()=>{$t||tn().then(t)},[]),e}var an={Star:y,Grid:Ye,BarChart4:T,MessageSquare:se,Mail:le,CreditCard:f,Zap:Re,FileText:v,Layout:d,Users:ge,AlertCircle:j,Code:P,Table:n,Type:Ue};Wt.map(e=>({type:e.type,icon:an[e.iconName]||Re,title:e.title,description:e.description,category:e.category,fields:e.fields,defaultContent:e.defaultContent}));var on=e=>e.replace(/^root:/,``).replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()),sn=(e,t)=>t&&typeof t==`object`&&t.url||e.toLowerCase().includes(`image`)?`media`:e.toLowerCase().includes(`email`)?`email`:e.toLowerCase().includes(`content`)||e.toLowerCase().includes(`description`)||e.toLowerCase().includes(`body`)?`richtext`:Array.isArray(t)?`array`:typeof t==`object`&&t?`group`:typeof t==`number`?`number`:typeof t==`boolean`?`boolean`:`text`,cn={Star:y,Grid:Ye,BarChart4:T,MessageSquare:se,Mail:le,CreditCard:f,Zap:Re,FileText:v,Layout:d,Users:ge,AlertCircle:j,Code:P,Table:n,HelpCircle:g},ln=(0,Z.createContext)([]);function un(e){return e?e.map(e=>({name:e.name,label:e.label,type:e.type,fields:e.fields?un(e.fields):void 0,options:e.options,placeholder:e.placeholder,hasMany:e.hasMany,hasMore:e.hasMore,language:e.language,layout:e.layout,dateFormat:e.dateFormat,components:e.components,description:e.description,admin:e.admin})):[]}function dn(e){let t={};for(let n of e.fields||[])n.type===`text`||n.type===`richtext`?t[n.name]=``:n.type===`media`?t[n.name]=null:n.type===`array`?t[n.name]=[]:n.type===`number`?t[n.name]=0:n.type===`boolean`?t[n.name]=!1:n.type===`code`?t[n.name]=``:t[n.name]=null;return t}function fn({children:e}){let t=Zt(),n=rn(),r=(0,Z.useMemo)(()=>{let e=t.map(e=>({type:e.slug,icon:cn[e.admin?.icon||``]||fe,title:e.labels?.singular||e.slug,description:e.admin?.description||``,category:e.admin?.category||`General`,fields:un(e.fields),defaultContent:dn(e)})),r=n.map(e=>({type:e.slug,icon:cn[e.icon]||fe,title:e.displayName,description:e.description,category:e.category,fields:e.fields,defaultContent:dn({fields:e.fields})}));return[...e,...r]},[t,n]);return(0,Q.jsx)(ln.Provider,{value:r,children:e})}function pn(){return(0,Z.useContext)(ln)}var mn=[`templatesOpen`,`mediaLibraryOpen`,`seoOpen`,`relationsModalOpen`,`blockPickerOpen`,`componentPickerOpen`,`showLocaleDropdown`];function hn(e){return t=>t?{[e]:!0,...Object.fromEntries(mn.filter(t=>t!==e).map(e=>[e,!1]))}:{[e]:!1}}var gn=Oe(e=>({templatesOpen:!1,mediaLibraryOpen:!1,seoOpen:!1,showLocaleDropdown:!1,showFieldIndicators:!0,relationsModalOpen:!1,blockPickerOpen:!1,componentPickerOpen:!1,componentPickerCallback:null,componentPickerBlocks:null,setTemplatesOpen:t=>e(hn(`templatesOpen`)(t)),setMediaLibraryOpen:t=>e(hn(`mediaLibraryOpen`)(t)),setSeoOpen:t=>e(hn(`seoOpen`)(t)),setShowLocaleDropdown:t=>e(hn(`showLocaleDropdown`)(t)),setShowFieldIndicators:t=>e({showFieldIndicators:t}),setRelationsModalOpen:t=>e(hn(`relationsModalOpen`)(t)),setBlockPickerOpen:t=>e(hn(`blockPickerOpen`)(t)),openComponentPicker:(t,n=null)=>e({componentPickerOpen:!0,componentPickerCallback:t,componentPickerBlocks:n,templatesOpen:!1,mediaLibraryOpen:!1,seoOpen:!1,relationsModalOpen:!1,blockPickerOpen:!1,showLocaleDropdown:!1}),closeComponentPicker:()=>e({componentPickerOpen:!1,componentPickerCallback:null,componentPickerBlocks:null})})),_n=(e,t={})=>{let{onEscape:n,containerRef:r}=t,i=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e)return;i.current=document.activeElement;let t=r?.current||document.body,a=[`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`[contenteditable="true"]`].join(`, `),o=Array.from(t.querySelectorAll(a)).filter(e=>{let t=window.getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`&&e.offsetParent!==null&&!e.hasAttribute(`disabled`)&&!e.hasAttribute(`inert`)});o.length>0&&o[0].focus();let s=e=>{if(e.key===`Escape`&&n){n();return}if(e.key===`Tab`){if(o.length===0)return;let t=o[0],n=o[o.length-1];e.shiftKey?document.activeElement===t&&(e.preventDefault(),n.focus()):document.activeElement===n&&(e.preventDefault(),t.focus())}};return document.addEventListener(`keydown`,s),()=>{document.removeEventListener(`keydown`,s),i.current&&i.current.focus()}},[e,n,r])},vn={Layout:`from-z-accent to-transparent`,Content:`from-z-accent to-transparent`,Commerce:`from-z-accent to-transparent`,Media:`from-rose-900/70 to-pink-900/40`,Social:`from-amber-900/70 to-orange-900/40`,General:`from-[#1a1a2e]/80 to-[#16213e]/60`},yn=[`All`,`Layout`,`Content`,`Media`,`Social`,`Commerce`,`General`],bn=()=>{let{theme:e}=G(),{componentPickerOpen:t,componentPickerCallback:n,componentPickerBlocks:r,closeComponentPicker:i}=gn(),a=pn(),o=(0,Z.useMemo)(()=>{if(!r||r.length===0)return a;let e=new Set(r.map(e=>e.slug||e));return a.filter(t=>e.has(t.type))},[a,r]),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`All`),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{t?setTimeout(()=>f.current?.focus(),80):(c(``),u(`All`))},[t]),_n(t,{containerRef:d,onEscape:i});let m=(0,Z.useMemo)(()=>{let e=new Set(o.map(e=>e.category||`General`));return yn.filter(t=>t===`All`||e.has(t))},[o]),h=(0,Z.useMemo)(()=>{let e=s.toLowerCase().trim();return o.filter(t=>{let n=!e||t.title.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description.toLowerCase().includes(e),r=l===`All`||(t.category||`General`)===l;return n&&r})},[o,s,l]),g=(0,Z.useMemo)(()=>{if(l!==`All`)return{[l]:h};let e={};return h.forEach(t=>{let n=t.category||`General`;e[n]||(e[n]=[]),e[n].push(t)}),e},[h,l]),_=e=>{n?.(e),i()},v=e===`dark`;return(0,Q.jsx)(H,{children:t&&(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[900] flex items-center justify-center p-4 md:p-8`,children:[(0,Q.jsx)(W.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:i,className:`absolute inset-0 bg-app/75 backdrop-blur-md`}),(0,Q.jsxs)(W.div,{ref:d,role:`dialog`,"aria-modal":`true`,"aria-label":`Add a Component`,initial:{opacity:0,scale:.96,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:16},transition:{duration:.2,ease:[.4,0,.2,1]},className:J(`relative w-full max-w-3xl flex flex-col overflow-hidden rounded-none-none shadow-sm max-h-[90vh] border`,v?`bg-[#08080a] border-z-border`:`bg-z-panel border-z-border`),style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-z-accent/70 to-transparent`}),(0,Q.jsxs)(`div`,{className:J(`px-6 pt-6 pb-4 border-b flex-shrink-0`,`border-z-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between mb-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-z-active-text mb-1.5`,children:`Zenith Page Builder`}),(0,Q.jsx)(`h3`,{className:J(`text-2xl font-semibold`,`text-z-primary`),children:`Add a Component`}),(0,Q.jsx)(`p`,{className:J(`text-sm mt-1`,v?`text-z-muted`:`text-z-secondary`),children:`Choose a component to add to your layout`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Close component picker`,className:J(`w-9 h-9 flex items-center justify-center border rounded-none-none transition-all flex-shrink-0 mt-0.5`,v?`bg-z-hover border-z-border text-z-primary hover:bg-z-panel hover:text-z-primary`:`bg-[var(--z-bg-hover)] border-z-border text-z-primary hover:bg-app hover:text-z-primary`),children:(0,Q.jsx)(B,{size:15})})]}),(0,Q.jsxs)(`div`,{className:`relative mb-4`,children:[(0,Q.jsx)(p,{size:13,className:J(`absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none`,v?`text-z-secondary`:`text-z-muted`)}),(0,Q.jsx)(`input`,{ref:f,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Search components...`,className:J(`w-full pl-10 pr-10 py-2.5 text-sm rounded-none-none border transition-all outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black`,v?`bg-z-hover border-z-border text-z-primary placeholder:text-z-muted focus:border-z-accent/40 focus:bg-z-panel/[0.06]`:`bg-z-input border-z-border text-z-primary placeholder:text-z-muted focus:border-z-active-border`)}),s&&(0,Q.jsx)(`button`,{onClick:()=>c(``),className:J(`absolute right-3 top-1/2 -translate-y-1/2 transition-colors`,v?`text-z-secondary hover:text-z-primary`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(B,{size:12})})]}),(0,Q.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto no-scrollbar`,children:m.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:J(`px-3 py-1.5 text-sm font-semibold whitespace-nowrap flex-shrink-0 transition-all rounded-none-none border`,l===e?`bg-z-accent border-z-accent text-z-primary shadow-sm`:v?`bg-z-hover border-z-border text-z-muted hover:text-z-primary hover:border-z-active-border`:`bg-z-input border-z-border text-z-secondary hover:text-z-primary hover:border-z-active-border/50`),children:e},e))})]}),(0,Q.jsx)(`div`,{className:`overflow-y-auto flex-1 p-6 space-y-8 custom-editor-scrollbar`,children:Object.keys(g).length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-center`,children:[(0,Q.jsx)(p,{size:28,className:v?`text-z-primary`:`text-z-secondary`}),(0,Q.jsxs)(`p`,{className:J(`text-sm font-bold`,v?`text-z-muted`:`text-z-secondary`),children:[`No results for "`,s,`"`]}),(0,Q.jsx)(`p`,{className:J(`text-xs`,v?`text-z-secondary`:`text-z-muted`),children:`Try a different keyword or browse all categories`})]}):Object.entries(g).map(([e,t])=>(0,Q.jsxs)(`div`,{children:[l===`All`&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,Q.jsx)(`span`,{className:J(`h-px flex-1`,v?`bg-z-hover`:`bg-[var(--z-bg-hover)]`)}),(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold `,v?`text-z-secondary`:`text-z-muted`),children:e}),(0,Q.jsx)(`span`,{className:J(`h-px flex-1`,v?`bg-z-hover`:`bg-[var(--z-bg-hover)]`)})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.icon,n=vn[e.category||`General`]??vn.General;return(0,Q.jsxs)(W.button,{type:`button`,whileHover:{scale:1.02},whileTap:{scale:.97},onClick:()=>_(e.type),className:J(`flex flex-col text-left group border overflow-hidden rounded-none-none transition-all`,v?`bg-z-panel border-z-border hover:border-z-accent/50 hover:shadow-sm`:`bg-z-panel border-z-border hover:border-z-active-border hover:shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:J(`w-full h-20 flex items-center justify-center relative bg-gradient-to-br`,n),children:[(0,Q.jsx)(`div`,{className:`text-z-primary/30 group-hover:text-z-primary/70 transition-colors duration-300`,style:{transform:`scale(2.5)`},children:(0,Q.jsx)(t,{size:16})}),e.category&&(0,Q.jsx)(`span`,{className:`absolute top-2 left-2 px-1.5 py-0.5 text-sm font-semibold bg-app/50 backdrop-blur text-z-primary/80 rounded-none-none`,children:e.category}),(0,Q.jsx)(`div`,{className:`absolute bottom-0 right-0 p-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Q.jsx)(`div`,{className:`w-5 h-5 bg-z-accent flex items-center justify-center rounded-none-none`,children:(0,Q.jsx)(w,{size:10,className:`text-z-primary`})})})]}),(0,Q.jsxs)(`div`,{className:J(`p-3 flex-1 transition-colors`,v?`group-hover:opacity-90/5`:`group-hover:bg-z-active-bg/50`),children:[(0,Q.jsx)(`p`,{className:J(`text-sm font-semibold italic mb-0.5`,`text-z-primary`),children:e.title}),(0,Q.jsx)(`p`,{className:J(`text-sm leading-relaxed line-clamp-2`,v?`text-z-secondary`:`text-z-muted`),children:e.description})]})]},e.type)})})]},e))}),(0,Q.jsxs)(`div`,{className:J(`px-6 py-3 border-t flex items-center justify-between flex-shrink-0`,v?`border-z-border bg-z-panel`:`border-z-border bg-[var(--z-bg-input)]/50`),children:[(0,Q.jsxs)(`p`,{className:J(`text-sm`,v?`text-z-secondary`:`text-z-muted`),children:[h.length,` component`,h.length===1?``:`s`,` available`]}),(0,Q.jsxs)(`p`,{className:J(`text-sm`,v?`text-z-secondary`:`text-z-muted`),children:[`Press`,` `,(0,Q.jsx)(`kbd`,{className:J(`px-1.5 py-0.5 font-mono rounded-none-none text-sm border`,v?`bg-z-hover border-z-border`:`bg-z-panel border-z-border`),children:`Esc`}),` `,`to close`]})]})]})]})})},xn=({open:e,title:t,message:n,confirmLabel:r=`Confirm`,danger:i=!1,onConfirm:a,onCancel:o})=>{let{theme:s}=G(),c=(0,Z.useRef)(null);_n(e,{onEscape:o,containerRef:c});let u=s===`dark`;return(0,Q.jsx)(H,{children:e&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[900] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-sm`,onClick:e=>{e.target===e.currentTarget&&o()},children:(0,Q.jsxs)(W.div,{ref:c,role:`alertdialog`,"aria-modal":`true`,"aria-label":t,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.15},className:J(`w-full max-w-sm border rounded-none-none shadow-2xl p-5`,u?`bg-app border-z-border text-z-primary`:`bg-z-panel border-z-border text-z-primary`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:J(`w-9 h-9 rounded-none-none border flex items-center justify-center shrink-0`,i?u?`bg-rose-500/10 border-rose-500/20 text-rose-400`:`bg-rose-50 border-rose-200 text-rose-500`:u?`bg-amber-500/10 border-amber-500/20 text-amber-400`:`bg-amber-50 border-amber-200 text-amber-500`),children:(0,Q.jsx)(l,{size:16})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:t}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold mt-1.5 leading-relaxed`,u?`text-z-muted`:`text-z-secondary`),children:n})]}),(0,Q.jsx)(`button`,{onClick:o,"aria-label":`Cancel`,className:J(`shrink-0 p-1 transition-colors`,u?`text-z-secondary hover:text-z-primary`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(B,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,Q.jsx)(`button`,{onClick:o,"aria-label":`Cancel action`,className:J(`flex-1 py-2 text-xs font-semibold border rounded-none-none transition-all`,u?`border-z-border text-z-muted hover:border-z-border hover:text-z-primary`:`border-z-border text-z-secondary hover:border-z-border-strong hover:text-z-primary`),children:`Cancel`}),(0,Q.jsx)(`button`,{onClick:a,"aria-label":r,className:J(`flex-1 py-2 text-xs font-semibold rounded-none-none transition-all`,i?`bg-rose-600 hover:bg-rose-500 text-z-primary`:`bg-z-accent hover:bg-z-border text-z-primary`),children:r})]})]})})})},Sn=()=>{let{isOpen:e,title:t,message:n,confirmText:r,variant:i,close:a}=Nt(Ee(e=>({isOpen:e.isOpen,title:e.title,message:e.message,confirmText:e.confirmText,variant:e.variant,close:e.close})));return(0,Q.jsx)(xn,{open:e,title:t,message:n,confirmLabel:r,danger:i===`danger`,onConfirm:()=>a(!0),onCancel:()=>a(!1)})},Cn=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-app gap-6 p-8`,children:[(0,Q.jsx)(`div`,{className:`text-[80px] leading-none select-none text-z-primary/5 font-semibold font-mono`,children:`500`}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-red-500/60`,children:`Unexpected Error`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-secondary font-bold`,children:`An unexpected error occurred. Please refresh the page or contact support.`}),(0,Q.jsx)(`button`,{onClick:()=>window.location.reload(),className:`mt-4 px-6 py-2 border border-z-border text-sm font-semibold hover:border-red-500/30 hover:text-red-400 transition-all`,children:`Reload`})]}):this.props.children}},wn=(0,Z.lazy)(()=>I(()=>import(`./CollectionsPage-PZFwuhHd.js`),__vite__mapDeps([0,1,2,3,4,5]))),Tn=(0,Z.lazy)(()=>I(()=>import(`./CollectionHooksPage-CbnXaL4D.js`),__vite__mapDeps([6,1,2,3,4,5]))),En=(0,Z.lazy)(()=>I(()=>import(`./AuditLogPage-TYWW1lG9.js`),__vite__mapDeps([7,1,2,3,4,5]))),Dn=(0,Z.lazy)(()=>I(()=>import(`./MediaLibrary-BzXE95xo.js`),__vite__mapDeps([8,1,2,3,4,5]))),On=(0,Z.lazy)(()=>I(()=>import(`./SpatialEditor-PCM56yAC.js`),__vite__mapDeps([9,1,2,3,4,5,10,11]))),kn=(0,Z.lazy)(()=>I(()=>import(`./ComponentBuilderPage-BC4Ea9AX.js`),__vite__mapDeps([12,1,2,3,4,5]))),An=(0,Z.lazy)(()=>I(()=>import(`./SettingsPage-BZn_S20X.js`),__vite__mapDeps([13,1,2,3,4,5,14,11]))),jn=(0,Z.lazy)(()=>I(()=>import(`./PluginsPage-jOgKwIzK.js`),__vite__mapDeps([15,1,2,3,4,5]))),Mn=(0,Z.lazy)(()=>I(()=>import(`./SchemaBuilderPage-D6jCyURY.js`),__vite__mapDeps([16,1,2,3,4,5,10]))),Nn=(0,Z.lazy)(()=>I(()=>import(`./BlockBuilderPage-CdheJ_nw.js`),__vite__mapDeps([17,1,2,3,4,5]))),Pn=(0,Z.lazy)(()=>I(()=>import(`./DashboardBuilder-C9W1ggsK.js`),__vite__mapDeps([18,1,2,3,4,5]))),Fn=(0,Z.lazy)(()=>I(()=>import(`./TemplatesPage-CaZgoHEq.js`),__vite__mapDeps([19,1,2,3,4,5]))),In=(0,Z.lazy)(()=>I(()=>import(`./SetupWizard-CBA43yJr.js`),__vite__mapDeps([20,1,2,3,4,5]))),Ln=(0,Z.lazy)(()=>I(()=>import(`./RedirectsPage-CpZ6qVGA.js`),__vite__mapDeps([21,1,2,3,4,5]))),Rn=(0,Z.lazy)(()=>I(()=>import(`./TrashPage-BYiY8Xrn.js`),__vite__mapDeps([22,1,2,3,4,5])));(0,Z.lazy)(()=>I(()=>import(`./BuilderPage-Iu8F_bN1.js`),__vite__mapDeps([23,1,2,3,4,5])));var zn=(0,Z.lazy)(()=>I(()=>import(`./ApiExplorerPage-DhdnjvFP.js`),__vite__mapDeps([14,1,2,3,4,5]))),Bn=()=>(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-black gap-6`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full border border-z-border shadow-[0_0_40px_rgba(255,255,255,0.02)] bg-[radial-gradient(circle,rgba(255,255,255,0.05)_0%,rgba(255,255,255,0)_70%)]`}),(0,Q.jsx)(`div`,{className:`absolute inset-[-4px] rounded-full border border-transparent border-t-white/30 border-r-white/10 animate-spin`,style:{animationDuration:`2s`}}),(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 bg-white/5 animate-pulse`,style:{animationDuration:`2s`}})]}),(0,Q.jsx)(`p`,{className:`text-[11px] font-semibold text-white/30 tracking-[0.3em] uppercase animate-pulse`,children:`Loading App`})]}),Vn=()=>(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-12 h-12`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-[-2px] rounded-full border border-transparent border-t-white/20 border-r-white/5 animate-spin`,style:{animationDuration:`1.5s`}}),(0,Q.jsx)(`div`,{className:`w-4 h-4 rounded-full border border-white/10 bg-white/5 animate-pulse`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] font-semibold text-white/20 uppercase tracking-widest`,children:`Loading...`})]}),Hn=({children:e})=>{let{isAuthenticated:t,isLoading:n,checkAuth:r}=tt(Ee(e=>({isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,checkAuth:e.checkAuth}))),[i,a]=(0,Z.useState)(null),o=Ae();if((0,Z.useEffect)(()=>{r()},[r]),(0,Z.useEffect)(()=>{t&&K.get(`/system/onboarding`).then(e=>a(!!e.data?.data?.completed)).catch(()=>a(!0))},[t]),n||t&&i===null)return(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-black gap-6`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full border border-z-border shadow-[0_0_40px_rgba(255,255,255,0.02)] bg-[radial-gradient(circle,rgba(255,255,255,0.05)_0%,rgba(255,255,255,0)_70%)]`}),(0,Q.jsx)(`div`,{className:`absolute inset-[-4px] rounded-full border border-transparent border-t-white/30 border-r-white/10 animate-spin`,style:{animationDuration:`2s`}}),(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 bg-white/5 animate-pulse`,style:{animationDuration:`2s`}})]}),(0,Q.jsx)(`p`,{className:`text-[11px] font-semibold text-white/30 tracking-[0.3em] uppercase animate-pulse`,children:`Initializing System`})]});if(!t)return(0,Q.jsx)(Ce,{to:`/login`,state:{from:o},replace:!0});if(!i&&o.pathname!==`/setup`)return(0,Q.jsx)(Ce,{to:`/setup`,replace:!0});let s=localStorage.getItem(`activeWorkspaceId`),c=localStorage.getItem(`activeSiteId`);return i&&(!s||!c)&&o.pathname!==`/sites`&&o.pathname!==`/setup`?(0,Q.jsx)(Ce,{to:`/sites`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})},Un=()=>(0,Q.jsx)(Xe,{children:(0,Q.jsx)(St,{children:(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(Ne,{position:`bottom-right`,toastOptions:{style:{background:`#000`,color:`#fff`,border:`1px solid rgba(255,255,255,0.05)`,fontSize:`11px`,fontWeight:`900`,textTransform:``,letterSpacing:`0.2em`,padding:`16px 24px`,borderRadius:`0px`,fontStyle:``}}}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(Sn,{}),(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(V,{path:`/login`,element:(0,Q.jsx)(kt,{})}),(0,Q.jsx)(V,{path:`/forgot-password`,element:(0,Q.jsx)(At,{})}),(0,Q.jsx)(V,{path:`/reset-password`,element:(0,Q.jsx)(jt,{})}),(0,Q.jsx)(V,{path:`/setup`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(In,{})})})}),(0,Q.jsx)(V,{path:`/sites`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(Mt,{})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/new`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/singleton`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/:id`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/globals/:slug`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{isGlobal:!0})})})})}),(0,Q.jsx)(V,{path:`/globals/:slug/:id`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{isGlobal:!0})})})})}),(0,Q.jsx)(V,{path:`/*`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Tt,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vn,{}),children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(V,{path:`/`,element:(0,Q.jsx)(Pn,{})}),(0,Q.jsx)(V,{path:`/collections`,element:(0,Q.jsx)(wn,{})}),(0,Q.jsx)(V,{path:`/collections/:slug`,element:(0,Q.jsx)(Vt,{})}),(0,Q.jsx)(V,{path:`/collections/:slug/hooks`,element:(0,Q.jsx)(Tn,{})}),(0,Q.jsx)(V,{path:`/audit-log`,element:(0,Q.jsx)(En,{})}),(0,Q.jsx)(V,{path:`/media`,element:(0,Q.jsx)(Dn,{})}),(0,Q.jsx)(V,{path:`/members`,element:(0,Q.jsx)(Ce,{to:`/collections/members`,replace:!0})}),(0,Q.jsx)(V,{path:`/templates`,element:(0,Q.jsx)(Fn,{})}),(0,Q.jsx)(V,{path:`/plugins`,element:(0,Q.jsx)(jn,{})}),(0,Q.jsx)(V,{path:`/schema-builder`,element:(0,Q.jsx)(Mn,{})}),(0,Q.jsx)(V,{path:`/block-builder`,element:(0,Q.jsx)(Nn,{})}),(0,Q.jsx)(V,{path:`/settings`,element:(0,Q.jsx)(An,{})}),(0,Q.jsx)(V,{path:`/api-explorer`,element:(0,Q.jsx)(zn,{})}),(0,Q.jsx)(V,{path:`/redirects`,element:(0,Q.jsx)(Ln,{})}),(0,Q.jsx)(V,{path:`/trash`,element:(0,Q.jsx)(Rn,{})}),(0,Q.jsx)(V,{path:`/component-builder`,element:(0,Q.jsx)(kn,{})}),wt.getRoutes().map(e=>{let t=(0,Z.lazy)(e.component);return(0,Q.jsx)(V,{path:e.path,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vn,{}),children:(0,Q.jsx)(t,{})})},e.path)}),(0,Q.jsx)(V,{path:`*`,element:(0,Q.jsx)(Ce,{to:`/`,replace:!0})})]})})})})})})]})})]})})});async function Wn(){try{let e=(await K.get(`/system/plugins`)).data?.data||[];for(let t of e)t.enabled&&t.config?.url&&(console.log(`[Zenith] Loading Plugin: ${t.name} (${t.config.url})`),await new Promise((e,n)=>{let r=document.createElement(`script`);r.type=`module`,r.src=t.config.url,r.onload=e,r.onerror=()=>{console.error(`[Zenith] Failed to load plugin script: ${t.config.url}`),e(null)},document.head.appendChild(r)}))}catch(e){console.error(`[Zenith] Failed to fetch system plugins at boot`,e)}et.createRoot(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(Un,{})}))}Wn();export{ut as _,sn as a,Qt as c,Rt as d,zt as f,Ct as g,xt as h,pn as i,Zt as l,Pt as m,_n as n,on as o,Lt as p,gn as r,nn as s,xn as t,Wt as u,ot as v,tt as y};
11
+ </div>`}},{type:`pageEmbed`,iconName:`Copy`,title:`Page Embed`,description:`Embed another page or reusable component`,category:`Advanced`,fields:[{name:`reference`,type:`relation`,relationTo:`pages`,label:`Select Page to Embed`}],defaultContent:{reference:null}}].map(e=>({...e,fields:[...e.fields,...Ht],defaultContent:{...e.defaultContent,...Ut}})),Gt=e=>e.replace(/^root:/,``).replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()),Kt=e=>e?e.map(e=>({name:e.name,label:e.label||Gt(e.name),type:e.type,required:e.required,placeholder:e.placeholder,options:e.options,fields:Kt(e.fields),hasMany:e.hasMany,hasMore:e.hasMore,language:e.language,layout:e.layout,dateFormat:e.dateFormat,components:e.components,description:e.description,admin:e.admin})):[],qt=Wt.map(e=>({slug:e.type,labels:{singular:e.title,plural:e.title+`s`},fields:Kt(e.fields),admin:{description:e.description,category:e.category,icon:e.iconName}})),Jt=10,$=new Map;function Yt(){if($.size>Jt){let e=$.keys().next().value;e&&$.delete(e)}}async function Xt(e){let t=$.get(e);if(t?.blocks)return $.delete(e),$.set(e,t),t.blocks;if(t?.promise)return t.promise;let n=(async()=>{try{let t=await K.get(`/blocks`);return t.data?.data&&Array.isArray(t.data.data)&&t.data.data.length>0?($.set(e,{blocks:t.data.data,promise:null}),Yt(),t.data.data):qt}catch{return qt}})();$.set(e,{blocks:null,promise:n}),Yt();try{let t=await n;return $.has(e)&&$.set(e,{blocks:t,promise:null}),t}catch(t){throw $.delete(e),t}}function Zt(){let e=q(e=>e.activeSiteId),[t,n]=(0,Z.useState)(()=>qt);return(0,Z.useEffect)(()=>{if(!e)return;let t=$.get(e);if(t?.blocks){n(t.blocks);return}let r=!0;return Xt(e).then(e=>{r&&n(e)}).catch(e=>{r&&console.error(`Failed to fetch blocks`,e)}),()=>{r=!1}},[e]),t}function Qt(e){e?$.delete(e):$.clear()}var $t=null,en=null;async function tn(){return $t||en||(en=(async()=>{try{let e=await K.get(`/system/components`);return e.data?.data&&Array.isArray(e.data.data)?($t=e.data.data,$t):[]}catch{return[]}})(),en)}function nn(){$t=null,en=null}function rn(){let[e,t]=(0,Z.useState)(()=>$t||[]);return(0,Z.useEffect)(()=>{$t||tn().then(t)},[]),e}var an={Star:y,Grid:Ye,BarChart4:T,MessageSquare:se,Mail:le,CreditCard:f,Zap:Re,FileText:v,Layout:d,Users:ge,AlertCircle:j,Code:P,Table:n,Type:Ue};Wt.map(e=>({type:e.type,icon:an[e.iconName]||Re,title:e.title,description:e.description,category:e.category,fields:e.fields,defaultContent:e.defaultContent}));var on=e=>e.replace(/^root:/,``).replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()),sn=(e,t)=>t&&typeof t==`object`&&t.url||e.toLowerCase().includes(`image`)?`media`:e.toLowerCase().includes(`email`)?`email`:e.toLowerCase().includes(`content`)||e.toLowerCase().includes(`description`)||e.toLowerCase().includes(`body`)?`richtext`:Array.isArray(t)?`array`:typeof t==`object`&&t?`group`:typeof t==`number`?`number`:typeof t==`boolean`?`boolean`:`text`,cn={Star:y,Grid:Ye,BarChart4:T,MessageSquare:se,Mail:le,CreditCard:f,Zap:Re,FileText:v,Layout:d,Users:ge,AlertCircle:j,Code:P,Table:n,HelpCircle:g},ln=(0,Z.createContext)([]);function un(e){return e?e.map(e=>({name:e.name,label:e.label,type:e.type,fields:e.fields?un(e.fields):void 0,options:e.options,placeholder:e.placeholder,hasMany:e.hasMany,hasMore:e.hasMore,language:e.language,layout:e.layout,dateFormat:e.dateFormat,components:e.components,description:e.description,admin:e.admin})):[]}function dn(e){let t={};for(let n of e.fields||[])n.type===`text`||n.type===`richtext`?t[n.name]=``:n.type===`media`?t[n.name]=null:n.type===`array`?t[n.name]=[]:n.type===`number`?t[n.name]=0:n.type===`boolean`?t[n.name]=!1:n.type===`code`?t[n.name]=``:t[n.name]=null;return t}function fn({children:e}){let t=Zt(),n=rn(),r=(0,Z.useMemo)(()=>{let e=t.map(e=>({type:e.slug,icon:cn[e.admin?.icon||``]||fe,title:e.labels?.singular||e.slug,description:e.admin?.description||``,category:e.admin?.category||`General`,fields:un(e.fields),defaultContent:dn(e)})),r=n.map(e=>({type:e.slug,icon:cn[e.icon]||fe,title:e.displayName,description:e.description,category:e.category,fields:e.fields,defaultContent:dn({fields:e.fields})}));return[...e,...r]},[t,n]);return(0,Q.jsx)(ln.Provider,{value:r,children:e})}function pn(){return(0,Z.useContext)(ln)}var mn=[`templatesOpen`,`mediaLibraryOpen`,`seoOpen`,`relationsModalOpen`,`blockPickerOpen`,`componentPickerOpen`,`showLocaleDropdown`];function hn(e){return t=>t?{[e]:!0,...Object.fromEntries(mn.filter(t=>t!==e).map(e=>[e,!1]))}:{[e]:!1}}var gn=Oe(e=>({templatesOpen:!1,mediaLibraryOpen:!1,seoOpen:!1,showLocaleDropdown:!1,showFieldIndicators:!0,relationsModalOpen:!1,blockPickerOpen:!1,componentPickerOpen:!1,componentPickerCallback:null,componentPickerBlocks:null,setTemplatesOpen:t=>e(hn(`templatesOpen`)(t)),setMediaLibraryOpen:t=>e(hn(`mediaLibraryOpen`)(t)),setSeoOpen:t=>e(hn(`seoOpen`)(t)),setShowLocaleDropdown:t=>e(hn(`showLocaleDropdown`)(t)),setShowFieldIndicators:t=>e({showFieldIndicators:t}),setRelationsModalOpen:t=>e(hn(`relationsModalOpen`)(t)),setBlockPickerOpen:t=>e(hn(`blockPickerOpen`)(t)),openComponentPicker:(t,n=null)=>e({componentPickerOpen:!0,componentPickerCallback:t,componentPickerBlocks:n,templatesOpen:!1,mediaLibraryOpen:!1,seoOpen:!1,relationsModalOpen:!1,blockPickerOpen:!1,showLocaleDropdown:!1}),closeComponentPicker:()=>e({componentPickerOpen:!1,componentPickerCallback:null,componentPickerBlocks:null})})),_n=(e,t={})=>{let{onEscape:n,containerRef:r}=t,i=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!e)return;i.current=document.activeElement;let t=r?.current||document.body,a=[`a[href]`,`button:not([disabled])`,`textarea:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`[contenteditable="true"]`].join(`, `),o=Array.from(t.querySelectorAll(a)).filter(e=>{let t=window.getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`&&e.offsetParent!==null&&!e.hasAttribute(`disabled`)&&!e.hasAttribute(`inert`)});o.length>0&&o[0].focus();let s=e=>{if(e.key===`Escape`&&n){n();return}if(e.key===`Tab`){if(o.length===0)return;let t=o[0],n=o[o.length-1];e.shiftKey?document.activeElement===t&&(e.preventDefault(),n.focus()):document.activeElement===n&&(e.preventDefault(),t.focus())}};return document.addEventListener(`keydown`,s),()=>{document.removeEventListener(`keydown`,s),i.current&&i.current.focus()}},[e,n,r])},vn={Layout:`from-z-accent to-transparent`,Content:`from-z-accent to-transparent`,Commerce:`from-z-accent to-transparent`,Media:`from-rose-900/70 to-pink-900/40`,Social:`from-amber-900/70 to-orange-900/40`,General:`from-[#1a1a2e]/80 to-[#16213e]/60`},yn=[`All`,`Layout`,`Content`,`Media`,`Social`,`Commerce`,`General`],bn=()=>{let{theme:e}=G(),{componentPickerOpen:t,componentPickerCallback:n,componentPickerBlocks:r,closeComponentPicker:i}=gn(),a=pn(),o=(0,Z.useMemo)(()=>{if(!r||r.length===0)return a;let e=new Set(r.map(e=>e.slug||e));return a.filter(t=>e.has(t.type))},[a,r]),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`All`),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{t?setTimeout(()=>f.current?.focus(),80):(c(``),u(`All`))},[t]),_n(t,{containerRef:d,onEscape:i});let m=(0,Z.useMemo)(()=>{let e=new Set(o.map(e=>e.category||`General`));return yn.filter(t=>t===`All`||e.has(t))},[o]),h=(0,Z.useMemo)(()=>{let e=s.toLowerCase().trim();return o.filter(t=>{let n=!e||t.title.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description.toLowerCase().includes(e),r=l===`All`||(t.category||`General`)===l;return n&&r})},[o,s,l]),g=(0,Z.useMemo)(()=>{if(l!==`All`)return{[l]:h};let e={};return h.forEach(t=>{let n=t.category||`General`;e[n]||(e[n]=[]),e[n].push(t)}),e},[h,l]),_=e=>{n?.(e),i()},v=e===`dark`;return(0,Q.jsx)(H,{children:t&&(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-[900] flex items-center justify-center p-4 md:p-8`,children:[(0,Q.jsx)(W.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:i,className:`absolute inset-0 bg-app/75 backdrop-blur-md`}),(0,Q.jsxs)(W.div,{ref:d,role:`dialog`,"aria-modal":`true`,"aria-label":`Add a Component`,initial:{opacity:0,scale:.96,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:16},transition:{duration:.2,ease:[.4,0,.2,1]},className:J(`relative w-full max-w-3xl flex flex-col overflow-hidden rounded-none-none shadow-sm max-h-[90vh] border`,v?`bg-[#08080a] border-z-border`:`bg-z-panel border-z-border`),style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-z-accent/70 to-transparent`}),(0,Q.jsxs)(`div`,{className:J(`px-6 pt-6 pb-4 border-b flex-shrink-0`,`border-z-border`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between mb-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-z-active-text mb-1.5`,children:`Zenith Page Builder`}),(0,Q.jsx)(`h3`,{className:J(`text-2xl font-semibold`,`text-z-primary`),children:`Add a Component`}),(0,Q.jsx)(`p`,{className:J(`text-sm mt-1`,v?`text-z-muted`:`text-z-secondary`),children:`Choose a component to add to your layout`})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Close component picker`,className:J(`w-9 h-9 flex items-center justify-center border rounded-none-none transition-all flex-shrink-0 mt-0.5`,v?`bg-z-hover border-z-border text-z-primary hover:bg-z-panel hover:text-z-primary`:`bg-[var(--z-bg-hover)] border-z-border text-z-primary hover:bg-app hover:text-z-primary`),children:(0,Q.jsx)(B,{size:15})})]}),(0,Q.jsxs)(`div`,{className:`relative mb-4`,children:[(0,Q.jsx)(p,{size:13,className:J(`absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none`,v?`text-z-secondary`:`text-z-muted`)}),(0,Q.jsx)(`input`,{ref:f,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Search components...`,className:J(`w-full pl-10 pr-10 py-2.5 text-sm rounded-none-none border transition-all outline-none focus-visible:ring-2 focus-visible:ring-z-active-border focus-visible:ring-offset-1 focus-visible:ring-offset-black`,v?`bg-z-hover border-z-border text-z-primary placeholder:text-z-muted focus:border-z-accent/40 focus:bg-z-panel/[0.06]`:`bg-z-input border-z-border text-z-primary placeholder:text-z-muted focus:border-z-active-border`)}),s&&(0,Q.jsx)(`button`,{onClick:()=>c(``),className:J(`absolute right-3 top-1/2 -translate-y-1/2 transition-colors`,v?`text-z-secondary hover:text-z-primary`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(B,{size:12})})]}),(0,Q.jsx)(`div`,{className:`flex gap-1.5 overflow-x-auto no-scrollbar`,children:m.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:J(`px-3 py-1.5 text-sm font-semibold whitespace-nowrap flex-shrink-0 transition-all rounded-none-none border`,l===e?`bg-z-accent border-z-accent text-z-primary shadow-sm`:v?`bg-z-hover border-z-border text-z-muted hover:text-z-primary hover:border-z-active-border`:`bg-z-input border-z-border text-z-secondary hover:text-z-primary hover:border-z-active-border/50`),children:e},e))})]}),(0,Q.jsx)(`div`,{className:`overflow-y-auto flex-1 p-6 space-y-8 custom-editor-scrollbar`,children:Object.keys(g).length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-center`,children:[(0,Q.jsx)(p,{size:28,className:v?`text-z-primary`:`text-z-secondary`}),(0,Q.jsxs)(`p`,{className:J(`text-sm font-bold`,v?`text-z-muted`:`text-z-secondary`),children:[`No results for "`,s,`"`]}),(0,Q.jsx)(`p`,{className:J(`text-xs`,v?`text-z-secondary`:`text-z-muted`),children:`Try a different keyword or browse all categories`})]}):Object.entries(g).map(([e,t])=>(0,Q.jsxs)(`div`,{children:[l===`All`&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,Q.jsx)(`span`,{className:J(`h-px flex-1`,v?`bg-z-hover`:`bg-[var(--z-bg-hover)]`)}),(0,Q.jsx)(`span`,{className:J(`text-sm font-semibold `,v?`text-z-secondary`:`text-z-muted`),children:e}),(0,Q.jsx)(`span`,{className:J(`h-px flex-1`,v?`bg-z-hover`:`bg-[var(--z-bg-hover)]`)})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.icon,n=vn[e.category||`General`]??vn.General;return(0,Q.jsxs)(W.button,{type:`button`,whileHover:{scale:1.02},whileTap:{scale:.97},onClick:()=>_(e.type),className:J(`flex flex-col text-left group border overflow-hidden rounded-none-none transition-all`,v?`bg-z-panel border-z-border hover:border-z-accent/50 hover:shadow-sm`:`bg-z-panel border-z-border hover:border-z-active-border hover:shadow-sm`),children:[(0,Q.jsxs)(`div`,{className:J(`w-full h-20 flex items-center justify-center relative bg-gradient-to-br`,n),children:[(0,Q.jsx)(`div`,{className:`text-z-primary/30 group-hover:text-z-primary/70 transition-colors duration-300`,style:{transform:`scale(2.5)`},children:(0,Q.jsx)(t,{size:16})}),e.category&&(0,Q.jsx)(`span`,{className:`absolute top-2 left-2 px-1.5 py-0.5 text-sm font-semibold bg-app/50 backdrop-blur text-z-primary/80 rounded-none-none`,children:e.category}),(0,Q.jsx)(`div`,{className:`absolute bottom-0 right-0 p-1.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Q.jsx)(`div`,{className:`w-5 h-5 bg-z-accent flex items-center justify-center rounded-none-none`,children:(0,Q.jsx)(w,{size:10,className:`text-z-primary`})})})]}),(0,Q.jsxs)(`div`,{className:J(`p-3 flex-1 transition-colors`,v?`group-hover:opacity-90/5`:`group-hover:bg-z-active-bg/50`),children:[(0,Q.jsx)(`p`,{className:J(`text-sm font-semibold italic mb-0.5`,`text-z-primary`),children:e.title}),(0,Q.jsx)(`p`,{className:J(`text-sm leading-relaxed line-clamp-2`,v?`text-z-secondary`:`text-z-muted`),children:e.description})]})]},e.type)})})]},e))}),(0,Q.jsxs)(`div`,{className:J(`px-6 py-3 border-t flex items-center justify-between flex-shrink-0`,v?`border-z-border bg-z-panel`:`border-z-border bg-[var(--z-bg-input)]/50`),children:[(0,Q.jsxs)(`p`,{className:J(`text-sm`,v?`text-z-secondary`:`text-z-muted`),children:[h.length,` component`,h.length===1?``:`s`,` available`]}),(0,Q.jsxs)(`p`,{className:J(`text-sm`,v?`text-z-secondary`:`text-z-muted`),children:[`Press`,` `,(0,Q.jsx)(`kbd`,{className:J(`px-1.5 py-0.5 font-mono rounded-none-none text-sm border`,v?`bg-z-hover border-z-border`:`bg-z-panel border-z-border`),children:`Esc`}),` `,`to close`]})]})]})]})})},xn=({open:e,title:t,message:n,confirmLabel:r=`Confirm`,danger:i=!1,onConfirm:a,onCancel:o})=>{let{theme:s}=G(),c=(0,Z.useRef)(null);_n(e,{onEscape:o,containerRef:c});let u=s===`dark`;return(0,Q.jsx)(H,{children:e&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[900] flex items-center justify-center bg-[var(--z-bg-modal)] backdrop-blur-sm`,onClick:e=>{e.target===e.currentTarget&&o()},children:(0,Q.jsxs)(W.div,{ref:c,role:`alertdialog`,"aria-modal":`true`,"aria-label":t,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.15},className:J(`w-full max-w-sm border rounded-none-none shadow-2xl p-5`,u?`bg-app border-z-border text-z-primary`:`bg-z-panel border-z-border text-z-primary`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:J(`w-9 h-9 rounded-none-none border flex items-center justify-center shrink-0`,i?u?`bg-rose-500/10 border-rose-500/20 text-rose-400`:`bg-rose-50 border-rose-200 text-rose-500`:u?`bg-amber-500/10 border-amber-500/20 text-amber-400`:`bg-amber-50 border-amber-200 text-amber-500`),children:(0,Q.jsx)(l,{size:16})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:t}),(0,Q.jsx)(`p`,{className:J(`text-xs font-bold mt-1.5 leading-relaxed`,u?`text-z-muted`:`text-z-secondary`),children:n})]}),(0,Q.jsx)(`button`,{onClick:o,"aria-label":`Cancel`,className:J(`shrink-0 p-1 transition-colors`,u?`text-z-secondary hover:text-z-primary`:`text-z-muted hover:text-z-primary`),children:(0,Q.jsx)(B,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,Q.jsx)(`button`,{onClick:o,"aria-label":`Cancel action`,className:J(`flex-1 py-2 text-xs font-semibold border rounded-none-none transition-all`,u?`border-z-border text-z-muted hover:border-z-border hover:text-z-primary`:`border-z-border text-z-secondary hover:border-z-border-strong hover:text-z-primary`),children:`Cancel`}),(0,Q.jsx)(`button`,{onClick:a,"aria-label":r,className:J(`flex-1 py-2 text-xs font-semibold rounded-none-none transition-all`,i?`bg-rose-600 hover:bg-rose-500 text-z-primary`:`bg-z-accent hover:bg-z-border text-z-primary`),children:r})]})]})})})},Sn=()=>{let{isOpen:e,title:t,message:n,confirmText:r,variant:i,close:a}=Nt(Ee(e=>({isOpen:e.isOpen,title:e.title,message:e.message,confirmText:e.confirmText,variant:e.variant,close:e.close})));return(0,Q.jsx)(xn,{open:e,title:t,message:n,confirmLabel:r,danger:i===`danger`,onConfirm:()=>a(!0),onCancel:()=>a(!1)})},Cn=class extends Z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-app gap-6 p-8`,children:[(0,Q.jsx)(`div`,{className:`text-[80px] leading-none select-none text-z-primary/5 font-semibold font-mono`,children:`500`}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-red-500/60`,children:`Unexpected Error`}),(0,Q.jsx)(`p`,{className:`text-sm text-z-secondary font-bold`,children:`An unexpected error occurred. Please refresh the page or contact support.`}),(0,Q.jsx)(`button`,{onClick:()=>window.location.reload(),className:`mt-4 px-6 py-2 border border-z-border text-sm font-semibold hover:border-red-500/30 hover:text-red-400 transition-all`,children:`Reload`})]}):this.props.children}},wn=(0,Z.lazy)(()=>I(()=>import(`./CollectionsPage-CL_t5JRI.js`),__vite__mapDeps([0,1,2,3,4,5]))),Tn=(0,Z.lazy)(()=>I(()=>import(`./CollectionHooksPage-DIaSrKDj.js`),__vite__mapDeps([6,1,2,3,4,5]))),En=(0,Z.lazy)(()=>I(()=>import(`./AuditLogPage-CwULx1tr.js`),__vite__mapDeps([7,1,2,3,4,5]))),Dn=(0,Z.lazy)(()=>I(()=>import(`./MediaLibrary-BzXE95xo.js`),__vite__mapDeps([8,1,2,3,4,5]))),On=(0,Z.lazy)(()=>I(()=>import(`./SpatialEditor-BohlovfE.js`),__vite__mapDeps([9,1,2,3,4,5,10,11]))),kn=(0,Z.lazy)(()=>I(()=>import(`./ComponentBuilderPage-C58Rr1cu.js`),__vite__mapDeps([12,1,2,3,4,5]))),An=(0,Z.lazy)(()=>I(()=>import(`./SettingsPage-B2r_uNVc.js`),__vite__mapDeps([13,1,2,3,4,5,14,11]))),jn=(0,Z.lazy)(()=>I(()=>import(`./PluginsPage-DAR4Fsz-.js`),__vite__mapDeps([15,1,2,3,4,5]))),Mn=(0,Z.lazy)(()=>I(()=>import(`./SchemaBuilderPage-BYprOkEv.js`),__vite__mapDeps([16,1,2,3,4,5,10]))),Nn=(0,Z.lazy)(()=>I(()=>import(`./BlockBuilderPage-XD1IjOgx.js`),__vite__mapDeps([17,1,2,3,4,5]))),Pn=(0,Z.lazy)(()=>I(()=>import(`./DashboardBuilder-Chjyqyb7.js`),__vite__mapDeps([18,1,2,3,4,5]))),Fn=(0,Z.lazy)(()=>I(()=>import(`./TemplatesPage-BplB2ksb.js`),__vite__mapDeps([19,1,2,3,4,5]))),In=(0,Z.lazy)(()=>I(()=>import(`./SetupWizard-CBA43yJr.js`),__vite__mapDeps([20,1,2,3,4,5]))),Ln=(0,Z.lazy)(()=>I(()=>import(`./RedirectsPage-DfMTJsac.js`),__vite__mapDeps([21,1,2,3,4,5]))),Rn=(0,Z.lazy)(()=>I(()=>import(`./TrashPage-BIhKrs5x.js`),__vite__mapDeps([22,1,2,3,4,5])));(0,Z.lazy)(()=>I(()=>import(`./BuilderPage-Iu8F_bN1.js`),__vite__mapDeps([23,1,2,3,4,5])));var zn=(0,Z.lazy)(()=>I(()=>import(`./ApiExplorerPage-85UWt1EW.js`),__vite__mapDeps([14,1,2,3,4,5]))),Bn=()=>(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-black gap-6`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full border border-z-border shadow-[0_0_40px_rgba(255,255,255,0.02)] bg-[radial-gradient(circle,rgba(255,255,255,0.05)_0%,rgba(255,255,255,0)_70%)]`}),(0,Q.jsx)(`div`,{className:`absolute inset-[-4px] rounded-full border border-transparent border-t-white/30 border-r-white/10 animate-spin`,style:{animationDuration:`2s`}}),(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 bg-white/5 animate-pulse`,style:{animationDuration:`2s`}})]}),(0,Q.jsx)(`p`,{className:`text-[11px] font-semibold text-white/30 tracking-[0.3em] uppercase animate-pulse`,children:`Loading App`})]}),Vn=()=>(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-12 h-12`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-[-2px] rounded-full border border-transparent border-t-white/20 border-r-white/5 animate-spin`,style:{animationDuration:`1.5s`}}),(0,Q.jsx)(`div`,{className:`w-4 h-4 rounded-full border border-white/10 bg-white/5 animate-pulse`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] font-semibold text-white/20 uppercase tracking-widest`,children:`Loading...`})]}),Hn=({children:e})=>{let{isAuthenticated:t,isLoading:n,checkAuth:r}=tt(Ee(e=>({isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,checkAuth:e.checkAuth}))),[i,a]=(0,Z.useState)(null),o=Ae();if((0,Z.useEffect)(()=>{r()},[r]),(0,Z.useEffect)(()=>{t&&K.get(`/system/onboarding`).then(e=>a(!!e.data?.data?.completed)).catch(()=>a(!0))},[t]),n||t&&i===null)return(0,Q.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-black gap-6`,children:[(0,Q.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full border border-z-border shadow-[0_0_40px_rgba(255,255,255,0.02)] bg-[radial-gradient(circle,rgba(255,255,255,0.05)_0%,rgba(255,255,255,0)_70%)]`}),(0,Q.jsx)(`div`,{className:`absolute inset-[-4px] rounded-full border border-transparent border-t-white/30 border-r-white/10 animate-spin`,style:{animationDuration:`2s`}}),(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 bg-white/5 animate-pulse`,style:{animationDuration:`2s`}})]}),(0,Q.jsx)(`p`,{className:`text-[11px] font-semibold text-white/30 tracking-[0.3em] uppercase animate-pulse`,children:`Initializing System`})]});if(!t)return(0,Q.jsx)(Ce,{to:`/login`,state:{from:o},replace:!0});if(!i&&o.pathname!==`/setup`)return(0,Q.jsx)(Ce,{to:`/setup`,replace:!0});let s=localStorage.getItem(`activeWorkspaceId`),c=localStorage.getItem(`activeSiteId`);return i&&(!s||!c)&&o.pathname!==`/sites`&&o.pathname!==`/setup`?(0,Q.jsx)(Ce,{to:`/sites`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})},Un=()=>(0,Q.jsx)(Xe,{children:(0,Q.jsx)(St,{children:(0,Q.jsxs)(fn,{children:[(0,Q.jsx)(Ne,{position:`bottom-right`,toastOptions:{style:{background:`#000`,color:`#fff`,border:`1px solid rgba(255,255,255,0.05)`,fontSize:`11px`,fontWeight:`900`,textTransform:``,letterSpacing:`0.2em`,padding:`16px 24px`,borderRadius:`0px`,fontStyle:``}}}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(Sn,{}),(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(V,{path:`/login`,element:(0,Q.jsx)(kt,{})}),(0,Q.jsx)(V,{path:`/forgot-password`,element:(0,Q.jsx)(At,{})}),(0,Q.jsx)(V,{path:`/reset-password`,element:(0,Q.jsx)(jt,{})}),(0,Q.jsx)(V,{path:`/setup`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(In,{})})})}),(0,Q.jsx)(V,{path:`/sites`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(Mt,{})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/new`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/singleton`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/collections/:slug/:id`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{})})})})}),(0,Q.jsx)(V,{path:`/globals/:slug`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{isGlobal:!0})})})})}),(0,Q.jsx)(V,{path:`/globals/:slug/:id`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bn,{}),children:(0,Q.jsx)(On,{isGlobal:!0})})})})}),(0,Q.jsx)(V,{path:`/*`,element:(0,Q.jsx)(Hn,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Tt,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vn,{}),children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(V,{path:`/`,element:(0,Q.jsx)(Pn,{})}),(0,Q.jsx)(V,{path:`/collections`,element:(0,Q.jsx)(wn,{})}),(0,Q.jsx)(V,{path:`/collections/:slug`,element:(0,Q.jsx)(Vt,{})}),(0,Q.jsx)(V,{path:`/collections/:slug/hooks`,element:(0,Q.jsx)(Tn,{})}),(0,Q.jsx)(V,{path:`/audit-log`,element:(0,Q.jsx)(En,{})}),(0,Q.jsx)(V,{path:`/media`,element:(0,Q.jsx)(Dn,{})}),(0,Q.jsx)(V,{path:`/members`,element:(0,Q.jsx)(Ce,{to:`/collections/members`,replace:!0})}),(0,Q.jsx)(V,{path:`/templates`,element:(0,Q.jsx)(Fn,{})}),(0,Q.jsx)(V,{path:`/plugins`,element:(0,Q.jsx)(jn,{})}),(0,Q.jsx)(V,{path:`/schema-builder`,element:(0,Q.jsx)(Mn,{})}),(0,Q.jsx)(V,{path:`/block-builder`,element:(0,Q.jsx)(Nn,{})}),(0,Q.jsx)(V,{path:`/settings`,element:(0,Q.jsx)(An,{})}),(0,Q.jsx)(V,{path:`/api-explorer`,element:(0,Q.jsx)(zn,{})}),(0,Q.jsx)(V,{path:`/redirects`,element:(0,Q.jsx)(Ln,{})}),(0,Q.jsx)(V,{path:`/trash`,element:(0,Q.jsx)(Rn,{})}),(0,Q.jsx)(V,{path:`/component-builder`,element:(0,Q.jsx)(kn,{})}),wt.getRoutes().map(e=>{let t=(0,Z.lazy)(e.component);return(0,Q.jsx)(V,{path:e.path,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vn,{}),children:(0,Q.jsx)(t,{})})},e.path)}),(0,Q.jsx)(V,{path:`*`,element:(0,Q.jsx)(Ce,{to:`/`,replace:!0})})]})})})})})})]})})]})})});async function Wn(){try{let e=(await K.get(`/system/plugins`)).data?.data||[];for(let t of e)t.enabled&&t.config?.url&&(console.log(`[Zenith] Loading Plugin: ${t.name} (${t.config.url})`),await new Promise((e,n)=>{let r=document.createElement(`script`);r.type=`module`,r.src=t.config.url,r.onload=e,r.onerror=()=>{console.error(`[Zenith] Failed to load plugin script: ${t.config.url}`),e(null)},document.head.appendChild(r)}))}catch(e){console.error(`[Zenith] Failed to fetch system plugins at boot`,e)}et.createRoot(document.getElementById(`root`)).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(Un,{})}))}Wn();export{ut as _,sn as a,Qt as c,Rt as d,zt as f,Ct as g,xt as h,pn as i,Zt as l,Pt as m,_n as n,on as o,Lt as p,gn as r,nn as s,xn as t,Wt as u,ot as v,tt as y};