your-ai-workflow-firebase-os 1.2.21 → 1.2.22

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.
@@ -1,37 +1,38 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./theme.config-0Lvwt5Bo.cjs`),n=require(`./ContactPopup-5mXFBqTs.cjs`),r=require(`./contactForm.config-CXyq-EbM.cjs`),i=require(`./supportForm.config-haLod4rv.cjs`);let a=require(`react`);a=e.i(a,1);let o=require(`firebase/firestore`),s=require(`firebase/auth`),c=require(`firebase/storage`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`),d=require(`react-dom`);var f=(0,a.createContext)({user:null,userRole:null,loading:!0,signOut:async()=>{},registerUser:async()=>{},refreshUser:async()=>{},userInactive:!1,roleResolved:!1,activeOrg:null,activeWorkspace:null,checkOrg:async()=>{},workspaceAccess:{},userWorkspaces:[],switchWorkspace:async()=>{},createWorkspace:async()=>{},createOrg:async()=>{}});function p({children:e}){let t=n.Ct(),[r,i]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(!1),v=a.default.useRef(null),y=a.default.useRef(null);return(0,a.useEffect)(()=>{let e;if(!n.wt){h(!1),_(!0);return}let r=(0,s.onAuthStateChanged)(n.wt,async r=>{if(r?.uid===y.current&&g){i(r);return}if(y.current=r?.uid||null,r){let a=localStorage.getItem(`fbos_role_${r.uid}`);a&&(u(a),_(!0),h(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,r.uid),i(r);try{let i=(0,o.doc)(n.Tt,`user_profiles`,r.uid),a=(await(0,o.getDoc)(i)).data()||{};(0,o.setDoc)(i,{uid:r.uid,email:r.email,displayName:r.displayName||a.displayName||``,lastLoginAt:new Date().toISOString(),createdAt:a.createdAt||new Date().toISOString()},{merge:!0}).catch(e=>console.error(`Failed to sync profile:`,e)),e&&e(),e=(0,o.onSnapshot)(i,e=>{if(e.exists()){let n=e.data(),a=n.role||`user`,s=``;try{s={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ADMIN_EMAILS:void 0,VITE_FIREBASE_API_KEY:void 0,VITE_FIREBASE_APP_ID:void 0,VITE_FIREBASE_AUTH_DOMAIN:void 0,VITE_FIREBASE_MESSAGING_SENDER_ID:void 0,VITE_FIREBASE_PROJECT_ID:void 0,VITE_FIREBASE_STORAGE_BUCKET:void 0}?.VITE_ADMIN_EMAILS||``}catch{}let c=t.adminEmails||(s?s.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]);c.length>0&&!n.role&&c.map(e=>e.toLowerCase()).some(e=>r.email?.toLowerCase()===e)&&(a=`admin`,(0,o.updateDoc)(i,{role:`admin`}).catch(e=>console.error(`Error auto-setting admin role:`,e))),v.current===null&&(v.current=a),u(a),localStorage.setItem(`fbos_role_${r.uid}`,a),p(n.inactive===!0)}_(!0),h(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),_(!0),h(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),_(!0),h(!1)}}else console.log(`[AuthContext] No user currently signed in.`),i(null),u(null),p(!1),_(!0),h(!1),v.current=null,e&&e()});return()=>{r(),e&&e()}},[]),(0,l.jsx)(f.Provider,{value:{user:r,userRole:c,loading:m,signOut:async()=>{await(0,s.signOut)(n.wt),i(null)},registerUser:async(e,t,r,i)=>{let{createUserWithEmailAndPassword:a}=await import(`firebase/auth`),{user:c}=await a(n.wt,e,t),l=`${r} ${i}`.trim();await(0,s.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,o.setDoc)((0,o.doc)(n.Tt,`user_profiles`,c.uid),{uid:c.uid,email:c.email,displayName:l,createdAt:new Date().toISOString()},{merge:!0})}catch(e){console.warn(`Could not write public profile on registration.`,e)}await(0,s.sendEmailVerification)(c)},refreshUser:async()=>{n.wt.currentUser&&(await n.wt.currentUser.reload(),i(Object.assign(Object.create(Object.getPrototypeOf(n.wt.currentUser)),n.wt.currentUser)))},userInactive:d,roleResolved:g},children:e})}var m=()=>(0,a.useContext)(f);function h(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)([]),s=(0,a.useRef)(null),c=(0,u.useNavigate)();(0,a.useEffect)(()=>{function e(e){s.current&&!s.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let d=(0,a.useRef)({users:[],submissions:[],requests:[]}),f=(e,t)=>{d.current[e]=t;let n=[...d.current.users,...d.current.submissions,...d.current.requests];n.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(n.slice(0,8))};(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_profiles`),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(5)),e=>{f(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||`Unknown`,time:t.createdAt}}))}),t=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`submissions`,e.docs.map(e=>{let t=e.data();return{id:`s_${e.id}`,type:`submission`,title:`New form submission`,subtitle:t.name||t.email||`Anonymous`,time:t.submittedAt}}))}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`requests`,e.docs.map(e=>{let t=e.data();return{id:`r_${e.id}`,type:`request`,title:`New support request`,subtitle:t.name||t.submitterName||t.contactEmail||t.email||`Anonymous`,time:t.submittedAt}}))});return()=>{e(),t(),r()}},[]);let[p,m]=(0,a.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),h=()=>{let n=!e;if(t(n),n){let e=Date.now();m(e),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,e.toString())}},g=r.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>p||isNaN(t)}),_=e=>{t(!1),c(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},v=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)};return(0,l.jsxs)(`div`,{className:`relative z-50 flex-shrink-0 mr-1 md:mr-2`,ref:s,children:[(0,l.jsxs)(`button`,{onClick:h,className:`p-2 rounded-xl glass-panel transition-all border border-transparent relative text-notification-icon hover:bg-foreground/5 hover:border-[var(--panel-border)]`,"aria-label":`Admin Notifications`,children:[(0,l.jsx)(n.mt,{className:`w-4 h-4 md:w-5 md:h-5`}),g&&(0,l.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-[-60px] md:right-0 w-[320px] md:w-[400px] glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col origin-top-right overflow-hidden bg-[var(--panel-bg)]`,children:[(0,l.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:`Admin`})]}),(0,l.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:r.length===0?(0,l.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):r.map(e=>(0,l.jsxs)(`button`,{onClick:()=>_(e.type),className:`w-full flex items-start gap-3 p-3 rounded-xl hover:bg-foreground/5 transition-all text-left group border border-transparent hover:border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-foreground/5 text-notification-icon`,children:e.type===`user`?(0,l.jsx)(n.d,{className:`w-4 h-4`}):e.type===`submission`?(0,l.jsx)(n.k,{className:`w-4 h-4`}):(0,l.jsx)(n.tt,{className:`w-4 h-4`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:v(e.time)})]})]},e.id))})]})})]})}var g=[{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],_=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}),v=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`drive`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`submissions`,hidden:!1},{id:`requests`,hidden:!1},{id:`settings`,hidden:!1},{id:`profile`,hidden:!1},{id:`support`,hidden:!0}],y={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},b={templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function x({customMenu:e,standalone:t}){let{user:r,userRole:i,signOut:s}=m(),c=(0,u.useNavigate)(),[d,f]=(0,a.useState)(!1),[p,v]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),D=r?.displayName||r?.email?.split(`@`)[0]||`User`,ee=D.charAt(0).toUpperCase()+D.slice(1),{theme:O,toggleTheme:k,activeConfig:A}=n.xt(),te=async()=>{await s(),c(`/`),f(!1)},[j,M]=(0,a.useState)({...b}),[N,ne]=(0,a.useState)(g);(0,a.useEffect)(()=>{if(!n.Tt)return;let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_pages`),e=>{let t={...b};e.forEach(e=>{let n=e.data();if(n.enabled===!1)return;let r=n.pageName||n.title||b[e.id]?.label||e.id,i=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:r,path:i}}),M(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{ne(e.exists()&&Array.isArray(e.data().order)?_(e.data().order):g)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&F(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),t(),r()}},[]);let[P,F]=(0,a.useState)(y.tabName),re=(()=>{let e=new Set(N.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return N.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=j[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(j).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path})}),n})(),I=e||re,L=(0,a.useRef)(null),R=(0,a.useRef)(null),[ie,z]=(0,a.useState)(I.length);(0,a.useEffect)(()=>{if(t||r)return;let e=()=>{let e=L.current,t=R.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){z(I.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?28:0),i>n){a=!1;break}if(a){z(I.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?28:0);if(i+50>n)break;o=i,s++}z(Math.max(s,1))},n=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(n);let i=new ResizeObserver(()=>requestAnimationFrame(e));return L.current&&i.observe(L.current),()=>{cancelAnimationFrame(n),i.disconnect()}},[I.map(e=>e.label).join(`|`),t,r,I.length]);let B=I.slice(0,ie),V=I.slice(ie);return(0,l.jsxs)(`nav`,{className:`flex items-center justify-between w-full max-w-7xl mx-auto z-40 p-4 md:p-10 relative`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50`,children:(0,l.jsxs)(u.Link,{to:`/`,className:`flex items-center gap-2 md:gap-3 group cursor-pointer z-50`,children:[(0,l.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-xl glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-[360deg] group-active:scale-95 overflow-hidden`,children:A?.logoUrl?(0,l.jsx)(`img`,{src:A.logoUrl,alt:`Logo`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.X,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsx)(`span`,{className:`hidden lg:block font-bold text-[22px] tracking-tight text-gradient transition-colors duration-300 drop-shadow-sm`,children:A?.appName||``})]})}),(0,l.jsx)(n.a,{children:x&&(0,l.jsx)(n.t,{formId:`contact`,onClose:()=>S(!1)})}),(0,l.jsx)(n.a,{children:C&&(0,l.jsx)(n.t,{formId:`support`,onClose:()=>w(!1)})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!t&&!r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:R,"aria-hidden":`true`,className:`flex items-center gap-7 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,height:0,pointerEvents:`none`},children:I.map((e,t)=>(0,l.jsxs)(`span`,{"data-measure-nav":!0,className:`text-[13px] md:text-[14px] font-bold tracking-wide flex items-center gap-1.5 shrink-0`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]},e.path||t))}),(0,l.jsxs)(`div`,{className:`hidden sm:flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:L,children:[B.map((e,t)=>(0,l.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>v(e.label),onMouseLeave:()=>v(null),children:[e.path?(0,l.jsxs)(u.Link,{to:e.path,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all cursor-pointer flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]}):(0,l.jsxs)(`button`,{onClick:e.action,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]}),e.submenu&&p===e.label&&(0,l.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`min-w-[180px] max-h-[300px] overflow-y-auto styled-scrollbars bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2`,children:e.submenu.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,className:`px-5 py-3 text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:e.action,className:`px-5 py-3 text-left w-full text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})})]},`${e.path||`no-path`}-${t}`)),V.length>0&&(0,l.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>f(`overflow`),children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${d===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-5 h-5`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,l.jsx)(n.a,{children:d===`overflow`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:5,scale:.98},className:`absolute top-[100%] pt-1 right-0 min-w-[200px] max-h-[350px] overflow-y-auto styled-scrollbars bg-background border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2 z-50 origin-top-right`,children:V.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,onClick:()=>f(!1),className:`px-5 py-3 text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:()=>{e.action&&e.action(),f(!1)},className:`px-5 py-3 text-left w-full text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})]})})]})]}),A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 mr-2 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40 shrink-0`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(u.Link,{to:`/login`,className:`hidden sm:flex text-[14px] font-bold tracking-wide text-foreground/80 hover:text-accent transition-colors px-3 py-1.5 shrink-0`,children:`Sign In`}),(0,l.jsx)(u.Link,{to:`/register`,className:`hidden sm:flex text-[13px] md:text-[14px] font-bold tracking-wide px-4 py-1.5 md:px-5 md:py-2 rounded-xl btn-primary transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 active:scale-95 items-center justify-center ml-2`,children:`Get Started`}),(0,l.jsxs)(`div`,{className:`relative sm:hidden ml-1`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`guest`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/templates`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.P,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,l.jsxs)(u.Link,{to:`/setup`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,l.jsxs)(u.Link,{to:`/contact`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,l.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,l.jsxs)(u.Link,{to:`/login`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full`,children:[(0,l.jsx)(n.A,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,l.jsx)(u.Link,{to:`/register`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl btn-primary w-full shadow-lg hover:-translate-y-0.5 transition-transform text-white`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!t&&r&&(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 mr-1`,children:[i===`admin`&&(0,l.jsx)(h,{}),A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})})]}),(0,l.jsxs)(`div`,{className:`relative z-50 flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,l.jsxs)(`button`,{onClick:()=>f(d===`user`?!1:`user`),className:`flex items-center gap-2 group p-1 sm:pr-2.5 rounded-full glass-panel hover:bg-foreground/5 transition-all duration-300 border ${d===`user`?`border-accent/40 bg-foreground/5`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-9 md:h-9 rounded-full bg-accent/10 flex items-center justify-center overflow-hidden border border-[var(--panel-border)] group-hover:border-accent/30 transition-colors shrink-0 text-accent`,children:r.photoURL&&!T?(0,l.jsx)(`img`,{src:r.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,l.jsx)(n.d,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`hidden sm:flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,l.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:ee}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:i===`admin`?`Admin`:`Free User`})]})]}),(0,l.jsx)(n.a,{children:d===`user`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-0 w-[280px] md:w-[320px] glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-2xl z-50 flex flex-col origin-top-right`,children:[(0,l.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:ee}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:r.email})]}),(0,l.jsxs)(`div`,{className:`py-1`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.d,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.H,{className:`w-3 h-3 text-accent`})}),`Drive`]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.u,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.k,{className:`w-3 h-3 text-accent`})}),`Submissions`]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.tt,{className:`w-3 h-3 text-accent`})}),`Requests`]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.y,{className:`w-3 h-3 text-accent`})}),`Settings`]}),(0,l.jsxs)(u.Link,{to:`/pages`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.L,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3 text-left`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.tt,{className:`w-3 h-3 text-accent`})}),P]})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`button`,{onClick:te,className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-bold tracking-wide hover:bg-red-500/10 hover:text-red-500 text-foreground/70 transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-red-500/5 flex items-center justify-center shrink-0 text-red-500`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3`,children:[(0,l.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,l.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,l.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]}),(0,l.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`nav`?!1:`nav`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`nav`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`nav`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.d,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Profile Settings`})]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.H,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Drive`})]}),(0,l.jsxs)(u.Link,{to:`/dashboard`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.I,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Dashboard`})]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.u,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Users`})]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Submissions`})]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.tt,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Requests`})]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Settings`})]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.tt,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Support`})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(`button`,{onClick:te,className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-red-500/10 text-red-500/80 hover:text-red-500 transition-all w-full`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign Out`})})})]})]})})]})]})]}),t&&(0,l.jsx)(l.Fragment,{children:A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4`}):(0,l.jsx)(n.E,{className:`w-4 h-4`})})})]})]})}var S={hero:{title:`Firebase OS.`,showSubtitle:!0,subtitle:`The Open-Source Firebase Starter`,text:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`,buttons:{primary:{text:`Start Building Free`,action:`register`},secondary:{text:`Sign In`,action:`sign_in`}}}};function C(){let[e,t]=(0,a.useState)(null),r=n.Ct()?.defaultConfigs?.home||S,[i,s]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`fbos_home_config`);if(e)return JSON.parse(e)}catch{}return r}),[c,d]=(0,a.useState)(!0);if((0,a.useEffect)(()=>(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_pages`,`home`),e=>{if(e.exists()){let t=e.data();s(t),localStorage.setItem(`fbos_home_config`,JSON.stringify(t))}else s(r),localStorage.removeItem(`fbos_home_config`)}),[]),!c)return null;let f=i||S,p=f?.hero?.showSubtitle??!0;f?.hero?.subtitleEmoji;let m=f?.hero?.title||f?.heroTitle||`The Open-Source Firebase Starter`,h=f?.hero?.subtitle||f?.heroSubtitle||`The Open-Source Firebase Starter`,g=f?.hero?.text||f?.heroText||`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`;f?.hero?.buttons?.primary?.text||f?.primaryBtnText,f?.hero?.buttons?.primary?.action||f?.primaryBtnAction;let _=f?.hero?.buttons?.primary||{},v=f?.hero?.buttons?.secondary||{},y=(e,n,r,i)=>{let a=e.text||n,o=e.action||r,s=i.replace(/rounded-\[.*?\]|rounded-\w+/g,``).replace(/border /g,``).replace(/border-\[.*?\]/g,``),c={borderRadius:`var(--btn-radius, 0.75rem)`};if(o===`form`){let n=e.form||`contact`;return(0,l.jsx)(`button`,{onClick:()=>t(n),className:s,style:c,children:a})}if(o===`redirect`){let t=e.url||`/`;return t.startsWith(`http`)?(0,l.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:s,style:c,children:a}):(0,l.jsx)(u.Link,{to:t,className:s,style:c,children:a})}return(0,l.jsx)(u.Link,{to:{sign_in:`/login`,register:`/register`}[o]||`/register`,className:s,style:c,children:a})};return(0,l.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full max-w-5xl mx-auto mt-4 md:mt-12 mb-16 md:mb-24 z-10 relative`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[p&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.2},className:`inline-flex items-center gap-2 md:gap-3 px-5 md:px-6 py-2 md:py-2.5 mb-8 md:mb-10 text-[13px] md:text-[15px] font-semibold tracking-wide uppercase rounded-full glass-panel text-foreground glow-hover cursor-pointer`,children:[h===S.hero.subtitle&&(0,l.jsx)(n.s,{className:`w-4 h-4 text-accent`}),` `,h]}),(0,l.jsx)(n.i.h1,{className:`text-5xl sm:text-6xl md:text-7xl lg:text-[5.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:m}),(0,l.jsx)(`p`,{className:`text-[15px] sm:text-lg md:text-xl lg:text-[22px] text-foreground/60 max-w-3xl mx-auto font-medium leading-[1.6] md:leading-[1.7] mb-10 md:mb-14 px-6 md:px-4`,children:g}),(0,l.jsxs)(n.i.div,{className:`flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 w-full max-w-2xl mx-auto px-6`,initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:[y(_,`Start Building Free`,`register`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`),y(v,`Sign In`,`sign_in`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`)]})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsx)(n.t,{onClose:()=>t(null),formId:e})})]})}function w(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),o=(0,u.useNavigate)(),{registerUser:c}=m();return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Firebase OS and start building today.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),r=n.get(`email`),a=n.get(`password`),s=n.get(`firstName`),d=n.get(`lastName`);if(a.length<6){i(`Password must be at least 6 characters.`),t(!1);return}try{await c(r,a,s,d),o(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?i((0,l.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,l.jsx)(u.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?i(`Password must be at least 6 characters.`):i(e?.message||`An error occurred during registration.`)}finally{t(!1)}},children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,l.jsx)(n.r,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,l.jsx)(n.r,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(n.r,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Create Account `,(0,l.jsx)(n.ht,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.wt,new s.GoogleAuthProvider)}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),`Sign up with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,l.jsx)(u.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function T(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o]=(0,u.useSearchParams)(),c=(0,u.useNavigate)(),[d]=(0,a.useState)(o.get(`email`)||``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Firebase OS.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget),a=r.get(`email`),d=r.get(`password`);try{await(0,s.signInWithEmailAndPassword)(n.wt,a,d),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?i((0,l.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,l.jsx)(u.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):i(e?.message||`Invalid credentials.`),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,l.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,l.jsx)(u.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,l.jsx)(n.r,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Sign In `,(0,l.jsx)(n.ht,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.wt,new s.GoogleAuthProvider),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),`Sign in with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,l.jsx)(u.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function E(){let{user:e,refreshUser:t}=m(),r=(0,u.useNavigate)(),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover text-center shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,l.jsxs)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[`We've sent a verification link to `,(0,l.jsx)(`span`,{className:`font-semibold text-foreground`,children:e?.email}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}),f&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium rounded-xl border ${f.includes(`Failed`)||f.includes(`not verified`)||f.includes(`wrong`)?`text-red-400 bg-red-500/10 border-red-500/20`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`}`,children:f}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[(0,l.jsx)(n.n,{variant:`primary`,onClick:async()=>{o(!0),p(``);try{if(n.wt.currentUser){if(await n.wt.currentUser.reload(),!n.wt.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),o(!1);return}await n.wt.currentUser.getIdToken(!0),await t(),r(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),o(!1)}},isLoading:i,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`I've verified my email`}),(0,l.jsx)(n.n,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,s.sendEmailVerification)(e),p(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?p(`Failed to resend: Please wait a minute before trying again.`):p(e?.message||`Failed to resend. Please try again later.`)}finally{d(!1)}}},isLoading:c,className:`w-full py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`Resend verification link`})]})]})})}var D={pages:{path:`/pages`,label:`Pages`,icon:n.L,roles:[`admin`]},forms:{path:`/forms`,label:`Forms`,icon:n.S,roles:[`admin`]},drive:{path:`/drive`,label:`Drive`,icon:n.H,roles:[`admin`,`user`,`editor`,`guest`]},users:{path:`/users`,label:`Users`,icon:n.u,roles:[`admin`]},theme:{path:`/theme`,label:`Theme`,icon:n.T,roles:[`admin`]},submissions:{path:`/submissions`,label:`Submissions`,icon:n.k,roles:[`admin`]},requests:{path:`/requests`,label:`Requests`,icon:n.tt,roles:[`admin`]},settings:{path:`/settings`,label:`Settings`,icon:n.y,roles:[`admin`]},profile:{path:`/profile`,label:`Profile`,icon:n.d,roles:[`admin`,`user`,`editor`,`guest`]},support:{path:`/support`,label:`Support`,icon:n.tt,roles:[`user`,`editor`,`guest`]}};function ee({customTabs:e=[]}){let{pathname:t}=(0,u.useLocation)(),{userRole:r}=m(),[i,s]=(0,a.useState)(!1),c=(0,a.useRef)(null),[d,f]=(0,a.useState)({}),[p,h]=(0,a.useState)(v);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&f(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),f(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?_(e.data().order):v;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(D).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}}),Object.entries(d).forEach(([t,r])=>{let i=e[t],a=i?.icon??n.L;if(r?.iconName){let e=r.iconName.trim(),t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);n.o[t]?a=n.o[t]:n.o[e]&&(a=n.o[e])}let o=i?.roles??[`admin`];r?.pageType===`admin`?o=[`admin`]:r?.pageType===`shared`?o=[`admin`,`editor`,`user`]:r?.pageType===`private`?o=[`admin`,`user`]:r?.pageType===`public`&&(o=[`admin`,`user`,`editor`,`guest`]),e[t]={id:t,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+t,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||t,icon:a,roles:o,exact:!0}});let t=[],r=new Set;p.forEach(n=>{n.hidden||e[n.id]&&(t.push(e[n.id]),r.add(n.id))});let i=[],a=[];return Object.keys(e).forEach(t=>{if(r.has(t))return;let n=p.find(e=>e.id===t);n?.hidden||(t in d&&!n?i.push(e[t]):a.push(e[t]))}),i.length>0&&t.unshift(...i),a.length>0&&t.push(...a),t})(),...e.map(e=>({...e,id:e.path}))].filter(e=>e.id===`support`&&r===`admin`?!1:Array.isArray(e.roles)?e.roles.includes(r||`guest`):!1),y=(0,a.useRef)(null),b=(0,a.useRef)(null),[x,S]=(0,a.useState)(g.length);(0,a.useEffect)(()=>{let e=()=>{let e=y.current,t=b.current;if(!e||!t)return;let n=e.clientWidth;if(n===0)return;let r=t.querySelectorAll(`[data-measure-tab]`);if(r.length===0){S(g.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?40:0),i>n){a=!1;break}if(a){S(g.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?40:0);if(i+52>n)break;o=i,s++}S(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return y.current&&n.observe(y.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let C=g.slice(0,x),w=g.slice(x),T=e=>e.exact?t===e.path:t.startsWith(e.path),E=w.some(e=>T(e));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:b,"aria-hidden":`true`,className:`flex items-center gap-6 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:g.map(e=>{let t=e.icon;return(0,l.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,l.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,l.jsxs)(`div`,{ref:y,className:`w-full flex items-center gap-6 md:gap-10 mb-8 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[C.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[14.5px] font-semibold transition-all duration-300 pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,l.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),w.length>0&&(0,l.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:c,children:[(0,l.jsx)(`button`,{onClick:()=>s(!i),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${E?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,l.jsx)(n.J,{className:`w-5 h-5`})}),(0,l.jsx)(n.a,{children:i&&(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl z-50 flex flex-col py-2 overflow-hidden`,children:w.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>s(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,l.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function O(){let{user:e,refreshUser:t}=m(),[r,i]=(0,a.useState)(e?.displayName||``),[u,d]=(0,a.useState)(e?.email||``),[f,p]=(0,a.useState)(e?.photoURL||``),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(null),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(``),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),[D,O]=(0,a.useState)(!0);a.default.useEffect(()=>{i(e?.displayName||``),d(e?.email||``),p(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let k=async t=>{if(e)try{let r=[`mem_files`,`admin_files`];(await(0,o.getDocs)((0,o.collection)(n.Tt,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`);t.pageType===`shared`&&r.push(`mem_${n}_records`),t.pageType===`admin`&&r.push(`admin_${n}_records`)});for(let i of r)try{let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let a=(0,o.writeBatch)(n.Tt);r.docs.forEach(e=>a.update(e.ref,{creatorAvatar:t})),await a.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Profile Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsx)(n.a,{children:_&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.98,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:-10},className:`p-4 mb-6 rounded-2xl border flex flex-col sm:flex-row sm:items-center gap-3 ${_.type===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-accent/10 border-accent/20 text-accent`}`,children:[_.type===`success`?(0,l.jsx)(n.nt,{className:`w-5 h-5 shrink-0`}):(0,l.jsx)(n.rt,{className:`w-5 h-5 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,l.jsx)(`form`,{onSubmit:async i=>{if(i.preventDefault(),e){g(!0),v(null);try{r!==e.displayName&&await(0,s.updateProfile)(e,{displayName:r});let i=!1;if(u!==e.email){let t=await(0,s.fetchSignInMethodsForEmail)(n.wt,u);if(t&&t.length>0)throw Error(`An account with this email already exists.`);await(0,s.verifyBeforeUpdateEmail)(e,u),i=!0}if(y){if(y!==x)throw Error(`Passwords do not match.`);if(y.length<6)throw Error(`Password must be at least 6 characters.`);await(0,s.updatePassword)(e,y),b(``),S(``)}await t(),v(i?{text:`Profile updated. A verification link has been sent to your new email address.`,type:`success`}:{text:`Profile successfully updated.`,type:`success`})}catch(e){console.error(e),e.code===`auth/requires-recent-login`?v({text:`For security, please sign out and sign back in before changing your email or password.`,type:`error`}):v({text:e.message||`Failed to update profile.`,type:`error`})}finally{g(!1)}}},className:`w-full flex flex-col`,children:(0,l.jsxs)(`div`,{className:`glass-panel w-full p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 md:w-28 md:h-28 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group transition-transform duration-300 hover:scale-[1.02]`,children:[(T||f&&D&&!C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),f&&!C?(0,l.jsx)(`img`,{src:f,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${D?`opacity-0`:`opacity-100`}`,onLoad:()=>O(!1),onError:()=>{w(!0),O(!1)}}):(0,l.jsx)(n.d,{className:`w-10 h-10 md:w-12 md:h-12 text-accent`}),!T&&(0,l.jsxs)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2 z-10 backdrop-blur-sm`,children:[(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 rounded-full hover:bg-white/20 transition-colors text-white`,title:`Upload Photo`,children:[(0,l.jsx)(n.ut,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:async r=>{let i=r.target.files?.[0];if(!(!i||!e)){if(i.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}E(!0),w(!1),O(!0);try{let r=(0,c.ref)(n.Dt,`user_avatars/${e.uid}/file.png`);await(0,c.uploadBytes)(r,i,{customMetadata:{ownerId:e.uid}});let a=await(0,c.getDownloadURL)(r);await(0,s.updateProfile)(e,{photoURL:a}),await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid),{avatar:a}),p(a),await t(),k(a),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{E(!1)}}},className:`hidden`})]}),f&&(0,l.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){E(!0),w(!1),O(!1);try{await(0,c.deleteObject)((0,c.ref)(n.Dt,`user_avatars/${e.uid}/file.png`)).catch(e=>console.error(e)),await(0,s.updateProfile)(e,{photoURL:``}),await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid),{avatar:``}),p(``),await t(),k(``),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`})}finally{E(!1)}}},className:`p-2 rounded-full hover:bg-red-500/80 text-white transition-colors`,title:`Delete Photo`,children:(0,l.jsx)(n.h,{className:`w-5 h-5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,l.jsx)(`h3`,{className:`font-extrabold text-2xl text-foreground mb-1`,children:r||`Firebase OS User`}),(0,l.jsx)(`div`,{className:`text-[12px] font-mono uppercase tracking-widest text-accent bg-accent/10 px-2.5 py-1 rounded-md border border-accent/20 inline-block`,children:e?.emailVerified?`Verified Account`:`Unverified`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-2 font-medium`,children:e?.email})]})]}),(0,l.jsxs)(`div`,{className:`space-y-6`,children:[(0,l.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`name`,value:r,onChange:e=>i(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(n.r,{name:`email`,type:`email`,value:u,onChange:e=>d(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Changing email sends a verification link to the new address.`})]})]})]}),(0,l.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`password`,type:`password`,label:`New Password`,value:y,onChange:e=>b(e.target.value),placeholder:`Minimum 6 characters`}),(0,l.jsx)(n.r,{name:`confirmPassword`,type:`password`,label:`Confirm Password`,value:x,onChange:e=>S(e.target.value),placeholder:`Repeat password`})]})]}),(0,l.jsx)(`div`,{className:`pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:h,className:`px-12 py-3 md:py-2.5 text-[14px] md:text-[15px] font-bold tracking-wide rounded-xl hover:-translate-y-0.5`,children:`Save Changes`})})]})})]})]})}function k(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(0),[d,f]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e;return o>0&&(e=setInterval(()=>c(e=>e-1),1e3)),()=>clearInterval(e)},[o]),(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] text-center`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-40 blur-[15px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.R,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium text-emerald-400 bg-emerald-500/10 rounded-xl border border-emerald-500/20 max-w-[360px] mx-auto`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,s.sendPasswordResetEmail)(n.wt,r)}catch(e){console.error(e)}finally{i(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),c(e===1?60:120),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${o>0?`bg-foreground/5 text-foreground/40 border border-[var(--panel-border)] shadow-none cursor-not-allowed hover:translate-y-0`:`hover:-translate-y-0.5`}`,isLoading:e,disabled:o>0,children:o>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(o)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,l.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,l.jsxs)(u.Link,{to:`/login`,className:`inline-flex items-center text-[13px] md:text-[14px] text-foreground/70 font-medium hover:text-accent transition-colors tracking-wide`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}function A(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)(!0),s=(0,u.useNavigate)(),{id:d}=(0,u.useParams)(),[f,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(!1),C=d?f.find(e=>e.id===d)||null:f.length>0?f[0]:null,w=e=>{s(e?`/users/${e.id}`:`/users`)};(0,a.useEffect)(()=>{i(!0);let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),p(t),i(!1),!d&&t.length>0&&s(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),i(!1)});return()=>e()},[d,s]);let T=f.find(t=>t.id===e?.uid),E=e=>e.id===T?.id?!1:e.role!==`admin`||!T?.createdAt?!0:e.createdAt?new Date(T.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,D=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.id),{role:r?`admin`:null}),g({text:`User role updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},O=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.id),{inactive:r}),g({text:`User ${r?`deactivated`:`activated`} successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},k=async()=>{if(v(!1),!(!C||!E(C)||y===C.displayName))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,C.id),{displayName:y}),g({text:`Name updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},A=async e=>{let t=e.target.files?.[0];if(!(!t||!C||!E(C))){if(t.size>2*1024*1024){g({text:`File too large.`,type:`error`});return}S(!0);try{let e=(0,c.ref)(n.Dt,`user_avatars/${C.id}/file.png`);await(0,c.uploadBytes)(e,t);let r=await(0,c.getDownloadURL)(e);await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,C.id),{avatar:r}),g({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>g(null),3e3)}catch{g({text:`Failed to upload photo.`,type:`error`})}S(!1)}},[te,j]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e;return r&&f.length===0?e=setTimeout(()=>j(!0),150):j(!1),()=>clearTimeout(e)},[r,f.length]),r&&f.length===0?te?(0,l.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/60 backdrop-blur-xl transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}):null:(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Users`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(n.a,{children:h&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`p-4 text-[14px] font-medium border ${h.type===`error`?`text-red-500 bg-red-500/10 border-red-500/20 shadow-[0_0_15px_rgba(239,68,68,0.1)]`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20 shadow-[0_0_15px_rgba(52,211,153,0.1)]`} rounded-xl flex items-center gap-2`,children:[h.type===`success`&&(0,l.jsx)(n.nt,{className:`w-4 h-4 shrink-0`}),h.text]})}),(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsx)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm`,children:f.length===0?(0,l.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col hide-scrollbar bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-4 border-b border-[var(--panel-border)] font-bold text-[13px] text-foreground/70 uppercase tracking-wider`,children:`System Users`}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:f.map(e=>(0,l.jsxs)(`div`,{onClick:()=>w(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${C?.id===e.id?`bg-accent/10 border-accent/40 shadow-sm`:`glass-panel border-transparent hover:border-[var(--panel-border)]`} ${e.inactive?`opacity-50 grayscale`:``}`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full overflow-hidden bg-accent/20 shrink-0 flex items-center justify-center border border-[var(--panel-border)]`,children:e.avatar||e.photoURL?(0,l.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]})]},e.id))})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10 relative`,children:C?(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 md:gap-8 mb-10`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group`,children:[x?(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`}):C.avatar||C.photoURL?(0,l.jsx)(`img`,{src:C.avatar||C.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-10 h-10 text-accent`}),!x&&E(C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center z-10 backdrop-blur-md`,children:(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 hover:bg-white/20 transition-colors text-white rounded-full`,title:`Upload Photo`,children:[(0,l.jsx)(n.ut,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:A,className:`hidden`})]})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 w-full relative`,children:[_?(0,l.jsx)(`input`,{autoFocus:!0,value:y,onChange:e=>b(e.target.value),onBlur:k,onKeyDown:e=>e.key===`Enter`&&k(),className:`text-2xl md:text-3xl font-extrabold mb-1 bg-transparent border-b-2 border-accent outline-none text-foreground w-full py-1`}):(0,l.jsx)(`h3`,{onDoubleClick:()=>{E(C)&&(b(C.displayName||``),v(!0))},className:`text-2xl md:text-3xl font-extrabold mb-1 select-none ${E(C)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:E(C)?`Double-click to edit`:``,children:C.displayName||`No Name`}),(0,l.jsx)(`p`,{className:`text-[14px] font-mono text-foreground/50`,children:C.email}),!E(C)&&C.id!==T?.id&&(0,l.jsx)(`div`,{className:`mt-3 inline-block self-start px-3 py-1.5 rounded-lg bg-foreground/5 border border-[var(--panel-border)] text-[11px] font-bold text-foreground/50 tracking-wide uppercase`,children:`Privileged Admin Account`})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-between`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Admin Access`}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`Toggle system privileges`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>D(C,C.role!==`admin`),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.role===`admin`?`bg-accent`:`bg-foreground/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.role===`admin`?`translate-x-6`:`translate-x-1`}`})})]}),(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between ${C.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] ${C.inactive?`text-amber-500`:`text-red-500`}`,children:C.inactive?`Reactivate User`:`Deactivate User`}),(0,l.jsx)(`span`,{className:`text-[12px] ${C.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>O(C,!C.inactive),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.inactive?`bg-amber-500`:`bg-red-500/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,l.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,l.jsx)(n.u,{className:`w-12 h-12 mb-4`}),(0,l.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function te({isOpen:e,title:t,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:s,isProcessing:c=!1,disableConfirm:u=!1}){return(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!c&&s(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:t}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:s,disabled:c,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,l.jsx)(n.n,{onClick:o,disabled:c||u,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:c?(0,l.jsx)(n.M,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var j=[`pages`,`forms`,`drive`,`users`,`theme`,`submissions`,`requests`,`settings`,`profile`,`support`],M={pages:`Pages`,forms:`Forms`,drive:`Drive`,users:`Users`,theme:`Theme`,submissions:`Submissions`,requests:`Requests`,settings:`Settings`,profile:`Profile`,support:`Request Support`},N=new Set([`home`]),ne=new Set([`settings`]);function P(){let[e,t]=(0,a.useState)(`menu`),[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)({}),[u,d]=(0,a.useState)(g),[f,p]=(0,a.useState)(v),[m,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_pages`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.title||e.id,path:n.route||(e.id===`home`?`/`:`/`+e.id),type:`public`,isSystem:[`home`,`templates`,`contact`,`setup`].includes(e.id)}}),t.setup||={id:`setup`,title:`Setup`,path:`/setup`,type:`public`,isSystem:!0},t.templates||={id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0},t.contact||={id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0},i(t)}),t=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_tabs`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.tabName||n.title||M[e.id]||e.id,path:n.route||`/`+e.id,type:n.pageType||`admin`,isSystem:j.includes(e.id)}}),j.forEach(e=>{t[e]||(t[e]={id:e,title:M[e]||e,path:`/`+e,type:`admin`,isSystem:!0})}),c(t)}),r=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{d(e.exists()?_(e.data().order||[]):g)}),a=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{p(e.exists()?_(e.data().order||[]):v)});return()=>{e(),t(),r(),a()}},[]);let C=async(e,t)=>{if((t?ne:N).has(e))return;let i=t?f:u,a=t?`tab_order`:`page_order`,c=i.filter(e=>(t?s:r)[e.id]||(t?j.includes(e.id):[`home`,`contact`].includes(e.id))),l=c.some(t=>t.id===e)?c.map(t=>t.id===e?{...t,hidden:!t.hidden}:t):[...c,{id:e,hidden:!0}];await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,a),{order:l})},w=(e,t)=>{e.isSystem||b({info:e,isTab:t})},T=async()=>{if(!y)return;S(!0);let e=y.isTab?`sys_tabs`:`sys_pages`,t=y.isTab?`tab_order`:`page_order`,r=y.isTab?f:u;try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,e,y.info.id));let i=r.filter(e=>e.id!==y.info.id);await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,t),{order:i})}catch(e){console.error(`Delete failed`,e)}S(!1),b(null)},E=async(e,t,i)=>{let a=e?f:u,c=e?s:r,l=e?`tab_order`:`page_order`,d=a.filter(t=>c[t.id]||(e?j.includes(t.id):[`home`,`contact`].includes(t.id)));Object.keys(c).forEach(e=>{d.some(t=>t.id===e)||d.push({id:e,hidden:!1})});let p=d.findIndex(e=>e.id===t);if(p===-1)return;let m=+(!e&&d[0]?.id===`home`),h=i===`up`?Math.max(m,p-1):Math.min(d.length-1,p+1);if(p===h)return;let g=[...d],[_]=g.splice(p,1);g.splice(h,0,_),await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,l),{order:g})},D=async()=>{if(!m){h(!0);try{let e=new Set(g.map(e=>e.id)),t=new Set(v.map(e=>e.id)),r=u.filter(t=>!e.has(t.id)),i=f.filter(e=>!t.has(e.id)),a=[...r.map(e=>({...e,hidden:!1})),...g],s=[...i.map(e=>({...e,hidden:!1})),...v],c=(0,o.writeBatch)(n.Tt);c.set((0,o.doc)(n.Tt,`sys_configs`,`page_order`),{order:a}),c.set((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),{order:s}),await c.commit()}finally{setTimeout(()=>h(!1),600)}}},O=e=>{let t=e?f:u,n=e?s:r,i=t.filter(t=>n[t.id]||(e?j.includes(t.id):[`home`,`contact`].includes(t.id))),a=new Set(i.map(e=>e.id)),o=Object.keys(n).filter(e=>!a.has(e)).map(e=>({id:e,hidden:!1})),c=[...i,...o];return e||(c=c.filter(e=>e.id!==`home`)),c};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/settings`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-6 pb-4 font-bold text-[13px] text-foreground/40 uppercase tracking-widest`,children:`Configuration`}),(0,l.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4 space-y-1`,children:[(0,l.jsxs)(`button`,{onClick:()=>t(`menu`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`menu`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.O,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Menu Settings`})]}),(0,l.jsxs)(`button`,{onClick:()=>t(`tabs`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`tabs`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.pt,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Tabs Settings`})]})]})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10`,children:(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-8`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold text-foreground tracking-tighter mb-2`,children:e===`menu`?`Menu Settings`:`Dashboard Tabs`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 max-w-xl`,children:e===`menu`?`Reorder or hide public menu items. Changes take effect instantly for all visitors.`:`Manage visibility and order of all internal dashboard tabs.`})]}),(0,l.jsx)(`button`,{onClick:D,disabled:m,title:`Reset order and visibility to defaults`,className:`p-3 h-fit bg-foreground/5 hover:bg-foreground/10 text-foreground/70 active:scale-95 disabled:opacity-50 disabled:pointer-events-none rounded-xl transition-all font-bold text-[13px] flex items-center justify-center border border-transparent hover:border-[var(--panel-border)] shadow-sm shrink-0`,children:m?(0,l.jsx)(n.M,{className:`w-5 h-5 text-foreground/50 animate-spin`}):(0,l.jsx)(n.x,{className:`w-5 h-5 text-foreground/50`})})]}),(e=>{let t=e?s:r,i=e?ne:N,a=O(e);return(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:a.map((r,o)=>{let s=t[r.id],c=s?.title||M[r.id]||r.id,u=s?.path||`/`+r.id,d=s?.isSystem??j.includes(r.id),f=i.has(r.id),p=o===0,m=o===a.length-1;return(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-4 glass-panel border border-[var(--panel-border)] rounded-2xl transition-all duration-200 ${r.hidden?`opacity-40`:`opacity-100`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center w-6`,children:[(0,l.jsx)(`button`,{disabled:p,onClick:()=>E(e,r.id,`up`),className:`text-foreground/40 hover:text-accent disabled:opacity-20`,children:(0,l.jsx)(n.it,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{disabled:m,onClick:()=>E(e,r.id,`down`),className:`text-foreground/40 hover:text-accent disabled:opacity-20 -mt-1`,children:(0,l.jsx)(n.st,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-foreground text-[14px]`,children:c}),(0,l.jsx)(`span`,{className:`text-[12px] font-mono text-foreground/50`,children:u})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!f&&(0,l.jsx)(`button`,{onClick:()=>C(r.id,e),title:r.hidden?`Show this page`:`Hide this page`,className:`p-2 rounded-xl transition-colors ${r.hidden?`hover:bg-foreground/5 text-foreground/40`:`hover:bg-accent/10 text-accent`}`,children:r.hidden?(0,l.jsx)(n.q,{className:`w-4 h-4`}):(0,l.jsx)(n.K,{className:`w-4 h-4`})}),s&&!d&&(0,l.jsx)(`button`,{onClick:()=>w(s,e),className:`p-2 rounded-xl hover:bg-red-500/10 text-foreground/40 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]},r.id)})})})(e===`tabs`)]})})]})]})]}),(0,l.jsx)(te,{isOpen:!!y,onCancel:()=>b(null),onConfirm:T,title:`Delete Item`,message:`Are you sure you want to delete "${y?.info?.title??``}"? This cannot be undone.`,confirmText:`Delete`,isProcessing:x})]})}function F(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();n.avatar&&(i=n.avatar),n.name&&!e.name&&(e.name=n.name),n.email&&!e.email&&(e.email=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching submissions:`,e),i(!1)});return()=>e()},[]);let m=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},h=e=>{c(t=>t===e?null:e)},g=async(e,t=!1)=>{p(e);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_submissions`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}p(null)},_=e.filter(e=>!e.isArchived),v=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Form Submissions`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/submissions`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.D,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No Submissions`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Try submitting a form on the public layout to see it appear here.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[_.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All submissions have been archived.`})}),(0,l.jsx)(n.a,{children:_.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),g(e.id,!1)},disabled:f===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Submission`,children:f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),v.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>d(!u),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[u?`Hide`:`View`,` `,v.length,` Archived Submission`,v.length===1?``:`s`,(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:u&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>g(e.id,e.isArchived),disabled:f===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.vt,{className:`w-4 h-4`}),`Unarchive Submission`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function re(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)(!1),[p,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();(n.avatar||n.photoURL)&&(i=n.avatar||n.photoURL),n.displayName&&!e.name&&(e.name=n.displayName),n.email&&!e.email&&(e.email=n.email),n.email&&!e.contactEmail&&(e.contactEmail=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching requests:`,e),i(!1)});return()=>e()},[]);let h=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},g=e=>{c(t=>t===e?null:e)},_=async(e,t=!1)=>{m(e);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_requests`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}m(null)},v=e.filter(e=>!e.isArchived),y=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`User Requests`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/requests`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.tt,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No User Requests`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`User support tickets will appear here once submitted.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[v.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All requests have been archived.`})}),(0,l.jsx)(n.a,{children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(u.Link,{to:`/users/${e.uid}`,onClick:e=>e.stopPropagation(),className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate hover:text-accent flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_(e.id,!1)},disabled:p===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Request`,children:p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.rt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),y.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>f(!d),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[d?`Hide`:`View`,` `,y.length,` Archived Request`,y.length===1?``:`s`,(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 transition-transform duration-300 ${d?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:d&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(`div`,{className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.rt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>_(e.id,e.isArchived),disabled:p===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.vt,{className:`w-4 h-4`}),`Unarchive Request`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function I(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)([]),[s,f]=(0,a.useState)(!1),p=(0,u.useNavigate)(),{"*":h}=(0,u.useParams)(),g=h?h.split(`/`).filter(Boolean):[],_=g[0]||`private`,v=null,y=null;_===`users`?(v=g[1]||null,y=g[2]||null):y=g[1]||null;let b={public:`pub_`,shared:`mem_`,private:`user_`,admin:`admin_`,users:`users_`},x={pub_:`public`,mem_:`shared`,user_:`private`,admin_:`admin`,users_:`users`},S=b[_]||`user_`,C=e=>{p(`/drive/${x[e]}`)},[w,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{S===`users_`&&t===`admin`&&w.length===0&&(0,o.getDocs)((0,o.collection)(n.Tt,`user_profiles`)).then(e=>{T(e.docs.map(e=>({id:e.id,...e.data()})))})},[S,t,w.length]);let[E,D]=(0,a.useState)(!1),[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(``),[M,N]=(0,a.useState)(`user_`),[ne,P]=(0,a.useState)(!1),[F,re]=(0,a.useState)(!1),[I,L]=(0,a.useState)(!1),R=(0,a.useRef)(null),ie=e=>{e.preventDefault(),e.stopPropagation(),L(!0)},z=e=>{e.preventDefault(),e.stopPropagation(),L(!1)},B=e=>{if(e.preventDefault(),e.stopPropagation(),L(!1),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name),N(S),P(!0)}},V=y&&r.find(e=>e._id===y)||null,H=e=>{le(!0),p(e?S===`users_`&&v?`/drive/users/${v}/${e._id}`:`/drive/${x[S]}/${e._id}`:S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},[U,W]=(0,a.useState)(null),[G,K]=(0,a.useState)(!1),[ae,q]=(0,a.useState)(null),[J,oe]=(0,a.useState)(!1),[Y,se]=(0,a.useState)(null),[ce,le]=(0,a.useState)(!0),[ue,de]=(0,a.useState)({}),[fe,X]=(0,a.useState)(!1);(0,a.useEffect)(()=>(V||ae||U||ne||fe?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[V,ae,U,ne,fe]),(0,a.useEffect)(()=>{if(!s&&y&&!r.some(e=>e._id===y)){X(!0);let e=setTimeout(()=>{X(!1),p(S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},2500);return()=>clearTimeout(e)}else X(!1)},[s,y,r,S,p,v]),(0,a.useEffect)(()=>{if(!e)return;f(!0);let r=(t===`admin`?[`pub_`,`mem_`,`user_`,`admin_`]:[`pub_`,`mem_`,`user_`]).map(r=>{let a;return a=r===`user_`&&t!==`admin`?(0,o.query)((0,o.collection)(n.Tt,`${r}files`),(0,o.where)(`uid`,`==`,e.uid)):(0,o.query)((0,o.collection)(n.Tt,`${r}files`),(0,o.orderBy)(`createdAt`,`desc`)),(0,o.onSnapshot)(a,e=>{let t=(e.docs||[]).map(e=>({_id:e.id,accessPrefix:r,...e.data()}));i(e=>[...e.filter(e=>e.accessPrefix!==r),...t].sort((e,t)=>{let n=e.createdAt?.toMillis?e.createdAt.toMillis():0;return(t.createdAt?.toMillis?t.createdAt.toMillis():0)-n})),f(!1)},e=>{console.warn(`Error listening to ${r}files:`,e)})});return()=>r.forEach(e=>e())},[e?.uid,t]);let pe=e=>{if(e.target.files&&e.target.files[0]){let t=e.target.files[0];k(t),j(t.name)}},me=e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name)}},Z=async r=>{if(r.preventDefault(),!(!O||!A)){D(!0);try{let r=(0,c.ref)(n.Dt,`${M}files/${`${Date.now()}_${O.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(r,O,{customMetadata:{ownerId:e.uid}});let i=await(0,c.getDownloadURL)(r);await(0,o.addDoc)((0,o.collection)(n.Tt,`${M}files`),{fileName:A,fileType:O.type||`unknown`,fileSize:O.size,downloadURL:i,uid:e.uid,uploaderEmail:e.email||`user`,uploaderRole:t||`user`,createdAt:(0,o.serverTimestamp)()}),P(!1),k(null),j(``),C(M)}catch(e){console.error(e),alert(`Upload failed: ${e.message}`)}D(!1)}},he=async()=>{if(ae){oe(!0);try{try{await(0,c.deleteObject)((0,c.ref)(n.Dt,ae.url))}catch(e){console.warn(`Storage item missing:`,e)}await(0,o.deleteDoc)((0,o.doc)(n.Tt,`${ae.prefix}files`,ae.id)),i(e=>e.filter(e=>e._id!==ae.id)),q(null)}catch(e){alert(e.message)}oe(!1)}},ge=async()=>{if(!U||!U.name.trim()){W(null);return}let e=r.find(e=>e._id===U.id);if(e&&e.fileName===U.name.trim()){W(null);return}K(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`${U.prefix}files`,U.id),{fileName:U.name.trim()}),i(e=>e.map(e=>e._id===U.id?{...e,fileName:U.name.trim()}:e)),W(null)}catch(e){console.error(`Rename failed:`,e)}K(!1)},_e=(e,t)=>{navigator.clipboard.writeText(e),se(t),setTimeout(()=>se(null),2e3)},ve=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=n=>e?n.accessPrefix===`mem_`?n.uid===e.uid?!0:t===`admin`?n.uploaderRole!==`admin`:!1:n.accessPrefix===`admin_`?n.uid===e.uid:n.accessPrefix===`pub_`?t===`admin`:n.uid===e.uid||t===`admin`:!1,ye=(e,t,r=!1)=>{let i=r?`w-16 h-16`:`w-10 h-10`,a=r?`w-8 h-8`:`w-5 h-5`;return e.startsWith(`image/`)?r?(0,l.jsx)(`img`,{src:t,alt:`preview`,className:`w-full h-full object-contain rounded-lg`}):(0,l.jsx)(`div`,{className:`${i} bg-cover bg-center rounded-lg`,style:{backgroundImage:`url(${t})`}}):e.includes(`video`)||e.includes(`audio`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,l.jsx)(n.l,{className:a})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,l.jsx)(n.G,{className:a})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,l.jsx)(n._t,{className:a})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,l.jsx)(n.Q,{className:a})}):(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,l.jsx)(n.W,{className:a})})},be=[{id:`user_`,label:`Private`,icon:n.j,description:`This is a private folder availbale to all users in your app. Each user can see their own files. Admins can see all everyone's files here.`},{id:`mem_`,label:`Shared`,icon:n.u,description:`This is a shared folder that all signed-in users can see. Every user can upload files here and view other member's files. However, editing and deletion are strictly restricted to the original creator of the file.`},{id:`pub_`,label:`Public`,icon:n.U,description:`This admin-only folder is for assets like logos, banners, or favicons. Files here are view-only for everyone; only admins can upload or delete them.`},{id:`admin_`,label:`Admin Shared`,icon:n.v,description:`This is a shared folder for app administrators. Admins can view everything here, but they can only edit or delete files that they themselves uploaded.`},{id:`users_`,label:`User Uploads`,icon:n.X,description:`View all underlying private user uploads securely. Select a user to explore their files.`}].filter(e=>t===`admin`?!0:e.id===`user_`||e.id===`mem_`),xe=[];xe=S===`users_`?r.filter(e=>e.accessPrefix===`user_`&&e.uid===v):S===`user_`?r.filter(t=>t.accessPrefix===`user_`&&t.uid===e?.uid):r.filter(e=>e.accessPrefix===S);let Se=be.find(e=>e.id===S);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 flex flex-col pt-12 min-h-screen relative overflow-visible`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Drive`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/drive`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,onDragOver:ie,onDragLeave:z,onDrop:B,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-row glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[600px] bg-background`,children:[(0,l.jsxs)(`div`,{className:`w-[280px] border-r border-[var(--panel-border)] bg-foreground/[0.01] p-4 flex flex-col shrink-0 overflow-y-auto hide-scrollbar`,children:[(0,l.jsx)(`div`,{className:`text-[11px] font-extrabold text-foreground/40 uppercase tracking-widest pl-4 mb-4 mt-2`,children:`Locations`}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2`,children:be.map(e=>(0,l.jsxs)(`button`,{onClick:()=>C(e.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all font-bold text-[14px] text-left ${S===e.id?`bg-accent/15 text-accent shadow-sm border border-accent/20`:`text-foreground/70 hover:bg-foreground/5 hover:text-foreground border border-transparent`}`,children:[(0,l.jsx)(e.icon,{className:`w-5 h-5 ${S===e.id?`text-accent`:`text-foreground/40`}`}),e.label]},e.id))})]}),(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col relative w-full h-full min-w-0`,children:[(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex items-start justify-between gap-6 shrink-0 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,l.jsxs)(`div`,{className:`flex-1 max-w-xl`,children:[(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground tracking-tight flex items-center gap-3`,children:Se?.label}),(0,l.jsx)(`p`,{className:`text-[13px] mt-3 text-foreground/60 leading-relaxed font-medium`,children:Se?.description})]}),S!==`users_`&&(0,l.jsxs)(n.n,{onClick:()=>{N(S),P(!0)},className:`flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold shadow-md hover:shadow-lg transition-all glow-hover border-transparent !border-0 outline-none ring-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add File Here`]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[300px]`,children:[s&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm rounded-b-[2rem]`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),S===`users_`&&!v?(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-20`,children:[w.map(e=>(0,l.jsxs)(`div`,{onClick:()=>p(`/drive/users/${e.id}`),className:`flex items-center gap-4 bg-background border border-[var(--panel-border)] p-5 rounded-2xl cursor-pointer hover:border-accent/50 hover:shadow-md transition-all group`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-foreground/5 flex items-center justify-center shrink-0 border border-[var(--panel-border)]`,children:e.photoURL?(0,l.jsx)(`img`,{src:e.photoURL,alt:`avatar`,className:`w-full h-full rounded-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-foreground/40`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground truncate group-hover:text-accent transition-colors text-[14px]`,children:[e.firstName,` `,e.lastName]}),(0,l.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/50 truncate mt-0.5`,children:e.email})]})]},e.id)),w.length===0&&(0,l.jsxs)(`div`,{className:`col-span-full py-12 flex flex-col items-center justify-center text-center`,children:[(0,l.jsx)(n.d,{className:`w-12 h-12 text-foreground/10 mb-4`}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground/50`,children:`No users found`})]})]}):xe.length>0?(0,l.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 pb-20`,children:xe.map(e=>(0,l.jsxs)(`div`,{className:`flex flex-col bg-background border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all group overflow-hidden shadow-sm hover:shadow-md h-[190px] relative`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10 bg-background/90 backdrop-blur-md rounded-lg p-1 border border-[var(--panel-border)] shadow-xl`,children:[(0,l.jsx)(`a`,{href:e.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-blue-500 transition-colors`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_e(e.accessPrefix===`pub_`?e.downloadURL:`${window.location.origin}/drive/${x[e.accessPrefix]}/${e._id}`,e._id)},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-emerald-500 transition-colors`,title:`Copy Link`,children:Y===e._id?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(e)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),W({id:e._id,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),q({id:e._id,url:e.downloadURL,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`h-[120px] w-full border-b border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center overflow-hidden relative cursor-pointer rounded-t-[calc(1rem-1px)]`,onClick:()=>H(e),children:e.fileType.startsWith(`image/`)?(0,l.jsxs)(l.Fragment,{children:[ue[e._id]!==!1&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-0`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})}),(0,l.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 group-hover:scale-105 ${ue[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>de(t=>({...t,[e._id]:!1})),onError:()=>de(t=>({...t,[e._id]:!1}))})]}):ye(e.fileType,e.downloadURL,!0)}),(0,l.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!U&&H(e),children:[U?.id===e._id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:U.name,onChange:e=>W({...U,name:e.target.value}),onBlur:()=>ge(),onKeyDown:e=>{e.key===`Enter`&&ge(),e.key===`Escape`&&W(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,l.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground truncate select-none group-hover:text-accent transition-colors`,title:e.fileName,children:e.fileName}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:ve(e.fileSize)})]})]},e._id))}):!s&&(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name),N(S),P(!0)}},onClick:()=>{N(S),P(!0)},className:`absolute inset-0 m-6 flex flex-col items-center justify-center text-foreground/40 transition-colors cursor-pointer group`,children:[(0,l.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`Folder is empty`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40 group-hover:text-foreground/60 transition-colors`,children:`Click here or drag and drop a file to upload`})]})]})]})]})]}),(0,l.jsx)(n.a,{children:ne&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!E&&P(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[480px] border-[var(--panel-border)] border rounded-3xl relative z-10 glass-panel shadow-2xl flex flex-col bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-[var(--panel-border)]/50 relative z-20`,children:[(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`button`,{onClick:()=>re(!F),className:`flex items-center gap-2 group outline-none`,children:[(0,l.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload to`}),(0,l.jsx)(`span`,{className:`bg-accent/10 group-hover:bg-accent/20 text-accent px-2 py-1 rounded-md text-[13px] font-bold transition-colors flex items-center gap-1 shadow-sm`,children:be.find(e=>e.id===M)?.label})]}),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(a.default.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[90]`,onClick:()=>re(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:`absolute top-full left-0 mt-3 w-48 bg-background border border-[var(--panel-border)] rounded-xl shadow-2xl py-1 overflow-hidden z-[100]`,children:be.map(e=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>{N(e.id),re(!1)},className:`w-full text-left px-4 py-3 hover:bg-foreground/5 text-[13px] font-bold text-foreground flex items-center gap-3 transition-colors outline-none`,children:[(0,l.jsx)(e.icon,{className:`w-4 h-4 text-foreground/50`}),e.label]},e.id))})]})})]}),(0,l.jsx)(`button`,{onClick:()=>!E&&P(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),O?(0,l.jsxs)(`form`,{onSubmit:Z,className:`p-6 flex flex-col gap-6 relative z-10 rounded-b-[2rem]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)] shadow-sm`,children:[ye(O.type,URL.createObjectURL(O)),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:O.name}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:ve(O.size)})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!E&&k(null),className:`w-8 h-8 flex items-center justify-center text-foreground/40 hover:text-red-500 rounded-xl hover:bg-red-500/10 transition-colors shrink-0`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`Edit File Name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,value:A,onChange:e=>j(e.target.value),disabled:E,className:`no-glow w-full bg-foreground/[0.02] border border-[var(--panel-border)] rounded-xl px-4 py-3.5 text-[14px] font-bold text-foreground outline-none focus:border-accent transition-colors shadow-sm`})]}),(0,l.jsx)(`div`,{className:`flex justify-end pt-4 mt-2 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:E,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:E?`Uploading to Drive...`:`Save to ${be.find(e=>e.id===M)?.label}`})})]}):(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:me,className:`p-12 flex flex-col items-center justify-center rounded-b-[2rem]`,children:[(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-foreground/5 flex items-center justify-center mb-5 border-2 border-dashed border-[var(--panel-border)]`,children:(0,l.jsx)(n.$,{className:`w-8 h-8 text-foreground/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground mb-1`,children:`Drag and drop file here`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-8`,children:`or click to browse local files`}),(0,l.jsx)(`input`,{type:`file`,ref:R,onChange:pe,className:`hidden`}),(0,l.jsx)(n.n,{onClick:()=>R.current?.click(),className:`px-8 py-3 rounded-full font-bold shadow-md btn-primary transition-colors`,children:`Browse Files`})]})]})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:V&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>H(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>H(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:V.fileName}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[V.fileType,` • `,ve(V.fileSize),V.accessPrefix===`mem_`&&(V.uploaderEmail||V.uid)&&` • From: ${V.uploaderEmail||V.uid}`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>_e(V.accessPrefix===`pub_`?V.downloadURL:`${window.location.origin}/drive/${x[V.accessPrefix]}/${V._id}`,V._id),className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500`,title:`Copy Link`,children:Y===V._id?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(V)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{H(null),W({id:V._id,name:V.fileName,prefix:V.accessPrefix})},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-purple-500 transition-colors rounded-xl shadow-sm`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{H(null),q({id:V._id,url:V.downloadURL,name:V.fileName,prefix:V.accessPrefix})},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsx)(`a`,{href:V.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>H(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ce&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none fade-in`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),V.fileType.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>le(!1),src:V.downloadURL,alt:V.fileName,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):V.fileType.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>le(!1),src:V.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):V.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>le(!1),src:V.downloadURL,className:`w-full h-full border-none bg-white rounded-lg relative z-10 transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,title:`PDF Preview`}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),le(!1)},children:[(0,l.jsx)(n.W,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:fe&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/90 backdrop-blur-xl`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-sm flex flex-col items-center pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-red-500/20 bg-background/80 p-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6`,children:(0,l.jsx)(n.c,{className:`w-8 h-8 text-red-500`})}),(0,l.jsx)(`h3`,{className:`text-xl font-bold text-foreground mb-2`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 font-medium leading-relaxed`,children:`You don't have access to this file, or it may have been deleted.`}),(0,l.jsx)(`div`,{className:`w-5 h-5 border-2 border-accent/20 border-t-accent rounded-full animate-spin mt-6`})]})]})}),(0,l.jsx)(te,{isOpen:!!ae,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:ae?.name}),` This action is permanent.`]}),onConfirm:he,onCancel:()=>q(null),isProcessing:J,confirmText:`Yes, Delete`}),(0,l.jsx)(n.a,{children:I&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`fixed inset-0 z-[1000] bg-background/60 backdrop-blur-md pointer-events-none flex items-center justify-center p-6`,children:(0,l.jsxs)(n.i.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent p-12 rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6 relative`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-accent/5 rounded-[38px] animate-pulse`}),(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent shadow-[0_0_40px_rgba(var(--accent-rgb),0.2)]`,children:(0,l.jsx)(n.$,{className:`w-10 h-10 animate-bounce`})}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-2 relative z-10`,children:[(0,l.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop files to upload`}),(0,l.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:`Your files will be staged for review`})]})]})})})]})}function L(){let e=[{id:`form`,title:`Inline Form`,description:`A static, embedded contact form designed directly into the page layout.`,icon:n.P,path:`/templates/inline_form`},{id:`popup`,title:`Modal Popup Form`,description:`A centralized popup contact form that visually blurs the background context.`,icon:n.yt,path:`/templates/popup_form`},{id:`confirmation`,title:`Action Confirmation`,description:`A classic confirmation dialog styled for decisive user actions.`,icon:n.lt,path:`/templates/confirmation`},{id:`board`,title:`Board View`,description:`A modern, drag-and-drop styled Kanban board aesthetic for task management.`,icon:n.z,path:`/templates/board`},{id:`table`,title:`Data Table`,description:`A clean, column-based data table optimized for large datasets and bulk actions.`,icon:n.g,path:`/templates/table`},{id:`calendar`,title:`Calendar View`,description:`A structured monthly calendar grid for scheduling and date-based resource planning.`,icon:n.dt,path:`/templates/calendar`}];return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,l.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-4xl md:text-5xl lg:text-[4.8rem] leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`Premium Templates`}),(0,l.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Explore our collection of fully functional, beautifully designed boilerplate components.`})]}),(0,l.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[80%] h-[80%] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),e.map((e,t)=>{let r=e.icon;return(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},children:(0,l.jsxs)(u.Link,{to:e.path,className:`flex items-center gap-6 w-full p-4 md:px-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group hover:bg-foreground/[0.02]`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-accent/10 flex items-center justify-center text-accent shrink-0 border border-accent/20 group-hover:scale-105 transition-transform`,children:(0,l.jsx)(r,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground truncate`,children:e.title}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 truncate font-medium`,children:e.description})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary shrink-0 transition-transform shadow-lg group-hover:-translate-y-0.5`,children:[`View `,(0,l.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]})},e.id)})]})]})}function R(){let[e,t]=(0,a.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[r,i]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`relative z-10 w-full`,children:r===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.nt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):r===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Try interacting with this simulated inline template block.`})]}),(0,l.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),i(`loading`);try{let r=n.wt.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.Tt,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),i(`success`),setTimeout(()=>{i(`idle`),t({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{i(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:n=>t({...e,favoriteService:n.target.value})}),(0,l.jsx)(n.r,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:n=>t({...e,satisfactionRating:n.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:n=>t({...e,detailedThoughts:n.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})})]})})]})}function ie(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)({concept:``,featureRequest:``,notes:``}),[s,c]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Popup Form`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,l.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 text-foreground/70`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col w-full min-h-[150px] p-6 lg:p-10`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),(0,l.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,l.jsxs)(n.n,{onClick:()=>t(!0),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center justify-center gap-2 btn-primary transition-all hover:-translate-y-1`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>t(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,l.jsx)(`button`,{onClick:()=>t(!1),className:`absolute -top-2 -right-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-foreground/5 text-foreground/60 hover:text-foreground transition-colors z-20`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),s===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.nt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed max-w-[280px]`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):s===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Fill out the simulated fields below to test the interaction.`})]}),(0,l.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),c(`loading`);try{let e=n.wt.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.Tt,`user_submissions`),{uid:e,...r,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),c(`success`),setTimeout(()=>{c(`idle`),i({concept:``,featureRequest:``,notes:``}),t(!1)},3e3)}catch{c(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:r.concept,onChange:e=>i({...r,concept:e.target.value})}),(0,l.jsx)(n.r,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:r.featureRequest,onChange:e=>i({...r,featureRequest:e.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:r.notes,onChange:e=>i({...r,notes:e.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})]})]})]})})]})}function z(){let[e,t]=(0,a.useState)(void 0);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 items-center`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsxs)(`div`,{className:`w-full max-w-5xl mx-auto mt-2 glass-panel rounded-3xl border border-[var(--panel-border)] p-6 md:p-10 relative overflow-hidden shadow-2xl`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center text-red-500 shrink-0`,children:(0,l.jsx)(n.p,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,l.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,l.jsx)(`p`,{className:`text-[12px] sm:text-[13px] text-foreground/50 font-medium mt-0.5 truncate`,children:`Size: 4.2 MB • Modified 2 hours ago`})]})]}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(null),className:`w-full sm:w-auto shrink-0 flex items-center justify-center px-6 py-3 sm:py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-red-500/5 sm:bg-transparent`,children:`Delete File`})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 opacity-50 pointer-events-none mt-2`,children:[1,2].map(e=>(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,l.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,l.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,l.jsx)(n.a,{children:e!==void 0&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsx)(n.a,{mode:`wait`,children:e===null?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:`Are you entirely sure you wish to delete this configuration? This action is permanent.`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,l.jsx)(n.n,{onClick:()=>t(!0),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:`Yes, Delete`})]})]},`confirm`):e===!0?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.ct,{className:`w-5 h-5`}),` Verified`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.c,{className:`w-5 h-5`}),` Aborted`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var B=(e,t=[])=>{let n=(e.pageName||e.pageId||`custom_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`I need your help building the inner content for a newly created Public Page. This page is powered by the \`PublicPageTemplate\` (located at \`src/templates/PublicPageTemplate.tsx\`).
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-DYteiM-1.cjs`),t=require(`./theme.config-0Lvwt5Bo.cjs`),n=require(`./ContactPopup-5mXFBqTs.cjs`),r=require(`./contactForm.config-CXyq-EbM.cjs`),i=require(`./supportForm.config-haLod4rv.cjs`);let a=require(`react`);a=e.i(a,1);let o=require(`firebase/firestore`),s=require(`firebase/auth`),c=require(`firebase/storage`),l=require(`react/jsx-runtime`),u=require(`react-router-dom`),d=require(`react-dom`);var f=(0,a.createContext)({user:null,userRole:null,loading:!0,signOut:async()=>{},registerUser:async()=>{},refreshUser:async()=>{},userInactive:!1,roleResolved:!1,activeOrg:null,activeWorkspace:null,checkOrg:async()=>{},workspaceAccess:{},userWorkspaces:[],switchWorkspace:async()=>{},createWorkspace:async()=>{},createOrg:async()=>{}});function p({children:e}){let t=n.Ct(),[r,i]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[d,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(!1),v=a.default.useRef(null),y=a.default.useRef(null);return(0,a.useEffect)(()=>{let e;if(!n.wt){h(!1),_(!0);return}let r=(0,s.onAuthStateChanged)(n.wt,async r=>{if(r?.uid===y.current&&g){i(r);return}if(y.current=r?.uid||null,r){let a=localStorage.getItem(`fbos_role_${r.uid}`);a&&(u(a),_(!0),h(!1)),console.log(`[AuthContext] 1. onAuthStateChanged fired for user:`,r.uid),i(r);try{let i=(0,o.doc)(n.Tt,`user_profiles`,r.uid),a=(await(0,o.getDoc)(i)).data()||{};(0,o.setDoc)(i,{uid:r.uid,email:r.email,displayName:r.displayName||a.displayName||``,lastLoginAt:new Date().toISOString(),createdAt:a.createdAt||new Date().toISOString()},{merge:!0}).catch(e=>console.error(`Failed to sync profile:`,e)),e&&e(),e=(0,o.onSnapshot)(i,e=>{if(e.exists()){let n=e.data(),a=n.role||`user`,s=``;try{s={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ADMIN_EMAILS:void 0,VITE_FIREBASE_API_KEY:void 0,VITE_FIREBASE_APP_ID:void 0,VITE_FIREBASE_AUTH_DOMAIN:void 0,VITE_FIREBASE_MESSAGING_SENDER_ID:void 0,VITE_FIREBASE_PROJECT_ID:void 0,VITE_FIREBASE_STORAGE_BUCKET:void 0}?.VITE_ADMIN_EMAILS||``}catch{}let c=t.adminEmails||(s?s.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]);c.length>0&&!n.role&&c.map(e=>e.toLowerCase()).some(e=>r.email?.toLowerCase()===e)&&(a=`admin`,(0,o.updateDoc)(i,{role:`admin`}).catch(e=>console.error(`Error auto-setting admin role:`,e))),v.current===null&&(v.current=a),u(a),localStorage.setItem(`fbos_role_${r.uid}`,a),p(n.inactive===!0)}_(!0),h(!1)},e=>{console.warn(`[AuthContext] user_profiles snapshot error (safe to ignore during auth transition):`,e),_(!0),h(!1)})}catch(e){console.error(`[AuthContext] ERROR in auth resolution:`,e),_(!0),h(!1)}}else console.log(`[AuthContext] No user currently signed in.`),i(null),u(null),p(!1),_(!0),h(!1),v.current=null,e&&e()});return()=>{r(),e&&e()}},[]),(0,l.jsx)(f.Provider,{value:{user:r,userRole:c,loading:m,signOut:async()=>{await(0,s.signOut)(n.wt),i(null)},registerUser:async(e,t,r,i)=>{let{createUserWithEmailAndPassword:a}=await import(`firebase/auth`),{user:c}=await a(n.wt,e,t),l=`${r} ${i}`.trim();await(0,s.updateProfile)(c,{displayName:l});try{await c.getIdToken(!0),await(0,o.setDoc)((0,o.doc)(n.Tt,`user_profiles`,c.uid),{uid:c.uid,email:c.email,displayName:l,createdAt:new Date().toISOString()},{merge:!0})}catch(e){console.warn(`Could not write public profile on registration.`,e)}await(0,s.sendEmailVerification)(c)},refreshUser:async()=>{n.wt.currentUser&&(await n.wt.currentUser.reload(),i(Object.assign(Object.create(Object.getPrototypeOf(n.wt.currentUser)),n.wt.currentUser)))},userInactive:d,roleResolved:g},children:e})}var m=()=>(0,a.useContext)(f);function h(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)([]),s=(0,a.useRef)(null),c=(0,u.useNavigate)();(0,a.useEffect)(()=>{function e(e){s.current&&!s.current.contains(e.target)&&t(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let d=(0,a.useRef)({users:[],submissions:[],requests:[]}),f=(e,t)=>{d.current[e]=t;let n=[...d.current.users,...d.current.submissions,...d.current.requests];n.sort((e,t)=>{let n=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return((t.time?.toDate?t.time.toDate().getTime():new Date(t.time).getTime())||0)-(n||0)}),i(n.slice(0,8))};(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_profiles`),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(5)),e=>{f(`users`,e.docs.map(e=>{let t=e.data();return{id:`u_${e.id}`,type:`user`,title:`New user registered`,subtitle:t.email||`Unknown`,time:t.createdAt}}))}),t=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`submissions`,e.docs.map(e=>{let t=e.data();return{id:`s_${e.id}`,type:`submission`,title:`New form submission`,subtitle:t.name||t.email||`Anonymous`,time:t.submittedAt}}))}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`),(0,o.limit)(5)),e=>{f(`requests`,e.docs.map(e=>{let t=e.data();return{id:`r_${e.id}`,type:`request`,title:`New support request`,subtitle:t.name||t.submitterName||t.contactEmail||t.email||`Anonymous`,time:t.submittedAt}}))});return()=>{e(),t(),r()}},[]);let[p,m]=(0,a.useState)(()=>typeof window<`u`?parseInt(localStorage.getItem(`admin_notifications_last_read`)||`0`,10):0),h=()=>{let n=!e;if(t(n),n){let e=Date.now();m(e),typeof window<`u`&&localStorage.setItem(`admin_notifications_last_read`,e.toString())}},g=r.some(e=>{if(!e.time)return!0;let t=e.time?.toDate?e.time.toDate().getTime():new Date(e.time).getTime();return t>p||isNaN(t)}),_=e=>{t(!1),c(e===`user`?`/users`:e===`submission`?`/submissions`:`/requests`)},v=e=>{if(!e)return``;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)};return(0,l.jsxs)(`div`,{className:`relative z-50 flex-shrink-0 mr-1 md:mr-2`,ref:s,children:[(0,l.jsxs)(`button`,{onClick:h,className:`p-2 rounded-xl glass-panel transition-all border border-transparent relative text-notification-icon hover:bg-foreground/5 hover:border-[var(--panel-border)]`,"aria-label":`Admin Notifications`,children:[(0,l.jsx)(n.mt,{className:`w-4 h-4 md:w-5 md:h-5`}),g&&(0,l.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-red-500 rounded-full animate-pulse`})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-[-60px] md:right-0 w-[320px] md:w-[400px] glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col origin-top-right overflow-hidden bg-[var(--panel-bg)]`,children:[(0,l.jsxs)(`div`,{className:`px-4 border-b border-[var(--panel-border)]/50 pb-3 pt-4 flex items-center justify-between`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground tracking-wide`,children:`Notifications`}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md`,children:`Admin`})]}),(0,l.jsx)(`div`,{className:`max-h-[350px] overflow-y-auto w-full p-2 flex flex-col gap-1`,children:r.length===0?(0,l.jsx)(`div`,{className:`p-6 text-center text-foreground/40 text-[13px] font-medium`,children:`No recent activity.`}):r.map(e=>(0,l.jsxs)(`button`,{onClick:()=>_(e.type),className:`w-full flex items-start gap-3 p-3 rounded-xl hover:bg-foreground/5 transition-all text-left group border border-transparent hover:border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`mt-0.5 w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-foreground/5 text-notification-icon`,children:e.type===`user`?(0,l.jsx)(n.d,{className:`w-4 h-4`}):e.type===`submission`?(0,l.jsx)(n.k,{className:`w-4 h-4`}):(0,l.jsx)(n.tt,{className:`w-4 h-4`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-2`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-semibold text-foreground group-hover:text-accent transition-colors truncate`,children:e.title}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/60 truncate`,children:e.subtitle}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wide text-foreground/40 mt-1`,children:v(e.time)})]})]},e.id))})]})})]})}var g=[{id:`contact`,hidden:!1},{id:`templates`,hidden:!1},{id:`setup`,hidden:!1}],_=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden}),v=[{id:`pages`,hidden:!1},{id:`forms`,hidden:!1},{id:`drive`,hidden:!1},{id:`users`,hidden:!1},{id:`theme`,hidden:!1},{id:`submissions`,hidden:!1},{id:`requests`,hidden:!1},{id:`settings`,hidden:!1},{id:`profile`,hidden:!1},{id:`support`,hidden:!0}],y={route:`/support`,template:`popup_form`,form:`support`,tabName:`Support`,iconName:``},b={templates:{label:`Templates`,path:`/templates`},setup:{label:`Setup`,path:`/setup`},contact:{label:`Contact`,path:`/contact`}};function x({customMenu:e,standalone:t}){let{user:r,userRole:i,signOut:s}=m(),c=(0,u.useNavigate)(),[d,f]=(0,a.useState)(!1),[p,v]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),D=r?.displayName||r?.email?.split(`@`)[0]||`User`,ee=D.charAt(0).toUpperCase()+D.slice(1),{theme:O,toggleTheme:k,activeConfig:A}=n.xt(),te=async()=>{await s(),c(`/`),f(!1)},[j,M]=(0,a.useState)({...b}),[N,P]=(0,a.useState)(g);(0,a.useEffect)(()=>{if(!n.Tt)return;let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_pages`),e=>{let t={...b};e.forEach(e=>{let n=e.data();if(n.enabled===!1)return;let r=n.pageName||n.title||b[e.id]?.label||e.id,i=n.route||(e.id===`home`?`/`:`/`+e.id);t[e.id]={label:r,path:i}}),M(t)},e=>{console.warn(`sys_pages snapshot error (safe to ignore during auth transition):`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{P(e.exists()&&Array.isArray(e.data().order)?_(e.data().order):g)},e=>{console.warn(`page_order snapshot error (safe to ignore during auth transition):`,e)}),r=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_tabs`,`support`),e=>{e.exists()&&e.data().pageName&&I(e.data().pageName)},e=>{console.warn(`support snapshot error (safe to ignore during auth transition):`,e)});return()=>{e(),t(),r()}},[]);let[F,I]=(0,a.useState)(y.tabName),L=(()=>{let e=new Set(N.filter(e=>e.hidden).map(e=>e.id)),t=new Set,n=[];return N.forEach(e=>{if(e.hidden||e.id===`home`)return;let r=j[e.id];r&&(n.push({label:r.label,path:r.path}),t.add(e.id))}),Object.entries(j).forEach(([r,i])=>{!t.has(r)&&!e.has(r)&&r!==`home`&&i.path!==`/`&&i.path!==`/support`&&n.push({label:i.label,path:i.path})}),n})(),R=e||L,z=(0,a.useRef)(null),B=(0,a.useRef)(null),[ne,V]=(0,a.useState)(R.length);(0,a.useEffect)(()=>{if(t||r)return;let e=()=>{let e=z.current,t=B.current;if(!e||!t)return;let n=e.clientWidth,r=t.querySelectorAll(`[data-measure-nav]`);if(r.length===0){V(R.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?28:0),i>n){a=!1;break}if(a){V(R.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?28:0);if(i+50>n)break;o=i,s++}V(Math.max(s,1))},n=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(n);let i=new ResizeObserver(()=>requestAnimationFrame(e));return z.current&&i.observe(z.current),()=>{cancelAnimationFrame(n),i.disconnect()}},[R.map(e=>e.label).join(`|`),t,r,R.length]);let H=R.slice(0,ne),U=R.slice(ne);return(0,l.jsxs)(`nav`,{className:`flex items-center justify-between w-full max-w-7xl mx-auto z-40 p-4 md:p-10 relative`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50`,children:(0,l.jsxs)(u.Link,{to:`/`,className:`flex items-center gap-2 md:gap-3 group cursor-pointer z-50`,children:[(0,l.jsx)(`div`,{className:`w-9 h-9 md:w-10 md:h-10 rounded-xl glass-panel flex items-center justify-center glow-hover shadow-lg transition-transform duration-500 group-hover:rotate-[360deg] group-active:scale-95 overflow-hidden`,children:A?.logoUrl?(0,l.jsx)(`img`,{src:A.logoUrl,alt:`Logo`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.X,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsx)(`span`,{className:`hidden lg:block font-bold text-[22px] tracking-tight text-gradient transition-colors duration-300 drop-shadow-sm`,children:A?.appName||``})]})}),(0,l.jsx)(n.a,{children:x&&(0,l.jsx)(n.t,{formId:`contact`,onClose:()=>S(!1)})}),(0,l.jsx)(n.a,{children:C&&(0,l.jsx)(n.t,{formId:`support`,onClose:()=>w(!1)})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-4 z-50 relative ml-auto flex-1 justify-end`,children:[!t&&!r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:B,"aria-hidden":`true`,className:`flex items-center gap-7 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,height:0,pointerEvents:`none`},children:R.map((e,t)=>(0,l.jsxs)(`span`,{"data-measure-nav":!0,className:`text-[13px] md:text-[14px] font-bold tracking-wide flex items-center gap-1.5 shrink-0`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]},e.path||t))}),(0,l.jsxs)(`div`,{className:`hidden sm:flex items-center gap-7 mr-6 w-full max-w-full justify-end relative`,ref:z,children:[H.map((e,t)=>(0,l.jsxs)(`div`,{className:`relative shrink-0`,onMouseEnter:()=>v(e.label),onMouseLeave:()=>v(null),children:[e.path?(0,l.jsxs)(u.Link,{to:e.path,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all cursor-pointer flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]}):(0,l.jsxs)(`button`,{onClick:e.action,className:`text-[13px] md:text-[14px] font-bold tracking-wide text-foreground/50 hover:text-accent transition-all flex items-center gap-1.5`,children:[e.label,e.submenu&&(0,l.jsx)(n.st,{className:`w-3 h-3`})]}),e.submenu&&p===e.label&&(0,l.jsx)(`div`,{className:`absolute top-[100%] left-0 pt-2 z-50`,children:(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:`min-w-[180px] max-h-[300px] overflow-y-auto styled-scrollbars bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2`,children:e.submenu.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,className:`px-5 py-3 text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:e.action,className:`px-5 py-3 text-left w-full text-[13px] font-medium text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})})]},`${e.path||`no-path`}-${t}`)),U.length>0&&(0,l.jsxs)(`div`,{className:`relative flex items-center shrink-0`,onMouseEnter:()=>f(`overflow`),children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`overflow`?!1:`overflow`),className:`p-1 rounded-lg transition-colors flex items-center ${d===`overflow`?`bg-foreground/5 text-accent`:`text-foreground/50 hover:bg-foreground/5 hover:text-accent`}`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-5 h-5`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`}),(0,l.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`})]})}),(0,l.jsx)(n.a,{children:d===`overflow`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:5,scale:.98},className:`absolute top-[100%] pt-1 right-0 min-w-[200px] max-h-[350px] overflow-y-auto styled-scrollbars bg-background border border-[var(--panel-border)] rounded-2xl shadow-xl flex flex-col py-2 z-50 origin-top-right`,children:U.map((e,t)=>e.path?(0,l.jsx)(u.Link,{to:e.path,onClick:()=>f(!1),className:`px-5 py-3 text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t):(0,l.jsx)(`button`,{onClick:()=>{e.action&&e.action(),f(!1)},className:`px-5 py-3 text-left w-full text-[13px] font-bold tracking-wide text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors`,children:e.label},t))})]})})]})]}),A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 mr-2 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40 shrink-0`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(u.Link,{to:`/login`,className:`hidden sm:flex text-[14px] font-bold tracking-wide text-foreground/80 hover:text-accent transition-colors px-3 py-1.5 shrink-0`,children:`Sign In`}),(0,l.jsx)(u.Link,{to:`/register`,className:`hidden sm:flex text-[13px] md:text-[14px] font-bold tracking-wide px-4 py-1.5 md:px-5 md:py-2 rounded-xl btn-primary transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 active:scale-95 items-center justify-center ml-2`,children:`Get Started`}),(0,l.jsxs)(`div`,{className:`relative sm:hidden ml-1`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`guest`?!1:`guest`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`guest`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`guest`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/templates`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.P,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Templates`})]}),(0,l.jsxs)(u.Link,{to:`/setup`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Setup`})]}),(0,l.jsxs)(u.Link,{to:`/contact`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Contact`})]}),(0,l.jsxs)(`div`,{className:`pt-2 mt-1 border-t border-[var(--panel-border)]/50 flex flex-col gap-1`,children:[(0,l.jsxs)(u.Link,{to:`/login`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full`,children:[(0,l.jsx)(n.A,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign In`})]}),(0,l.jsx)(u.Link,{to:`/register`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl btn-primary w-full shadow-lg hover:-translate-y-0.5 transition-transform text-white`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-bold mx-auto`,children:`Get Started`})})]})]})]})})]})]})]}),!t&&r&&(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 mr-1`,children:[i===`admin`&&(0,l.jsx)(h,{}),A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4 md:w-5 md:h-5`}):(0,l.jsx)(n.E,{className:`w-4 h-4 md:w-5 md:h-5`})})]}),(0,l.jsxs)(`div`,{className:`relative z-50 flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,l.jsxs)(`button`,{onClick:()=>f(d===`user`?!1:`user`),className:`flex items-center gap-2 group p-1 sm:pr-2.5 rounded-full glass-panel hover:bg-foreground/5 transition-all duration-300 border ${d===`user`?`border-accent/40 bg-foreground/5`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-9 md:h-9 rounded-full bg-accent/10 flex items-center justify-center overflow-hidden border border-[var(--panel-border)] group-hover:border-accent/30 transition-colors shrink-0 text-accent`,children:r.photoURL&&!T?(0,l.jsx)(`img`,{src:r.photoURL,alt:`Profile`,className:`w-full h-full object-cover`,onError:()=>E(!0)}):(0,l.jsx)(n.d,{className:`w-4 h-4 md:w-5 md:h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`hidden sm:flex flex-col text-left mr-1 justify-center min-w-[70px] max-w-[160px]`,children:[(0,l.jsx)(`span`,{className:`text-[12px] font-extrabold leading-tight text-foreground truncate w-full`,children:ee}),(0,l.jsx)(`span`,{className:`text-[10px] font-mono tracking-wider leading-tight text-accent truncate w-full mt-0.5 uppercase font-bold`,children:i===`admin`?`Admin`:`Free User`})]})]}),(0,l.jsx)(n.a,{children:d===`user`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-5,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98,y:-5},className:`absolute top-full mt-2 right-0 w-[280px] md:w-[320px] glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-2xl z-50 flex flex-col origin-top-right`,children:[(0,l.jsxs)(`div`,{className:`p-3 border-b border-[var(--panel-border)]/50 mb-1 flex flex-col gap-1.5`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[15px] text-foreground truncate`,children:ee}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate font-mono`,children:r.email})]}),(0,l.jsxs)(`div`,{className:`py-1`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.d,{className:`w-3 h-3 text-accent`})}),`Profile Settings`]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.H,{className:`w-3 h-3 text-accent`})}),`Drive`]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.u,{className:`w-3 h-3 text-accent`})}),`Users`]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.k,{className:`w-3 h-3 text-accent`})}),`Submissions`]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.tt,{className:`w-3 h-3 text-accent`})}),`Requests`]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.y,{className:`w-3 h-3 text-accent`})}),`Settings`]}),(0,l.jsxs)(u.Link,{to:`/pages`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.L,{className:`w-3 h-3 text-accent`})}),`Pages`]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-semibold tracking-wide hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all gap-3 text-left`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.tt,{className:`w-3 h-3 text-accent`})}),F]})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`button`,{onClick:te,className:`flex items-center w-full px-3 py-2.5 rounded-xl text-[13px] font-bold tracking-wide hover:bg-red-500/10 hover:text-red-500 text-foreground/70 transition-all gap-3`,children:[(0,l.jsx)(`span`,{className:`w-5 h-5 rounded-md bg-red-500/5 flex items-center justify-center shrink-0 text-red-500`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-3 h-3`,children:[(0,l.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,l.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,l.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]})}),`Sign Out`]})})]})]})})]}),(0,l.jsxs)(`div`,{className:`relative sm:hidden`,children:[(0,l.jsx)(`button`,{onClick:()=>f(d===`nav`?!1:`nav`),className:`p-2 rounded-xl glass-panel glow-hover border transition-all ${d===`nav`?`border-accent bg-foreground/5`:`border-[var(--panel-border)] hover:bg-foreground/5`}`,children:(0,l.jsx)(n.O,{className:`w-5 h-5 text-accent/80`})}),(0,l.jsx)(n.a,{children:d===`nav`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>f(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.95},className:`absolute top-full right-0 mt-3 w-[220px] p-2 glass-panel border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 flex flex-col gap-1 origin-top-right`,children:[(0,l.jsxs)(u.Link,{to:`/profile`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.d,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Profile Settings`})]}),(0,l.jsxs)(u.Link,{to:`/drive`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.H,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Drive`})]}),(0,l.jsxs)(u.Link,{to:`/dashboard`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.I,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Dashboard`})]}),i===`admin`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Link,{to:`/users`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.u,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Users`})]}),(0,l.jsxs)(u.Link,{to:`/submissions`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.k,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Submissions`})]}),(0,l.jsxs)(u.Link,{to:`/requests`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.tt,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Requests`})]}),(0,l.jsxs)(u.Link,{to:`/settings`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all`,children:[(0,l.jsx)(n.y,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Settings`})]})]}),i!==`admin`&&(0,l.jsxs)(u.Link,{to:`/support`,onClick:()=>f(!1),className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-foreground/5 text-foreground/80 hover:text-foreground transition-all w-full text-left`,children:[(0,l.jsx)(n.tt,{className:`w-4 h-4 text-accent/70`}),` `,(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Support`})]}),(0,l.jsx)(`div`,{className:`pt-1 mt-1 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(`button`,{onClick:te,className:`flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-red-500/10 text-red-500/80 hover:text-red-500 transition-all w-full`,children:(0,l.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Sign Out`})})})]})]})})]})]})]}),t&&(0,l.jsx)(l.Fragment,{children:A?.showThemeToggle&&(0,l.jsx)(`button`,{onClick:k,className:`p-2 ml-1 rounded-xl glass-panel hover:bg-foreground/5 transition-all text-accent border border-[var(--panel-border)] hover:border-accent/40`,"aria-label":`Toggle Theme`,children:O===`dark`?(0,l.jsx)(n._,{className:`w-4 h-4`}):(0,l.jsx)(n.E,{className:`w-4 h-4`})})})]})]})}var S={hero:{title:`Firebase OS.`,showSubtitle:!0,subtitle:`The Open-Source Firebase Starter`,text:`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`,buttons:{primary:{text:`Start Building Free`,action:`register`},secondary:{text:`Sign In`,action:`sign_in`}}}};function C(){let[e,t]=(0,a.useState)(null),r=n.Ct()?.defaultConfigs?.home||S,[i,s]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`fbos_home_config`);if(e)return JSON.parse(e)}catch{}return r}),[c,d]=(0,a.useState)(!0);if((0,a.useEffect)(()=>(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_pages`,`home`),e=>{if(e.exists()){let t=e.data();s(t),localStorage.setItem(`fbos_home_config`,JSON.stringify(t))}else s(r),localStorage.removeItem(`fbos_home_config`)}),[]),!c)return null;let f=i||S,p=f?.hero?.showSubtitle??!0;f?.hero?.subtitleEmoji;let m=f?.hero?.title||f?.heroTitle||`The Open-Source Firebase Starter`,h=f?.hero?.subtitle||f?.heroSubtitle||`The Open-Source Firebase Starter`,g=f?.hero?.text||f?.heroText||`A production-ready Firebase backend template with Auth, Firestore prefix rules, and a clean dashboard — ready for vibe-coded apps.`;f?.hero?.buttons?.primary?.text||f?.primaryBtnText,f?.hero?.buttons?.primary?.action||f?.primaryBtnAction;let _=f?.hero?.buttons?.primary||{},v=f?.hero?.buttons?.secondary||{},y=(e,n,r,i)=>{let a=e.text||n,o=e.action||r,s=i.replace(/rounded-\[.*?\]|rounded-\w+/g,``).replace(/border /g,``).replace(/border-\[.*?\]/g,``),c={borderRadius:`var(--btn-radius, 0.75rem)`};if(o===`form`){let n=e.form||`contact`;return(0,l.jsx)(`button`,{onClick:()=>t(n),className:s,style:c,children:a})}if(o===`redirect`){let t=e.url||`/`;return t.startsWith(`http`)?(0,l.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:s,style:c,children:a}):(0,l.jsx)(u.Link,{to:t,className:s,style:c,children:a})}return(0,l.jsx)(u.Link,{to:{sign_in:`/login`,register:`/register`}[o]||`/register`,className:s,style:c,children:a})};return(0,l.jsxs)(`main`,{className:`flex-1 flex flex-col items-center justify-center w-full max-w-5xl mx-auto mt-4 md:mt-12 mb-16 md:mb-24 z-10 relative`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:`text-center mb-8 md:mb-12`,children:[p&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{delay:.2},className:`inline-flex items-center gap-2 md:gap-3 px-5 md:px-6 py-2 md:py-2.5 mb-8 md:mb-10 text-[13px] md:text-[15px] font-semibold tracking-wide uppercase rounded-full glass-panel text-foreground glow-hover cursor-pointer`,children:[h===S.hero.subtitle&&(0,l.jsx)(n.s,{className:`w-4 h-4 text-accent`}),` `,h]}),(0,l.jsx)(n.i.h1,{className:`text-5xl sm:text-6xl md:text-7xl lg:text-[5.5rem] font-extrabold tracking-tight mb-6 md:mb-8 text-gradient animate-float leading-[1.1] md:leading-[1.15] px-2`,children:m}),(0,l.jsx)(`p`,{className:`text-[15px] sm:text-lg md:text-xl lg:text-[22px] text-foreground/60 max-w-3xl mx-auto font-medium leading-[1.6] md:leading-[1.7] mb-10 md:mb-14 px-6 md:px-4`,children:g}),(0,l.jsxs)(n.i.div,{className:`flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 w-full max-w-2xl mx-auto px-6`,initial:{opacity:0},animate:{opacity:1},transition:{delay:.5},children:[y(_,`Start Building Free`,`register`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`),y(v,`Sign In`,`sign_in`,`w-full sm:w-auto px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-secondary text-[15px] transition-all duration-300 flex items-center justify-center hover:-translate-y-1`)]})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsx)(n.t,{onClose:()=>t(null),formId:e})})]})}function w(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),o=(0,u.useNavigate)(),{registerUser:c}=m();return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Create an account`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Join Firebase OS and start building today.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let n=new FormData(e.currentTarget),r=n.get(`email`),a=n.get(`password`),s=n.get(`firstName`),d=n.get(`lastName`);if(a.length<6){i(`Password must be at least 6 characters.`),t(!1);return}try{await c(r,a,s,d),o(`/verify`)}catch(e){e?.code===`auth/email-already-in-use`?i((0,l.jsxs)(`span`,{children:[`An account with this email already exists.`,` `,(0,l.jsx)(u.Link,{to:`/login?email=${encodeURIComponent(r)}`,className:`font-bold underline hover:text-accent transition-colors`,children:`Sign in?`})]})):e?.code===`auth/weak-password`?i(`Password must be at least 6 characters.`):i(e?.message||`An error occurred during registration.`)}finally{t(!1)}},children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,l.jsx)(n.r,{name:`firstName`,label:`First Name`,type:`text`,placeholder:`John`,required:!0}),(0,l.jsx)(n.r,{name:`lastName`,label:`Last Name`,type:`text`,placeholder:`Doe`,required:!0})]}),(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(n.r,{name:`password`,label:`Password`,type:`password`,placeholder:`••••••••`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Create Account `,(0,l.jsx)(n.ht,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.wt,new s.GoogleAuthProvider)}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-[15px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),`Sign up with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`Already have an account? `,(0,l.jsx)(u.Link,{to:`/login`,className:`text-accent hover:underline font-bold ml-1`,children:`Sign in`})]})]})]})})}function T(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o]=(0,u.useSearchParams)(),c=(0,u.useNavigate)(),[d]=(0,a.useState)(o.get(`email`)||``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mt-6 md:mt-8 mb-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Welcome back`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Sign in to Firebase OS.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 mb-6 text-[14px] font-medium text-red-400 bg-red-500/10 rounded-xl border border-red-500/20`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget),a=r.get(`email`),d=r.get(`password`);try{await(0,s.signInWithEmailAndPassword)(n.wt,a,d),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e?.code===`auth/invalid-credential`||e?.code===`auth/user-not-found`||e?.code===`auth/wrong-password`?i((0,l.jsxs)(`span`,{children:[`Email or Password are incorrect.`,` `,(0,l.jsx)(u.Link,{to:`/reset-password`,className:`font-bold underline hover:text-red-400 transition-colors`,children:`Reset password?`})]})):i(e?.message||`Invalid credentials.`),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Email`,type:`email`,defaultValue:d,placeholder:`name@example.com`,required:!0}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center pr-1`,children:[(0,l.jsx)(`label`,{className:`text-[14px] md:text-[15px] tracking-wide font-medium text-foreground/80 select-none pb-1`,children:`Password`}),(0,l.jsx)(u.Link,{to:`/reset-password`,className:`text-[13px] md:text-[14px] text-accent hover:underline font-bold tracking-wide`,children:`Forgot Password?`})]}),(0,l.jsx)(n.r,{name:`password`,type:`password`,placeholder:`••••••••`,required:!0})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsxs)(n.n,{type:`submit`,className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,isLoading:e,children:[`Sign In `,(0,l.jsx)(n.ht,{className:`ml-2 w-4 h-4 group-hover:translate-x-1 transition-transform shrink-0`})]})})]}),(0,l.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:[(0,l.jsxs)(n.n,{variant:`secondary`,onClick:async()=>{t(!0);try{await(0,s.signInWithPopup)(n.wt,new s.GoogleAuthProvider),c(o.get(`from`)||`/dashboard`,{replace:!0})}catch(e){e instanceof Error&&i(e.message)}finally{t(!1)}},className:`w-full py-3 text-base font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,disabled:e,children:[(0,l.jsxs)(`svg`,{className:`w-5 h-5 mr-3`,viewBox:`0 0 24 24`,children:[(0,l.jsx)(`path`,{fill:`currentColor`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,l.jsx)(`path`,{fill:`currentColor`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]}),`Sign in with Google`]}),(0,l.jsxs)(`p`,{className:`text-[14px] text-foreground/70 font-medium pt-2 tracking-wide`,children:[`New here? `,(0,l.jsx)(u.Link,{to:`/register`,className:`text-accent hover:underline font-bold ml-1`,children:`Create account`})]})]})]})})}function E(){let{user:e,refreshUser:t}=m(),r=(0,u.useNavigate)(),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(``);return(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover text-center shadow-[0_8px_32px_rgba(0,0,0,0.08)]`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsx)(`h1`,{className:`text-2xl md:text-3xl font-extrabold mb-3 text-foreground tracking-tight`,children:`Verify your email`}),(0,l.jsxs)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/60 mb-6 md:mb-8 leading-[1.6] tracking-wide`,children:[`We've sent a verification link to `,(0,l.jsx)(`span`,{className:`font-semibold text-foreground`,children:e?.email}),`. Please check your inbox (and spam folder) to verify your account and access your dashboard.`]}),f&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium rounded-xl border ${f.includes(`Failed`)||f.includes(`not verified`)||f.includes(`wrong`)?`text-red-400 bg-red-500/10 border-red-500/20`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`}`,children:f}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 max-w-[360px] mx-auto`,children:[(0,l.jsx)(n.n,{variant:`primary`,onClick:async()=>{o(!0),p(``);try{if(n.wt.currentUser){if(await n.wt.currentUser.reload(),!n.wt.currentUser.emailVerified){p(`Email is not verified yet. Please check your inbox.`),o(!1);return}await n.wt.currentUser.getIdToken(!0),await t(),r(`/dashboard`)}}catch{p(`Something went wrong. Please try again.`),o(!1)}},isLoading:i,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`I've verified my email`}),(0,l.jsx)(n.n,{variant:`ghost`,onClick:async()=>{if(e){d(!0),p(``);try{await(0,s.sendEmailVerification)(e),p(`Verification email sent! Please check your inbox.`)}catch(e){e?.code===`auth/too-many-requests`?p(`Failed to resend: Please wait a minute before trying again.`):p(e?.message||`Failed to resend. Please try again later.`)}finally{d(!1)}}},isLoading:c,className:`w-full py-2.5 md:py-3 text-[13px] md:text-[14px] font-semibold tracking-wide rounded-xl transition-all hover:-translate-y-0.5`,children:`Resend verification link`})]})]})})}var D={pages:{path:`/pages`,label:`Pages`,icon:n.L,roles:[`admin`]},forms:{path:`/forms`,label:`Forms`,icon:n.S,roles:[`admin`]},drive:{path:`/drive`,label:`Drive`,icon:n.H,roles:[`admin`,`user`,`editor`,`guest`]},users:{path:`/users`,label:`Users`,icon:n.u,roles:[`admin`]},theme:{path:`/theme`,label:`Theme`,icon:n.T,roles:[`admin`]},submissions:{path:`/submissions`,label:`Submissions`,icon:n.k,roles:[`admin`]},requests:{path:`/requests`,label:`Requests`,icon:n.tt,roles:[`admin`]},settings:{path:`/settings`,label:`Settings`,icon:n.y,roles:[`admin`]},profile:{path:`/profile`,label:`Profile`,icon:n.d,roles:[`admin`,`user`,`editor`,`guest`]},support:{path:`/support`,label:`Support`,icon:n.tt,roles:[`user`,`editor`,`guest`]}};function ee({customTabs:e=[]}){let{pathname:t}=(0,u.useLocation)(),{userRole:r}=m(),[i,s]=(0,a.useState)(!1),c=(0,a.useRef)(null),[d,f]=(0,a.useState)({}),[p,h]=(0,a.useState)(v);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(`fbos_nav_tabs`);e&&f(JSON.parse(e));let t=localStorage.getItem(`fbos_nav_order`);t&&h(JSON.parse(t))}catch{}let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_tabs`),e=>{let t={};e.forEach(e=>{t[e.id]=e.data()}),f(t),localStorage.setItem(`fbos_nav_tabs`,JSON.stringify(t))},e=>{console.warn(`sys_tabs snapshot error:`,e)}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{let t=e.exists()&&Array.isArray(e.data().order)?_(e.data().order):v;h(t),localStorage.setItem(`fbos_nav_order`,JSON.stringify(t))},e=>{console.warn(`tab_order snapshot error:`,e)});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{function e(e){c.current&&!c.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let g=[...(()=>{let e={};Object.entries(D).forEach(([t,n])=>{e[t]={id:t,...n,exact:!0}}),Object.entries(d).forEach(([t,r])=>{let i=e[t],a=i?.icon??n.L;if(r?.iconName){let e=r.iconName.trim(),t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);n.o[t]?a=n.o[t]:n.o[e]&&(a=n.o[e])}let o=i?.roles??[`admin`];r?.pageType===`admin`?o=[`admin`]:r?.pageType===`shared`?o=[`admin`,`editor`,`user`]:r?.pageType===`private`?o=[`admin`,`user`]:r?.pageType===`public`&&(o=[`admin`,`user`,`editor`,`guest`]),e[t]={id:t,path:r?.route?r.route.startsWith(`/`)?r.route:`/`+r.route:i?.path??`/`+t,label:r?.tabName||r?.pageTitle||r?.pageName||i?.label||t,icon:a,roles:o,exact:!0}});let t=[],r=new Set;p.forEach(n=>{n.hidden||e[n.id]&&(t.push(e[n.id]),r.add(n.id))});let i=[],a=[];return Object.keys(e).forEach(t=>{if(r.has(t))return;let n=p.find(e=>e.id===t);n?.hidden||(t in d&&!n?i.push(e[t]):a.push(e[t]))}),i.length>0&&t.unshift(...i),a.length>0&&t.push(...a),t})(),...e.map(e=>({...e,id:e.path}))].filter(e=>e.id===`support`&&r===`admin`?!1:Array.isArray(e.roles)?e.roles.includes(r||`guest`):!1),y=(0,a.useRef)(null),b=(0,a.useRef)(null),[x,S]=(0,a.useState)(g.length);(0,a.useEffect)(()=>{let e=()=>{let e=y.current,t=b.current;if(!e||!t)return;let n=e.clientWidth;if(n===0)return;let r=t.querySelectorAll(`[data-measure-tab]`);if(r.length===0){S(g.length);return}let i=0,a=!0;for(let e=0;e<r.length;e++)if(i+=r[e].offsetWidth+(e>0?40:0),i>n){a=!1;break}if(a){S(g.length);return}let o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e].offsetWidth,i=o+t+(e>0?40:0);if(i+52>n)break;o=i,s++}S(Math.max(s,1))},t=requestAnimationFrame(e);if(typeof ResizeObserver>`u`)return()=>cancelAnimationFrame(t);let n=new ResizeObserver(()=>requestAnimationFrame(e));return y.current&&n.observe(y.current),()=>{cancelAnimationFrame(t),n.disconnect()}},[g.map(e=>e.id+e.label).join(`|`),g.length]);let C=g.slice(0,x),w=g.slice(x),T=e=>e.exact?t===e.path:t.startsWith(e.path),E=w.some(e=>T(e));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{ref:b,"aria-hidden":`true`,className:`flex items-center gap-6 md:gap-10 whitespace-nowrap px-1`,style:{position:`fixed`,top:-9999,left:0,visibility:`hidden`,pointerEvents:`none`},children:g.map(e=>{let t=e.icon;return(0,l.jsxs)(`span`,{"data-measure-tab":!0,className:`flex items-center gap-2 text-[14.5px] font-semibold shrink-0 pb-3`,children:[(0,l.jsx)(t,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)})}),(0,l.jsxs)(`div`,{ref:y,className:`w-full flex items-center gap-6 md:gap-10 mb-8 border-b border-[var(--panel-border)] px-1 whitespace-nowrap relative`,children:[C.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,className:`flex items-center gap-2 text-[14.5px] font-semibold transition-all duration-300 pb-3 -mb-[1px] border-b-2 shrink-0 ${t?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,children:[(0,l.jsx)(n,{className:`w-[18px] h-[18px]`}),e.label]},e.path||e.id)}),w.length>0&&(0,l.jsxs)(`div`,{className:`relative shrink-0 ml-auto`,ref:c,children:[(0,l.jsx)(`button`,{onClick:()=>s(!i),className:`flex items-center justify-center transition-all duration-300 pb-3 -mb-[1px] border-b-2 cursor-pointer ${E?`text-accent border-accent`:`text-foreground/50 hover:text-foreground/80 border-transparent`}`,title:`More items`,children:(0,l.jsx)(n.J,{className:`w-5 h-5`})}),(0,l.jsx)(n.a,{children:i&&(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`absolute top-[100%] right-0 mt-2 min-w-[200px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-xl z-50 flex flex-col py-2 overflow-hidden`,children:w.map(e=>{let t=T(e),n=e.icon;return(0,l.jsxs)(u.Link,{to:e.path||`/`,onClick:()=>s(!1),className:`flex items-center gap-3 px-5 py-3 text-[14px] font-medium transition-colors ${t?`text-accent bg-accent/5`:`text-foreground/70 hover:text-foreground hover:bg-foreground/5`}`,children:[(0,l.jsx)(n,{className:`w-4 h-4`}),e.label]},e.path||e.id)})})})]})]})]})}function O(){let{user:e,refreshUser:t}=m(),[r,i]=(0,a.useState)(e?.displayName||``),[u,d]=(0,a.useState)(e?.email||``),[f,p]=(0,a.useState)(e?.photoURL||``),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(null),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(``),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)(!1),[D,O]=(0,a.useState)(!0);a.default.useEffect(()=>{i(e?.displayName||``),d(e?.email||``),p(e?.photoURL||``)},[e?.uid,e?.displayName,e?.email,e?.photoURL]);let k=async t=>{if(e)try{let r=[`mem_files`,`admin_files`];(await(0,o.getDocs)((0,o.collection)(n.Tt,`sys_tabs`))).forEach(e=>{let t=e.data(),n=(t.tabName||e.id).toLowerCase().replace(/[^a-z0-9]+/g,`_`);t.pageType===`shared`&&r.push(`mem_${n}_records`),t.pageType===`admin`&&r.push(`admin_${n}_records`)});for(let i of r)try{let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,e.uid)));if(r.empty)continue;let a=(0,o.writeBatch)(n.Tt);r.docs.forEach(e=>a.update(e.ref,{creatorAvatar:t})),await a.commit()}catch{}}catch(e){console.error(`Error propagating avatar to records:`,e)}};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Profile Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/profile`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsx)(n.a,{children:_&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.98,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:-10},className:`p-4 mb-6 rounded-2xl border flex flex-col sm:flex-row sm:items-center gap-3 ${_.type===`error`?`bg-red-500/10 border-red-500/20 text-red-400`:`bg-accent/10 border-accent/20 text-accent`}`,children:[_.type===`success`?(0,l.jsx)(n.nt,{className:`w-5 h-5 shrink-0`}):(0,l.jsx)(n.rt,{className:`w-5 h-5 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px] font-semibold tracking-wide leading-relaxed`,children:_.text})]})}),(0,l.jsx)(`form`,{onSubmit:async i=>{if(i.preventDefault(),e){g(!0),v(null);try{r!==e.displayName&&await(0,s.updateProfile)(e,{displayName:r});let i=!1;if(u!==e.email){let t=await(0,s.fetchSignInMethodsForEmail)(n.wt,u);if(t&&t.length>0)throw Error(`An account with this email already exists.`);await(0,s.verifyBeforeUpdateEmail)(e,u),i=!0}if(y){if(y!==x)throw Error(`Passwords do not match.`);if(y.length<6)throw Error(`Password must be at least 6 characters.`);await(0,s.updatePassword)(e,y),b(``),S(``)}await t(),v(i?{text:`Profile updated. A verification link has been sent to your new email address.`,type:`success`}:{text:`Profile successfully updated.`,type:`success`})}catch(e){console.error(e),e.code===`auth/requires-recent-login`?v({text:`For security, please sign out and sign back in before changing your email or password.`,type:`error`}):v({text:e.message||`Failed to update profile.`,type:`error`})}finally{g(!1)}}},className:`w-full flex flex-col`,children:(0,l.jsxs)(`div`,{className:`glass-panel w-full p-8 md:p-12 rounded-3xl border border-[var(--panel-border)] shadow-2xl space-y-8 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 pb-6 border-b border-[var(--panel-border)]/50`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 md:w-28 md:h-28 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group transition-transform duration-300 hover:scale-[1.02]`,children:[(T||f&&D&&!C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-10`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),f&&!C?(0,l.jsx)(`img`,{src:f,alt:`Avatar`,className:`w-full h-full object-cover transition-opacity duration-300 ${D?`opacity-0`:`opacity-100`}`,onLoad:()=>O(!1),onError:()=>{w(!0),O(!1)}}):(0,l.jsx)(n.d,{className:`w-10 h-10 md:w-12 md:h-12 text-accent`}),!T&&(0,l.jsxs)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2 z-10 backdrop-blur-sm`,children:[(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 rounded-full hover:bg-white/20 transition-colors text-white`,title:`Upload Photo`,children:[(0,l.jsx)(n.ut,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:async r=>{let i=r.target.files?.[0];if(!(!i||!e)){if(i.size>2*1024*1024){v({text:`File too large. Please select an image under 2MB.`,type:`error`});return}E(!0),w(!1),O(!0);try{let r=(0,c.ref)(n.Dt,`user_avatars/${e.uid}/file.png`);await(0,c.uploadBytes)(r,i,{customMetadata:{ownerId:e.uid}});let a=await(0,c.getDownloadURL)(r);await(0,s.updateProfile)(e,{photoURL:a}),await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid),{avatar:a}),p(a),await t(),k(a),v({text:`Avatar successfully updated!`,type:`success`})}catch(e){console.error(e),v({text:`Failed to upload photo.`,type:`error`})}finally{E(!1)}}},className:`hidden`})]}),f&&(0,l.jsx)(`button`,{type:`button`,onClick:async()=>{if(e){E(!0),w(!1),O(!1);try{await(0,c.deleteObject)((0,c.ref)(n.Dt,`user_avatars/${e.uid}/file.png`)).catch(e=>console.error(e)),await(0,s.updateProfile)(e,{photoURL:``}),await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid),{avatar:``}),p(``),await t(),k(``),v({text:`Avatar removed.`,type:`success`})}catch(e){console.error(e),v({text:`Failed to delete photo.`,type:`error`})}finally{E(!1)}}},className:`p-2 rounded-full hover:bg-red-500/80 text-white transition-colors`,title:`Delete Photo`,children:(0,l.jsx)(n.h,{className:`w-5 h-5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,l.jsx)(`h3`,{className:`font-extrabold text-2xl text-foreground mb-1`,children:r||`Firebase OS User`}),(0,l.jsx)(`div`,{className:`text-[12px] font-mono uppercase tracking-widest text-accent bg-accent/10 px-2.5 py-1 rounded-md border border-accent/20 inline-block`,children:e?.emailVerified?`Verified Account`:`Unverified`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/40 mt-2 font-medium`,children:e?.email})]})]}),(0,l.jsxs)(`div`,{className:`space-y-6`,children:[(0,l.jsx)(`h3`,{className:`text-[16px] font-extrabold text-foreground flex items-center gap-2`,children:`Account Details`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`name`,value:r,onChange:e=>i(e.target.value),label:`Display Name`,placeholder:`John Doe`}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(n.r,{name:`email`,type:`email`,value:u,onChange:e=>d(e.target.value),label:`Email Address`,placeholder:`name@example.com`,required:!0}),(0,l.jsx)(`p`,{className:`text-[11px] text-foreground/40 mt-1.5 px-2 font-medium`,children:`Changing email sends a verification link to the new address.`})]})]})]}),(0,l.jsxs)(`div`,{className:`pt-6 border-t border-[var(--panel-border)]/50`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground mb-4 flex items-center gap-2`,children:`Change Password`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5 md:gap-6`,children:[(0,l.jsx)(n.r,{name:`password`,type:`password`,label:`New Password`,value:y,onChange:e=>b(e.target.value),placeholder:`Minimum 6 characters`}),(0,l.jsx)(n.r,{name:`confirmPassword`,type:`password`,label:`Confirm Password`,value:x,onChange:e=>S(e.target.value),placeholder:`Repeat password`})]})]}),(0,l.jsx)(`div`,{className:`pt-8 border-t border-[var(--panel-border)]/50 flex justify-start w-full`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:h,className:`px-12 py-3 md:py-2.5 text-[14px] md:text-[15px] font-bold tracking-wide rounded-xl hover:-translate-y-0.5`,children:`Save Changes`})})]})})]})]})}function k(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(0),[d,f]=(0,a.useState)(0);return(0,a.useEffect)(()=>{let e;return o>0&&(e=setInterval(()=>c(e=>e-1),1e3)),()=>clearInterval(e)},[o]),(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center w-full z-10 px-4 mb-16 mt-6 md:mt-8`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5},className:`w-full max-w-[480px] p-6 md:p-8 lg:p-10 rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] text-center`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-40 blur-[15px] rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`w-14 h-14 md:w-16 md:h-16 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mx-auto mb-5 md:mb-6 animate-float shadow-xl`,children:(0,l.jsx)(n.R,{className:`w-7 h-7 md:w-8 md:h-8 text-accent opacity-90`})}),(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold mb-2 md:mb-3 text-foreground tracking-tight`,children:`Reset Password`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide`,children:`Enter your email to receive a recovery link.`})]}),r&&(0,l.jsx)(`div`,{className:`p-3 md:p-4 mb-5 md:mb-6 text-[13px] md:text-[14px] font-medium text-emerald-400 bg-emerald-500/10 rounded-xl border border-emerald-500/20 max-w-[360px] mx-auto`,children:r}),(0,l.jsxs)(`form`,{className:`space-y-4 text-left max-w-[360px] mx-auto`,onSubmit:async e=>{e.preventDefault(),t(!0),i(null);let r=new FormData(e.currentTarget).get(`email`);try{await(0,s.sendPasswordResetEmail)(n.wt,r)}catch(e){console.error(e)}finally{i(`If an account exists, a password reset link has been sent. Please check your inbox (and spam folder).`);let e=d+1;f(e),c(e===1?60:120),t(!1)}},children:[(0,l.jsx)(n.r,{name:`email`,label:`Work Email`,type:`email`,placeholder:`name@company.com`,required:!0}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full py-2.5 md:py-3 text-[14px] font-bold tracking-wide rounded-xl md:rounded-xl transition-all ${o>0?`bg-foreground/5 text-foreground/40 border border-[var(--panel-border)] shadow-none cursor-not-allowed hover:translate-y-0`:`hover:-translate-y-0.5`}`,isLoading:e,disabled:o>0,children:o>0?`Resend link in ${(e=>`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`)(o)}`:d>0?`Resend reset password link`:`Send Reset Link`})})]}),(0,l.jsx)(`div`,{className:`mt-6 pt-5 border-t border-[var(--panel-border)] space-y-4 text-center`,children:(0,l.jsxs)(u.Link,{to:`/login`,className:`inline-flex items-center text-[13px] md:text-[14px] text-foreground/70 font-medium hover:text-accent transition-colors tracking-wide`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4 mr-2`}),`Back to Sign In`]})})]})})}function A(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)(!0),s=(0,u.useNavigate)(),{id:d}=(0,u.useParams)(),[f,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(!1),C=d?f.find(e=>e.id===d)||null:f.length>0?f[0]:null,w=e=>{s(e?`/users/${e.id}`:`/users`)};(0,a.useEffect)(()=>{i(!0);let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`user_profiles`),e=>{let t=[];e.forEach(e=>{t.push({id:e.id,...e.data()})}),p(t),i(!1),!d&&t.length>0&&s(`/users/${t[0].id}`,{replace:!0})},e=>{console.error(`Error fetching users:`,e),i(!1)});return()=>e()},[d,s]);let T=f.find(t=>t.id===e?.uid),E=e=>e.id===T?.id?!1:e.role!==`admin`||!T?.createdAt?!0:e.createdAt?new Date(T.createdAt).getTime()<=new Date(e.createdAt).getTime():!1,D=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.id),{role:r?`admin`:null}),g({text:`User role updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},O=async(e,r)=>{if(!(t!==`admin`||!E(e)))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,e.id),{inactive:r}),g({text:`User ${r?`deactivated`:`activated`} successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},k=async()=>{if(v(!1),!(!C||!E(C)||y===C.displayName))try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,C.id),{displayName:y}),g({text:`Name updated successfully`,type:`success`}),setTimeout(()=>g(null),3e3)}catch(e){g({text:e.message,type:`error`}),setTimeout(()=>g(null),3e3)}},A=async e=>{let t=e.target.files?.[0];if(!(!t||!C||!E(C))){if(t.size>2*1024*1024){g({text:`File too large.`,type:`error`});return}S(!0);try{let e=(0,c.ref)(n.Dt,`user_avatars/${C.id}/file.png`);await(0,c.uploadBytes)(e,t);let r=await(0,c.getDownloadURL)(e);await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_profiles`,C.id),{avatar:r}),g({text:`Avatar successfully updated.`,type:`success`}),setTimeout(()=>g(null),3e3)}catch{g({text:`Failed to upload photo.`,type:`error`})}S(!1)}},[te,j]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e;return r&&f.length===0?e=setTimeout(()=>j(!0),150):j(!1),()=>clearTimeout(e)},[r,f.length]),r&&f.length===0?te?(0,l.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/60 backdrop-blur-xl transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}):null:(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Users`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/users`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500 pb-20`,children:[(0,l.jsx)(n.a,{children:h&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`p-4 text-[14px] font-medium border ${h.type===`error`?`text-red-500 bg-red-500/10 border-red-500/20 shadow-[0_0_15px_rgba(239,68,68,0.1)]`:`text-emerald-400 bg-emerald-500/10 border-emerald-500/20 shadow-[0_0_15px_rgba(52,211,153,0.1)]`} rounded-xl flex items-center gap-2`,children:[h.type===`success`&&(0,l.jsx)(n.nt,{className:`w-4 h-4 shrink-0`}),h.text]})}),(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsx)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm`,children:f.length===0?(0,l.jsx)(`div`,{className:`p-8 text-center text-foreground/50 text-[14px]`,children:`No members found.`}):(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col hide-scrollbar bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-4 border-b border-[var(--panel-border)] font-bold text-[13px] text-foreground/70 uppercase tracking-wider`,children:`System Users`}),(0,l.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:f.map(e=>(0,l.jsxs)(`div`,{onClick:()=>w(e),className:`p-4 py-5 rounded-2xl border transition-all flex items-center gap-4 cursor-pointer ${C?.id===e.id?`bg-accent/10 border-accent/40 shadow-sm`:`glass-panel border-transparent hover:border-[var(--panel-border)]`} ${e.inactive?`opacity-50 grayscale`:``}`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full overflow-hidden bg-accent/20 shrink-0 flex items-center justify-center border border-[var(--panel-border)]`,children:e.avatar||e.photoURL?(0,l.jsx)(`img`,{src:e.avatar||e.photoURL,alt:``,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-accent`})}),(0,l.jsxs)(`div`,{className:`flex flex-col truncate`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] truncate`,children:e.displayName||`No Name`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 truncate font-mono mt-0.5`,children:e.email})]})]},e.id))})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10 relative`,children:C?(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full max-w-lg`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-6 md:gap-8 mb-10`,children:[(0,l.jsxs)(`div`,{className:`w-24 h-24 rounded-full glass-panel border-4 border-[var(--panel-border)] shadow-xl bg-accent/10 flex items-center justify-center relative overflow-hidden shrink-0 group`,children:[x?(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`}):C.avatar||C.photoURL?(0,l.jsx)(`img`,{src:C.avatar||C.photoURL,alt:`Avatar`,className:`w-full h-full object-cover`}):(0,l.jsx)(n.d,{className:`w-10 h-10 text-accent`}),!x&&E(C)&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center z-10 backdrop-blur-md`,children:(0,l.jsxs)(`label`,{className:`flex flex-col items-center justify-center cursor-pointer p-2 hover:bg-white/20 transition-colors text-white rounded-full`,title:`Upload Photo`,children:[(0,l.jsx)(n.ut,{className:`w-5 h-5`}),(0,l.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:A,className:`hidden`})]})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 w-full relative`,children:[_?(0,l.jsx)(`input`,{autoFocus:!0,value:y,onChange:e=>b(e.target.value),onBlur:k,onKeyDown:e=>e.key===`Enter`&&k(),className:`text-2xl md:text-3xl font-extrabold mb-1 bg-transparent border-b-2 border-accent outline-none text-foreground w-full py-1`}):(0,l.jsx)(`h3`,{onDoubleClick:()=>{E(C)&&(b(C.displayName||``),v(!0))},className:`text-2xl md:text-3xl font-extrabold mb-1 select-none ${E(C)?`cursor-pointer hover:text-accent transition-colors`:``}`,title:E(C)?`Double-click to edit`:``,children:C.displayName||`No Name`}),(0,l.jsx)(`p`,{className:`text-[14px] font-mono text-foreground/50`,children:C.email}),!E(C)&&C.id!==T?.id&&(0,l.jsx)(`div`,{className:`mt-3 inline-block self-start px-3 py-1.5 rounded-lg bg-foreground/5 border border-[var(--panel-border)] text-[11px] font-bold text-foreground/50 tracking-wide uppercase`,children:`Privileged Admin Account`})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border border-[var(--panel-border)] flex items-center justify-between`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] text-foreground`,children:`Admin Access`}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50`,children:`Toggle system privileges`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>D(C,C.role!==`admin`),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.role===`admin`?`bg-accent`:`bg-foreground/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.role===`admin`?`translate-x-6`:`translate-x-1`}`})})]}),(0,l.jsxs)(`div`,{className:`p-4 rounded-2xl glass-panel border flex items-center justify-between ${C.inactive?`border-amber-500/30 bg-amber-500/5`:`border-red-500/20 bg-red-500/5`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] ${C.inactive?`text-amber-500`:`text-red-500`}`,children:C.inactive?`Reactivate User`:`Deactivate User`}),(0,l.jsx)(`span`,{className:`text-[12px] ${C.inactive?`text-amber-500/70`:`text-red-500/70`}`,children:`Block access to this app`})]}),(0,l.jsx)(`button`,{type:`button`,disabled:!E(C),onClick:()=>O(C,!C.inactive),className:`relative inline-flex h-7 w-12 items-center rounded-full transition-colors focus:outline-none shadow-inner ${C.inactive?`bg-amber-500`:`bg-red-500/20`} ${E(C)?`cursor-pointer`:`opacity-50 cursor-not-allowed`}`,children:(0,l.jsx)(`span`,{className:`inline-block h-5 w-5 transform rounded-full bg-white transition-transform shadow-md ${C.inactive?`translate-x-6`:`translate-x-1`}`})})]})]})]}):(0,l.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center opacity-30 pointer-events-none`,children:[(0,l.jsx)(n.u,{className:`w-12 h-12 mb-4`}),(0,l.jsx)(`p`,{className:`font-bold tracking-widest uppercase text-[12px]`,children:`Select a User`})]})})]})})]})]})}function te({isOpen:e,title:t,message:r,confirmText:i=`Delete`,cancelText:a=`Cancel`,onConfirm:o,onCancel:s,isProcessing:c=!1,disableConfirm:u=!1}){return(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!c&&s(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsxs)(`div`,{className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:t}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:r}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:s,disabled:c,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:a}),(0,l.jsx)(n.n,{onClick:o,disabled:c||u,className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:c?(0,l.jsx)(n.M,{className:`w-5 h-5 animate-spin mx-auto`}):i})]})]})})]})})}var j=[`pages`,`forms`,`drive`,`users`,`theme`,`submissions`,`requests`,`settings`,`profile`,`support`],M={pages:`Pages`,forms:`Forms`,drive:`Drive`,users:`Users`,theme:`Theme`,submissions:`Submissions`,requests:`Requests`,settings:`Settings`,profile:`Profile`,support:`Request Support`},N=new Set([`home`]),P=new Set([`settings`]);function F(){let[e,t]=(0,a.useState)(`menu`),[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)({}),[u,d]=(0,a.useState)(g),[f,p]=(0,a.useState)(v),[m,h]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_pages`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.title||e.id,path:n.route||(e.id===`home`?`/`:`/`+e.id),type:`public`,isSystem:[`home`,`templates`,`contact`,`setup`].includes(e.id)}}),t.setup||={id:`setup`,title:`Setup`,path:`/setup`,type:`public`,isSystem:!0},t.templates||={id:`templates`,title:`Templates`,path:`/templates`,type:`public`,isSystem:!0},t.contact||={id:`contact`,title:`Contact`,path:`/contact`,type:`public`,isSystem:!0},i(t)}),t=(0,o.onSnapshot)((0,o.collection)(n.Tt,`sys_tabs`),e=>{let t={};e.forEach(e=>{let n=e.data();t[e.id]={id:e.id,title:n.pageName||n.tabName||n.title||M[e.id]||e.id,path:n.route||`/`+e.id,type:n.pageType||`admin`,isSystem:j.includes(e.id)}}),j.forEach(e=>{t[e]||(t[e]={id:e,title:M[e]||e,path:`/`+e,type:`admin`,isSystem:!0})}),c(t)}),r=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{d(e.exists()?_(e.data().order||[]):g)}),a=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{p(e.exists()?_(e.data().order||[]):v)});return()=>{e(),t(),r(),a()}},[]);let C=async(e,t)=>{if((t?P:N).has(e))return;let i=t?f:u,a=t?`tab_order`:`page_order`,c=i.filter(e=>(t?s:r)[e.id]||(t?j.includes(e.id):[`home`,`contact`].includes(e.id))),l=c.some(t=>t.id===e)?c.map(t=>t.id===e?{...t,hidden:!t.hidden}:t):[...c,{id:e,hidden:!0}];await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,a),{order:l})},w=(e,t)=>{e.isSystem||b({info:e,isTab:t})},T=async()=>{if(!y)return;S(!0);let e=y.isTab?`sys_tabs`:`sys_pages`,t=y.isTab?`tab_order`:`page_order`,r=y.isTab?f:u;try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,e,y.info.id));let i=r.filter(e=>e.id!==y.info.id);await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,t),{order:i})}catch(e){console.error(`Delete failed`,e)}S(!1),b(null)},E=async(e,t,i)=>{let a=e?f:u,c=e?s:r,l=e?`tab_order`:`page_order`,d=a.filter(t=>c[t.id]||(e?j.includes(t.id):[`home`,`contact`].includes(t.id)));Object.keys(c).forEach(e=>{d.some(t=>t.id===e)||d.push({id:e,hidden:!1})});let p=d.findIndex(e=>e.id===t);if(p===-1)return;let m=+(!e&&d[0]?.id===`home`),h=i===`up`?Math.max(m,p-1):Math.min(d.length-1,p+1);if(p===h)return;let g=[...d],[_]=g.splice(p,1);g.splice(h,0,_),await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,l),{order:g})},D=async()=>{if(!m){h(!0);try{let e=new Set(g.map(e=>e.id)),t=new Set(v.map(e=>e.id)),r=u.filter(t=>!e.has(t.id)),i=f.filter(e=>!t.has(e.id)),a=[...r.map(e=>({...e,hidden:!1})),...g],s=[...i.map(e=>({...e,hidden:!1})),...v],c=(0,o.writeBatch)(n.Tt);c.set((0,o.doc)(n.Tt,`sys_configs`,`page_order`),{order:a}),c.set((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),{order:s}),await c.commit()}finally{setTimeout(()=>h(!1),600)}}},O=e=>{let t=e?f:u,n=e?s:r,i=t.filter(t=>n[t.id]||(e?j.includes(t.id):[`home`,`contact`].includes(t.id))),a=new Set(i.map(e=>e.id)),o=Object.keys(n).filter(e=>!a.has(e)).map(e=>({id:e,hidden:!1})),c=[...i,...o];return e||(c=c.filter(e=>e.id!==`home`)),c};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Settings`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/settings`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`glass-panel rounded-3xl border border-[var(--panel-border)] shadow-sm grid grid-cols-1 md:grid-cols-3 min-h-[500px]`,children:[(0,l.jsxs)(`div`,{className:`md:col-span-1 border-r md:border-r-[var(--panel-border)] border-b md:border-b-0 border-[var(--panel-border)] flex flex-col bg-black/5 dark:bg-white/5 rounded-t-3xl md:rounded-tr-none md:rounded-l-3xl`,children:[(0,l.jsx)(`div`,{className:`p-6 pb-4 font-bold text-[13px] text-foreground/40 uppercase tracking-widest`,children:`Configuration`}),(0,l.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4 space-y-1`,children:[(0,l.jsxs)(`button`,{onClick:()=>t(`menu`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`menu`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.O,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Menu Settings`})]}),(0,l.jsxs)(`button`,{onClick:()=>t(`tabs`),className:`w-full p-3 rounded-xl transition-all flex items-center gap-3 cursor-pointer ${e===`tabs`?`bg-accent/10 text-accent font-bold`:`bg-transparent text-foreground/70 hover:bg-foreground/5 hover:text-foreground font-medium`}`,children:[(0,l.jsx)(n.pt,{className:`w-4 h-4 shrink-0`}),(0,l.jsx)(`span`,{className:`text-[14px]`,children:`Tabs Settings`})]})]})]}),(0,l.jsx)(`div`,{className:`md:col-span-2 flex flex-col p-6 md:p-10`,children:(0,l.jsxs)(`div`,{className:`animate-in fade-in duration-300 w-full`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-8`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`h3`,{className:`text-2xl md:text-3xl font-extrabold text-foreground tracking-tighter mb-2`,children:e===`menu`?`Menu Settings`:`Dashboard Tabs`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 max-w-xl`,children:e===`menu`?`Reorder or hide public menu items. Changes take effect instantly for all visitors.`:`Manage visibility and order of all internal dashboard tabs.`})]}),(0,l.jsx)(`button`,{onClick:D,disabled:m,title:`Reset order and visibility to defaults`,className:`p-3 h-fit bg-foreground/5 hover:bg-foreground/10 text-foreground/70 active:scale-95 disabled:opacity-50 disabled:pointer-events-none rounded-xl transition-all font-bold text-[13px] flex items-center justify-center border border-transparent hover:border-[var(--panel-border)] shadow-sm shrink-0`,children:m?(0,l.jsx)(n.M,{className:`w-5 h-5 text-foreground/50 animate-spin`}):(0,l.jsx)(n.x,{className:`w-5 h-5 text-foreground/50`})})]}),(e=>{let t=e?s:r,i=e?P:N,a=O(e);return(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:a.map((r,o)=>{let s=t[r.id],c=s?.title||M[r.id]||r.id,u=s?.path||`/`+r.id,d=s?.isSystem??j.includes(r.id),f=i.has(r.id),p=o===0,m=o===a.length-1;return(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-4 glass-panel border border-[var(--panel-border)] rounded-2xl transition-all duration-200 ${r.hidden?`opacity-40`:`opacity-100`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center w-6`,children:[(0,l.jsx)(`button`,{disabled:p,onClick:()=>E(e,r.id,`up`),className:`text-foreground/40 hover:text-accent disabled:opacity-20`,children:(0,l.jsx)(n.it,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{disabled:m,onClick:()=>E(e,r.id,`down`),className:`text-foreground/40 hover:text-accent disabled:opacity-20 -mt-1`,children:(0,l.jsx)(n.st,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col`,children:[(0,l.jsx)(`span`,{className:`font-bold text-foreground text-[14px]`,children:c}),(0,l.jsx)(`span`,{className:`text-[12px] font-mono text-foreground/50`,children:u})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!f&&(0,l.jsx)(`button`,{onClick:()=>C(r.id,e),title:r.hidden?`Show this page`:`Hide this page`,className:`p-2 rounded-xl transition-colors ${r.hidden?`hover:bg-foreground/5 text-foreground/40`:`hover:bg-accent/10 text-accent`}`,children:r.hidden?(0,l.jsx)(n.q,{className:`w-4 h-4`}):(0,l.jsx)(n.K,{className:`w-4 h-4`})}),s&&!d&&(0,l.jsx)(`button`,{onClick:()=>w(s,e),className:`p-2 rounded-xl hover:bg-red-500/10 text-foreground/40 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]},r.id)})})})(e===`tabs`)]})})]})]})]}),(0,l.jsx)(te,{isOpen:!!y,onCancel:()=>b(null),onConfirm:T,title:`Delete Item`,message:`Are you sure you want to delete "${y?.info?.title??``}"? This cannot be undone.`,confirmText:`Delete`,isProcessing:x})]})}function I(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_submissions`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();n.avatar&&(i=n.avatar),n.name&&!e.name&&(e.name=n.name),n.email&&!e.email&&(e.email=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching submissions:`,e),i(!1)});return()=>e()},[]);let m=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},h=e=>{c(t=>t===e?null:e)},g=async(e,t=!1)=>{p(e);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_submissions`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}p(null)},_=e.filter(e=>!e.isArchived),v=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Form Submissions`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/submissions`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.D,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No Submissions`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`Try submitting a form on the public layout to see it appear here.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[_.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All submissions have been archived.`})}),(0,l.jsx)(n.a,{children:_.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),g(e.id,!1)},disabled:f===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Submission`,children:f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),v.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>d(!u),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[u?`Hide`:`View`,` `,v.length,` Archived Submission`,v.length===1?``:`s`,(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 transition-transform duration-300 ${u?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:u&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&h(e.id)},onClick:()=>h(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm`,children:(0,l.jsx)(n.k,{className:`w-4 h-4`})})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 justify-center`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||e.full_name||`Anonymous Submission`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsx)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:e.email||e.contactEmail||`No email provided`})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:m(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:m(e.submittedAt)}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>g(e.id,e.isArchived),disabled:f===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[f===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.vt,{className:`w-4 h-4`}),`Unarchive Submission`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function L(){let[e,t]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)(!1),[p,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,`user_requests`),(0,o.orderBy)(`submittedAt`,`desc`)),async e=>{let r=[];for(let t of e.docs){let e=t.data(),i=``;if(e.uid&&e.uid!==`guest`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));if(t.exists()){let n=t.data();(n.avatar||n.photoURL)&&(i=n.avatar||n.photoURL),n.displayName&&!e.name&&(e.name=n.displayName),n.email&&!e.email&&(e.email=n.email),n.email&&!e.contactEmail&&(e.contactEmail=n.email)}}catch(e){console.error(`Failed to fetch avatar`,e)}r.push({...e,id:t.id,avatarUrl:i})}t(r),i(!1)},e=>{console.error(`Error fetching requests:`,e),i(!1)});return()=>e()},[]);let h=e=>{if(!e)return`Just now`;let t=e.toDate?e.toDate():new Date(e);return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`numeric`}).format(t)},g=e=>{c(t=>t===e?null:e)},_=async(e,t=!1)=>{m(e);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`user_requests`,e),{isArchived:!t}),!t&&s===e&&c(null)}catch(e){console.error(`Failed to archive/unarchive`,e)}m(null)},v=e.filter(e=>!e.isArchived),y=e.filter(e=>e.isArchived);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`User Requests`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/requests`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 flex flex-col glass-panel rounded-3xl p-6 md:p-10 relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/5 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col`,children:r?(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[500px]`,children:(0,l.jsx)(`div`,{className:`w-8 h-8 md:w-10 md:h-10 border-4 border-accent/20 border-t-accent rounded-full animate-spin`})}):e.length===0?(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-8`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.tt,{className:`w-6 h-6 outline-none`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No User Requests`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 font-medium max-w-md`,children:`User support tickets will appear here once submitted.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-3 pb-8`,children:[v.length===0&&(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-dashed border-[var(--panel-border)] rounded-2xl flex flex-col items-center justify-center p-8 text-center mb-4`,children:(0,l.jsx)(`p`,{className:`text-[14px] font-bold text-foreground/50`,children:`All requests have been archived.`})}),(0,l.jsx)(n.a,{children:v.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(u.Link,{to:`/users/${e.uid}`,onClick:e=>e.stopPropagation(),className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate hover:text-accent flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-4 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_(e.id,!1)},disabled:p===e.id,className:`p-1.5 rounded-lg text-foreground/30 hover:text-orange-500 hover:bg-orange-500/10 transition-colors`,title:`Archive Request`,children:p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n._t,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`p-1.5 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.rt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e))]})})})]},e.id)})}),y.length>0&&(0,l.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`flex justify-center`,children:(0,l.jsxs)(`button`,{onClick:()=>f(!d),className:`flex items-center gap-2 text-[11px] font-bold text-foreground/40 hover:text-foreground/70 transition-colors py-2 uppercase tracking-widest outline-none`,children:[d?`Hide`:`View`,` `,y.length,` Archived Request`,y.length===1?``:`s`,(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 transition-transform duration-300 ${d?`rotate-180`:``}`})]})}),(0,l.jsx)(n.a,{children:d&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4`,children:(0,l.jsx)(`div`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>{let r=s===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`glass-panel border border-[var(--panel-border)] rounded-2xl flex flex-col overflow-hidden opacity-50 grayscale hover:opacity-100 hover:grayscale-0 hover:border-accent/40 transition-all duration-300`,children:[(0,l.jsxs)(`div`,{role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&g(e.id)},onClick:()=>g(e.id),className:`w-full flex items-center justify-between p-4 md:px-6 hover:bg-foreground/[0.02] transition-colors text-left cursor-pointer`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`relative shrink-0 grayscale`,children:e.avatarUrl||e.submitterAvatar?(0,l.jsx)(`img`,{src:e.avatarUrl||e.submitterAvatar,alt:e.submitterName||e.name,className:`w-10 h-10 rounded-full object-cover border border-[var(--panel-border)] shadow-sm`}):(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-accent/10 text-accent flex items-center justify-center font-bold border border-accent/20 shadow-sm uppercase`,children:(e.submitterName||e.name||e.contactEmail||e.email||`U`)[0]})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[e.uid===`guest`?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`font-bold text-[14px] md:text-[15px] text-foreground truncate`,children:e.name||`Anonymous User`}),e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}):(0,l.jsxs)(`div`,{className:`w-fit font-bold text-[14px] md:text-[15px] text-foreground truncate flex items-center gap-2`,children:[e.submitterName||e.name||`Anonymous User`,e.formId&&(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-accent bg-accent/10 px-2 py-0.5 rounded-md border border-accent/20 shrink-0`,children:e.formId.replace(/_/g,` `)})]}),(0,l.jsxs)(`span`,{className:`text-[13px] text-foreground/50 truncate flex items-center gap-1.5 font-medium mt-0.5`,children:[(0,l.jsx)(n.k,{className:`w-3.5 h-3.5`}),` `,e.contactEmail||e.email||`No email provided`]})]})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-6 ml-6 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-medium text-foreground/40`,children:h(e.submittedAt)}),(0,l.jsx)(`div`,{className:`p-2 rounded-xl glass-panel transition-transform ${r?`rotate-180 bg-foreground/5`:``}`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 text-foreground/50`})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-4 md:p-6 pt-0 mt-2 border-t border-[var(--panel-border)]/30`,children:[(0,l.jsx)(`div`,{className:`md:hidden text-[12px] font-medium text-foreground/40 w-fit mb-4`,children:h(e.submittedAt)}),e.topic&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-[13px] text-foreground/70 bg-foreground/5 px-4 py-2.5 rounded-xl w-fit border border-[var(--panel-border)]`,children:[(0,l.jsx)(n.rt,{className:`w-4 h-4 text-accent`}),(0,l.jsx)(`span`,{className:`font-medium text-accent`,children:`Topic:`}),(0,l.jsx)(`span`,{className:`font-bold`,children:e.topic})]}),Object.entries(e).filter(([e])=>![`id`,`uid`,`submittedAt`,`avatarUrl`,`name`,`full_name`,`email`,`contactEmail`,`topic`,`isArchived`].includes(e)&&!e.toLowerCase().startsWith(`submitter`)&&e.toLowerCase()!==`formid`).map(([e,t])=>(0,l.jsxs)(`div`,{className:`bg-foreground/[0.02] rounded-2xl p-5 border border-[var(--panel-border)] relative mb-3`,children:[(0,l.jsx)(`div`,{className:`flex items-center gap-2 mb-3 text-foreground/60 w-full justify-between`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2 text-accent`,children:(0,l.jsx)(`span`,{className:`text-[12px] font-bold uppercase tracking-widest text-accent`,children:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})})}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] text-foreground/80 leading-relaxed whitespace-pre-wrap font-medium`,children:typeof t==`boolean`?t?`Yes`:`No`:e.toLowerCase()===`budget`&&t?`$${t}`:String(t||`No data provided`)})]},e)),(0,l.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,l.jsxs)(`button`,{onClick:()=>_(e.id,e.isArchived),disabled:p===e.id,className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-[13px] font-bold text-foreground/70 hover:text-emerald-500 bg-foreground/5 hover:bg-emerald-500/10 transition-colors border border-transparent shadow-sm`,children:[p===e.id?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(n.vt,{className:`w-4 h-4`}),`Unarchive Request`]})})]})})})]},e.id)})})})})]})]})})]})]})]})}function R(){let{user:e,userRole:t}=m(),[r,i]=(0,a.useState)([]),[s,f]=(0,a.useState)(!1),p=(0,u.useNavigate)(),{"*":h}=(0,u.useParams)(),g=h?h.split(`/`).filter(Boolean):[],_=g[0]||`private`,v=null,y=null;_===`users`?(v=g[1]||null,y=g[2]||null):y=g[1]||null;let b={public:`pub_`,shared:`mem_`,private:`user_`,admin:`admin_`,users:`users_`},x={pub_:`public`,mem_:`shared`,user_:`private`,admin_:`admin`,users_:`users`},S=b[_]||`user_`,C=e=>{p(`/drive/${x[e]}`)},[w,T]=(0,a.useState)([]);(0,a.useEffect)(()=>{S===`users_`&&t===`admin`&&w.length===0&&(0,o.getDocs)((0,o.collection)(n.Tt,`user_profiles`)).then(e=>{T(e.docs.map(e=>({id:e.id,...e.data()})))})},[S,t,w.length]);let[E,D]=(0,a.useState)(!1),[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(``),[M,N]=(0,a.useState)(`user_`),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(!1),[R,z]=(0,a.useState)(!1),B=(0,a.useRef)(null),ne=e=>{e.preventDefault(),e.stopPropagation(),z(!0)},V=e=>{e.preventDefault(),e.stopPropagation(),z(!1)},H=e=>{if(e.preventDefault(),e.stopPropagation(),z(!1),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name),N(S),F(!0)}},U=y&&r.find(e=>e._id===y)||null,W=e=>{le(!0),p(e?S===`users_`&&v?`/drive/users/${v}/${e._id}`:`/drive/${x[S]}/${e._id}`:S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},[G,re]=(0,a.useState)(null),[ie,K]=(0,a.useState)(!1),[q,J]=(0,a.useState)(null),[Y,ae]=(0,a.useState)(!1),[oe,se]=(0,a.useState)(null),[ce,le]=(0,a.useState)(!0),[ue,de]=(0,a.useState)({}),[fe,X]=(0,a.useState)(!1);(0,a.useEffect)(()=>(U||q||G||P||fe?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[U,q,G,P,fe]),(0,a.useEffect)(()=>{if(!s&&y&&!r.some(e=>e._id===y)){X(!0);let e=setTimeout(()=>{X(!1),p(S===`users_`&&v?`/drive/users/${v}`:`/drive/${x[S]}`)},2500);return()=>clearTimeout(e)}else X(!1)},[s,y,r,S,p,v]),(0,a.useEffect)(()=>{if(!e)return;f(!0);let r=(t===`admin`?[`pub_`,`mem_`,`user_`,`admin_`]:[`pub_`,`mem_`,`user_`]).map(r=>{let a;return a=r===`user_`&&t!==`admin`?(0,o.query)((0,o.collection)(n.Tt,`${r}files`),(0,o.where)(`uid`,`==`,e.uid)):(0,o.query)((0,o.collection)(n.Tt,`${r}files`),(0,o.orderBy)(`createdAt`,`desc`)),(0,o.onSnapshot)(a,e=>{let t=(e.docs||[]).map(e=>({_id:e.id,accessPrefix:r,...e.data()}));i(e=>[...e.filter(e=>e.accessPrefix!==r),...t].sort((e,t)=>{let n=e.createdAt?.toMillis?e.createdAt.toMillis():0;return(t.createdAt?.toMillis?t.createdAt.toMillis():0)-n})),f(!1)},e=>{console.warn(`Error listening to ${r}files:`,e)})});return()=>r.forEach(e=>e())},[e?.uid,t]);let pe=e=>{if(e.target.files&&e.target.files[0]){let t=e.target.files[0];k(t),j(t.name)}},me=e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name)}},Z=async r=>{if(r.preventDefault(),!(!O||!A)){D(!0);try{let r=(0,c.ref)(n.Dt,`${M}files/${`${Date.now()}_${O.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(r,O,{customMetadata:{ownerId:e.uid}});let i=await(0,c.getDownloadURL)(r);await(0,o.addDoc)((0,o.collection)(n.Tt,`${M}files`),{fileName:A,fileType:O.type||`unknown`,fileSize:O.size,downloadURL:i,uid:e.uid,uploaderEmail:e.email||`user`,uploaderRole:t||`user`,createdAt:(0,o.serverTimestamp)()}),F(!1),k(null),j(``),C(M)}catch(e){console.error(e),alert(`Upload failed: ${e.message}`)}D(!1)}},he=async()=>{if(q){ae(!0);try{try{await(0,c.deleteObject)((0,c.ref)(n.Dt,q.url))}catch(e){console.warn(`Storage item missing:`,e)}await(0,o.deleteDoc)((0,o.doc)(n.Tt,`${q.prefix}files`,q.id)),i(e=>e.filter(e=>e._id!==q.id)),J(null)}catch(e){alert(e.message)}ae(!1)}},ge=async()=>{if(!G||!G.name.trim()){re(null);return}let e=r.find(e=>e._id===G.id);if(e&&e.fileName===G.name.trim()){re(null);return}K(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,`${G.prefix}files`,G.id),{fileName:G.name.trim()}),i(e=>e.map(e=>e._id===G.id?{...e,fileName:G.name.trim()}:e)),re(null)}catch(e){console.error(`Rename failed:`,e)}K(!1)},_e=(e,t)=>{navigator.clipboard.writeText(e),se(t),setTimeout(()=>se(null),2e3)},ve=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=n=>e?n.accessPrefix===`mem_`?n.uid===e.uid?!0:t===`admin`?n.uploaderRole!==`admin`:!1:n.accessPrefix===`admin_`?n.uid===e.uid:n.accessPrefix===`pub_`?t===`admin`:n.uid===e.uid||t===`admin`:!1,ye=(e,t,r=!1)=>{let i=r?`w-16 h-16`:`w-10 h-10`,a=r?`w-8 h-8`:`w-5 h-5`;return e.startsWith(`image/`)?r?(0,l.jsx)(`img`,{src:t,alt:`preview`,className:`w-full h-full object-contain rounded-lg`}):(0,l.jsx)(`div`,{className:`${i} bg-cover bg-center rounded-lg`,style:{backgroundImage:`url(${t})`}}):e.includes(`video`)||e.includes(`audio`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-purple-500/10 text-purple-500 rounded-lg`,children:(0,l.jsx)(n.l,{className:a})}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-blue-500/10 text-blue-500 rounded-lg`,children:(0,l.jsx)(n.G,{className:a})}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-yellow-500/10 text-yellow-500 rounded-lg`,children:(0,l.jsx)(n._t,{className:a})}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-emerald-500/10 text-emerald-500 rounded-lg`,children:(0,l.jsx)(n.Q,{className:a})}):(0,l.jsx)(`div`,{className:`${i} flex items-center justify-center bg-foreground/5 text-foreground/40 rounded-lg`,children:(0,l.jsx)(n.W,{className:a})})},be=[{id:`user_`,label:`Private`,icon:n.j,description:`This is a private folder availbale to all users in your app. Each user can see their own files. Admins can see all everyone's files here.`},{id:`mem_`,label:`Shared`,icon:n.u,description:`This is a shared folder that all signed-in users can see. Every user can upload files here and view other member's files. However, editing and deletion are strictly restricted to the original creator of the file.`},{id:`pub_`,label:`Public`,icon:n.U,description:`This admin-only folder is for assets like logos, banners, or favicons. Files here are view-only for everyone; only admins can upload or delete them.`},{id:`admin_`,label:`Admin Shared`,icon:n.v,description:`This is a shared folder for app administrators. Admins can view everything here, but they can only edit or delete files that they themselves uploaded.`},{id:`users_`,label:`User Uploads`,icon:n.X,description:`View all underlying private user uploads securely. Select a user to explore their files.`}].filter(e=>t===`admin`?!0:e.id===`user_`||e.id===`mem_`),xe=[];xe=S===`users_`?r.filter(e=>e.accessPrefix===`user_`&&e.uid===v):S===`user_`?r.filter(t=>t.accessPrefix===`user_`&&t.uid===e?.uid):r.filter(e=>e.accessPrefix===S);let Se=be.find(e=>e.id===S);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 flex flex-col pt-12 min-h-screen relative overflow-visible`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Drive`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/drive`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,onDragOver:ne,onDragLeave:V,onDrop:H,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-row glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl min-h-[600px] bg-background`,children:[(0,l.jsxs)(`div`,{className:`w-[280px] border-r border-[var(--panel-border)] bg-foreground/[0.01] p-4 flex flex-col shrink-0 overflow-y-auto hide-scrollbar`,children:[(0,l.jsx)(`div`,{className:`text-[11px] font-extrabold text-foreground/40 uppercase tracking-widest pl-4 mb-4 mt-2`,children:`Locations`}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2`,children:be.map(e=>(0,l.jsxs)(`button`,{onClick:()=>C(e.id),className:`w-full flex items-center gap-3 px-4 py-3.5 rounded-2xl transition-all font-bold text-[14px] text-left ${S===e.id?`bg-accent/15 text-accent shadow-sm border border-accent/20`:`text-foreground/70 hover:bg-foreground/5 hover:text-foreground border border-transparent`}`,children:[(0,l.jsx)(e.icon,{className:`w-5 h-5 ${S===e.id?`text-accent`:`text-foreground/40`}`}),e.label]},e.id))})]}),(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col relative w-full h-full min-w-0`,children:[(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex items-start justify-between gap-6 shrink-0 border-b border-[var(--panel-border)]/50 bg-background/50`,children:[(0,l.jsxs)(`div`,{className:`flex-1 max-w-xl`,children:[(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground tracking-tight flex items-center gap-3`,children:Se?.label}),(0,l.jsx)(`p`,{className:`text-[13px] mt-3 text-foreground/60 leading-relaxed font-medium`,children:Se?.description})]}),S!==`users_`&&(0,l.jsxs)(n.n,{onClick:()=>{N(S),F(!0)},className:`flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-bold shadow-md hover:shadow-lg transition-all glow-hover border-transparent !border-0 outline-none ring-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add File Here`]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[300px]`,children:[s&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm rounded-b-[2rem]`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),S===`users_`&&!v?(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-20`,children:[w.map(e=>(0,l.jsxs)(`div`,{onClick:()=>p(`/drive/users/${e.id}`),className:`flex items-center gap-4 bg-background border border-[var(--panel-border)] p-5 rounded-2xl cursor-pointer hover:border-accent/50 hover:shadow-md transition-all group`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-foreground/5 flex items-center justify-center shrink-0 border border-[var(--panel-border)]`,children:e.photoURL?(0,l.jsx)(`img`,{src:e.photoURL,alt:`avatar`,className:`w-full h-full rounded-full object-cover`}):(0,l.jsx)(n.d,{className:`w-5 h-5 text-foreground/40`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground truncate group-hover:text-accent transition-colors text-[14px]`,children:[e.firstName,` `,e.lastName]}),(0,l.jsx)(`span`,{className:`text-[12px] font-medium text-foreground/50 truncate mt-0.5`,children:e.email})]})]},e.id)),w.length===0&&(0,l.jsxs)(`div`,{className:`col-span-full py-12 flex flex-col items-center justify-center text-center`,children:[(0,l.jsx)(n.d,{className:`w-12 h-12 text-foreground/10 mb-4`}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground/50`,children:`No users found`})]})]}):xe.length>0?(0,l.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 pb-20`,children:xe.map(e=>(0,l.jsxs)(`div`,{className:`flex flex-col bg-background border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all group overflow-hidden shadow-sm hover:shadow-md h-[190px] relative`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex flex-col gap-1 opacity-0 group-hover:opacity-100 transition-opacity z-10 bg-background/90 backdrop-blur-md rounded-lg p-1 border border-[var(--panel-border)] shadow-xl`,children:[(0,l.jsx)(`a`,{href:e.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-blue-500 transition-colors`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),_e(e.accessPrefix===`pub_`?e.downloadURL:`${window.location.origin}/drive/${x[e.accessPrefix]}/${e._id}`,e._id)},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-emerald-500 transition-colors`,title:`Copy Link`,children:oe===e._id?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(e)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),re({id:e._id,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-purple-500 transition-colors`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),J({id:e._id,url:e.downloadURL,name:e.fileName,prefix:e.accessPrefix})},className:`p-1.5 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`h-[120px] w-full border-b border-[var(--panel-border)]/50 bg-foreground/[0.02] flex items-center justify-center overflow-hidden relative cursor-pointer rounded-t-[calc(1rem-1px)]`,onClick:()=>W(e),children:e.fileType.startsWith(`image/`)?(0,l.jsxs)(l.Fragment,{children:[ue[e._id]!==!1&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-accent/5 backdrop-blur-sm z-0`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})}),(0,l.jsx)(`img`,{src:e.downloadURL,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 group-hover:scale-105 ${ue[e._id]===!1?`opacity-100`:`opacity-0`}`,onLoad:()=>de(t=>({...t,[e._id]:!1})),onError:()=>de(t=>({...t,[e._id]:!1}))})]}):ye(e.fileType,e.downloadURL,!0)}),(0,l.jsxs)(`div`,{className:`p-3 flex flex-col justify-center flex-1 min-w-0`,onClick:()=>!G&&W(e),children:[G?.id===e._id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:G.name,onChange:e=>re({...G,name:e.target.value}),onBlur:()=>ge(),onKeyDown:e=>{e.key===`Enter`&&ge(),e.key===`Escape`&&re(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[12.5px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full`}):(0,l.jsx)(`span`,{className:`text-[12.5px] font-bold text-foreground truncate select-none group-hover:text-accent transition-colors`,title:e.fileName,children:e.fileName}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/40 font-bold uppercase tracking-wider mt-1 select-none`,children:ve(e.fileSize)})]})]},e._id))}):!s&&(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(e.preventDefault(),e.dataTransfer.files&&e.dataTransfer.files[0]){let t=e.dataTransfer.files[0];k(t),j(t.name),N(S),F(!0)}},onClick:()=>{N(S),F(!0)},className:`absolute inset-0 m-6 flex flex-col items-center justify-center text-foreground/40 transition-colors cursor-pointer group`,children:[(0,l.jsx)(`p`,{className:`text-[20px] font-bold text-foreground/50 group-hover:text-foreground/70 transition-colors`,children:`Folder is empty`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium mt-1 text-foreground/40 group-hover:text-foreground/60 transition-colors`,children:`Click here or drag and drop a file to upload`})]})]})]})]})]}),(0,l.jsx)(n.a,{children:P&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!E&&F(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[480px] border-[var(--panel-border)] border rounded-3xl relative z-10 glass-panel shadow-2xl flex flex-col bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-[var(--panel-border)]/50 relative z-20`,children:[(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`button`,{onClick:()=>L(!I),className:`flex items-center gap-2 group outline-none`,children:[(0,l.jsx)(`span`,{className:`text-[16px] font-extrabold text-foreground tracking-tight`,children:`Upload to`}),(0,l.jsx)(`span`,{className:`bg-accent/10 group-hover:bg-accent/20 text-accent px-2 py-1 rounded-md text-[13px] font-bold transition-colors flex items-center gap-1 shadow-sm`,children:be.find(e=>e.id===M)?.label})]}),(0,l.jsx)(n.a,{children:I&&(0,l.jsxs)(a.default.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[90]`,onClick:()=>L(!1)}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:`absolute top-full left-0 mt-3 w-48 bg-background border border-[var(--panel-border)] rounded-xl shadow-2xl py-1 overflow-hidden z-[100]`,children:be.map(e=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>{N(e.id),L(!1)},className:`w-full text-left px-4 py-3 hover:bg-foreground/5 text-[13px] font-bold text-foreground flex items-center gap-3 transition-colors outline-none`,children:[(0,l.jsx)(e.icon,{className:`w-4 h-4 text-foreground/50`}),e.label]},e.id))})]})})]}),(0,l.jsx)(`button`,{onClick:()=>!E&&F(!1),className:`text-foreground/40 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),O?(0,l.jsxs)(`form`,{onSubmit:Z,className:`p-6 flex flex-col gap-6 relative z-10 rounded-b-[2rem]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 bg-foreground/[0.03] p-4 rounded-2xl border border-[var(--panel-border)] shadow-sm`,children:[ye(O.type,URL.createObjectURL(O)),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground truncate`,children:O.name}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold uppercase tracking-wider mt-1`,children:ve(O.size)})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!E&&k(null),className:`w-8 h-8 flex items-center justify-center text-foreground/40 hover:text-red-500 rounded-xl hover:bg-red-500/10 transition-colors shrink-0`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest pl-1`,children:`Edit File Name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,value:A,onChange:e=>j(e.target.value),disabled:E,className:`no-glow w-full bg-foreground/[0.02] border border-[var(--panel-border)] rounded-xl px-4 py-3.5 text-[14px] font-bold text-foreground outline-none focus:border-accent transition-colors shadow-sm`})]}),(0,l.jsx)(`div`,{className:`flex justify-end pt-4 mt-2 border-t border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:E,className:`w-full py-4 rounded-xl text-[14px] font-bold shadow-lg`,children:E?`Uploading to Drive...`:`Save to ${be.find(e=>e.id===M)?.label}`})})]}):(0,l.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:me,className:`p-12 flex flex-col items-center justify-center rounded-b-[2rem]`,children:[(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-foreground/5 flex items-center justify-center mb-5 border-2 border-dashed border-[var(--panel-border)]`,children:(0,l.jsx)(n.$,{className:`w-8 h-8 text-foreground/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold text-foreground mb-1`,children:`Drag and drop file here`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 font-medium mb-8`,children:`or click to browse local files`}),(0,l.jsx)(`input`,{type:`file`,ref:B,onChange:pe,className:`hidden`}),(0,l.jsx)(n.n,{onClick:()=>B.current?.click(),className:`px-8 py-3 rounded-full font-bold shadow-md btn-primary transition-colors`,children:`Browse Files`})]})]})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:U&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>W(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>W(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:U.fileName}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[U.fileType,` • `,ve(U.fileSize),U.accessPrefix===`mem_`&&(U.uploaderEmail||U.uid)&&` • From: ${U.uploaderEmail||U.uid}`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>_e(U.accessPrefix===`pub_`?U.downloadURL:`${window.location.origin}/drive/${x[U.accessPrefix]}/${U._id}`,U._id),className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500`,title:`Copy Link`,children:oe===U._id?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),Q(U)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{W(null),re({id:U._id,name:U.fileName,prefix:U.accessPrefix})},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-purple-500 transition-colors rounded-xl shadow-sm`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{W(null),J({id:U._id,url:U.downloadURL,name:U.fileName,prefix:U.accessPrefix})},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})})]}),(0,l.jsx)(`a`,{href:U.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>W(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[ce&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none fade-in`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),U.fileType.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>le(!1),src:U.downloadURL,alt:U.fileName,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):U.fileType.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>le(!1),src:U.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):U.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>le(!1),src:U.downloadURL,className:`w-full h-full border-none bg-white rounded-lg relative z-10 transition-opacity duration-500 ${ce?`opacity-0`:`opacity-100`}`,title:`PDF Preview`}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),le(!1)},children:[(0,l.jsx)(n.W,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:fe&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/90 backdrop-blur-xl`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`relative z-10 w-full max-w-sm flex flex-col items-center pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-red-500/20 bg-background/80 p-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 flex items-center justify-center mb-6`,children:(0,l.jsx)(n.c,{className:`w-8 h-8 text-red-500`})}),(0,l.jsx)(`h3`,{className:`text-xl font-bold text-foreground mb-2`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 font-medium leading-relaxed`,children:`You don't have access to this file, or it may have been deleted.`}),(0,l.jsx)(`div`,{className:`w-5 h-5 border-2 border-accent/20 border-t-accent rounded-full animate-spin mt-6`})]})]})}),(0,l.jsx)(te,{isOpen:!!q,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:q?.name}),` This action is permanent.`]}),onConfirm:he,onCancel:()=>J(null),isProcessing:Y,confirmText:`Yes, Delete`}),(0,l.jsx)(n.a,{children:R&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`fixed inset-0 z-[1000] bg-background/60 backdrop-blur-md pointer-events-none flex items-center justify-center p-6`,children:(0,l.jsxs)(n.i.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:`w-full max-w-lg aspect-video bg-background/80 border-2 border-dashed border-accent p-12 rounded-[40px] shadow-2xl flex flex-col items-center justify-center gap-6 relative`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-accent/5 rounded-[38px] animate-pulse`}),(0,l.jsx)(`div`,{className:`w-20 h-20 rounded-full bg-accent/10 flex items-center justify-center text-accent shadow-[0_0_40px_rgba(var(--accent-rgb),0.2)]`,children:(0,l.jsx)(n.$,{className:`w-10 h-10 animate-bounce`})}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-2 relative z-10`,children:[(0,l.jsx)(`span`,{className:`text-[24px] font-extrabold text-foreground tracking-tight`,children:`Drop files to upload`}),(0,l.jsx)(`span`,{className:`text-[14px] font-medium text-foreground/50`,children:`Your files will be staged for review`})]})]})})})]})}function z(){let e=[{id:`form`,title:`Inline Form`,description:`A static, embedded contact form designed directly into the page layout.`,icon:n.P,path:`/templates/inline_form`},{id:`popup`,title:`Modal Popup Form`,description:`A centralized popup contact form that visually blurs the background context.`,icon:n.yt,path:`/templates/popup_form`},{id:`confirmation`,title:`Action Confirmation`,description:`A classic confirmation dialog styled for decisive user actions.`,icon:n.lt,path:`/templates/confirmation`},{id:`board`,title:`Board View`,description:`A modern, drag-and-drop styled Kanban board aesthetic for task management.`,icon:n.z,path:`/templates/board`},{id:`table`,title:`Data Table`,description:`A clean, column-based data table optimized for large datasets and bulk actions.`,icon:n.g,path:`/templates/table`},{id:`calendar`,title:`Calendar View`,description:`A structured monthly calendar grid for scheduling and date-based resource planning.`,icon:n.dt,path:`/templates/calendar`}];return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-10 text-center`,children:[(0,l.jsx)(`h1`,{className:`w-fit mx-auto inline-block text-4xl md:text-5xl lg:text-[4.8rem] leading-[1.1] font-extrabold tracking-tight mb-4 text-gradient animate-float`,children:`Premium Templates`}),(0,l.jsx)(`p`,{className:`text-foreground/60 text-lg font-medium max-w-2xl mx-auto`,children:`Explore our collection of fully functional, beautifully designed boilerplate components.`})]}),(0,l.jsxs)(`div`,{className:`w-full max-w-4xl mx-auto flex flex-col gap-4 relative`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[80%] h-[80%] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),e.map((e,t)=>{let r=e.icon;return(0,l.jsx)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.05},children:(0,l.jsxs)(u.Link,{to:e.path,className:`flex items-center gap-6 w-full p-4 md:px-6 glass-panel border border-[var(--panel-border)] rounded-2xl hover:border-accent/40 transition-all duration-300 group hover:bg-foreground/[0.02]`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-accent/10 flex items-center justify-center text-accent shrink-0 border border-accent/20 group-hover:scale-105 transition-transform`,children:(0,l.jsx)(r,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-[15px] font-bold text-foreground truncate`,children:e.title}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 truncate font-medium`,children:e.description})]}),(0,l.jsxs)(`div`,{className:`hidden md:flex items-center gap-2 text-[13px] font-bold px-5 py-2.5 rounded-xl btn-primary shrink-0 transition-transform shadow-lg group-hover:-translate-y-0.5`,children:[`View `,(0,l.jsx)(`span`,{className:`font-black leading-none ml-0.5`,children:`→`})]})]})},e.id)})]})]})}function B(){let[e,t]=(0,a.useState)({favoriteService:``,satisfactionRating:``,detailedThoughts:``}),[r,i]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mb-6`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsx)(`div`,{className:`w-full max-w-5xl mx-auto mt-6`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-auto`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsx)(`div`,{className:`relative z-10 w-full`,children:r===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.nt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):r===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Inline Form Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Try interacting with this simulated inline template block.`})]}),(0,l.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),i(`loading`);try{let r=n.wt.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.Tt,`user_submissions`),{uid:r,...e,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),i(`success`),setTimeout(()=>{i(`idle`),t({favoriteService:``,satisfactionRating:``,detailedThoughts:``})},3e3)}catch{i(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Favorite Service`,placeholder:`e.g. Design Consulting`,value:e.favoriteService,onChange:n=>t({...e,favoriteService:n.target.value})}),(0,l.jsx)(n.r,{label:`Satisfaction Rating`,type:`number`,placeholder:`1 to 10`,value:e.satisfactionRating,onChange:n=>t({...e,satisfactionRating:n.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Detailed Thoughts`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:e.detailedThoughts,onChange:n=>t({...e,detailedThoughts:n.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})})]})})]})}function ne(){let[e,t]=(0,a.useState)(!1),[r,i]=(0,a.useState)({concept:``,featureRequest:``,notes:``}),[s,c]=(0,a.useState)(`idle`);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Popup Form`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/popup_form`]})]}),(0,l.jsx)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 text-foreground/70`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col w-full min-h-[150px] p-6 lg:p-10`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),(0,l.jsx)(`div`,{className:`flex h-full w-full justify-end items-start relative z-10`,children:(0,l.jsxs)(n.n,{onClick:()=>t(!0),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center justify-center gap-2 btn-primary transition-all hover:-translate-y-1`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Open Form`]})})]}),(0,l.jsx)(n.a,{children:e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl cursor-pointer`,onClick:()=>t(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 lg:p-10 rounded-3xl md:rounded-3xl glass-panel relative glow-hover shadow-[0_8px_32px_rgba(0,0,0,0.08)] z-10 mx-4 max-h-[95vh] overflow-y-auto no-scrollbar`,children:[(0,l.jsx)(`div`,{className:`absolute -inset-[1px] bg-gradient-to-br from-[var(--primary-glow)] to-transparent opacity-30 blur-[20px] rounded-3xl md:rounded-3xl -z-10`}),(0,l.jsxs)(`div`,{className:`relative z-10 w-full`,children:[(0,l.jsx)(`button`,{onClick:()=>t(!1),className:`absolute -top-2 -right-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-foreground/5 text-foreground/60 hover:text-foreground transition-colors z-20`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),s===`success`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-500 mb-4`,children:(0,l.jsx)(n.nt,{className:`w-8 h-8`})}),(0,l.jsx)(`h4`,{className:`text-xl font-bold text-foreground mb-2`,children:`Simulation Complete!`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/60 leading-relaxed max-w-[280px]`,children:`Your test data was sent successfully. Log in as an admin and check the Submissions tab!`})]}):s===`loading`?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 border-4 border-accent border-r-transparent rounded-full animate-spin mb-4`}),(0,l.jsx)(`h4`,{className:`text-lg font-bold text-foreground tracking-tight`,children:`Processing`}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/50 mt-1`,children:`Simulating submission...`})]}):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},children:[(0,l.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,l.jsx)(`h3`,{className:`text-2xl sm:text-3xl font-extrabold mb-2 text-foreground tracking-tight break-words`,children:`Popup Template`}),(0,l.jsx)(`p`,{className:`text-[14px] md:text-[15px] font-medium text-foreground/60 tracking-wide leading-relaxed`,children:`Fill out the simulated fields below to test the interaction.`})]}),(0,l.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),c(`loading`);try{let e=n.wt.currentUser?.uid||`guest`;await(0,o.addDoc)((0,o.collection)(n.Tt,`user_submissions`),{uid:e,...r,type:`template_simulation`,submittedAt:(0,o.serverTimestamp)()}),c(`success`),setTimeout(()=>{c(`idle`),i({concept:``,featureRequest:``,notes:``}),t(!1)},3e3)}catch{c(`error`)}},className:`space-y-4 w-full`,children:[(0,l.jsx)(n.r,{label:`Concept Name`,placeholder:`e.g. Project Apollo`,value:r.concept,onChange:e=>i({...r,concept:e.target.value})}),(0,l.jsx)(n.r,{label:`Feature Request`,placeholder:`e.g. Real-time sync`,value:r.featureRequest,onChange:e=>i({...r,featureRequest:e.target.value})}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Simulated Notes`}),(0,l.jsx)(`textarea`,{rows:3,placeholder:`Type something here...`,value:r.notes,onChange:e=>i({...r,notes:e.target.value}),className:`flex w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus disabled:cursor-not-allowed disabled:opacity-50 glass-panel min-h-[100px] resize-none`})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,className:`w-full px-6 md:px-8 py-3 md:py-3.5 rounded-xl font-semibold tracking-wide btn-primary text-[15px] shadow-xl transition-all duration-300 hover:-translate-y-1 active:scale-95 flex items-center justify-center`,isLoading:!1,children:`Trigger Simulation`})})]})]})]})]})]})})]})}function V(){let[e,t]=(0,a.useState)(void 0);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 items-center`,children:[(0,l.jsx)(`div`,{className:`w-full max-w-5xl mb-8`,children:(0,l.jsxs)(u.Link,{to:`/templates`,className:`inline-flex items-center gap-2 text-foreground/50 hover:text-accent transition-colors font-medium text-[14px]`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Back to Templates`]})}),(0,l.jsxs)(`div`,{className:`w-full max-w-5xl mx-auto mt-2 glass-panel rounded-3xl border border-[var(--panel-border)] p-6 md:p-10 relative overflow-hidden shadow-2xl`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-8 pb-6 border-b border-[var(--panel-border)]/50`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold text-foreground tracking-tight`,children:`System Files`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50 mt-1`,children:`Review and manage core application assets.`})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center text-red-500 shrink-0`,children:(0,l.jsx)(n.p,{className:`w-5 h-5`})}),(0,l.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[(0,l.jsx)(`h4`,{className:`font-bold text-[14px] sm:text-[15px] text-foreground truncate`,children:`Critical Configuration File`}),(0,l.jsx)(`p`,{className:`text-[12px] sm:text-[13px] text-foreground/50 font-medium mt-0.5 truncate`,children:`Size: 4.2 MB • Modified 2 hours ago`})]})]}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(null),className:`w-full sm:w-auto shrink-0 flex items-center justify-center px-6 py-3 sm:py-2.5 text-[13px] font-bold rounded-xl text-red-500 hover:bg-red-500/10 hover:border-red-500/20 bg-red-500/5 sm:bg-transparent`,children:`Delete File`})]}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 opacity-50 pointer-events-none mt-2`,children:[1,2].map(e=>(0,l.jsxs)(`div`,{className:`glass-panel p-5 rounded-2xl border border-[var(--panel-border)]/20 flex items-center gap-4`,children:[(0,l.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-foreground/5 shrink-0`}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 flex-1`,children:[(0,l.jsx)(`div`,{className:`w-32 h-3 rounded-full bg-foreground/10`}),(0,l.jsx)(`div`,{className:`w-20 h-2 rounded-full bg-foreground/5`})]})]},e))})]})]}),(0,l.jsx)(n.a,{children:e!==void 0&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-xl`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[400px] p-6 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 text-center`,children:(0,l.jsx)(n.a,{mode:`wait`,children:e===null?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold mb-2 text-foreground tracking-tight`,children:`Confirm Deletion`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 leading-relaxed mb-6`,children:`Are you entirely sure you wish to delete this configuration? This action is permanent.`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 w-full`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(!1),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl`,children:`Cancel`}),(0,l.jsx)(n.n,{onClick:()=>t(!0),className:`flex-1 py-2.5 text-[13px] font-bold rounded-xl bg-red-500 hover:bg-red-600 border-none text-white shadow-xl hover:shadow-red-500/20 glow-hover`,children:`Yes, Delete`})]})]},`confirm`):e===!0?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-green-500 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.ct,{className:`w-5 h-5`}),` Verified`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Action successfully executed.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`success`):(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full flex flex-col items-center py-2`,children:[(0,l.jsxs)(`h3`,{className:`text-xl font-extrabold mb-1 text-foreground/80 tracking-tight flex items-center gap-2`,children:[(0,l.jsx)(n.c,{className:`w-5 h-5`}),` Aborted`]}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mb-6`,children:`Cancellation securely caught.`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>t(void 0),className:`px-6 py-2 rounded-xl text-[13px] font-bold`,children:`Close Panel`})]},`error`)})})]})})]})}var H=(e,t=[])=>{let n=(e.pageName||e.pageId||`custom_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`Create a microcomponent for the Public Landing Page: \`${e.pageName}\`.
2
2
 
3
- The page "infrastructure" (routing, header, public accessibility) is already set up and working. Your goal is to design the "Landing Content" that lives inside this page.
4
-
5
- ### ── Current Page Configuration ──────────────────────────────────────────────
6
- \`\`\`json
7
- ${JSON.stringify({pageName:e.pageName,pageTitle:e.pageTitle,route:e.route,template:e.template},null,2)}
8
- \`\`\`
3
+ ### ── Context ────────────────────────────────────────────────────────────────
4
+ - **Route**: \`${e.route}\`
5
+ - **Examples Folder**: Check \`src/your-ai-workflow-firebase-os/microcomponents/\` for reference examples of how to build and insert microcomponents.
9
6
 
10
7
  ### ── Available Forms ────────────────────────────────────────────────────────
11
- The following public forms are available in the system. **These are for your information only—do NOT use them unless specifically needed.** Your priority is to listen to the user's specific input and decide if a particular modal, form, or component is actually required for the context of this page:
12
8
  ${t.length>0?t.map(e=>`- ${e}`).join(`
13
9
  `):`- No public forms found`}
10
+ Use these only if specifically requested by the user.
14
11
 
15
- ### ── Your Mission ────────────────────────────────────────────────────────────
16
- 1. **Create the Content Layer**: Design a new micro-component at \`src/microcomponents/${r}.tsx\`.
17
- 2. **Build the UI**: Inside this component, build the landing page content (hero sections, feature grids, contact sections, etc.).
18
- 3. **Inject into Template**: Once created, import and place \`<${r} />\` inside the main content area of \`src/templates/PublicPageTemplate.tsx\`, replacing the placeholder robot icon and default text.
12
+ ### ── Your Task ──────────────────────────────────────────────────────────────
13
+ 1. **Create Microcomponent**: Build \`src/microcomponents/${r}.tsx\`.
14
+ 2. **Build Content**: Implement landing page content (hero sections, features, etc).
15
+ 3. **Register Route**: In \`src/App.tsx\`, map your microcomponent to the \`customRoutes\` prop of \`<FirebaseOS>\`:
19
16
 
20
- ### ── Guardrails ─────────────────────────────────────────────────────────────
21
- - **DO NOT** modify the outer layout of \`PublicPageTemplate.tsx\` (back buttons, page header, footer, dynamic title).
22
- - **DO NOT** change the routing or page exports.
23
- - Focus exclusively on the inner content box using the micro-component strategy.
17
+ \`\`\`tsx
18
+ import { ${r} } from './microcomponents/${r}';
24
19
 
25
- ### ── Aesthetic & Performance (Theme System) ───────────────────────────────
26
- Build with the user's active theme in mind:
27
- - **CSS Variables**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-bg)\`, \`var(--panel-border)\`.
28
- - **Components**: Re-use \`<Button />\`, \`<Input />\`, \`<ConfirmModal />\`, and \`<ContactPopup />\` natively.
29
- - **Styles**: Use the \`glass-panel\` class for sections and \`text-gradient\` for headers.
20
+ // Inside App.tsx:
21
+ <FirebaseOS
22
+ customRoutes={{
23
+ '${e.route}': ${r}
24
+ }}
25
+ // ...
26
+ />
27
+ \`\`\`
30
28
 
31
- ### ── Important Formatting Rules ──────────────────────────────────────────────
32
- - **NO REDUNDANT HEADERS**: The parent template already injects a large dynamic page title and action buttons. DO NOT add a main \`<h1>\` or \`<h2>\` page title at the top of your micro-component. Start directly with your cards, lists, or sub-sections.
29
+ ### ── Guidelines ─────────────────────────────────────────────────────────────
30
+ - **Use Theme Tokens**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-border)\`.
31
+ - **Pre-built UI**: Import \`{ Button, Input, ContactPopup }\` from \`your-ai-workflow-firebase-os\`.
32
+ - **Layout**: Use \`glass-panel\` class for sections. DO NOT add redundant \`<h1>\` page titles (the layout handles this).
33
+ - **DO NOT create React Router routes**. Only use the \`customRoutes\` mapping.
33
34
 
34
- [WHAT SHOULD I BUILD ON THIS PUBLIC PAGE?]`},V="### Theme & Styling (Dynamic Firestore Theme)\nOur application uses a dynamic theme engine. You MUST use these global CSS variable tokens to ensure your design matches the user's active theme:\n- **Colors**: `var(--bg-color)`, `var(--fg-color)`, `var(--accent-color)`, `var(--accent-deep)`, `var(--panel-bg)`, `var(--panel-border)`.\n- **Text**: Use the `text-foreground` (standard), `text-accent` (primary), and `text-gradient` (headings) classes.\n- **Glassmorphism**: Always use the `.glass-panel` utility class for containers/cards.",H=`- **<Button />**, **<Input />**, **<ConfirmModal />**, **<DashboardNav />**, **<ContactPopup />**, **<CustomSelect />**.`,U=`- **<Button />**, **<Input />**, **<ConfirmModal />**, **<DashboardNav />**, **<CustomSelect />**.`,W=(e,t,n,r=[])=>`I need your help modifying the core Calendar Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
35
+ [WHAT SHOULD I BUILD ON THIS PUBLIC PAGE?]`},U="### Theme & Styling (Dynamic Firestore Theme)\nOur application uses a dynamic theme engine. You MUST use these global CSS variable tokens to ensure your design matches the user's active theme:\n- **Colors**: `var(--bg-color)`, `var(--fg-color)`, `var(--accent-color)`, `var(--accent-deep)`, `var(--panel-bg)`, `var(--panel-border)`.\n- **Text**: Use the `text-foreground` (standard), `text-accent` (primary), and `text-gradient` (headings) classes.\n- **Glassmorphism**: Always use the `.glass-panel` utility class for containers/cards.",W=`- **<Button />**, **<Input />**, **<ConfirmModal />**, **<DashboardNav />**, **<ContactPopup />**, **<CustomSelect />**.`,G=`- **<Button />**, **<Input />**, **<ConfirmModal />**, **<DashboardNav />**, **<CustomSelect />**.`,re=(e,t,n,r=[])=>`I need your help modifying the core Calendar Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
35
36
 
36
37
  This is a core template located at \`src/templates/TemplateCalendar.tsx\`. Any changes you make here will affect ALL calendar views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
37
38
 
@@ -55,11 +56,11 @@ ${r.length>0?r.map(e=>`- ${e}`).join(`
55
56
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, UI elements, and data sync logic without breaking existing functionality.
56
57
 
57
58
  ### ── Architecture & Reusable Components ────────────────────────────────────
58
- ${H}
59
+ ${W}
59
60
 
60
- ${V}
61
+ ${U}
61
62
 
62
- [DESCRIBE FEATURE TO ADD HERE]`,G=(e,t,n,r=[])=>`I need your help modifying the core Calendar Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
63
+ [DESCRIBE FEATURE TO ADD HERE]`,ie=(e,t,n,r=[])=>`I need your help modifying the core Calendar Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
63
64
 
64
65
  This is a core template located at \`src/templates/TemplateCalendar.tsx\`. Any changes you make here will affect ALL calendar views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
65
66
 
@@ -78,9 +79,9 @@ The current tab is configured with:
78
79
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, UI elements, and data sync logic without breaking existing functionality.
79
80
 
80
81
  ### ── Architecture & Reusable Components ────────────────────────────────────
81
- ${U}
82
+ ${G}
82
83
 
83
- ${V}
84
+ ${U}
84
85
 
85
86
  [DESCRIBE FEATURE TO ADD HERE]`,K=(e,t,n,r=[])=>`I need your help modifying the core Calendar Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
86
87
 
@@ -106,11 +107,11 @@ ${r.length>0?r.map(e=>`- ${e}`).join(`
106
107
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, UI elements, and data sync logic without breaking existing functionality.
107
108
 
108
109
  ### ── Architecture & Reusable Components ────────────────────────────────────
109
- ${H}
110
+ ${W}
110
111
 
111
- ${V}
112
+ ${U}
112
113
 
113
- [DESCRIBE FEATURE TO ADD HERE]`,ae=(e,t,n,r,i=[])=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
114
+ [DESCRIBE FEATURE TO ADD HERE]`,q=(e,t,n,r,i=[])=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
114
115
 
115
116
  This is a core template located at \`src/templates/TemplateBoard.tsx\`. Any changes you make here will affect ALL board views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
116
117
 
@@ -135,11 +136,11 @@ ${i.length>0?i.map(e=>`- ${e}`).join(`
135
136
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, drag-and-drop logic, and UI elements.
136
137
 
137
138
  ### ── Architecture & Reusable Components ────────────────────────────────────
138
- ${H}
139
+ ${W}
139
140
 
140
- ${V}
141
+ ${U}
141
142
 
142
- [DESCRIBE FEATURE TO ADD HERE]`,q=(e,t,n,r)=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
143
+ [DESCRIBE FEATURE TO ADD HERE]`,J=(e,t,n,r)=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
143
144
 
144
145
  This is a core template located at \`src/templates/TemplateBoard.tsx\`. Any changes you make here will affect ALL board views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
145
146
 
@@ -159,11 +160,11 @@ The current tab is configured with:
159
160
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, drag-and-drop logic, and UI elements.
160
161
 
161
162
  ### ── Architecture & Reusable Components ────────────────────────────────────
162
- ${U}
163
+ ${G}
163
164
 
164
- ${V}
165
+ ${U}
165
166
 
166
- [DESCRIBE FEATURE TO ADD HERE]`,J=(e,t,n,r,i=[])=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
167
+ [DESCRIBE FEATURE TO ADD HERE]`,Y=(e,t,n,r,i=[])=>`I need your help modifying the core Board Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
167
168
 
168
169
  This is a core template located at \`src/templates/TemplateBoard.tsx\`. Any changes you make here will affect ALL board views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
169
170
 
@@ -188,11 +189,11 @@ ${i.length>0?i.map(e=>`- ${e}`).join(`
188
189
  2. **Handle UX/UI**: Integrate your changes natively with the existing state, drag-and-drop logic, and UI elements.
189
190
 
190
191
  ### ── Architecture & Reusable Components ────────────────────────────────────
191
- ${H}
192
+ ${W}
192
193
 
193
- ${V}
194
+ ${U}
194
195
 
195
- [DESCRIBE FEATURE TO ADD HERE]`,oe=(e,t,n,r=[])=>`I need your help modifying the core Table Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
196
+ [DESCRIBE FEATURE TO ADD HERE]`,ae=(e,t,n,r=[])=>`I need your help modifying the core Table Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
196
197
 
197
198
  This is a core template located at \`src/templates/TemplateTable.tsx\`. Any changes you make here will affect ALL table views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
198
199
 
@@ -216,11 +217,11 @@ ${r.length>0?r.map(e=>`- ${e}`).join(`
216
217
  2. **Handle UX/UI**: Integrate your changes natively with the existing state (columns, rows, colors) and UI elements.
217
218
 
218
219
  ### ── Architecture & Reusable Components ────────────────────────────────────
219
- ${H}
220
+ ${W}
220
221
 
221
- ${V}
222
+ ${U}
222
223
 
223
- [DESCRIBE FEATURE TO ADD HERE]`,Y=(e,t,n)=>`I need your help modifying the core Table Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
224
+ [DESCRIBE FEATURE TO ADD HERE]`,oe=(e,t,n)=>`I need your help modifying the core Table Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
224
225
 
225
226
  This is a core template located at \`src/templates/TemplateTable.tsx\`. Any changes you make here will affect ALL table views across the application. Do not completely rewrite it from scratch; instead, carefully integrate the requested features into the existing architecture.
226
227
 
@@ -239,9 +240,9 @@ The current tab is configured with:
239
240
  2. **Handle UX/UI**: Integrate your changes natively with the existing state (columns, rows, colors) and UI elements.
240
241
 
241
242
  ### ── Architecture & Reusable Components ────────────────────────────────────
242
- ${U}
243
+ ${G}
243
244
 
244
- ${V}
245
+ ${U}
245
246
 
246
247
  [DESCRIBE FEATURE TO ADD HERE]`,se=(e,t,n,r=[])=>`I need your help modifying the core Table Template which currently powers the "${e?.tabTitle||e?.tabName||t}" tab.
247
248
 
@@ -267,160 +268,107 @@ ${r.length>0?r.map(e=>`- ${e}`).join(`
267
268
  2. **Handle UX/UI**: Integrate your changes natively with the existing state (columns, rows, colors) and UI elements.
268
269
 
269
270
  ### ── Architecture & Reusable Components ────────────────────────────────────
270
- ${H}
271
+ ${W}
271
272
 
272
- ${V}
273
-
274
- [DESCRIBE FEATURE TO ADD HERE]`,ce=(e,t)=>{let n=(e.tabName||e.pageId||`shared_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`);return`${n.charAt(0).toUpperCase()}${n.slice(1)}`,`I need your help building the inner functionality for an **already existing** Shared Member View. This view is powered by the \`SharedPageTemplate\` (located at \`src/templates/SharedPageTemplate.tsx\`).
275
-
276
- The "infrastructure" (real-time sync, collaborative routing) is entirely set up and functioning. Your goal is to design the "Community Content" that lives inside this specific shared view.
273
+ ${U}
277
274
 
278
- ### ── Current View Configuration ──────────────────────────────────────────────
279
- \`\`\`json
280
- ${JSON.stringify({viewName:e.tabName,viewTitle:e.tabTitle,route:e.route,template:e.template,storageEnabled:!!e.storage,showActionButton:!!e.showButton},null,2)}
281
- \`\`\`
275
+ [DESCRIBE FEATURE TO ADD HERE]`,ce=(e,t)=>{let n=(e.tabName||e.pageId||`shared_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`Create a microcomponent for the Shared view: \`${e.tabName}\`.
282
276
 
283
- ### ── Note on Forms ──────────────────────────────────────────────────────────
284
- **No forms are needed for this view.** Focus on building the collaborative features and shared content areas requested by the user.
277
+ ### ── Context ────────────────────────────────────────────────────────────────
278
+ - **Route**: \`${e.route}\`
279
+ - **Data Collection**: \`${t}\`
280
+ - **Storage**: ${e.storage?`Enabled (mem_files/)`:`Disabled`}
281
+ - **Security**: Data is visible to all authenticated members. Only admins and the original creator can edit/delete.
282
+ - **Examples Folder**: Check \`src/your-ai-workflow-firebase-os/microcomponents/\` for reference examples of how to build and insert microcomponents.
285
283
 
286
- ### ── Data & Storage Architecture ─────────────────────────────────────────────
287
- All logged-in members share the data on this page. The system is configured for collaboration:
288
- - **Firestore Collection**: \`${t}\`. All authenticated users can read and create records here. The template ensures only creators can edit/delete their own items.
289
- - **Storage Layer**: ${e.storage?"Enabled. Shared files are saved to `mem_files/` and are visible to all members.":`Disabled for this view.`}
290
- - **Access Level**: Shared Member Access. Requires authentication.
284
+ ### ── Your Task ──────────────────────────────────────────────────────────────
285
+ 1. **Create Microcomponent**: Build \`src/microcomponents/${r}.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top.
286
+ 2. **Handle UX/UI**: Implement the required shared dashboard interface (charts, lists, management tools). Write your own Firebase queries using the provided collection. No forms are needed.
287
+ 3. **Register Route**: In \`src/App.tsx\`, map your microcomponent to the \`customRoutes\` prop of \`<FirebaseOS>\`:
291
288
 
292
- ### ── Your Mission ────────────────────────────────────────────────────────────
293
- 1. **Create the Page**: Create a full page component at \`src/pages/\${microName}Page.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top of the content area.
294
- 2. **Handle UX/UI**: Inside this component, build the collaborative interface (group lists, message boards, shared resource trackers).
295
- 3. **Register the Route**: Open \`src/App.tsx\` and map this component to the \`customRoutes\` prop of \`<FirebaseOS>\`:
296
289
  \`\`\`tsx
297
- import { \${microName}Page } from './pages/\${microName}Page';
290
+ import { ${r} } from './microcomponents/${r}';
298
291
 
299
292
  // Inside App.tsx:
300
293
  <FirebaseOS
301
294
  customRoutes={{
302
- '\${config.route}': \${microName}Page
295
+ '${e.route}': ${r}
303
296
  }}
304
297
  // ...
305
298
  />
306
299
  \`\`\`
307
300
 
308
- ### ── Guardrails ─────────────────────────────────────────────────────────────
309
- - **CRITICAL: DO NOT CREATE A NEW ROUTE IN REACT ROUTER.** You are only mapping a component to an existing dynamic route via \\\`customRoutes\\\`.
310
- - **Database Logic**: You must write your own database queries inside the component using the provided collection names.
311
- - **NEVER** expose administrative control settings in this shared view.
301
+ ### ── Guidelines ─────────────────────────────────────────────────────────────
302
+ - **Use Theme Tokens**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-border)\`.
303
+ - **Pre-built UI**: Import \`{ Button, Input, ConfirmModal }\` from \`your-ai-workflow-firebase-os\`.
304
+ - **Layout**: Use \`glass-panel\` class for cards. DO NOT add redundant \`<h1>\` page titles (the layout handles this).
305
+ - **DO NOT create React Router routes**. Only use the \`customRoutes\` mapping.
312
306
 
313
- ### ── Aesthetic & Performance (Theme System) ───────────────────────────────
314
- Build with the user's active theme in mind:
315
- - **CSS Variables**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-bg)\`, \`var(--panel-border)\`.
316
- - **Components**: Re-use \`<Button />\`, \`<Input />\`, \`<ConfirmModal />\`, and \`<DashboardNav />\` natively.
317
- - **Styles**: Use \`glass-panel\` and \`text-gradient\` for a premium look.
318
- - **Example**: See \`src/microcomponents/SharedExampleContent.tsx\` for a structural reference.
319
-
320
- ### ── Important Formatting Rules ──────────────────────────────────────────────
321
- - **NO REDUNDANT HEADERS**: The parent template already injects a large dynamic page title and action buttons. DO NOT add a main \`<h1>\` or \`<h2>\` page title at the top of your micro-component. Start directly with your cards, lists, or sub-sections.
322
-
323
- [WHAT SHARED FEATURE SHOULD I BUILD IN THIS VIEW?]`},le=(e,t)=>{let n=(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`);return`${n.charAt(0).toUpperCase()}${n.slice(1)}`,`I need your help building the inner functionality for an **already existing** Admin View. This view is powered by the \`AdminPageTemplate\` (located at \`src/templates/AdminPageTemplate.tsx\`).
324
-
325
- The "infrastructure" (routing, header, database connection) is entirely set up and functioning. Your goal is to design the "Dashboard Content" that lives inside this specific admin view.
326
-
327
- ### ── Current View Configuration ──────────────────────────────────────────────
328
- \`\`\`json
329
- ${JSON.stringify({viewName:e.tabName,viewTitle:e.tabTitle,route:e.route,template:e.template,storageEnabled:!!e.storage,showActionButton:!!e.showButton,buttonStyle:e.buttonAction||`primary`},null,2)}
330
- \`\`\`
307
+ [WHAT FEATURES SHOULD I ADD TO THIS SHARED VIEW?]`},le=(e,t)=>{let n=(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`Create a microcomponent for the Admin view: \`${e.tabName}\`.
331
308
 
332
- ### ── Note on Forms ──────────────────────────────────────────────────────────
333
- **No forms are needed for this view.** Focus on building the administrative dashboard and management tools requested by the user.
309
+ ### ── Context ────────────────────────────────────────────────────────────────
310
+ - **Route**: \`${e.route}\`
311
+ - **Data Collection**: \`${t}\`
312
+ - **Storage**: ${e.storage?`Enabled (admin_files/)`:`Disabled`}
313
+ - **Examples Folder**: Check \`src/your-ai-workflow-firebase-os/microcomponents/\` for reference examples of how to build and insert microcomponents.
334
314
 
335
- ### ── Data & Storage Architecture ─────────────────────────────────────────────
336
- The app is already configured to handle data for this specific view using these paths:
337
- - **Firestore Collection**: \`${t}\` (Use this for all view data).
338
- - **Storage Layer**: ${e.storage?"Enabled. Uploads are handled via `admin_files/` folder in Storage and mirrored to a shared Firestore collection for tracking.":`Disabled for this view.`}
339
- - **Access Level**: Full Admin Access. This view is only visible to users with the 'admin' role.
315
+ ### ── Your Task ──────────────────────────────────────────────────────────────
316
+ 1. **Create Microcomponent**: Build \`src/microcomponents/${r}.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top.
317
+ 2. **Handle UX/UI**: Implement the required admin dashboard interface (charts, lists, management tools). Write your own Firebase queries using the provided collection. No forms are needed.
318
+ 3. **Register Route**: In \`src/App.tsx\`, map your microcomponent to the \`customRoutes\` prop of \`<FirebaseOS>\`:
340
319
 
341
- ### ── Your Mission ────────────────────────────────────────────────────────────
342
- 1. **Create the Page**: Create a full page component at \`src/pages/\${microName}Page.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top of the content area.
343
- 2. **Handle UX/UI**: Inside this component, build the interface (lists, charts, management forms, or any feature requested).
344
- 3. **Register the Route**: Open \`src/App.tsx\` and map this component to the \`customRoutes\` prop of \`<FirebaseOS>\`:
345
320
  \`\`\`tsx
346
- import { \${microName}Page } from './pages/\${microName}Page';
321
+ import { ${r} } from './microcomponents/${r}';
347
322
 
348
323
  // Inside App.tsx:
349
324
  <FirebaseOS
350
325
  customRoutes={{
351
- '\${config.route}': \${microName}Page
326
+ '${e.route}': ${r}
352
327
  }}
353
328
  // ...
354
329
  />
355
330
  \`\`\`
356
331
 
357
- ### ── Guardrails ─────────────────────────────────────────────────────────────
358
- - **CRITICAL: DO NOT CREATE A NEW ROUTE IN REACT ROUTER.** You are only mapping a component to an existing dynamic route via \\\`customRoutes\\\`.
359
- - **Database Logic**: You must write your own database queries inside the component using the provided collection names.
360
-
361
- ### ── Aesthetic & Performance (Theme System) ───────────────────────────────
362
- Build with the user's active theme in mind:
363
- - **CSS Variables**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-bg)\`, \`var(--panel-border)\`.
364
- - **Components**: Re-use \`<Button />\`, \`<Input />\`, \`<ConfirmModal />\`, and \`<DashboardNav />\` natively.
365
- - **Styles**: Use \`glass-panel\` and \`text-gradient\` for a premium look.
366
- - **Example**: See \`src/microcomponents/AdminExampleContent.tsx\` for a structural reference.
367
-
368
- ### ── Important Formatting Rules ──────────────────────────────────────────────
369
- - **NO REDUNDANT HEADERS**: The parent template already injects a large dynamic page title and action buttons. DO NOT add a main \`<h1>\` or \`<h2>\` page title at the top of your micro-component. Start directly with your cards, lists, or sub-sections.
332
+ ### ── Guidelines ─────────────────────────────────────────────────────────────
333
+ - **Use Theme Tokens**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-border)\`.
334
+ - **Pre-built UI**: Import \`{ Button, Input, ConfirmModal }\` from \`your-ai-workflow-firebase-os\`.
335
+ - **Layout**: Use \`glass-panel\` class for cards. DO NOT add redundant \`<h1>\` page titles (the layout handles this).
336
+ - **DO NOT create React Router routes**. Only use the \`customRoutes\` mapping.
370
337
 
371
- [WHAT FEATURES SHOULD I ADD TO THIS ADMIN VIEW?]`},ue=(e,t,n=[])=>{let r=(e.tabName||e.pageId||`private_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`);return`${r.charAt(0).toUpperCase()}${r.slice(1)}`,`I need your help building the inner functionality for an **already existing** Private User View. This view is powered by the \`PrivatePageTemplate\` (located at \`src/templates/PrivatePageTemplate.tsx\`).
338
+ [WHAT FEATURES SHOULD I ADD TO THIS ADMIN VIEW?]`},ue=(e,t)=>{let n=(e.tabName||e.pageId||`private_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),r=`${n.charAt(0).toUpperCase()}${n.slice(1)}Content`;return`Create a microcomponent for the Private view: \`${e.tabName}\`.
372
339
 
373
- The "infrastructure" (auth-guards, dynamic routing, navigation menus, database sync) is entirely set up and functioning. Your task is strictly to design the "Dashboard Content" that lives inside this specific user view.
340
+ ### ── Context ────────────────────────────────────────────────────────────────
341
+ - **Route**: \`${e.route}\`
342
+ - **Data Collection**: \`${t}\`
343
+ - **Storage**: ${e.storage?`Enabled (user_files/)`:`Disabled`}
344
+ - **Security**: Data must be filtered by \`where('uid', '==', user.uid)\`.
345
+ - **Examples Folder**: Check \`src/your-ai-workflow-firebase-os/microcomponents/\` for reference examples of how to build and insert microcomponents.
374
346
 
375
- ### ── Current View Configuration ──────────────────────────────────────────────
376
- \`\`\`json
377
- ${JSON.stringify({viewName:e.tabName,viewTitle:e.tabTitle,route:e.route,template:e.template,storageEnabled:!!e.storage,showActionButton:!!e.showButton,availablePrivateForms:n},null,2)}
378
- \`\`\`
347
+ ### ── Your Task ──────────────────────────────────────────────────────────────
348
+ 1. **Create Microcomponent**: Build \`src/microcomponents/${r}.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top.
349
+ 2. **Handle UX/UI**: Implement the required private dashboard interface (charts, lists, management tools). Write your own Firebase queries using the provided collection. No forms are needed.
350
+ 3. **Register Route**: In \`src/App.tsx\`, map your microcomponent to the \`customRoutes\` prop of \`<FirebaseOS>\`:
379
351
 
380
- ### ── Available Forms ────────────────────────────────────────────────────────
381
- The following private forms are available in the system. **These are for your information only—do NOT use them unless specifically needed.** Your priority is to listen to the user's specific input and decide if a particular modal, form, or component is actually required for the context of this page:
382
- ${n.length>0?n.map(e=>`- ${e}`).join(`
383
- `):`- No private forms found`}
384
-
385
- ### ── Data & Storage Architecture ─────────────────────────────────────────────
386
- Every user sees their own unique data on this page. The system is rigged to handle this isolation:
387
- - **Firestore Collection**: \`${t}\`. The template already filters this by \`uid == current_user.uid\`. Use this for all record storage.
388
- - **Storage Layer**: ${e.storage?"Enabled. User files are saved to `user_files/` and strictly isolated by user ID.":`Disabled for this view.`}
389
- - **Access Level**: Private. Only the owner of the data can view or modify these records.
390
-
391
- ### ── Your Mission ────────────────────────────────────────────────────────────
392
- 1. **Create the Page**: Create a full page component at \`src/pages/\${microName}Page.tsx\`. Include \`<DashboardNav />\` from \`your-ai-workflow-firebase-os\` at the top of the content area.
393
- 2. **Handle UX/UI**: Inside this component, build the interface (lists, charts, forms, etc).
394
- 3. **Register the Route**: Open \`src/App.tsx\` and map this component to the \`customRoutes\` prop of \`<FirebaseOS>\`:
395
352
  \`\`\`tsx
396
- import { \${microName}Page } from './pages/\${microName}Page';
353
+ import { ${r} } from './microcomponents/${r}';
397
354
 
398
355
  // Inside App.tsx:
399
356
  <FirebaseOS
400
357
  customRoutes={{
401
- '\${config.route}': \${microName}Page
358
+ '${e.route}': ${r}
402
359
  }}
403
360
  // ...
404
361
  />
405
362
  \`\`\`
406
363
 
407
- ### ── Guardrails ─────────────────────────────────────────────────────────────
408
- - **CRITICAL: DO NOT CREATE A NEW ROUTE IN REACT ROUTER.** You are only mapping a component to an existing dynamic route via \\\`customRoutes\\\`.
409
- - **Database Logic**: You must write your own database queries inside the component using the provided collection names.
410
- - Re-use the \`ContactPopup\` component with the available private forms if the user needs to submit requests.
411
-
412
- ### ── Aesthetic & Performance (Theme System) ───────────────────────────────
413
- Build with the user's active theme in mind:
414
- - **CSS Variables**: Use \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-bg)\`, \`var(--panel-border)\`.
415
- - **Components**: Re-use \`<Button />\`, \`<Input />\`, \`<ConfirmModal />\`, and \`<DashboardNav />\` natively.
416
- - **Styles**: Use \`glass-panel\` and \`text-gradient\` for a premium look.
417
- - **Example**: See \`src/microcomponents/PrivateExampleContent.tsx\` for a structural reference.
418
-
419
- ### ── Important Formatting Rules ──────────────────────────────────────────────
420
- - **NO REDUNDANT HEADERS**: The parent template already injects a large dynamic page title and action buttons. DO NOT add a main \`<h1>\` or \`<h2>\` page title at the top of your micro-component. Start directly with your cards, lists, or sub-sections.
364
+ ### ── Guidelines ─────────────────────────────────────────────────────────────
365
+ - **Use Theme Tokens**: \`var(--bg-color)\`, \`var(--fg-color)\`, \`var(--accent-color)\`, \`var(--panel-border)\`.
366
+ - **Pre-built UI**: Import \`{ Button, Input, ConfirmModal }\` from \`your-ai-workflow-firebase-os\`.
367
+ - **Layout**: Use \`glass-panel\` class for cards. DO NOT add redundant \`<h1>\` page titles (the layout handles this).
368
+ - **DO NOT create React Router routes**. Only use the \`customRoutes\` mapping.
421
369
 
422
- [WHAT SHOULD I BUILD INSIDE THIS PRIVATE VIEW?]`},de=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function fe({title:e=`Board View`,subtitle:t=`/templates/board`,backUrl:r=`/templates`,tasksCollection:i=`pub_tasks`,categoriesCollection:s=`pub_categories`,config:c}){let{user:d}=m(),f=!!c;c?.isPrivate&&!c?.isAdmin&&c?.isShared;let p=c?.isAdmin||c?.isShared,h=f?p:!0,g=c?.showButton!==!1,_=c?.buttonText||`+`,v=c?.buttonStyle||`primary`,y=c?.keyName||`key`,b=c?.valueName||`value`,[x,S]=(0,a.useState)([]),[C,w]=(0,a.useState)([]),[T,E]=(0,a.useState)([]),[D,O]=(0,a.useState)(null),[k,A]=(0,a.useState)(null),[j,M]=(0,a.useState)({name:``}),[N,ne]=(0,a.useState)([]),[P,F]=(0,a.useState)(null),[re,I]=(0,a.useState)(null),[L,R]=(0,a.useState)(null),[ie,z]=(0,a.useState)(null),[B,V]=(0,a.useState)(!1),[H,U]=(0,a.useState)(null),[W,G]=(0,a.useState)(``),[K,oe]=(0,a.useState)(null),[Y,se]=(0,a.useState)(!1),ce=c?.isAdmin?q(c,e,i,s):c?.isPrivate?ae(c,e,i,s,T):J(c,e,i,s,T),le=()=>{navigator.clipboard.writeText(ce),se(!0),setTimeout(()=>se(!1),2e3)};(0,a.useEffect)(()=>{let e=c?.isShared,t=c?.isAdmin,r=c?.isPrivate&&!t&&!e,a=!t&&!e&&!r;r||a?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=a?`public`:`private`;E(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):E([]);let l=i.startsWith(`user_`),u=s.startsWith(`user_`);if(l&&!d)return;try{let e=localStorage.getItem(`fbos_board_tasks_${i}`);e&&S(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${s}`);t&&w(JSON.parse(t))}catch{}let f=(0,o.onSnapshot)(l&&d?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,d.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];e.forEach(e=>{let n=e.data();t.push({id:e.id,categoryId:n.categoryId,name:n.name||n.text||`Unnamed Item`,fields:n.fields||(n.value?[{key:`Label`,value:n.value}]:[]),order:n.order||0})});let n=t.sort((e,t)=>(e.order||0)-(t.order||0));S(n),localStorage.setItem(`fbos_board_tasks_${i}`,JSON.stringify(n))}),p=(0,o.onSnapshot)(u&&d?(0,o.query)((0,o.collection)(n.Tt,s),(0,o.where)(`uid`,`==`,d.uid)):(0,o.collection)(n.Tt,s),e=>{let t=[];if(e.forEach(e=>{t.push({id:e.id,...e.data()})}),t.length===0){let e=[{id:`todo`,title:`To Do`,createdAt:Date.now()-2e3},{id:`in_progress`,title:`In Progress`,createdAt:Date.now()-1e3},{id:`review`,title:`Review`,createdAt:Date.now()}],t=d?{uid:d.uid}:{};e.forEach(e=>(0,o.setDoc)((0,o.doc)(n.Tt,s,e.id),{...t,title:e.title,createdAt:e.createdAt}))}else w(t),localStorage.setItem(`fbos_board_cats_${s}`,JSON.stringify(t))});return()=>{f(),p()}},[i,s,d]);let ue=(e,t)=>{t?(A(t.id),M({id:t.id,name:t.name}),ne(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(O(e),M({name:``}),ne([{key:``,value:``}]))},fe=(e,t,n)=>{let r=[...N];r[e]={key:t,value:n},e===N.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),ne(r)},X=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`taskId`,t),F(t)},pe=(e,t)=>{e.preventDefault(),e.stopPropagation(),t!==P&&I(t)},me=(e,t)=>{e.preventDefault(),e.stopPropagation(),R(t)},Z=e=>{e.preventDefault(),I(null),R(null)},he=async(e,t,r)=>{e.preventDefault(),e.stopPropagation(),I(null),R(null);let a=e.dataTransfer.getData(`taskId`);if(!a||a===r){F(null);return}let s=x.find(e=>e.id===a);if(!s)return;let c=x.filter(e=>e.categoryId===t).sort((e,t)=>(e.order||0)-(t.order||0));if(s.categoryId===t?(c=c.filter(e=>e.id!==a),c.push(s)):c.push({...s,categoryId:t}),r){let e=c.findIndex(e=>e.id===r),t=c.findIndex(e=>e.id===a),[n]=c.splice(t,1);c.splice(e,0,n)}c.forEach((e,r)=>{let a={categoryId:t,order:r};d&&(a.uid=d.uid),(0,o.setDoc)((0,o.doc)(n.Tt,i,e.id),a,{merge:!0})}),F(null)},ge=async e=>{let t=j.id||`item_${Date.now()}`,r=j.name.trim(),a=r||`Untitled Item`,s=N.filter(e=>e.key.trim()!==``||e.value.trim()!==``),c=!0,l=j.id?x.find(e=>e.id===j.id):null;if(l){let e=JSON.stringify(l.fields||[]),t=JSON.stringify(s);l.name===a&&e===t&&(c=!1)}else !r&&s.length===0&&(c=!1);if(!c){O(null),A(null);return}z(j.id||`new`);let u={categoryId:e,name:a,fields:s};d&&!j.id&&(u.uid=d.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,i,t),u,{merge:!0}),setTimeout(()=>{O(null),A(null),z(null)},400)},_e=(e,t)=>{oe({type:`item`,id:e,title:t})},ve=async()=>{let e=`cat_${Date.now()}`,t={title:``,createdAt:Date.now()};d&&(t.uid=d.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,s,e),t),U(e),G(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},Q=async e=>{W.trim()?await(0,o.setDoc)((0,o.doc)(n.Tt,s,e),{title:W},{merge:!0}):await(0,o.deleteDoc)((0,o.doc)(n.Tt,s,e)),U(null)},ye=(e,t)=>{oe({type:`category`,id:e,title:t})},be=async()=>{if(K){V(!0);try{if(K.type===`item`)await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,K.id)),A(null);else{let e=x.filter(e=>e.categoryId===K.id);for(let t of e)await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,t.id));await(0,o.deleteDoc)((0,o.doc)(n.Tt,s,K.id))}}catch{}V(!1),oe(null)}},xe=[...C].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen overflow-x-hidden`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),f&&(0,l.jsx)(`div`,{className:`mb-6`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-start sm:items-center mb-6 border-b border-[var(--panel-border)] pb-6 gap-4 relative z-20 shrink-0`,children:[!f&&r&&(0,l.jsxs)(u.Link,{to:r,className:`px-5 py-2 hover:bg-foreground/5 transition-all flex items-center gap-2`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}),f&&(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:c?.tabTitle||c?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[x.length,` `,x.length===1?`item`:`items`,` · `,xe.length,` `,xe.length===1?`category`:`categories`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 w-full sm:w-auto`,children:[c?.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:le,title:Y?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${Y?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-lg`}`,children:Y?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),g&&(0,l.jsx)(n.n,{variant:v===`secondary`?`secondary`:void 0,onClick:ve,className:`flex-1 sm:flex-none px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:_===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):_})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0`,children:(0,l.jsxs)(`div`,{id:`board-container`,className:`w-full h-full flex flex-row gap-4 md:gap-6 overflow-x-auto pb-4 snap-x snap-mandatory styled-scrollbars items-start`,children:[xe.map((e,t)=>{let r=x.filter(t=>t.categoryId===e.id);r.sort((e,t)=>(e.order||0)-(t.order||0));let i=de.find(t=>t.text===e.color)||de.find(e=>e.text===`text-accent`);return i.text,i.bgLight,i.bgHover,(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.1},className:`w-[300px] md:w-[320px] shrink-0 flex flex-col max-h-full rounded-3xl p-4 snap-center relative border transition-colors ${de.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${de.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,l.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[H===e.id?(0,l.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Q(e.id)}}),(0,l.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),onBlur:t=>{t.relatedTarget?.closest(`.category-color-picker`)||Q(e.id)},onKeyDown:t=>t.key===`Enter`&&Q(e.id),className:`bg-transparent border-none outline-none font-bold text-[14px] w-full p-0 ${e.color||`text-foreground/80`}`,placeholder:`Category name`}),(0,l.jsxs)(`div`,{className:`absolute top-8 left-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-[100] category-color-picker items-center`,tabIndex:-1,children:[(0,l.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await(0,o.setDoc)((0,o.doc)(n.Tt,`pub_categories`,e.id),{color:``},{merge:!0}),U(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Reset Category Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),de.map(t=>(0,l.jsx)(`button`,{onMouseDown:async r=>{r.preventDefault(),await(0,o.setDoc)((0,o.doc)(n.Tt,`pub_categories`,e.id),{color:t.text},{merge:!0})},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]}):(0,l.jsxs)(`div`,{className:`flex items-center gap-2 w-full cursor-pointer hover:text-foreground transition-colors pr-8`,onClick:()=>{U(e.id),G(e.title)},children:[(0,l.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${de.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,l.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,l.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:r.length})]}),C.length>1&&(0,l.jsx)(`button`,{onClick:()=>ye(e.id,e.title),className:`absolute right-0 opacity-0 group-hover:opacity-100 text-foreground/30 hover:text-red-500 transition-all shrink-0`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-all ${L===e.id&&!re?`bg-foreground/5 scale-[1.01] border-dashed border border-accent/20`:``}`,onDragOver:t=>me(t,e.id),onDragLeave:Z,onDrop:t=>he(t,e.id),children:[(0,l.jsx)(n.a,{children:r.map(t=>k===t.id?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100]`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),ge(e.id)}}),(0,l.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))}}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,l.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,l.jsx)(`input`,{placeholder:y,value:t.key,onChange:e=>fe(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&ge(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px] shrink-0`,style:{width:`${Math.max(3,t.key.length||y.length)}ch`}}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,l.jsx)(`textarea`,{rows:1,placeholder:b,value:t.value,onChange:e=>fe(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),ie===t.id&&(0,l.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,l.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},t.id):(0,l.jsxs)(n.i.div,{draggable:!0,onDragStart:e=>X(e,t.id),onDragOver:e=>pe(e,t.id),onDragLeave:Z,onDrop:n=>he(n,e.id,t.id),initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md cursor-grab active:cursor-grabbing hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${re===t.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${P===t.id?`opacity-30 scale-95 border-dashed border-2`:``}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity bg-background/90 backdrop-blur-md border border-[var(--panel-border)] rounded-lg p-1 z-20 shadow-md`,children:[(0,l.jsx)(`button`,{onClick:n=>{n.stopPropagation(),ue(e.id,t)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),_e(t.id,t.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})})]}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:t.name}),t.fields&&t.fields.length>0&&(0,l.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:t.fields.map((e,t)=>(0,l.jsxs)(`div`,{className:`inline-flex bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 max-w-full`,children:[(0,l.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,l.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[h&&f&&d?(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[d.photoURL?(0,l.jsx)(`img`,{src:d.photoURL,className:`w-4 h-4 rounded-full shrink-0 object-cover`}):(0,l.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[9px] font-bold shrink-0`,children:(d.displayName||d.email||`U`)[0].toUpperCase()}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:d.displayName||d.email?.split(`@`)[0]||`User`})]}):(0,l.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`}),(0,l.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:t.id.startsWith(`item_`)?new Date(parseInt(t.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})]},t.id))}),D===e.id?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100] mt-1`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),ge(e.id)}}),(0,l.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},autoFocus:!0}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,l.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,l.jsx)(`input`,{placeholder:y,style:{width:`${Math.max(3,t.key.length||y.length)}ch`},value:t.key,onChange:e=>fe(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&ge(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,l.jsx)(`textarea`,{rows:1,placeholder:b,value:t.value,onChange:e=>fe(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),ie===`new`&&(0,l.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,l.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,l.jsxs)(`button`,{onClick:()=>ue(e.id),className:`flex items-center gap-2 justify-center w-full py-2.5 mt-1 rounded-xl border border-transparent text-[12px] font-bold text-foreground/40 hover:text-foreground hover:bg-foreground/[0.03] transition-all shrink-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,l.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`})]})}),(0,l.jsx)(`style`,{children:`.styled-scrollbars::-webkit-scrollbar { width: 6px; height: 6px; } .styled-scrollbars::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent-color) 20%, transparent); border-radius: 4px; } .styled-scrollbars::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent-color) 40%, transparent); }`}),(0,l.jsx)(te,{isOpen:!!K,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:K?.title}),` This action is permanent.`]}),onConfirm:be,onCancel:()=>oe(null),isProcessing:B,confirmText:`Yes, Delete`})]})}function X(e){return Array.isArray?Array.isArray(e):be(e)===`[object Array]`}function pe(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function me(e){return e==null?``:pe(e)}function Z(e){return typeof e==`string`}function he(e){return typeof e==`number`}function ge(e){return e===!0||e===!1||ve(e)&&be(e)==`[object Boolean]`}function _e(e){return typeof e==`object`}function ve(e){return _e(e)&&e!==null}function Q(e){return e!=null}function ye(e){return!e.trim().length}function be(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var xe=`Incorrect 'index' type`,Se=e=>`Invalid value for key ${e}`,Ce=e=>`Pattern length exceeds max of ${e}.`,we=e=>`Missing ${e} property in key`,Te=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ee=Object.prototype.hasOwnProperty,De=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Oe(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Oe(e){let t=null,n=null,r=null,i=1,a=null;if(Z(e)||X(e))r=e,t=ke(e),n=Ae(e);else{if(!Ee.call(e,`name`))throw Error(we(`name`));let o=e.name;if(r=o,Ee.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(Te(o));t=ke(o),n=Ae(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function ke(e){return X(e)?e:e.split(`.`)}function Ae(e){return X(e)?e.join(`.`):e}function je(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Q(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Q(s))return;if(a===t.length-1&&(Z(s)||he(s)||ge(s)||typeof s==`bigint`))n.push(o===void 0?me(s):{v:me(s),i:o});else if(X(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,Z(t)?t.split(`.`):t,0),r?n:n[0]}var Me={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ne={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Pe={location:0,threshold:.6,distance:100},Fe={useExtendedSearch:!1,useTokenSearch:!1,getFn:je,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...Ne,...Me,...Pe,...Fe}),Ie=/[^ ]+/g;function Le(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(Ie).length;if(n.has(i))return n.get(i);let a=1/i**(.5*e),o=parseFloat(Math.round(a*r)/r);return n.set(i,o),o},clear(){n.clear()}}}var Re=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=Le(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Z(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){let t=this.size();Z(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)--this.records[t].i}removeAll(e){for(let t=e.length-1;t>=0;--t)this.records.splice(e[t],1);for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i=e}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Q(e)||ye(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((t,r)=>{let i=t.getFn?t.getFn(e):this.getFn(e,t.path);if(Q(i)){if(X(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Q(n)){if(Z(n)){if(!ye(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Q(n.v)){let t=Z(n.v)?n.v:me(n.v);if(!ye(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(Z(i)&&!ye(i)){let e={v:i,n:this.norm.get(i)};n.$[r]=e}}}),this.records.push(n)}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function ze(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new Re({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Oe)),i.setSources(t),i.create(),i}function Be(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Re({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function Ve(e=[],t=$.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}var He=32;function Ue(e,t,n,{location:r=$.location,distance:i=$.distance,threshold:a=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:s=$.minMatchCharLength,includeMatches:c=$.includeMatches,ignoreLocation:l=$.ignoreLocation}={}){if(t.length>He)throw Error(Ce(He));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=u+d,S=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=x;for(;r<i;)h(t,f+i)<=p?r=i:x=i,i=Math.floor((x-r)/2+r);x=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(g&&(_[i]=+!!o),c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&S&&(b=h(t,i),b<=p)){if(p=b,m=i,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}let C={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=Ve(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function We(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function Ge(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var Ke={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},qe=RegExp(`[`+Object.keys(Ke).join(``)+`]`,`g`),Je=String.prototype.normalize?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(qe,e=>Ke[e]):e=>e,Ye=class{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Je(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:We(e),startIndex:t})},d=this.pattern.length;if(d>He){let e=0,t=d%He,n=d-t;for(;e<n;)u(this.pattern.substr(e,He),e),e+=He;if(t){let e=d-He;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Je(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=Ue(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=Ge(u)),p}},Xe=class{constructor(e){this.pattern=e}static isMultiMatch(e){return Ze(e,this.multiRegex)}static isSingleMatch(e){return Ze(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function Ze(e,t){let n=e.match(t);return n?n[1]:null}var Qe=class extends Xe{constructor(e){super(e)}static get type(){return`exact`}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){let t=e===this.pattern;return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},$e=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-exact`}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){let t=e.indexOf(this.pattern)===-1;return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},et=class extends Xe{constructor(e){super(e)}static get type(){return`prefix-exact`}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){let t=e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},tt=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-prefix-exact`}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){let t=!e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},nt=class extends Xe{constructor(e){super(e)}static get type(){return`suffix-exact`}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){let t=e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[e.length-this.pattern.length,e.length-1]}}},rt=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-suffix-exact`}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){let t=!e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},it=class extends Xe{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){super(e),this._bitapSearch=new Ye(e,{location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return`fuzzy`}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}},at=class extends Xe{constructor(e){super(e)}static get type(){return`include`}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n,r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+i,r.push([n,t-1]);let a=!!r.length;return{isMatch:a,score:+!a,indices:r}}},ot=[Qe,at,et,tt,rt,nt,$e,it],st=ot.length,ct=`\0`,lt=`|`;function ut(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function dt(e,t={}){return e.replace(/\\\|/g,ct).split(lt).map(e=>{let n=ut(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<st;){let e=ot[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<st;){let e=ot[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var ft=new Set([it.type,at.type]),pt=class{constructor(e,{isCaseSensitive:t=$.isCaseSensitive,ignoreDiacritics:n=$.ignoreDiacritics,includeMatches:r=$.includeMatches,minMatchCharLength:i=$.minMatchCharLength,ignoreLocation:a=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:s=$.location,threshold:c=$.threshold,distance:l=$.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Je(e):e,this.pattern=e,this.query=dt(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Je(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l){a+=1,s+=d;let e=r.constructor.type;e.startsWith(`inverse`)&&(c=!0),n&&(ft.has(e)?o.push(...u):o.push(u))}else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=Ge(o)),e}}return{isMatch:!1,score:1}}},mt=[];function ht(...e){mt.push(...e)}function gt(e,t){for(let n=0,r=mt.length;n<r;n+=1){let r=mt[n];if(r.condition(e,t))return new r(e,t)}return new Ye(e,t)}var _t={AND:`$and`,OR:`$or`},vt={PATH:`$path`,PATTERN:`$val`},yt=e=>!!(e[_t.AND]||e[_t.OR]),bt=e=>!!e[vt.PATH],xt=e=>!X(e)&&_e(e)&&!yt(e),St=e=>({[_t.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Ct(e,t,{auto:n=!0}={}){let r=e=>{if(Z(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=gt(e,t)),r}let i=Object.keys(e),a=bt(e);if(!a&&i.length>1&&!yt(e))return r(St(e));if(xt(e)){let r=a?e[vt.PATH]:i[0],o=a?e[vt.PATTERN]:e[r];if(!Z(o))throw Error(Se(r));let s={keyId:Ae(r),pattern:o};return n&&(s.searcher=gt(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];X(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return yt(e)||(e=St(e)),r(e)}function wt(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function Tt(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=wt(e.matches,{ignoreFieldNorm:t})})}var Et=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function Dt(e,t){let n=e.matches;t.matches=[],Q(n)&&n.forEach(e=>{if(!Q(e.indices)||!e.indices.length)return;let{indices:n,value:r}=e,i={indices:n,value:r};e.key&&(i.key=e.key.src),e.idx>-1&&(i.refIndex=e.idx),t.matches.push(i)})}function Ot(e,t){t.score=e.score}function kt(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(Dt),r&&i.push(Ot),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var At=/\b\w+\b/g;function jt({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Je(n)),n.match(At)||[]}}}function Mt(e,t,n){let r=new Map,i=new Map,a=0;function o(e,t,o,s){let c=n.tokenize(e);if(!c.length)return;a++;let l=new Map;for(let e of c)l.set(e,(l.get(e)||0)+1);for(let[e,n]of l){let a={docIdx:t,keyIdx:o,subIdx:s,tf:n},c=r.get(e);c||(c=[],r.set(e,c)),c.push(a),i.set(e,(i.get(e)||0)+1)}}for(let n of e){let{i:e,v:r,$:i}=n;if(r!==void 0){o(r,e,-1,-1);continue}if(i)for(let n=0;n<t;n++){let t=i[n];if(t)if(Array.isArray(t))for(let r of t)o(r.v,e,n,r.i??-1);else o(t.v,e,n,-1)}}return{terms:r,fieldCount:a,df:i}}function Nt(e,t,n,r){let{i,v:a,$:o}=t;function s(t,n,a){let o=r.tokenize(t);if(!o.length)return;e.fieldCount++;let s=new Map;for(let e of o)s.set(e,(s.get(e)||0)+1);for(let[t,r]of s){let o={docIdx:i,keyIdx:n,subIdx:a,tf:r},s=e.terms.get(t);s||(s=[],e.terms.set(t,s)),s.push(o),e.df.set(t,(e.df.get(t)||0)+1)}}if(a!==void 0){s(a,-1,-1);return}if(o)for(let e=0;e<n;e++){let t=o[e];if(t)if(Array.isArray(t))for(let n of t)s(n.v,e,n.i??-1);else s(t.v,e,-1)}}function Pt(e,t){for(let[n,r]of e.terms){let i=r.filter(e=>e.docIdx!==t),a=r.length-i.length;a>0&&(e.fieldCount-=a,e.df.set(n,(e.df.get(n)||0)-a),i.length===0?(e.terms.delete(n),e.df.delete(n)):e.terms.set(n,i))}}var Ft=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new De(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=gt(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Re))throw Error(xe);if(this._myIndex=t||ze(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=jt({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=Mt(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(Q(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=jt({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});Nt(this._invertedIndex,e,this._myIndex.keys.length,t)}}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){if(this._invertedIndex)for(let e of n)Pt(this._invertedIndex,e);for(let e=n.length-1;e>=0;--e)this._docs.splice(n[e],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._invertedIndex&&Pt(this._invertedIndex,e);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),t}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(Z(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return he(n)&&n>-1&&(e=e.slice(0,n)),e}let c=he(n)&&n>0&&Z(e),l;if(c){let t=new Et(n);Z(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Z(e)?Z(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Tt(l,{ignoreFieldNorm:s}),a&&l.sort(o),he(n)&&n>-1&&(l=l.slice(0,n));return kt(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{records:i}=this._myIndex,a=t?null:[];return i.forEach(({v:e,i,n:o})=>{if(!Q(e))return;let{isMatch:s,score:c,indices:l}=r.searchIn(e);if(s){let r={item:e,idx:i,matches:[{score:c,value:e,norm:o,indices:l}]};t?(r.score=wt(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=Ct(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===_t.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Q(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{keys:i,records:a}=this._myIndex,o=t?null:[];return a.forEach(({$:e,i:a})=>{if(!Q(e))return;let s=[],c=!1,l=!1;if(i.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(s.push(...i),i[0].hasInverse&&(l=!0)):c=!0}),!(l&&c)&&s.length){let r={idx:a,item:e,matches:s};t?(r.score=wt(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!Q(t))return[];let r=[];if(X(t))t.forEach(({v:t,i,n:a})=>{if(!Q(t))return;let{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(t);o&&r.push({score:s,key:e,value:t,idx:i,norm:a,indices:c,hasInverse:l})});else{let{v:i,n:a}=t,{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(i);o&&r.push({score:s,key:e,value:i,norm:a,indices:c,hasInverse:l})}return r}},It=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=jt({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new Ye(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0;for(let a=0;a<this.termSearchers.length;a++){let o=this.termSearchers[a].searchIn(e),s=this.idfWeights[a];r+=s,o.isMatch&&(i++,n+=s*(1-o.score),o.indices&&t.push(...o.indices))}if(i===0)return{isMatch:!1,score:1};let a=r>0?1-n/r:0,o={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&t.length&&(o.indices=Ge(t)),o}};Ft.version=`7.3.0`,Ft.createIndex=ze,Ft.parseIndex=Be,Ft.config=$,Ft.match=function(e,t,n){return gt(e,{...$,...n}).searchIn(t)},Ft.parseQuery=Ct,ht(pt),ht(It),Ft.use=function(...e){e.forEach(e=>ht(e))};var Lt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function Rt({title:e=`Table View`,subtitle:t=`/templates/table`,backUrl:r=`/templates`,tableCollection:i=`pub_table_data`,config:s}){let{user:c}=m(),d=!!s;s?.isPrivate&&!s?.isAdmin&&s?.isShared;let f=s?.isAdmin||s?.isShared,p=d?f:!0,h=s?.showButton!==!1,g=s?.buttonText||`+`,_=s?.buttonStyle||`secondary`,v=s?.showExportButton!==!1,y=s?.showPrompt,[b,x]=(0,a.useState)([]),[S,C]=(0,a.useState)(`demo`),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(!1),[O,k]=(0,a.useState)(``),[A,te]=(0,a.useState)(!1),[j,M]=(0,a.useState)(!1),[N,ne]=(0,a.useState)([]),P=s?.isAdmin?Y(s,e,i):s?.isPrivate?oe(s,e,i,N):se(s,e,i,N),F=()=>{navigator.clipboard.writeText(P),M(!0),setTimeout(()=>M(!1),2e3)},[re,I]=(0,a.useState)(null),[L,R]=(0,a.useState)(null),[ie,z]=(0,a.useState)(``),[B,V]=(0,a.useState)(``),[H,U]=(0,a.useState)(null),[W,G]=(0,a.useState)(null),[K,ae]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=s?.isShared,t=s?.isAdmin,r=s?.isPrivate&&!t&&!e,a=!t&&!e&&!r;r||a?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=a?`public`:`private`;ne(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):ne([]);let l=i.startsWith(`user_`);if(l&&!c)return;try{let e=localStorage.getItem(`fbos_tables_${i}`);e&&x(JSON.parse(e))}catch{}let u=(0,o.onSnapshot)(l&&c?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,c.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];if(e.forEach(e=>{t.push({id:e.id,...e.data()})}),t.length===0){let e={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...c?{uid:c.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,o.setDoc)((0,o.doc)(n.Tt,i,`demo`),e)}else{let e=t.sort((e,t)=>(e.name||``).localeCompare(t.name||``));x(e),localStorage.setItem(`fbos_tables_${i}`,JSON.stringify(e))}});return()=>u()},[i,c]);let q=b.find(e=>e.id===S)||b[0]||{columns:[],rows:[]},J=async e=>{q.id&&(c&&i.startsWith(`user_`)&&(e.uid=c.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,i,q.id),e,{merge:!0}))},ce=()=>{if(!q.rows||q.rows.length===0)return;let e=q.columns.join(`,`),t=q.rows.map(e=>q.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
423
- `),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${q.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},le=(e,t,n)=>{J({...q,rows:q.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},ue=()=>{let e={id:Date.now().toString()};q.columns.forEach(t=>e[t]=``),J({...q,rows:[...q.rows||[],e]})},de=e=>{J({...q,rows:q.rows.filter(t=>t.id!==e)})},fe=()=>{let e=`Column ${(q.columns?.length||0)+1}`;q.columns?.includes(e)||(J({...q,columns:[...q.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},X=e=>{let t=(q.columns||[]).filter(t=>t!==e),n=(q.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...q.colColors||{}};delete r[e],J({...q,columns:t,rows:n,colColors:r})},pe=async e=>{e.trim()&&q.id&&e!==q.name&&await(0,o.setDoc)((0,o.doc)(n.Tt,i,q.id),{name:e},{merge:!0})},me=async()=>{te(!0),T(!1);let e=`tbl_${Date.now()}`;await(0,o.setDoc)((0,o.doc)(n.Tt,i,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...c?{uid:c.uid}:{},rows:[]}),setTimeout(()=>{C(e),te(!1)},600)},Z=e=>{let t=B.trim();if(t&&t!==e&&!q.columns?.includes(t)){let n=q.columns.map(n=>n===e?t:n),r=(q.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...q.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),J({...q,columns:n,rows:r,colColors:i})}R(null)},he=q.rows||[];return ie.trim()!==``&&(he=new Ft(he.map(e=>({...e,_creatorMatch:`Guest`})),{keys:(q.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(ie).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),d&&(0,l.jsx)(`div`,{className:`mb-6`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[!d&&r&&(0,l.jsxs)(u.Link,{to:r,className:`px-4 md:px-5 py-2.5 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` `,(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:`Go Back`})]}),d&&(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:s?.tabTitle||s?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[b.length,` `,b.length===1?`table`:`tables`]})]}),(0,l.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[y&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:F,title:j?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${j?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-lg`}`,children:j?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),v&&(0,l.jsx)(n.n,{variant:`secondary`,onClick:ce,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})}),h&&(0,l.jsx)(n.n,{variant:_===`primary`?void 0:`secondary`,onClick:ue,className:`px-3 py-2.5 font-bold rounded-xl border border-[var(--panel-border)] shadow-sm flex items-center gap-2`,children:g===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):g})]})]}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative z-10 block`,children:[(0,l.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,l.jsxs)(`div`,{className:`p-4 md:px-6 border-b border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between bg-foreground/[0.01] gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col w-full sm:w-auto relative`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,l.jsxs)(`div`,{className:`relative flex items-center`,children:[E?(0,l.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{D(!1),pe(e.currentTarget.textContent||``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent border-b-2 border-accent outline-none text-[16px] font-bold text-foreground inline-block min-w-[20px] whitespace-nowrap px-1 py-0.5`,children:q.name||`Unnamed Table`}):(0,l.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 cursor-pointer hover:text-accent transition-colors truncate max-w-[200px]`,onClick:()=>D(!0),title:`Click to rename table`,children:q.name||`Unnamed Table`}),(0,l.jsx)(n.a,{children:w&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>T(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`absolute top-[120%] left-0 w-[220px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 py-2 flex flex-col`,children:[(0,l.jsx)(`div`,{className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-foreground/40 border-b border-[var(--panel-border)] mb-1`,children:`Your Tables`}),(0,l.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:b.map(e=>(0,l.jsx)(`button`,{onClick:()=>{C(e.id),T(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${S===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,l.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,l.jsxs)(`button`,{onClick:me,className:`w-full px-4 py-2.5 text-[13px] font-bold text-left text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors flex items-center gap-2`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,l.jsx)(`button`,{onClick:()=>T(!w),className:`p-1 px-1.5 rounded-lg hover:bg-foreground/5 transition-colors text-foreground/40 hover:text-foreground shrink-0 border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 transition-transform ${w?`rotate-180 text-accent`:``}`})})]}),(0,l.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(q.rows||[]).length,` Records`]})]}),(0,l.jsxs)(`div`,{className:`relative w-full sm:max-w-[300px]`,children:[(0,l.jsx)(n.b,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,l.jsx)(`input`,{type:`text`,placeholder:`Search active records...`,value:ie,onChange:e=>z(e.target.value),className:`w-full bg-background border border-[var(--panel-border)] rounded-xl py-2.5 px-9 text-[13px] font-medium text-foreground focus:outline-none focus:border-accent transition-colors shadow-inner`})]})]}),(0,l.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-x-auto w-full block min-h-[300px] relative styled-scrollbars`,children:(0,l.jsx)(n.a,{mode:`wait`,children:A?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 flex flex-col items-center justify-center bg-background/40 backdrop-blur-[2px] z-50`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,l.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,l.jsxs)(n.i.table,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full text-left border-collapse table-auto relative min-w-[800px]`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${q.headerColor?Lt.find(e=>e.text===q.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,l.jsx)(`th`,{className:`py-4 px-6 text-[12px] font-bold uppercase tracking-wider whitespace-nowrap text-foreground/50 w-32 border-r border-[var(--panel-border)]/20 ${p?``:`hidden`}`,children:`Creator`}),(q.columns||[]).map((e,t)=>{let r=(q.colColors||{})[e],i=(q.colorTimestamps||{})[`col_${e}`]||0;q.headerColor;let a=(q.colorTimestamps||{}).header||0,o=`bg-transparent`,s=`text-foreground/50`;if(r&&r!==`none`&&i>=a){let e=Lt.find(e=>e.text===r);e&&(o=e.bgCard,s=e.text)}return(0,l.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${s} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[L===e?(0,l.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,l.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{R(null),V(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&Z(e)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent outline-none border-b border-accent/40 font-bold text-[12px] uppercase tracking-wider p-0 m-0 ${s} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:B})}):(0,l.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{R(e),V(e)},children:(0,l.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,l.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,l.jsx)(`button`,{onClick:()=>G(W===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${r&&r!==`none`?`!opacity-100`:``} text-current`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),(q.columns||[]).length>1&&(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500/10 text-foreground/30 hover:text-red-500`,title:`Delete column`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})}),W===e&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>G(null)}),(0,l.jsxs)(`div`,{className:`absolute top-8 right-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...q.colColors||{},[e]:`none`},r={...q.colorTimestamps||{},[`col_${e}`]:Date.now()};J({...q,colColors:n,colorTimestamps:r}),G(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(t=>(0,l.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...q.colColors||{},[e]:t.text},i={...q.colorTimestamps||{},[`col_${e}`]:Date.now()};J({...q,colColors:r,colorTimestamps:i}),G(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]})]})]})},`col_${t}_${e}`)}),(0,l.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,l.jsx)(`button`,{onClick:()=>ae(!K),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${q.headerColor?Lt.find(e=>e.text===q.headerColor)?.text:`text-foreground/30`}`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),K&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>ae(!1)}),(0,l.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:()=>{J({...q,headerColor:``}),ae(!1)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Header Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(e=>(0,l.jsx)(`button`,{onClick:()=>{let t={...q.colorTimestamps||{},header:Date.now()};J({...q,headerColor:e.text,colorTimestamps:t}),ae(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,l.jsx)(`button`,{onClick:fe,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center`,children:(0,l.jsx)(n.C,{className:`w-4 h-4`})})]})})]})}),(0,l.jsxs)(`tbody`,{children:[he.map((e,t)=>{let r=t%2==1,i=(q.rowColors||{})[e.id],a=i?r?Lt.find(e=>e.text===i)?.bgAlt:Lt.find(e=>e.text===i)?.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`;return(0,l.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,l.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${a} ${p?``:`hidden`}`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:d&&c?(0,l.jsxs)(l.Fragment,{children:[c.photoURL?(0,l.jsx)(`img`,{src:c.photoURL,className:`w-5 h-5 rounded-full shrink-0 object-cover`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0`,children:(c.displayName||c.email||`U`)[0].toUpperCase()}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:c.displayName||c.email?.split(`@`)[0]||`User`})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0 shadow-inner group-hover:scale-110 transition-transform`,children:`G`}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(q.columns||[]).map(n=>{let i=re?.id===e.id&&re?.field===n,a=(q.colColors||{})[n],o=(q.colorTimestamps||{})[`col_${n}`]||0,s=(q.rowColors||{})[e.id],c=(q.colorTimestamps||{})[`row_${e.id}`]||0,u=``;u=c>o?s===`none`?``:s:o>c?a===`none`?``:a:s===`none`?``:s||a||``,u===`none`&&(u=``);let d=u?Lt.find(e=>e.text===u):null,f=d?r?d.bgAlt:d.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`,p=d?d.text:`text-foreground/80`;return(0,l.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${f} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>!i&&I({id:e.id,field:n}),children:[i?(0,l.jsx)(`textarea`,{autoFocus:!0,value:e[n]||``,onChange:t=>le(e.id,n,t.target.value),onBlur:()=>I(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&I(null)},className:`absolute inset-0 bg-transparent !border-0 !outline-none focus:!outline-none focus:!ring-0 !ring-0 !shadow-none focus:!shadow-none p-4 px-6 text-[14px] font-medium w-full h-full caret-accent ${p} z-20 resize-none styled-scrollbars`}):null,(0,l.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${p} ${n===`Status`&&e[n]===`Active`&&!u?`text-green-500`:``}`,children:e[n]||(0,l.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||t}_${n}`)}),(0,l.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${a} relative z-10`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-1 opacity-20 group-hover:opacity-100 transition-opacity relative`,children:[(0,l.jsx)(`button`,{onClick:()=>U(H===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${i?Lt.find(e=>e.text===i)?.text:`text-foreground/40`}`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),H===e.id&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>U(null)}),(0,l.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...q.rowColors||{},[e.id]:`none`},r={...q.colorTimestamps||{},[`row_${e.id}`]:Date.now()};J({...q,rowColors:n,colorTimestamps:r}),U(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Row Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(t=>(0,l.jsx)(`button`,{onClick:()=>{let n={...q.colorTimestamps||{},[`row_${e.id}`]:Date.now()};J({...q,rowColors:{...q.rowColors||{},[e.id]:t.text},colorTimestamps:n}),U(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),(0,l.jsx)(`button`,{onClick:()=>de(e.id),className:`p-2 ml-auto rounded-lg text-foreground/20 hover:text-red-500 hover:bg-red-500/10 transition-colors flex items-center justify-center`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})})]})})]},e.id||`row_${t}`)}),he.length===0&&(0,l.jsx)(`tr`,{children:(0,l.jsxs)(`td`,{colSpan:(q.columns||[]).length+2,className:`py-12 text-center text-foreground/40 text-[14px] font-medium border border-[var(--panel-border)] m-4 rounded-xl border-dashed`,children:[`No records found in `,q.name||`this table`,`.`]})}),(0,l.jsx)(`tr`,{children:(0,l.jsx)(`td`,{colSpan:(q.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,l.jsx)(`button`,{onClick:ue,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ml-2 border border-transparent hover:border-accent/20`,children:(0,l.jsx)(n.C,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]})}var zt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}],Bt={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function Vt({title:e=`Calendar View`,subtitle:t=`/templates/calendar`,backUrl:r=`/templates`,eventsCollection:i=`pub_events`,defaultTimeFormat:c=`12h`,config:d}){let f=!!(d?.isPrivate||d?.isAdmin||d?.isShared);d?.isAdmin,d?.isShared,d?.isPrivate;let p=d?.showButton!==!1,m=d?.buttonText||`+`,h=d?.buttonStyle||`primary`,g=d?.showViewsButton!==!1,_=d?.viewsButtonStyle||`secondary`,v=d?.showPrompt!==!1,y=d?.defaultView||`calendar`,b=d?.customFields||[],x=i.startsWith(`user_`)?`private`:i.startsWith(`mem_`)?`shared`:i.startsWith(`admin_`)?`admin_only`:`public`,[S,C]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${i}`);if(e===`list`||e===`month`)return e}catch{}return y===`board`?`list`:`month`}),[w,T]=(0,a.useState)([]),[E,D]=(0,a.useState)([]),[O,k]=(0,a.useState)(!1),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(!1),[ne,P]=(0,a.useState)(!1),[F,re]=(0,a.useState)(null),[I,L]=(0,a.useState)(Bt),[R,ie]=(0,a.useState)(new Date),[z,B]=(0,a.useState)(!1),[V,H]=(0,a.useState)(null),[U,ae]=(0,a.useState)(null),[q,J]=(0,a.useState)(!1),oe=`cal_24h_${i}`,[Y,se]=(0,a.useState)(()=>{try{let e=localStorage.getItem(oe);if(e!==null)return e===`true`}catch{}return c===`24h`}),ce=()=>{let e=!Y;se(e);try{localStorage.setItem(oe,String(e))}catch{}};(0,a.useEffect)(()=>{try{localStorage.setItem(`cal_view_${i}`,S)}catch{}x===`public`||x===`private`?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=x===`public`?`public`:`private`;T(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):T([])},[S,i,x]);let le=()=>{let e=S===`month`?`list`:`month`;C(e);try{localStorage.setItem(`cal_view_${i}`,e)}catch{}},ue=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},de=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,a.useEffect)(()=>(0,s.onAuthStateChanged)(n.wt,async e=>{if(H(e),e&&x===`admin_only`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));t.exists()&&ae(t.data())}catch{}J(!0)}),[x]),(0,a.useEffect)(()=>{if(!q)return;if(x!==`public`&&!V){D([]);return}try{let e=localStorage.getItem(`fbos_cal_${i}`);e&&D(JSON.parse(e))}catch{}let e=(0,o.onSnapshot)(x===`private`&&V?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,V.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];e.forEach(e=>t.push({id:e.id,...e.data()})),D(t),localStorage.setItem(`fbos_cal_${i}`,JSON.stringify(t))},e=>console.error(`Calendar events:`,e));return()=>e()},[i,x,V?.uid,q]);let fe=e=>!!V&&V.uid===e.uid,X=e=>x===`public`?!1:x===`private`?!!V:fe(e),pe=e=>{if(!e)return``;if(Y)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},me=e=>{if(!e)return`60m`;let t=parseInt(e,10);return isNaN(t)?e:t>=60?t%60==0?`${t/60}h`:`${Math.floor(t/60)}h ${t%60}m`:`${t}m`},Z=e=>{let[t,n]=(e||`12:00`).split(`:`),r=parseInt(t,10)||0,i=parseInt(n,10)||0,a=r>=12?`PM`:`AM`;return r=r%12||12,{h:r,m:i,ampm:a}},he=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},ge=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split(`T`)[0]},_e=()=>ge(new Date),ve=new Date(R.getFullYear(),R.getMonth(),1),Q=new Date(R.getFullYear(),R.getMonth()+1,0),ye=ve.getDay(),be=Q.getDate(),xe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Se=Array.from({length:42},(e,t)=>{let n=t-ye+1,r=new Date(R.getFullYear(),R.getMonth(),n);return{day:r.getDate(),dateStr:ge(r),isCurrentMonth:n>0&&n<=be}}),Ce=()=>ie(S===`month`?new Date(R.getFullYear(),R.getMonth()-1,1):new Date(R.getFullYear(),R.getMonth(),R.getDate()-1)),we=()=>ie(S===`month`?new Date(R.getFullYear(),R.getMonth()+1,1):new Date(R.getFullYear(),R.getMonth(),R.getDate()+1)),Te=e=>{if(x!==`public`&&!V)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);L({...Bt,dateStr:e||ge(t),time:`${n}:00`,guestEmail:x===`public`?ue():``,customFields:{}}),k(!0)},Ee=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}L({id:e.id,uid:e.uid,dateStr:e.dateStr,title:e.title,description:e.description||``,time:t||`12:00`,duration:e.duration||`60`,color:e.color||``,guestEmail:e.creatorEmail||``,customFields:e.customFields||{}}),k(!0)},De=async e=>{if(e.preventDefault(),I.title.trim()){N(!0);try{let e={dateStr:I.dateStr,title:I.title.trim(),description:I.description.trim(),time:I.time,duration:I.duration||`60`};if(I.color&&(e.color=I.color),b.length>0&&(e.customFields=I.customFields),!I.id)if(x===`public`){let t=I.guestEmail.trim();e.creatorEmail=t,de(t)}else x===`private`||x===`shared`?(e.uid=V?.uid,e.creatorEmail=V?.email||``,e.creatorName=V?.displayName||``,e.creatorAvatar=V?.photoURL||``):x===`admin_only`&&(e.uid=V?.uid,e.creatorEmail=U?.email||V?.email||``,e.creatorName=U?.displayName||U?.name||``,e.creatorAvatar=U?.avatar||U?.avatarUrl||V?.photoURL||``);I.id?(await(0,o.setDoc)((0,o.doc)(n.Tt,i,I.id),e,{merge:!0}),A?.id===I.id&&j({...A,...e})):await(0,o.setDoc)((0,o.doc)(n.Tt,i,`ev_${Date.now()}`),e,{merge:!0}),k(!1)}catch(e){console.error(e)}N(!1)}},Oe=async()=>{if(F){P(!0);try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,F.id)),A?.id===F.id&&j(null),re(null),k(!1)}catch{}P(!1)}},ke=e=>{if(x===`private`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=zt.find(t=>t.text===e.color);return(0,l.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 p-3 rounded-xl bg-foreground/[0.03] border border-[var(--panel-border)]/50`,children:[e.creatorAvatar?(0,l.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full ${n?.bgCircle||`bg-accent`} flex items-center justify-center text-[13px] font-extrabold text-white shrink-0`,children:t}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},Ae=e=>{if(x===`private`||x===`public`||!e.creatorName&&!e.creatorEmail)return null;let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||``,n=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,l.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:n}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})},je=x===`admin_only`?G(d,e,i,w):x===`private`?W(d,e,i,w):K(d,e,i,w),Me=()=>{navigator.clipboard.writeText(je),B(!0),setTimeout(()=>B(!1),2e3)};if(q&&x!==`public`&&!V)return(0,l.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,l.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center mx-auto mb-4`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 text-accent`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold mb-2`,children:`Sign in required`}),(0,l.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,l.jsx)(u.Link,{to:`/login`,className:`inline-flex items-center justify-center gap-2 px-6 py-2.5 rounded-xl btn-primary font-bold text-[14px] w-full`,children:`Sign In`})]})});if(!q&&x!==`public`)return(0,l.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})});let Ne=(x===`public`||!!V)&&p,Pe=()=>(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[E.length,` `,E.length===1?`event`:`events`,` · `,S===`month`?`Month`:`Board`,` View`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[v&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:Me,title:z?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${z?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:z?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:ce,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary text-[12px] font-extrabold`,children:Y?`24h`:`12h`}),g&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:le,title:S===`month`?`Switch to Board`:`Switch to Calendar`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${_===`primary`?`btn-primary`:`btn-secondary`}`,children:S===`month`?(0,l.jsx)(n.F,{className:`w-4 h-4`}):(0,l.jsx)(n.dt,{className:`w-4 h-4`})}),Ne&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>Te(),className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${m===`+`?`w-10`:`px-5`} ${h===`primary`?`btn-primary`:`btn-secondary`}`,children:m===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:m})})]})]}),Fe=()=>(0,l.jsxs)(`div`,{className:`p-4 md:p-6 border-b border-[var(--panel-border)]/50 flex items-center justify-between bg-foreground/[0.01]`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold tracking-tight ml-2`,children:S===`month`?R.toLocaleString(`default`,{month:`long`,year:`numeric`}):R.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(`button`,{onClick:()=>ie(new Date),className:`px-4 py-2 text-[13px] font-bold border border-[var(--panel-border)] rounded-xl mr-2 hover:bg-foreground/5 transition-colors`,children:`Today`}),(0,l.jsx)(`button`,{onClick:Ce,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.ot,{className:`w-5 h-5`})}),(0,l.jsx)(`button`,{onClick:we,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.at,{className:`w-5 h-5`})})]})]}),$=()=>(0,l.jsxs)(l.Fragment,{children:[Fe(),S===`month`?(0,l.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,l.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,l.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:xe.map(e=>(0,l.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,l.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:Se.map((e,t)=>{let r=e.dateStr===_e(),i=E.filter(t=>t.dateStr===e.dateStr);return(0,l.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&Ne&&Te(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
370
+ [WHAT SHOULD I BUILD INSIDE THIS PRIVATE VIEW?]`},de=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function fe({title:e=`Board View`,subtitle:t=`/templates/board`,backUrl:r=`/templates`,tasksCollection:i=`pub_tasks`,categoriesCollection:s=`pub_categories`,config:c}){let{user:d}=m(),f=!!c;c?.isPrivate&&!c?.isAdmin&&c?.isShared;let p=c?.isAdmin||c?.isShared,h=f?p:!0,g=c?.showButton!==!1,_=c?.buttonText||`+`,v=c?.buttonStyle||`primary`,y=c?.keyName||`key`,b=c?.valueName||`value`,[x,S]=(0,a.useState)([]),[C,w]=(0,a.useState)([]),[T,E]=(0,a.useState)([]),[D,O]=(0,a.useState)(null),[k,A]=(0,a.useState)(null),[j,M]=(0,a.useState)({name:``}),[N,P]=(0,a.useState)([]),[F,I]=(0,a.useState)(null),[L,R]=(0,a.useState)(null),[z,B]=(0,a.useState)(null),[ne,V]=(0,a.useState)(null),[H,U]=(0,a.useState)(!1),[W,G]=(0,a.useState)(null),[re,ie]=(0,a.useState)(``),[K,ae]=(0,a.useState)(null),[oe,se]=(0,a.useState)(!1),ce=c?.isAdmin?J(c,e,i,s):c?.isPrivate?q(c,e,i,s,T):Y(c,e,i,s,T),le=()=>{navigator.clipboard.writeText(ce),se(!0),setTimeout(()=>se(!1),2e3)};(0,a.useEffect)(()=>{let e=c?.isShared,t=c?.isAdmin,r=c?.isPrivate&&!t&&!e,a=!t&&!e&&!r;r||a?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=a?`public`:`private`;E(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):E([]);let l=i.startsWith(`user_`),u=s.startsWith(`user_`);if(l&&!d)return;try{let e=localStorage.getItem(`fbos_board_tasks_${i}`);e&&S(JSON.parse(e));let t=localStorage.getItem(`fbos_board_cats_${s}`);t&&w(JSON.parse(t))}catch{}let f=(0,o.onSnapshot)(l&&d?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,d.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];e.forEach(e=>{let n=e.data();t.push({id:e.id,categoryId:n.categoryId,name:n.name||n.text||`Unnamed Item`,fields:n.fields||(n.value?[{key:`Label`,value:n.value}]:[]),order:n.order||0})});let n=t.sort((e,t)=>(e.order||0)-(t.order||0));S(n),localStorage.setItem(`fbos_board_tasks_${i}`,JSON.stringify(n))}),p=(0,o.onSnapshot)(u&&d?(0,o.query)((0,o.collection)(n.Tt,s),(0,o.where)(`uid`,`==`,d.uid)):(0,o.collection)(n.Tt,s),e=>{let t=[];if(e.forEach(e=>{t.push({id:e.id,...e.data()})}),t.length===0){let e=[{id:`todo`,title:`To Do`,createdAt:Date.now()-2e3},{id:`in_progress`,title:`In Progress`,createdAt:Date.now()-1e3},{id:`review`,title:`Review`,createdAt:Date.now()}],t=d?{uid:d.uid}:{};e.forEach(e=>(0,o.setDoc)((0,o.doc)(n.Tt,s,e.id),{...t,title:e.title,createdAt:e.createdAt}))}else w(t),localStorage.setItem(`fbos_board_cats_${s}`,JSON.stringify(t))});return()=>{f(),p()}},[i,s,d]);let ue=(e,t)=>{t?(A(t.id),M({id:t.id,name:t.name}),P(t.fields?.length?[...t.fields,{key:``,value:``}]:[{key:``,value:``}])):(O(e),M({name:``}),P([{key:``,value:``}]))},fe=(e,t,n)=>{let r=[...N];r[e]={key:t,value:n},e===N.length-1&&(t.trim()!==``||n.trim()!==``)&&r.push({key:``,value:``}),P(r)},X=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`taskId`,t),I(t)},pe=(e,t)=>{e.preventDefault(),e.stopPropagation(),t!==F&&R(t)},me=(e,t)=>{e.preventDefault(),e.stopPropagation(),B(t)},Z=e=>{e.preventDefault(),R(null),B(null)},he=async(e,t,r)=>{e.preventDefault(),e.stopPropagation(),R(null),B(null);let a=e.dataTransfer.getData(`taskId`);if(!a||a===r){I(null);return}let s=x.find(e=>e.id===a);if(!s)return;let c=x.filter(e=>e.categoryId===t).sort((e,t)=>(e.order||0)-(t.order||0));if(s.categoryId===t?(c=c.filter(e=>e.id!==a),c.push(s)):c.push({...s,categoryId:t}),r){let e=c.findIndex(e=>e.id===r),t=c.findIndex(e=>e.id===a),[n]=c.splice(t,1);c.splice(e,0,n)}c.forEach((e,r)=>{let a={categoryId:t,order:r};d&&(a.uid=d.uid),(0,o.setDoc)((0,o.doc)(n.Tt,i,e.id),a,{merge:!0})}),I(null)},ge=async e=>{let t=j.id||`item_${Date.now()}`,r=j.name.trim(),a=r||`Untitled Item`,s=N.filter(e=>e.key.trim()!==``||e.value.trim()!==``),c=!0,l=j.id?x.find(e=>e.id===j.id):null;if(l){let e=JSON.stringify(l.fields||[]),t=JSON.stringify(s);l.name===a&&e===t&&(c=!1)}else !r&&s.length===0&&(c=!1);if(!c){O(null),A(null);return}V(j.id||`new`);let u={categoryId:e,name:a,fields:s};d&&!j.id&&(u.uid=d.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,i,t),u,{merge:!0}),setTimeout(()=>{O(null),A(null),V(null)},400)},_e=(e,t)=>{ae({type:`item`,id:e,title:t})},ve=async()=>{let e=`cat_${Date.now()}`,t={title:``,createdAt:Date.now()};d&&(t.uid=d.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,s,e),t),G(e),ie(``),setTimeout(()=>{let e=document.getElementById(`board-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},150)},Q=async e=>{re.trim()?await(0,o.setDoc)((0,o.doc)(n.Tt,s,e),{title:re},{merge:!0}):await(0,o.deleteDoc)((0,o.doc)(n.Tt,s,e)),G(null)},ye=(e,t)=>{ae({type:`category`,id:e,title:t})},be=async()=>{if(K){U(!0);try{if(K.type===`item`)await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,K.id)),A(null);else{let e=x.filter(e=>e.categoryId===K.id);for(let t of e)await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,t.id));await(0,o.deleteDoc)((0,o.doc)(n.Tt,s,K.id))}}catch{}U(!1),ae(null)}},xe=[...C].sort((e,t)=>(e.createdAt||0)-(t.createdAt||0));return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen overflow-x-hidden`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),f&&(0,l.jsx)(`div`,{className:`mb-6`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-start sm:items-center mb-6 border-b border-[var(--panel-border)] pb-6 gap-4 relative z-20 shrink-0`,children:[!f&&r&&(0,l.jsxs)(u.Link,{to:r,className:`px-5 py-2 hover:bg-foreground/5 transition-all flex items-center gap-2`,style:{borderRadius:`var(--btn-radius, 0.75rem)`},children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}),f&&(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:c?.tabTitle||c?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[x.length,` `,x.length===1?`item`:`items`,` · `,xe.length,` `,xe.length===1?`category`:`categories`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 w-full sm:w-auto`,children:[c?.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:le,title:oe?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${oe?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-lg`}`,children:oe?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),g&&(0,l.jsx)(n.n,{variant:v===`secondary`?`secondary`:void 0,onClick:ve,className:`flex-1 sm:flex-none px-3 py-2.5 text-[14px] font-bold rounded-xl shadow-lg hover:-translate-y-0.5 transition-all shrink-0`,children:_===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):_})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative z-40 min-h-0`,children:(0,l.jsxs)(`div`,{id:`board-container`,className:`w-full h-full flex flex-row gap-4 md:gap-6 overflow-x-auto pb-4 snap-x snap-mandatory styled-scrollbars items-start`,children:[xe.map((e,t)=>{let r=x.filter(t=>t.categoryId===e.id);r.sort((e,t)=>(e.order||0)-(t.order||0));let i=de.find(t=>t.text===e.color)||de.find(e=>e.text===`text-accent`);return i.text,i.bgLight,i.bgHover,(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.1},className:`w-[300px] md:w-[320px] shrink-0 flex flex-col max-h-full rounded-3xl p-4 snap-center relative border transition-colors ${de.find(t=>t.text===e.color)?.bgCard||`bg-foreground/[0.02]`} ${de.find(t=>t.text===e.color)?.borderCard||`border-[var(--panel-border)]/50`}`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-2 relative z-[200]`,children:(0,l.jsxs)(`h3`,{className:`font-bold text-[14px] flex items-center w-full text-foreground/80 group relative z-[200]`,children:[W===e.id?(0,l.jsxs)(`div`,{className:`relative flex-1 w-full flex items-center pr-8 z-[200]`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),Q(e.id)}}),(0,l.jsx)(`input`,{value:re,onChange:e=>ie(e.target.value),onBlur:t=>{t.relatedTarget?.closest(`.category-color-picker`)||Q(e.id)},onKeyDown:t=>t.key===`Enter`&&Q(e.id),className:`bg-transparent border-none outline-none font-bold text-[14px] w-full p-0 ${e.color||`text-foreground/80`}`,placeholder:`Category name`}),(0,l.jsxs)(`div`,{className:`absolute top-8 left-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-[100] category-color-picker items-center`,tabIndex:-1,children:[(0,l.jsx)(`button`,{onClick:async t=>{t.preventDefault(),t.stopPropagation(),await(0,o.setDoc)((0,o.doc)(n.Tt,`pub_categories`,e.id),{color:``},{merge:!0}),G(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Reset Category Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),de.map(t=>(0,l.jsx)(`button`,{onMouseDown:async r=>{r.preventDefault(),await(0,o.setDoc)((0,o.doc)(n.Tt,`pub_categories`,e.id),{color:t.text},{merge:!0})},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]}):(0,l.jsxs)(`div`,{className:`flex items-center gap-2 w-full cursor-pointer hover:text-foreground transition-colors pr-8`,onClick:()=>{G(e.id),ie(e.title)},children:[(0,l.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${de.find(t=>t.text===e.color)?.bgCircle||`bg-foreground/20`} transition-colors shrink-0`}),(0,l.jsx)(`span`,{className:`truncate flex-1 max-w-[200px] ${e.color||``}`,children:e.title||`Untitled Category`}),(0,l.jsx)(`span`,{className:`text-[11px] bg-foreground/10 text-foreground/60 px-1.5 py-0.5 rounded-md font-medium shrink-0`,children:r.length})]}),C.length>1&&(0,l.jsx)(`button`,{onClick:()=>ye(e.id,e.title),className:`absolute right-0 opacity-0 group-hover:opacity-100 text-foreground/30 hover:text-red-500 transition-all shrink-0`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2.5 flex-1 overflow-y-auto styled-scrollbars pr-1 relative min-h-[150px] rounded-xl transition-all ${z===e.id&&!L?`bg-foreground/5 scale-[1.01] border-dashed border border-accent/20`:``}`,onDragOver:t=>me(t,e.id),onDragLeave:Z,onDrop:t=>he(t,e.id),children:[(0,l.jsx)(n.a,{children:r.map(t=>k===t.id?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100]`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),ge(e.id)}}),(0,l.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))}}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,l.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,l.jsx)(`input`,{placeholder:y,value:t.key,onChange:e=>fe(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&ge(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px] shrink-0`,style:{width:`${Math.max(3,t.key.length||y.length)}ch`}}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,l.jsx)(`textarea`,{rows:1,placeholder:b,value:t.value,onChange:e=>fe(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),ne===t.id&&(0,l.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,l.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]},t.id):(0,l.jsxs)(n.i.div,{draggable:!0,onDragStart:e=>X(e,t.id),onDragOver:e=>pe(e,t.id),onDragLeave:Z,onDrop:n=>he(n,e.id,t.id),initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-sm hover:shadow-md cursor-grab active:cursor-grabbing hover:border-accent/40 transition-all group flex flex-col gap-2 relative z-10 border ${L===t.id?`border-accent border-t-2 translate-y-1`:`border-[var(--panel-border)]`} ${F===t.id?`opacity-30 scale-95 border-dashed border-2`:``}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-2 right-2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity bg-background/90 backdrop-blur-md border border-[var(--panel-border)] rounded-lg p-1 z-20 shadow-md`,children:[(0,l.jsx)(`button`,{onClick:n=>{n.stopPropagation(),ue(e.id,t)},className:`p-1 hover:bg-foreground/5 rounded-md text-foreground/60 hover:text-accent transition-colors`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),_e(t.id,t.name)},className:`p-1 hover:bg-red-500/10 rounded-md text-foreground/60 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})})]}),(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/90 font-medium leading-snug break-words pr-12`,children:t.name}),t.fields&&t.fields.length>0&&(0,l.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 mt-2`,children:t.fields.map((e,t)=>(0,l.jsxs)(`div`,{className:`inline-flex bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 max-w-full`,children:[(0,l.jsxs)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative -top-[1px] shrink-0 break-all`,children:[e.key,`:`]}),(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/90 font-medium break-words leading-tight min-w-0`,children:e.value})]},t))}),(0,l.jsxs)(`div`,{className:`flex items-end justify-between mt-3 pt-3 border-t border-[var(--panel-border)]/50 w-full gap-2`,children:[h&&f&&d?(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`,children:[d.photoURL?(0,l.jsx)(`img`,{src:d.photoURL,className:`w-4 h-4 rounded-full shrink-0 object-cover`}):(0,l.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[9px] font-bold shrink-0`,children:(d.displayName||d.email||`U`)[0].toUpperCase()}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold text-foreground/60 truncate max-w-[80px]`,children:d.displayName||d.email?.split(`@`)[0]||`User`})]}):(0,l.jsx)(`div`,{className:`flex items-center gap-2 pr-2 border-r border-[var(--panel-border)] border-dashed mr-auto`}),(0,l.jsx)(`span`,{className:`text-[10px] text-foreground/40 font-bold text-right pt-0.5 shrink-0 max-w-[50%] truncate flex-1`,children:t.id.startsWith(`item_`)?new Date(parseInt(t.id.split(`_`)[1])).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Recently Added`})]})]},t.id))}),D===e.id?(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:`bg-background/80 rounded-xl p-3 shadow-md border border-accent/40 transition-all flex flex-col gap-2 relative z-[100] mt-1`,children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-[-1]`,onClick:t=>{t.stopPropagation(),ge(e.id)}}),(0,l.jsx)(`textarea`,{placeholder:`Write an item name...`,className:`no-glow bg-transparent border-none outline-none text-[13px] text-foreground/90 font-medium leading-snug resize-none w-full min-h-[40px] relative z-10`,value:j.name,onChange:e=>M({...j,name:e.target.value}),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},autoFocus:!0}),(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mt-1 relative z-10 w-full`,children:N.map((t,n)=>(0,l.jsxs)(`div`,{className:`flex items-start bg-foreground/[0.04] border border-[var(--panel-border)]/50 rounded-[8px] px-2.5 py-1.5 w-full`,children:[(0,l.jsx)(`input`,{placeholder:y,style:{width:`${Math.max(3,t.key.length||y.length)}ch`},value:t.key,onChange:e=>fe(n,e.target.value,t.value),onKeyDown:t=>t.key===`Enter`&&ge(e.id),className:`no-glow bg-transparent outline-none text-[11px] text-foreground/50 font-bold placeholder:text-foreground/30 relative top-[1px]`}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/50 font-bold mr-1.5 relative top-[1px]`,children:`:`}),(0,l.jsx)(`textarea`,{rows:1,placeholder:b,value:t.value,onChange:e=>fe(n,t.key,e.target.value),onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=t.scrollHeight+`px`},onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ge(e.id))},className:`no-glow bg-transparent outline-none text-[12px] text-foreground/90 font-medium flex-1 min-w-[40px] placeholder:opacity-40 resize-none overflow-hidden leading-tight relative top-[1px]`})]},n))}),ne===`new`&&(0,l.jsx)(`div`,{className:`flex items-center justify-end pt-1`,children:(0,l.jsx)(`div`,{className:`w-3 h-3 border-2 border-accent border-t-transparent rounded-full animate-spin`})})]}):(0,l.jsxs)(`button`,{onClick:()=>ue(e.id),className:`flex items-center gap-2 justify-center w-full py-2.5 mt-1 rounded-xl border border-transparent text-[12px] font-bold text-foreground/40 hover:text-foreground hover:bg-foreground/[0.03] transition-all shrink-0`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Add Item`]})]})]},e.id)}),(0,l.jsx)(`div`,{className:`w-[10px] shrink-0 pointer-events-none`})]})}),(0,l.jsx)(`style`,{children:`.styled-scrollbars::-webkit-scrollbar { width: 6px; height: 6px; } .styled-scrollbars::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent-color) 20%, transparent); border-radius: 4px; } .styled-scrollbars::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent-color) 40%, transparent); }`}),(0,l.jsx)(te,{isOpen:!!K,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:K?.title}),` This action is permanent.`]}),onConfirm:be,onCancel:()=>ae(null),isProcessing:H,confirmText:`Yes, Delete`})]})}function X(e){return Array.isArray?Array.isArray(e):be(e)===`[object Array]`}function pe(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function me(e){return e==null?``:pe(e)}function Z(e){return typeof e==`string`}function he(e){return typeof e==`number`}function ge(e){return e===!0||e===!1||ve(e)&&be(e)==`[object Boolean]`}function _e(e){return typeof e==`object`}function ve(e){return _e(e)&&e!==null}function Q(e){return e!=null}function ye(e){return!e.trim().length}function be(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var xe=`Incorrect 'index' type`,Se=e=>`Invalid value for key ${e}`,Ce=e=>`Pattern length exceeds max of ${e}.`,we=e=>`Missing ${e} property in key`,Te=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ee=Object.prototype.hasOwnProperty,De=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Oe(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Oe(e){let t=null,n=null,r=null,i=1,a=null;if(Z(e)||X(e))r=e,t=ke(e),n=Ae(e);else{if(!Ee.call(e,`name`))throw Error(we(`name`));let o=e.name;if(r=o,Ee.call(e,`weight`)&&(i=e.weight,i<=0))throw Error(Te(o));t=ke(o),n=Ae(o),a=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:a}}function ke(e){return X(e)?e:e.split(`.`)}function Ae(e){return X(e)?e.join(`.`):e}function je(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Q(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Q(s))return;if(a===t.length-1&&(Z(s)||he(s)||ge(s)||typeof s==`bigint`))n.push(o===void 0?me(s):{v:me(s),i:o});else if(X(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,Z(t)?t.split(`.`):t,0),r?n:n[0]}var Me={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ne={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Pe={location:0,threshold:.6,distance:100},Fe={useExtendedSearch:!1,useTokenSearch:!1,getFn:je,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=Object.freeze({...Ne,...Me,...Pe,...Fe}),Ie=/[^ ]+/g;function Le(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=t.match(Ie).length;if(n.has(i))return n.get(i);let a=1/i**(.5*e),o=parseFloat(Math.round(a*r)/r);return n.set(i,o),o},clear(){n.clear()}}}var Re=class{constructor({getFn:e=$.getFn,fieldNormWeight:t=$.fieldNormWeight}={}){this.norm=Le(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Z(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){let t=this.size();Z(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)--this.records[t].i}removeAll(e){for(let t=e.length-1;t>=0;--t)this.records.splice(e[t],1);for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i=e}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Q(e)||ye(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((t,r)=>{let i=t.getFn?t.getFn(e):this.getFn(e,t.path);if(Q(i)){if(X(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Q(n)){if(Z(n)){if(!ye(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Q(n.v)){let t=Z(n.v)?n.v:me(n.v);if(!ye(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[r]=e}else if(Z(i)&&!ye(i)){let e={v:i,n:this.norm.get(i)};n.$[r]=e}}}),this.records.push(n)}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function ze(e,t,{getFn:n=$.getFn,fieldNormWeight:r=$.fieldNormWeight}={}){let i=new Re({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Oe)),i.setSources(t),i.create(),i}function Be(e,{getFn:t=$.getFn,fieldNormWeight:n=$.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Re({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function Ve(e=[],t=$.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}var He=32;function Ue(e,t,n,{location:r=$.location,distance:i=$.distance,threshold:a=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:s=$.minMatchCharLength,includeMatches:c=$.includeMatches,ignoreLocation:l=$.ignoreLocation}={}){if(t.length>He)throw Error(Ce(He));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=u+d,S=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=x;for(;r<i;)h(t,f+i)<=p?r=i:x=i,i=Math.floor((x-r)/2+r);x=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(g&&(_[i]=+!!o),c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&S&&(b=h(t,i),b<=p)){if(p=b,m=i,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}let C={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=Ve(_,s);e.length?c&&(C.indices=e):C.isMatch=!1}return C}function We(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function Ge(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}var Ke={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},qe=RegExp(`[`+Object.keys(Ke).join(``)+`]`,`g`),Je=String.prototype.normalize?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(qe,e=>Ke[e]):e=>e,Ye=class{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Je(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:We(e),startIndex:t})},d=this.pattern.length;if(d>He){let e=0,t=d%He,n=d-t;for(;e<n;)u(this.pattern.substr(e,He),e),e+=He;if(t){let e=d-He;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Je(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=Ue(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=Ge(u)),p}},Xe=class{constructor(e){this.pattern=e}static isMultiMatch(e){return Ze(e,this.multiRegex)}static isSingleMatch(e){return Ze(e,this.singleRegex)}search(e){return{isMatch:!1,score:1}}};function Ze(e,t){let n=e.match(t);return n?n[1]:null}var Qe=class extends Xe{constructor(e){super(e)}static get type(){return`exact`}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){let t=e===this.pattern;return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},$e=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-exact`}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){let t=e.indexOf(this.pattern)===-1;return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},et=class extends Xe{constructor(e){super(e)}static get type(){return`prefix-exact`}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){let t=e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,this.pattern.length-1]}}},tt=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-prefix-exact`}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){let t=!e.startsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},nt=class extends Xe{constructor(e){super(e)}static get type(){return`suffix-exact`}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){let t=e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[e.length-this.pattern.length,e.length-1]}}},rt=class extends Xe{constructor(e){super(e)}static get type(){return`inverse-suffix-exact`}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){let t=!e.endsWith(this.pattern);return{isMatch:t,score:+!t,indices:[0,e.length-1]}}},it=class extends Xe{constructor(e,{location:t=$.location,threshold:n=$.threshold,distance:r=$.distance,includeMatches:i=$.includeMatches,findAllMatches:a=$.findAllMatches,minMatchCharLength:o=$.minMatchCharLength,isCaseSensitive:s=$.isCaseSensitive,ignoreDiacritics:c=$.ignoreDiacritics,ignoreLocation:l=$.ignoreLocation}={}){super(e),this._bitapSearch=new Ye(e,{location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return`fuzzy`}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}},at=class extends Xe{constructor(e){super(e)}static get type(){return`include`}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n,r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+i,r.push([n,t-1]);let a=!!r.length;return{isMatch:a,score:+!a,indices:r}}},ot=[Qe,at,et,tt,rt,nt,$e,it],st=ot.length,ct=`\0`,lt=`|`;function ut(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function dt(e,t={}){return e.replace(/\\\|/g,ct).split(lt).map(e=>{let n=ut(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<st;){let e=ot[o],n=e.isMultiMatch(i);n&&(r.push(new e(n,t)),a=!0)}if(!a)for(o=-1;++o<st;){let e=ot[o],n=e.isSingleMatch(i);if(n){r.push(new e(n,t));break}}}return r})}var ft=new Set([it.type,at.type]),pt=class{constructor(e,{isCaseSensitive:t=$.isCaseSensitive,ignoreDiacritics:n=$.ignoreDiacritics,includeMatches:r=$.includeMatches,minMatchCharLength:i=$.minMatchCharLength,ignoreLocation:a=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:s=$.location,threshold:c=$.threshold,distance:l=$.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Je(e):e,this.pattern=e,this.query=dt(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Je(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l){a+=1,s+=d;let e=r.constructor.type;e.startsWith(`inverse`)&&(c=!0),n&&(ft.has(e)?o.push(...u):o.push(u))}else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=Ge(o)),e}}return{isMatch:!1,score:1}}},mt=[];function ht(...e){mt.push(...e)}function gt(e,t){for(let n=0,r=mt.length;n<r;n+=1){let r=mt[n];if(r.condition(e,t))return new r(e,t)}return new Ye(e,t)}var _t={AND:`$and`,OR:`$or`},vt={PATH:`$path`,PATTERN:`$val`},yt=e=>!!(e[_t.AND]||e[_t.OR]),bt=e=>!!e[vt.PATH],xt=e=>!X(e)&&_e(e)&&!yt(e),St=e=>({[_t.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Ct(e,t,{auto:n=!0}={}){let r=e=>{if(Z(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=gt(e,t)),r}let i=Object.keys(e),a=bt(e);if(!a&&i.length>1&&!yt(e))return r(St(e));if(xt(e)){let r=a?e[vt.PATH]:i[0],o=a?e[vt.PATTERN]:e[r];if(!Z(o))throw Error(Se(r));let s={keyId:Ae(r),pattern:o};return n&&(s.searcher=gt(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];X(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return yt(e)||(e=St(e)),r(e)}function wt(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function Tt(e,{ignoreFieldNorm:t=$.ignoreFieldNorm}){e.forEach(e=>{e.score=wt(e.matches,{ignoreFieldNorm:t})})}var Et=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}};function Dt(e,t){let n=e.matches;t.matches=[],Q(n)&&n.forEach(e=>{if(!Q(e.indices)||!e.indices.length)return;let{indices:n,value:r}=e,i={indices:n,value:r};e.key&&(i.key=e.key.src),e.idx>-1&&(i.refIndex=e.idx),t.matches.push(i)})}function Ot(e,t){t.score=e.score}function kt(e,t,{includeMatches:n=$.includeMatches,includeScore:r=$.includeScore}={}){let i=[];return n&&i.push(Dt),r&&i.push(Ot),e.map(e=>{let{idx:n}=e,r={item:t[n],refIndex:n};return i.length&&i.forEach(t=>{t(e,r)}),r})}var At=/\b\w+\b/g;function jt({isCaseSensitive:e=!1,ignoreDiacritics:t=!1}={}){return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Je(n)),n.match(At)||[]}}}function Mt(e,t,n){let r=new Map,i=new Map,a=0;function o(e,t,o,s){let c=n.tokenize(e);if(!c.length)return;a++;let l=new Map;for(let e of c)l.set(e,(l.get(e)||0)+1);for(let[e,n]of l){let a={docIdx:t,keyIdx:o,subIdx:s,tf:n},c=r.get(e);c||(c=[],r.set(e,c)),c.push(a),i.set(e,(i.get(e)||0)+1)}}for(let n of e){let{i:e,v:r,$:i}=n;if(r!==void 0){o(r,e,-1,-1);continue}if(i)for(let n=0;n<t;n++){let t=i[n];if(t)if(Array.isArray(t))for(let r of t)o(r.v,e,n,r.i??-1);else o(t.v,e,n,-1)}}return{terms:r,fieldCount:a,df:i}}function Nt(e,t,n,r){let{i,v:a,$:o}=t;function s(t,n,a){let o=r.tokenize(t);if(!o.length)return;e.fieldCount++;let s=new Map;for(let e of o)s.set(e,(s.get(e)||0)+1);for(let[t,r]of s){let o={docIdx:i,keyIdx:n,subIdx:a,tf:r},s=e.terms.get(t);s||(s=[],e.terms.set(t,s)),s.push(o),e.df.set(t,(e.df.get(t)||0)+1)}}if(a!==void 0){s(a,-1,-1);return}if(o)for(let e=0;e<n;e++){let t=o[e];if(t)if(Array.isArray(t))for(let n of t)s(n.v,e,n.i??-1);else s(t.v,e,-1)}}function Pt(e,t){for(let[n,r]of e.terms){let i=r.filter(e=>e.docIdx!==t),a=r.length-i.length;a>0&&(e.fieldCount-=a,e.df.set(n,(e.df.get(n)||0)-a),i.length===0?(e.terms.delete(n),e.df.delete(n)):e.terms.set(n,i))}}var Ft=class{constructor(e,t,n){this.options={...$,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new De(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=gt(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Re))throw Error(xe);if(this._myIndex=t||ze(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=jt({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});this._invertedIndex=Mt(this._myIndex.records,this._myIndex.keys.length,e)}}add(e){if(Q(e)&&(this._docs.push(e),this._myIndex.add(e),this._invertedIndex)){let e=this._myIndex.records[this._myIndex.records.length-1],t=jt({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics});Nt(this._invertedIndex,e,this._myIndex.keys.length,t)}}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){if(this._invertedIndex)for(let e of n)Pt(this._invertedIndex,e);for(let e=n.length-1;e>=0;--e)this._docs.splice(n[e],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._invertedIndex&&Pt(this._invertedIndex,e);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),t}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(Z(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return he(n)&&n>-1&&(e=e.slice(0,n)),e}let c=he(n)&&n>0&&Z(e),l;if(c){let t=new Et(n);Z(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Z(e)?Z(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Tt(l,{ignoreFieldNorm:s}),a&&l.sort(o),he(n)&&n>-1&&(l=l.slice(0,n));return kt(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{records:i}=this._myIndex,a=t?null:[];return i.forEach(({v:e,i,n:o})=>{if(!Q(e))return;let{isMatch:s,score:c,indices:l}=r.searchIn(e);if(s){let r={item:e,idx:i,matches:[{score:c,value:e,norm:o,indices:l}]};t?(r.score=wt(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):a.push(r)}}),a}_searchLogical(e){let t=Ct(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===_t.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Q(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),{keys:i,records:a}=this._myIndex,o=t?null:[];return a.forEach(({$:e,i:a})=>{if(!Q(e))return;let s=[],c=!1,l=!1;if(i.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(s.push(...i),i[0].hasInverse&&(l=!0)):c=!0}),!(l&&c)&&s.length){let r={idx:a,item:e,matches:s};t?(r.score=wt(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}),o}_findMatches({key:e,value:t,searcher:n}){if(!Q(t))return[];let r=[];if(X(t))t.forEach(({v:t,i,n:a})=>{if(!Q(t))return;let{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(t);o&&r.push({score:s,key:e,value:t,idx:i,norm:a,indices:c,hasInverse:l})});else{let{v:i,n:a}=t,{isMatch:o,score:s,indices:c,hasInverse:l}=n.searchIn(i);o&&r.push({score:s,key:e,value:i,norm:a,indices:c,hasInverse:l})}return r}},It=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=jt({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new Ye(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0;for(let a=0;a<this.termSearchers.length;a++){let o=this.termSearchers[a].searchIn(e),s=this.idfWeights[a];r+=s,o.isMatch&&(i++,n+=s*(1-o.score),o.indices&&t.push(...o.indices))}if(i===0)return{isMatch:!1,score:1};let a=r>0?1-n/r:0,o={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&t.length&&(o.indices=Ge(t)),o}};Ft.version=`7.3.0`,Ft.createIndex=ze,Ft.parseIndex=Be,Ft.config=$,Ft.match=function(e,t,n){return gt(e,{...$,...n}).searchIn(t)},Ft.parseQuery=Ct,ht(pt),ht(It),Ft.use=function(...e){e.forEach(e=>ht(e))};var Lt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}];function Rt({title:e=`Table View`,subtitle:t=`/templates/table`,backUrl:r=`/templates`,tableCollection:i=`pub_table_data`,config:s}){let{user:c}=m(),d=!!s;s?.isPrivate&&!s?.isAdmin&&s?.isShared;let f=s?.isAdmin||s?.isShared,p=d?f:!0,h=s?.showButton!==!1,g=s?.buttonText||`+`,_=s?.buttonStyle||`secondary`,v=s?.showExportButton!==!1,y=s?.showPrompt,[b,x]=(0,a.useState)([]),[S,C]=(0,a.useState)(`demo`),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(!1),[O,k]=(0,a.useState)(``),[A,te]=(0,a.useState)(!1),[j,M]=(0,a.useState)(!1),[N,P]=(0,a.useState)([]),F=s?.isAdmin?oe(s,e,i):s?.isPrivate?ae(s,e,i,N):se(s,e,i,N),I=()=>{navigator.clipboard.writeText(F),M(!0),setTimeout(()=>M(!1),2e3)},[L,R]=(0,a.useState)(null),[z,B]=(0,a.useState)(null),[ne,V]=(0,a.useState)(``),[H,U]=(0,a.useState)(``),[W,G]=(0,a.useState)(null),[re,ie]=(0,a.useState)(null),[K,q]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=s?.isShared,t=s?.isAdmin,r=s?.isPrivate&&!t&&!e,a=!t&&!e&&!r;r||a?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=a?`public`:`private`;P(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):P([]);let l=i.startsWith(`user_`);if(l&&!c)return;try{let e=localStorage.getItem(`fbos_tables_${i}`);e&&x(JSON.parse(e))}catch{}let u=(0,o.onSnapshot)(l&&c?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,c.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];if(e.forEach(e=>{t.push({id:e.id,...e.data()})}),t.length===0){let e={name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`,`Column 4`],...c?{uid:c.uid}:{},rows:[{id:`1`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``},{id:`2`,"Column 1":``,"Column 2":``,"Column 3":``,"Column 4":``}]};(0,o.setDoc)((0,o.doc)(n.Tt,i,`demo`),e)}else{let e=t.sort((e,t)=>(e.name||``).localeCompare(t.name||``));x(e),localStorage.setItem(`fbos_tables_${i}`,JSON.stringify(e))}});return()=>u()},[i,c]);let J=b.find(e=>e.id===S)||b[0]||{columns:[],rows:[]},Y=async e=>{J.id&&(c&&i.startsWith(`user_`)&&(e.uid=c.uid),await(0,o.setDoc)((0,o.doc)(n.Tt,i,J.id),e,{merge:!0}))},ce=()=>{if(!J.rows||J.rows.length===0)return;let e=J.columns.join(`,`),t=J.rows.map(e=>J.columns.map(t=>`"${e[t]||``}"`).join(`,`)).join(`
371
+ `),n=new Blob([`${e}\n${t}`],{type:`text/csv`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export_${J.name||`table`}.csv`,i.click(),window.URL.revokeObjectURL(r)},le=(e,t,n)=>{Y({...J,rows:J.rows.map(r=>r.id===e?{...r,[t]:n}:r)})},ue=()=>{let e={id:Date.now().toString()};J.columns.forEach(t=>e[t]=``),Y({...J,rows:[...J.rows||[],e]})},de=e=>{Y({...J,rows:J.rows.filter(t=>t.id!==e)})},fe=()=>{let e=`Column ${(J.columns?.length||0)+1}`;J.columns?.includes(e)||(Y({...J,columns:[...J.columns||[],e]}),setTimeout(()=>{let e=document.getElementById(`table-scroll-container`);e&&e.scrollTo({left:e.scrollWidth,behavior:`smooth`})},100))},X=e=>{let t=(J.columns||[]).filter(t=>t!==e),n=(J.rows||[]).map(t=>{let n={...t};return delete n[e],n}),r={...J.colColors||{}};delete r[e],Y({...J,columns:t,rows:n,colColors:r})},pe=async e=>{e.trim()&&J.id&&e!==J.name&&await(0,o.setDoc)((0,o.doc)(n.Tt,i,J.id),{name:e},{merge:!0})},me=async()=>{te(!0),T(!1);let e=`tbl_${Date.now()}`;await(0,o.setDoc)((0,o.doc)(n.Tt,i,e),{name:`Unnamed Table`,columns:[`Column 1`,`Column 2`,`Column 3`],...c?{uid:c.uid}:{},rows:[]}),setTimeout(()=>{C(e),te(!1)},600)},Z=e=>{let t=H.trim();if(t&&t!==e&&!J.columns?.includes(t)){let n=J.columns.map(n=>n===e?t:n),r=(J.rows||[]).map(n=>{let r={...n};return r[t]=r[e]||``,delete r[e],r}),i={...J.colColors||{}};i[e]&&(i[t]=i[e],delete i[e]),Y({...J,columns:n,rows:r,colColors:i})}B(null)},he=J.rows||[];return ne.trim()!==``&&(he=new Ft(he.map(e=>({...e,_creatorMatch:`Guest`})),{keys:(J.columns||[]).concat([`_creatorMatch`]),threshold:.4,ignoreLocation:!0}).search(ne).map(e=>{let{_creatorMatch:t,...n}=e.item;return n})),(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),d&&(0,l.jsx)(`div`,{className:`mb-6`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[!d&&r&&(0,l.jsxs)(u.Link,{to:r,className:`px-4 md:px-5 py-2.5 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` `,(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:`Go Back`})]}),d&&(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:s?.tabTitle||s?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[b.length,` `,b.length===1?`table`:`tables`]})]}),(0,l.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[y&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:I,title:j?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${j?`bg-emerald-500/10 text-emerald-500 border border-emerald-500/20`:`btn-secondary shadow-lg`}`,children:j?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),v&&(0,l.jsx)(n.n,{variant:`secondary`,onClick:ce,className:`px-3 py-2.5 font-bold rounded-xl shadow-sm border border-[var(--panel-border)] flex items-center gap-2`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})}),h&&(0,l.jsx)(n.n,{variant:_===`primary`?void 0:`secondary`,onClick:ue,className:`px-3 py-2.5 font-bold rounded-xl border border-[var(--panel-border)] shadow-sm flex items-center gap-2`,children:g===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):g})]})]}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative z-10 block`,children:[(0,l.jsx)(`div`,{className:`absolute top-0 right-0 w-[400px] h-[400px] bg-accent/5 blur-[100px] rounded-full pointer-events-none -z-10`}),(0,l.jsxs)(`div`,{className:`p-4 md:px-6 border-b border-[var(--panel-border)]/50 flex flex-col sm:flex-row items-start sm:items-center justify-between bg-foreground/[0.01] gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col w-full sm:w-auto relative`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,l.jsxs)(`div`,{className:`relative flex items-center`,children:[E?(0,l.jsx)(`div`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:e=>{D(!1),pe(e.currentTarget.textContent||``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent border-b-2 border-accent outline-none text-[16px] font-bold text-foreground inline-block min-w-[20px] whitespace-nowrap px-1 py-0.5`,children:J.name||`Unnamed Table`}):(0,l.jsx)(`h3`,{className:`font-bold text-[16px] text-foreground/90 cursor-pointer hover:text-accent transition-colors truncate max-w-[200px]`,onClick:()=>D(!0),title:`Click to rename table`,children:J.name||`Unnamed Table`}),(0,l.jsx)(n.a,{children:w&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>T(!1)}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:`absolute top-[120%] left-0 w-[220px] bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] rounded-2xl shadow-2xl z-50 py-2 flex flex-col`,children:[(0,l.jsx)(`div`,{className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-foreground/40 border-b border-[var(--panel-border)] mb-1`,children:`Your Tables`}),(0,l.jsx)(`div`,{className:`max-h-[250px] overflow-y-auto styled-scrollbars z-50 relative`,children:b.map(e=>(0,l.jsx)(`button`,{onClick:()=>{C(e.id),T(!1)},className:`w-full px-4 py-2 text-[13px] font-bold text-left hover:bg-foreground/[0.03] transition-colors truncate ${S===e.id?`text-accent bg-accent/5`:`text-foreground/70`}`,children:e.name||`Unnamed Table`},e.id))}),(0,l.jsx)(`div`,{className:`w-full h-[1px] bg-[var(--panel-border)]/50 my-1`}),(0,l.jsxs)(`button`,{onClick:me,className:`w-full px-4 py-2.5 text-[13px] font-bold text-left text-foreground/70 hover:text-foreground hover:bg-foreground/5 transition-colors flex items-center gap-2`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Create New Table`]})]})]})})]}),(0,l.jsx)(`button`,{onClick:()=>T(!w),className:`p-1 px-1.5 rounded-lg hover:bg-foreground/5 transition-colors text-foreground/40 hover:text-foreground shrink-0 border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.st,{className:`w-4 h-4 transition-transform ${w?`rotate-180 text-accent`:``}`})})]}),(0,l.jsxs)(`span`,{className:`opacity-40 text-[11px] font-bold mt-1 uppercase tracking-wider`,children:[(J.rows||[]).length,` Records`]})]}),(0,l.jsxs)(`div`,{className:`relative w-full sm:max-w-[300px]`,children:[(0,l.jsx)(n.b,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-foreground/40`}),(0,l.jsx)(`input`,{type:`text`,placeholder:`Search active records...`,value:ne,onChange:e=>V(e.target.value),className:`w-full bg-background border border-[var(--panel-border)] rounded-xl py-2.5 px-9 text-[13px] font-medium text-foreground focus:outline-none focus:border-accent transition-colors shadow-inner`})]})]}),(0,l.jsx)(`div`,{id:`table-scroll-container`,className:`overflow-x-auto w-full block min-h-[300px] relative styled-scrollbars`,children:(0,l.jsx)(n.a,{mode:`wait`,children:A?(0,l.jsxs)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 flex flex-col items-center justify-center bg-background/40 backdrop-blur-[2px] z-50`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full border-2 border-accent border-r-transparent animate-spin mb-4`}),(0,l.jsx)(`p`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest`,children:`Generating Table`})]},`loader`):(0,l.jsxs)(n.i.table,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`w-full text-left border-collapse table-auto relative min-w-[800px]`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)] transition-colors ${J.headerColor?Lt.find(e=>e.text===J.headerColor)?.bgAlt:`bg-foreground/[0.02]`}`,children:[(0,l.jsx)(`th`,{className:`py-4 px-6 text-[12px] font-bold uppercase tracking-wider whitespace-nowrap text-foreground/50 w-32 border-r border-[var(--panel-border)]/20 ${p?``:`hidden`}`,children:`Creator`}),(J.columns||[]).map((e,t)=>{let r=(J.colColors||{})[e],i=(J.colorTimestamps||{})[`col_${e}`]||0;J.headerColor;let a=(J.colorTimestamps||{}).header||0,o=`bg-transparent`,s=`text-foreground/50`;if(r&&r!==`none`&&i>=a){let e=Lt.find(e=>e.text===r);e&&(o=e.bgCard,s=e.text)}return(0,l.jsx)(`th`,{className:`py-3 px-6 text-[12px] font-bold uppercase tracking-wider relative group h-[53px] min-w-[120px] ${s} ${o} border-r border-[var(--panel-border)]/20 last:border-r-0 select-none align-middle`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 w-full h-full`,children:[z===e?(0,l.jsx)(`div`,{className:`flex-1 min-w-[50px]`,children:(0,l.jsx)(`span`,{contentEditable:!0,suppressContentEditableWarning:!0,onBlur:t=>{B(null),U(t.currentTarget.textContent||``),(t.currentTarget.textContent||``).trim()!==``&&Z(e)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},className:`bg-transparent outline-none border-b border-accent/40 font-bold text-[12px] uppercase tracking-wider p-0 m-0 ${s} block w-full whitespace-nowrap overflow-hidden cursor-text`,ref:e=>{e&&requestAnimationFrame(()=>{e.focus()})},children:H})}):(0,l.jsx)(`div`,{className:`flex items-center gap-2 flex-1 overflow-hidden`,onClick:()=>{B(e),U(e)},children:(0,l.jsx)(`span`,{className:`truncate cursor-text`,children:e})}),(0,l.jsxs)(`div`,{className:`relative shrink-0 flex items-center h-full gap-0.5`,children:[(0,l.jsx)(`button`,{onClick:()=>ie(re===e?null:e),className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-foreground/10 ${r&&r!==`none`?`!opacity-100`:``} text-current`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),(J.columns||[]).length>1&&(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500/10 text-foreground/30 hover:text-red-500`,title:`Delete column`,children:(0,l.jsx)(n.m,{className:`w-3.5 h-3.5`})}),re===e&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>ie(null)}),(0,l.jsxs)(`div`,{className:`absolute top-8 right-0 flex gap-1.5 bg-background/95 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...J.colColors||{},[e]:`none`},r={...J.colorTimestamps||{},[`col_${e}`]:Date.now()};Y({...J,colColors:n,colorTimestamps:r}),ie(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(t=>(0,l.jsx)(`button`,{onClick:n=>{n.preventDefault(),n.stopPropagation();let r={...J.colColors||{},[e]:t.text},i={...J.colorTimestamps||{},[`col_${e}`]:Date.now()};Y({...J,colColors:r,colorTimestamps:i}),ie(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50 shrink-0`},t.name))]})]})]})]})},`col_${t}_${e}`)}),(0,l.jsx)(`th`,{className:`py-4 px-4 w-14 border-l border-[var(--panel-border)]/30 relative`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5 relative z-20`,children:[(0,l.jsx)(`button`,{onClick:()=>q(!K),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${J.headerColor?Lt.find(e=>e.text===J.headerColor)?.text:`text-foreground/30`}`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),K&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>q(!1)}),(0,l.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:()=>{Y({...J,headerColor:``}),q(!1)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Header Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(e=>(0,l.jsx)(`button`,{onClick:()=>{let t={...J.colorTimestamps||{},header:Date.now()};Y({...J,headerColor:e.text,colorTimestamps:t}),q(!1)},className:`w-4 h-4 rounded-full ${e.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},e.name))]})]}),(0,l.jsx)(`button`,{onClick:fe,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center`,children:(0,l.jsx)(n.C,{className:`w-4 h-4`})})]})})]})}),(0,l.jsxs)(`tbody`,{children:[he.map((e,t)=>{let r=t%2==1,i=(J.rowColors||{})[e.id],a=i?r?Lt.find(e=>e.text===i)?.bgAlt:Lt.find(e=>e.text===i)?.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`;return(0,l.jsxs)(`tr`,{className:`border-b border-[var(--panel-border)]/30 hover:bg-foreground/[0.04] transition-colors group`,children:[(0,l.jsx)(`td`,{className:`py-4 px-6 whitespace-nowrap h-[53px] border-r border-[var(--panel-border)]/20 ${a} ${p?``:`hidden`}`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-2`,children:d&&c?(0,l.jsxs)(l.Fragment,{children:[c.photoURL?(0,l.jsx)(`img`,{src:c.photoURL,className:`w-5 h-5 rounded-full shrink-0 object-cover`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0`,children:(c.displayName||c.email||`U`)[0].toUpperCase()}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:c.displayName||c.email?.split(`@`)[0]||`User`})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/20 text-accent flex items-center justify-center text-[10px] font-bold shrink-0 shadow-inner group-hover:scale-110 transition-transform`,children:`G`}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold text-foreground/80 tracking-tight shrink-0`,children:`Guest`})]})})}),(J.columns||[]).map(n=>{let i=L?.id===e.id&&L?.field===n,a=(J.colColors||{})[n],o=(J.colorTimestamps||{})[`col_${n}`]||0,s=(J.rowColors||{})[e.id],c=(J.colorTimestamps||{})[`row_${e.id}`]||0,u=``;u=c>o?s===`none`?``:s:o>c?a===`none`?``:a:s===`none`?``:s||a||``,u===`none`&&(u=``);let d=u?Lt.find(e=>e.text===u):null,f=d?r?d.bgAlt:d.bgCard:r?`bg-foreground/[0.02]`:`bg-transparent`,p=d?d.text:`text-foreground/80`;return(0,l.jsxs)(`td`,{className:`py-4 px-6 whitespace-pre-wrap min-w-[120px] text-[14px] font-medium relative ${f} align-top border-r border-[var(--panel-border)]/10 last:border-r-0`,onClick:()=>!i&&R({id:e.id,field:n}),children:[i?(0,l.jsx)(`textarea`,{autoFocus:!0,value:e[n]||``,onChange:t=>le(e.id,n,t.target.value),onBlur:()=>R(null),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&R(null)},className:`absolute inset-0 bg-transparent !border-0 !outline-none focus:!outline-none focus:!ring-0 !ring-0 !shadow-none focus:!shadow-none p-4 px-6 text-[14px] font-medium w-full h-full caret-accent ${p} z-20 resize-none styled-scrollbars`}):null,(0,l.jsx)(`span`,{className:`block w-full min-h-[20px] break-words transition-all ${i?`opacity-0`:`opacity-100`} ${p} ${n===`Status`&&e[n]===`Active`&&!u?`text-green-500`:``}`,children:e[n]||(0,l.jsx)(`span`,{className:`opacity-30 italic font-normal`,children:`empty`})})]},`cell_${e.id||t}_${n}`)}),(0,l.jsx)(`td`,{className:`py-4 px-4 whitespace-nowrap text-right h-[53px] ${a} relative z-10`,children:(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-1 opacity-20 group-hover:opacity-100 transition-opacity relative`,children:[(0,l.jsx)(`button`,{onClick:()=>G(W===e.id?null:e.id),className:`p-1.5 rounded-lg transition-colors hover:bg-foreground/10 ${i?Lt.find(e=>e.text===i)?.text:`text-foreground/40`}`,children:(0,l.jsx)(n.T,{className:`w-4 h-4`})}),W===e.id&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`fixed inset-0 z-30`,onClick:()=>G(null)}),(0,l.jsxs)(`div`,{className:`absolute top-6 right-8 flex gap-1.5 bg-background/90 backdrop-blur-xl border border-[var(--panel-border)] p-2 rounded-xl shadow-xl z-50 items-center`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.preventDefault(),t.stopPropagation();let n={...J.rowColors||{},[e.id]:`none`},r={...J.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Y({...J,rowColors:n,colorTimestamps:r}),G(null)},className:`w-4 h-4 rounded-full flex items-center justify-center bg-foreground/10 hover:bg-red-500/20 hover:text-red-500 text-foreground/40 transition-colors border border-[var(--panel-border)]/50 shrink-0`,title:`Remove Row Color`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})}),(0,l.jsx)(`div`,{className:`h-4 w-px bg-[var(--panel-border)]/50 mx-0.5`}),Lt.map(t=>(0,l.jsx)(`button`,{onClick:()=>{let n={...J.colorTimestamps||{},[`row_${e.id}`]:Date.now()};Y({...J,rowColors:{...J.rowColors||{},[e.id]:t.text},colorTimestamps:n}),G(null)},className:`w-4 h-4 rounded-full ${t.bgCircle} hover:scale-125 transition-transform border border-[var(--panel-border)]/50`},t.name))]})]}),(0,l.jsx)(`button`,{onClick:()=>de(e.id),className:`p-2 ml-auto rounded-lg text-foreground/20 hover:text-red-500 hover:bg-red-500/10 transition-colors flex items-center justify-center`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})})]})})]},e.id||`row_${t}`)}),he.length===0&&(0,l.jsx)(`tr`,{children:(0,l.jsxs)(`td`,{colSpan:(J.columns||[]).length+2,className:`py-12 text-center text-foreground/40 text-[14px] font-medium border border-[var(--panel-border)] m-4 rounded-xl border-dashed`,children:[`No records found in `,J.name||`this table`,`.`]})}),(0,l.jsx)(`tr`,{children:(0,l.jsx)(`td`,{colSpan:(J.columns||[]).length+2,className:`py-2 px-4 border-none bg-foreground/[0.01]`,children:(0,l.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,l.jsx)(`button`,{onClick:ue,className:`p-1.5 rounded-lg text-foreground/40 hover:text-accent hover:bg-accent/10 transition-colors flex items-center justify-center ml-2 border border-transparent hover:border-accent/20`,children:(0,l.jsx)(n.C,{className:`w-4 h-4`})})})})})]})]},`table`)})})]})]})}var zt=[{text:`text-red-400`,bgCircle:`bg-red-400`,bgCard:`bg-red-500/[0.08]`,borderCard:`border-red-500/30`,bgLight:`bg-red-500/15`,bgHover:`hover:bg-red-500`,bgAlt:`bg-red-500/[0.04]`,name:`Red`},{text:`text-orange-400`,bgCircle:`bg-orange-400`,bgCard:`bg-orange-500/[0.08]`,borderCard:`border-orange-500/30`,bgLight:`bg-orange-500/15`,bgHover:`hover:bg-orange-500`,bgAlt:`bg-orange-500/[0.04]`,name:`Orange`},{text:`text-yellow-400`,bgCircle:`bg-yellow-400`,bgCard:`bg-yellow-500/[0.08]`,borderCard:`border-yellow-500/30`,bgLight:`bg-yellow-500/15`,bgHover:`hover:bg-yellow-500`,bgAlt:`bg-yellow-500/[0.04]`,name:`Yellow`},{text:`text-green-400`,bgCircle:`bg-green-400`,bgCard:`bg-green-500/[0.08]`,borderCard:`border-green-500/30`,bgLight:`bg-green-500/15`,bgHover:`hover:bg-green-500`,bgAlt:`bg-green-500/[0.04]`,name:`Green`},{text:`text-blue-400`,bgCircle:`bg-blue-400`,bgCard:`bg-blue-500/[0.08]`,borderCard:`border-blue-500/30`,bgLight:`bg-blue-500/15`,bgHover:`hover:bg-blue-500`,bgAlt:`bg-blue-500/[0.04]`,name:`Blue`},{text:`text-accent`,bgCircle:`bg-accent`,bgCard:`bg-accent/[0.08]`,borderCard:`border-accent/30`,bgLight:`bg-accent/15`,bgHover:`hover:bg-accent`,bgAlt:`bg-accent/[0.04]`,name:`Purple`},{text:`text-pink-400`,bgCircle:`bg-pink-400`,bgCard:`bg-pink-500/[0.08]`,borderCard:`border-pink-500/30`,bgLight:`bg-pink-500/15`,bgHover:`hover:bg-pink-500`,bgAlt:`bg-pink-500/[0.04]`,name:`Pink`},{text:`text-foreground/60`,bgCircle:`bg-foreground/30`,bgCard:`bg-foreground/[0.04]`,borderCard:`border-[var(--panel-border)]/50`,bgLight:`bg-foreground/15`,bgHover:`hover:bg-foreground/30`,bgAlt:`bg-foreground/[0.02]`,name:`Default`}],Bt={dateStr:``,title:``,description:``,time:`12:00`,duration:`60`,color:``,guestEmail:``,customFields:{}};function Vt({title:e=`Calendar View`,subtitle:t=`/templates/calendar`,backUrl:r=`/templates`,eventsCollection:i=`pub_events`,defaultTimeFormat:c=`12h`,config:d}){let f=!!(d?.isPrivate||d?.isAdmin||d?.isShared);d?.isAdmin,d?.isShared,d?.isPrivate;let p=d?.showButton!==!1,m=d?.buttonText||`+`,h=d?.buttonStyle||`primary`,g=d?.showViewsButton!==!1,_=d?.viewsButtonStyle||`secondary`,v=d?.showPrompt!==!1,y=d?.defaultView||`calendar`,b=d?.customFields||[],x=i.startsWith(`user_`)?`private`:i.startsWith(`mem_`)?`shared`:i.startsWith(`admin_`)?`admin_only`:`public`,[S,C]=(0,a.useState)(()=>{try{let e=localStorage.getItem(`cal_view_${i}`);if(e===`list`||e===`month`)return e}catch{}return y===`board`?`list`:`month`}),[w,T]=(0,a.useState)([]),[E,D]=(0,a.useState)([]),[O,k]=(0,a.useState)(!1),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(Bt),[B,ne]=(0,a.useState)(new Date),[V,H]=(0,a.useState)(!1),[U,W]=(0,a.useState)(null),[G,q]=(0,a.useState)(null),[J,Y]=(0,a.useState)(!1),ae=`cal_24h_${i}`,[oe,se]=(0,a.useState)(()=>{try{let e=localStorage.getItem(ae);if(e!==null)return e===`true`}catch{}return c===`24h`}),ce=()=>{let e=!oe;se(e);try{localStorage.setItem(ae,String(e))}catch{}};(0,a.useEffect)(()=>{try{localStorage.setItem(`cal_view_${i}`,S)}catch{}x===`public`||x===`private`?(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=x===`public`?`public`:`private`;T(e.docs.filter(e=>e.data().formType===t).map(e=>e.id))}):T([])},[S,i,x]);let le=()=>{let e=S===`month`?`list`:`month`;C(e);try{localStorage.setItem(`cal_view_${i}`,e)}catch{}},ue=()=>{try{return sessionStorage.getItem(`cal_guest_email`)||``}catch{return``}},de=e=>{try{sessionStorage.setItem(`cal_guest_email`,e)}catch{}};(0,a.useEffect)(()=>(0,s.onAuthStateChanged)(n.wt,async e=>{if(W(e),e&&x===`admin_only`)try{let t=await(0,o.getDoc)((0,o.doc)(n.Tt,`user_profiles`,e.uid));t.exists()&&q(t.data())}catch{}Y(!0)}),[x]),(0,a.useEffect)(()=>{if(!J)return;if(x!==`public`&&!U){D([]);return}try{let e=localStorage.getItem(`fbos_cal_${i}`);e&&D(JSON.parse(e))}catch{}let e=(0,o.onSnapshot)(x===`private`&&U?(0,o.query)((0,o.collection)(n.Tt,i),(0,o.where)(`uid`,`==`,U.uid)):(0,o.collection)(n.Tt,i),e=>{let t=[];e.forEach(e=>t.push({id:e.id,...e.data()})),D(t),localStorage.setItem(`fbos_cal_${i}`,JSON.stringify(t))},e=>console.error(`Calendar events:`,e));return()=>e()},[i,x,U?.uid,J]);let fe=e=>!!U&&U.uid===e.uid,X=e=>x===`public`?!1:x===`private`?!!U:fe(e),pe=e=>{if(!e)return``;if(oe)return e;let[t,n]=e.split(`:`),r=parseInt(t,10),i=r>=12?`PM`:`AM`;return r=r%12||12,`${r}:${n} ${i}`},me=e=>{if(!e)return`60m`;let t=parseInt(e,10);return isNaN(t)?e:t>=60?t%60==0?`${t/60}h`:`${Math.floor(t/60)}h ${t%60}m`:`${t}m`},Z=e=>{let[t,n]=(e||`12:00`).split(`:`),r=parseInt(t,10)||0,i=parseInt(n,10)||0,a=r>=12?`PM`:`AM`;return r=r%12||12,{h:r,m:i,ampm:a}},he=(e,t,n)=>{let r=e%12;return n===`PM`&&(r+=12),`${r.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},ge=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().split(`T`)[0]},_e=()=>ge(new Date),ve=new Date(B.getFullYear(),B.getMonth(),1),Q=new Date(B.getFullYear(),B.getMonth()+1,0),ye=ve.getDay(),be=Q.getDate(),xe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Se=Array.from({length:42},(e,t)=>{let n=t-ye+1,r=new Date(B.getFullYear(),B.getMonth(),n);return{day:r.getDate(),dateStr:ge(r),isCurrentMonth:n>0&&n<=be}}),Ce=()=>ne(S===`month`?new Date(B.getFullYear(),B.getMonth()-1,1):new Date(B.getFullYear(),B.getMonth(),B.getDate()-1)),we=()=>ne(S===`month`?new Date(B.getFullYear(),B.getMonth()+1,1):new Date(B.getFullYear(),B.getMonth(),B.getDate()+1)),Te=e=>{if(x!==`public`&&!U)return;let t=new Date;t.setDate(t.getDate()+1);let n=new Date().getHours().toString().padStart(2,`0`);z({...Bt,dateStr:e||ge(t),time:`${n}:00`,guestEmail:x===`public`?ue():``,customFields:{}}),k(!0)},Ee=e=>{let t=e.time;if(t){let[e,n]=t.split(`:`);e&&n&&(t=`${e.padStart(2,`0`)}:${n}`)}z({id:e.id,uid:e.uid,dateStr:e.dateStr,title:e.title,description:e.description||``,time:t||`12:00`,duration:e.duration||`60`,color:e.color||``,guestEmail:e.creatorEmail||``,customFields:e.customFields||{}}),k(!0)},De=async e=>{if(e.preventDefault(),R.title.trim()){N(!0);try{let e={dateStr:R.dateStr,title:R.title.trim(),description:R.description.trim(),time:R.time,duration:R.duration||`60`};if(R.color&&(e.color=R.color),b.length>0&&(e.customFields=R.customFields),!R.id)if(x===`public`){let t=R.guestEmail.trim();e.creatorEmail=t,de(t)}else x===`private`||x===`shared`?(e.uid=U?.uid,e.creatorEmail=U?.email||``,e.creatorName=U?.displayName||``,e.creatorAvatar=U?.photoURL||``):x===`admin_only`&&(e.uid=U?.uid,e.creatorEmail=G?.email||U?.email||``,e.creatorName=G?.displayName||G?.name||``,e.creatorAvatar=G?.avatar||G?.avatarUrl||U?.photoURL||``);R.id?(await(0,o.setDoc)((0,o.doc)(n.Tt,i,R.id),e,{merge:!0}),A?.id===R.id&&j({...A,...e})):await(0,o.setDoc)((0,o.doc)(n.Tt,i,`ev_${Date.now()}`),e,{merge:!0}),k(!1)}catch(e){console.error(e)}N(!1)}},Oe=async()=>{if(I){F(!0);try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,i,I.id)),A?.id===I.id&&j(null),L(null),k(!1)}catch{}F(!1)}},ke=e=>{if(x===`private`||!e.creatorEmail&&!e.creatorName)return null;let t=(e.creatorName||e.creatorEmail||`?`).charAt(0).toUpperCase(),n=zt.find(t=>t.text===e.color);return(0,l.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 p-3 rounded-xl bg-foreground/[0.03] border border-[var(--panel-border)]/50`,children:[e.creatorAvatar?(0,l.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-8 h-8 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full ${n?.bgCircle||`bg-accent`} flex items-center justify-center text-[13px] font-extrabold text-white shrink-0`,children:t}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[e.creatorName&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold text-foreground/90 truncate`,children:e.creatorName}),e.creatorEmail&&(0,l.jsx)(`span`,{className:`text-[12px] text-foreground/50 truncate`,children:e.creatorEmail})]})]})},Ae=e=>{if(x===`private`||x===`public`||!e.creatorName&&!e.creatorEmail)return null;let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||``,n=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[e.creatorAvatar?(0,l.jsx)(`img`,{src:e.creatorAvatar,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:n}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),e.creatorEmail&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,e.creatorEmail]})]})]})},je=x===`admin_only`?ie(d,e,i,w):x===`private`?re(d,e,i,w):K(d,e,i,w),Me=()=>{navigator.clipboard.writeText(je),H(!0),setTimeout(()=>H(!1),2e3)};if(J&&x!==`public`&&!U)return(0,l.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen p-8`,children:(0,l.jsxs)(`div`,{className:`text-center glass-panel border border-[var(--panel-border)] rounded-3xl p-12 max-w-sm w-full`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-accent/10 border border-accent/20 flex items-center justify-center mx-auto mb-4`,children:(0,l.jsx)(n.k,{className:`w-7 h-7 text-accent`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold mb-2`,children:`Sign in required`}),(0,l.jsx)(`p`,{className:`text-foreground/50 text-[14px] mb-6`,children:`You need to be signed in to access this calendar.`}),(0,l.jsx)(u.Link,{to:`/login`,className:`inline-flex items-center justify-center gap-2 px-6 py-2.5 rounded-xl btn-primary font-bold text-[14px] w-full`,children:`Sign In`})]})});if(!J&&x!==`public`)return(0,l.jsx)(`main`,{className:`flex-1 w-full flex items-center justify-center min-h-screen`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})});let Ne=(x===`public`||!!U)&&p,Pe=()=>(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:d?.tabTitle||d?.tabName||e}),(0,l.jsxs)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:[E.length,` `,E.length===1?`event`:`events`,` · `,S===`month`?`Month`:`Board`,` View`]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[v&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:Me,title:V?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${V?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:V?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:ce,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer btn-secondary text-[12px] font-extrabold`,children:oe?`24h`:`12h`}),g&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:le,title:S===`month`?`Switch to Board`:`Switch to Calendar`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${_===`primary`?`btn-primary`:`btn-secondary`}`,children:S===`month`?(0,l.jsx)(n.F,{className:`w-4 h-4`}):(0,l.jsx)(n.dt,{className:`w-4 h-4`})}),Ne&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>Te(),className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${m===`+`?`w-10`:`px-5`} ${h===`primary`?`btn-primary`:`btn-secondary`}`,children:m===`+`?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:m})})]})]}),Fe=()=>(0,l.jsxs)(`div`,{className:`p-4 md:p-6 border-b border-[var(--panel-border)]/50 flex items-center justify-between bg-foreground/[0.01]`,children:[(0,l.jsx)(`h3`,{className:`text-xl font-extrabold tracking-tight ml-2`,children:S===`month`?B.toLocaleString(`default`,{month:`long`,year:`numeric`}):B.toLocaleString(`default`,{month:`long`,day:`numeric`,year:`numeric`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(`button`,{onClick:()=>ne(new Date),className:`px-4 py-2 text-[13px] font-bold border border-[var(--panel-border)] rounded-xl mr-2 hover:bg-foreground/5 transition-colors`,children:`Today`}),(0,l.jsx)(`button`,{onClick:Ce,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.ot,{className:`w-5 h-5`})}),(0,l.jsx)(`button`,{onClick:we,className:`p-2 rounded-xl text-foreground/50 hover:text-foreground hover:bg-foreground/5 transition-colors border border-transparent hover:border-[var(--panel-border)]`,children:(0,l.jsx)(n.at,{className:`w-5 h-5`})})]})]}),$=()=>(0,l.jsxs)(l.Fragment,{children:[Fe(),S===`month`?(0,l.jsx)(`div`,{className:`overflow-x-auto w-full flex-1`,children:(0,l.jsxs)(`div`,{className:`min-w-[800px] h-full flex flex-col`,children:[(0,l.jsx)(`div`,{className:`grid grid-cols-7 border-b border-[var(--panel-border)]/50 bg-foreground/[0.02]`,children:xe.map(e=>(0,l.jsx)(`div`,{className:`py-3 text-center text-[12px] font-bold uppercase tracking-wider text-foreground/40`,children:e},e))}),(0,l.jsx)(`div`,{className:`grid grid-cols-7 auto-rows-auto bg-[var(--panel-border)] gap-[1px] relative flex-1`,children:Se.map((e,t)=>{let r=e.dateStr===_e(),i=E.filter(t=>t.dateStr===e.dateStr);return(0,l.jsxs)(`div`,{onClick:()=>e.isCurrentMonth&&Ne&&Te(e.dateStr),className:`min-h-[140px] p-2 bg-[var(--panel-bg)] flex flex-col relative group
424
372
  ${e.isCurrentMonth?Ne?`hover:bg-foreground/[0.03] transition-colors cursor-cell`:``:`opacity-30 bg-background/50 pointer-events-none`}`,children:[(0,l.jsx)(`div`,{className:`flex justify-between items-start mb-2 shrink-0`,children:(0,l.jsx)(`span`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[14px] font-bold ${r?`bg-accent text-white shadow-lg shadow-accent/20`:`text-foreground/70 group-hover:text-foreground`}`,children:e.day})}),(0,l.jsx)(`div`,{className:`flex flex-col gap-1.5 flex-1 w-full relative z-10 pb-1`,children:i.map(e=>{let t=zt.find(t=>t.text===e.color),r=X(e);return(0,l.jsxs)(`div`,{className:`px-2 py-1.5 rounded-lg border transition-colors shadow-sm cursor-pointer group/ev relative ${t?t.bgCard+` `+t.borderCard:`bg-accent/20 border-accent/30 hover:bg-accent/40`}`,onClick:t=>{t.stopPropagation(),j(e)},children:[(0,l.jsx)(`p`,{className:`text-[12px] font-bold truncate leading-tight ${r?`pr-5`:``} ${t?t.text:`text-foreground`}`,children:e.title}),(0,l.jsx)(`p`,{className:`text-[10px] text-foreground/70 mt-0.5`,children:pe(e.time)}),r&&(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ee(e)},className:`absolute top-1 right-1 opacity-0 group-hover/ev:opacity-100 p-1 text-foreground/60 hover:bg-foreground/10 hover:text-foreground transition-all rounded`,children:(0,l.jsx)(n.w,{className:`w-3 h-3`})})]},e.id)})})]},t)})}),(0,l.jsx)(`style`,{children:`
425
373
  .styled-scrollbars::-webkit-scrollbar{width:4px}
426
374
  .styled-scrollbars::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--accent-color) 30%,transparent);border-radius:4px}
@@ -428,11 +376,11 @@ Build with the user's active theme in mind:
428
376
  input[type="date"]{color-scheme:dark}
429
377
  input[type="date"]::-webkit-calendar-picker-indicator{cursor:pointer;opacity:.5;transition:opacity .2s}
430
378
  input[type="date"]::-webkit-calendar-picker-indicator:hover{opacity:1}
431
- `})]})}):(0,l.jsxs)(`div`,{className:`flex flex-col p-4 md:p-8 overflow-y-auto w-full flex-1 gap-4`,children:[E.filter(e=>e.dateStr===ge(R)).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>{let t=new Date(e.dateStr+`T12:00:00`),r=zt.find(t=>t.text===e.color),i=X(e);return(0,l.jsxs)(`div`,{onClick:()=>j(e),className:`p-4 rounded-2xl border flex flex-col cursor-pointer transition-colors group ${r?r.bgCard+` `+r.borderCard+` hover:brightness-110`:`bg-foreground/[0.01] border-[var(--panel-border)]/70 hover:border-accent/40 hover:bg-foreground/[0.02]`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`w-11 h-11 md:w-12 md:h-12 rounded-xl flex flex-col items-center justify-center border transition-colors shadow-sm ${r?r.bgCard+` `+r.borderCard:`bg-foreground/5 border-[var(--panel-border)] group-hover:bg-accent/10 group-hover:border-accent/30`}`,children:[(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase leading-none mb-0.5 ${r?r.text:`text-foreground/40 group-hover:text-accent/60`}`,children:t.toLocaleString(`default`,{month:`short`})}),(0,l.jsx)(`span`,{className:`text-[18px] font-black leading-none ${r?r.text:`group-hover:text-accent`}`,children:t.getDate()})]}),(0,l.jsx)(`div`,{className:`h-6 w-px bg-[var(--panel-border)] hidden sm:block group-hover:bg-accent/30 transition-colors`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`h4`,{className:`text-[15px] md:text-[16px] font-extrabold tracking-tight truncate ${r?r.text:`text-foreground group-hover:text-accent`}`,children:e.title}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 text-[12px] text-foreground/50 font-medium`,children:[(0,l.jsx)(`span`,{children:pe(e.time)}),(0,l.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(n.et,{className:`w-3 h-3`}),me(e.duration)]})]})]}),i&&(0,l.jsxs)(`div`,{className:`ml-auto pl-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ee(e)},className:`p-2.5 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),re(e)},className:`p-2.5 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})})]})]}),f&&Ae(e)]},e.id)}),E.filter(e=>e.dateStr===ge(R)).length===0&&(0,l.jsx)(`div`,{className:`p-12 text-center text-foreground/40 font-medium`,children:`No events scheduled for this day.`})]})]}),Ie=()=>(0,l.jsxs)(n.a,{children:[A&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 rounded-3xl glass-panel border shadow-2xl relative z-10 ${zt.find(e=>e.text===A.color)?.bgCard||`bg-background`} ${zt.find(e=>e.text===A.color)?.borderCard||`border-[var(--panel-border)]`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 bg-background/50 backdrop-blur-3xl p-1 rounded-2xl border border-[var(--panel-border)]/50 shadow-sm z-50`,children:[X(A)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{j(null),Ee(A)},className:`p-2 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-all`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{re(A),j(null)},className:`p-2 rounded-xl text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-all`,title:`Delete`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`w-px h-6 bg-[var(--panel-border)]/50 mx-1`})]}),(0,l.jsx)(`button`,{onClick:()=>j(null),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),(0,l.jsxs)(`div`,{className:`mb-6 pr-32`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,l.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${zt.find(e=>e.text===A.color)?.bgCircle||`bg-accent`}`}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold tracking-[0.2em] uppercase ${zt.find(e=>e.text===A.color)?.text||`text-accent`}`,children:`Event Details`})]}),(0,l.jsx)(`h3`,{className:`text-3xl font-black mb-3 tracking-tight leading-tight break-words ${zt.find(e=>e.text===A.color)?.text||`text-foreground`}`,children:A.title}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 mt-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.dt,{className:`w-4 h-4 text-foreground/50`})}),new Date(A.dateStr+`T12:00:00`).toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-4 h-4 text-foreground/50`})}),pe(A.time),` `,(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[12px] ml-1`,children:[`(`,me(A.duration),`)`]})]})]}),ke(A)]}),(0,l.jsx)(`div`,{className:`w-full h-px bg-gradient-to-r from-[var(--panel-border)]/0 via-[var(--panel-border)] to-[var(--panel-border)]/0 mb-6`}),A.description?(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-[var(--panel-border)]/50 rounded-2xl py-3 px-4 mb-4 w-full overflow-hidden`,children:(0,l.jsx)(`div`,{className:`text-[14px] text-foreground/80 font-medium whitespace-pre-wrap leading-tight break-words`,children:A.description})}):(0,l.jsx)(`div`,{className:`p-4 mb-4 rounded-2xl border border-dashed border-[var(--panel-border)] bg-foreground/[0.01] text-center`,children:(0,l.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/40`,children:`No description provided for this event.`})}),A.customFields&&Object.entries(A.customFields).filter(([,e])=>e).length>0&&(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mb-2`,children:Object.entries(A.customFields).filter(([,e])=>e).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[13px]`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground/50 capitalize shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-foreground/80 font-medium break-words min-w-0`,children:t})]},e))})]})]},`view-modal`),O&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>k(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 max-h-[90vh] overflow-y-auto styled-scrollbars`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1`,children:[I.id&&X({uid:I.uid})&&(0,l.jsx)(`button`,{onClick:()=>{k(!1),re({id:I.id,...I})},className:`p-2 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-all`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>k(!1),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),(0,l.jsxs)(`div`,{className:`mb-6 pr-12`,children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold mb-1 tracking-tight`,children:I.id?`Edit Event`:`Add Event`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50`,children:I.id?`Modify your scheduled calendar block.`:`Schedule a new calendar block.`})]}),(0,l.jsxs)(`form`,{onSubmit:De,className:`space-y-4`,children:[x===`public`&&!I.id&&(0,l.jsx)(n.r,{label:`Your Email`,type:`email`,value:I.guestEmail,onChange:e=>L({...I,guestEmail:e.target.value}),placeholder:`you@example.com`,required:!0}),(0,l.jsx)(n.r,{label:`Event Title`,value:I.title,onChange:e=>L({...I,title:e.target.value}),placeholder:`e.g. Design Sync`,required:!0}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Description`}),(0,l.jsx)(`textarea`,{value:I.description,onChange:e=>L({...I,description:e.target.value}),placeholder:`e.g. Discussing the new features...`,className:`block min-h-[80px] w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus glass-panel styled-scrollbars resize-none`})]}),b.map(e=>(0,l.jsx)(n.r,{label:e,value:I.customFields[e]||``,onChange:t=>L({...I,customFields:{...I.customFields,[e]:t.target.value}}),placeholder:`Enter ${e.toLowerCase()}...`},e)),(0,l.jsx)(`style`,{children:`
379
+ `})]})}):(0,l.jsxs)(`div`,{className:`flex flex-col p-4 md:p-8 overflow-y-auto w-full flex-1 gap-4`,children:[E.filter(e=>e.dateStr===ge(B)).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>{let t=new Date(e.dateStr+`T12:00:00`),r=zt.find(t=>t.text===e.color),i=X(e);return(0,l.jsxs)(`div`,{onClick:()=>j(e),className:`p-4 rounded-2xl border flex flex-col cursor-pointer transition-colors group ${r?r.bgCard+` `+r.borderCard+` hover:brightness-110`:`bg-foreground/[0.01] border-[var(--panel-border)]/70 hover:border-accent/40 hover:bg-foreground/[0.02]`}`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`w-11 h-11 md:w-12 md:h-12 rounded-xl flex flex-col items-center justify-center border transition-colors shadow-sm ${r?r.bgCard+` `+r.borderCard:`bg-foreground/5 border-[var(--panel-border)] group-hover:bg-accent/10 group-hover:border-accent/30`}`,children:[(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase leading-none mb-0.5 ${r?r.text:`text-foreground/40 group-hover:text-accent/60`}`,children:t.toLocaleString(`default`,{month:`short`})}),(0,l.jsx)(`span`,{className:`text-[18px] font-black leading-none ${r?r.text:`group-hover:text-accent`}`,children:t.getDate()})]}),(0,l.jsx)(`div`,{className:`h-6 w-px bg-[var(--panel-border)] hidden sm:block group-hover:bg-accent/30 transition-colors`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`h4`,{className:`text-[15px] md:text-[16px] font-extrabold tracking-tight truncate ${r?r.text:`text-foreground group-hover:text-accent`}`,children:e.title}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 text-[12px] text-foreground/50 font-medium`,children:[(0,l.jsx)(`span`,{children:pe(e.time)}),(0,l.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(n.et,{className:`w-3 h-3`}),me(e.duration)]})]})]}),i&&(0,l.jsxs)(`div`,{className:`ml-auto pl-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ee(e)},className:`p-2.5 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-colors`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),L(e)},className:`p-2.5 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-colors`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})})]})]}),f&&Ae(e)]},e.id)}),E.filter(e=>e.dateStr===ge(B)).length===0&&(0,l.jsx)(`div`,{className:`p-12 text-center text-foreground/40 font-medium`,children:`No events scheduled for this day.`})]})]}),Ie=()=>(0,l.jsxs)(n.a,{children:[A&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>j(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 rounded-3xl glass-panel border shadow-2xl relative z-10 ${zt.find(e=>e.text===A.color)?.bgCard||`bg-background`} ${zt.find(e=>e.text===A.color)?.borderCard||`border-[var(--panel-border)]`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 bg-background/50 backdrop-blur-3xl p-1 rounded-2xl border border-[var(--panel-border)]/50 shadow-sm z-50`,children:[X(A)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:()=>{j(null),Ee(A)},className:`p-2 rounded-xl text-foreground/50 hover:bg-foreground/10 hover:text-foreground transition-all`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{L(A),j(null)},className:`p-2 rounded-xl text-foreground/50 hover:bg-red-500/10 hover:text-red-500 transition-all`,title:`Delete`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})}),(0,l.jsx)(`div`,{className:`w-px h-6 bg-[var(--panel-border)]/50 mx-1`})]}),(0,l.jsx)(`button`,{onClick:()=>j(null),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),(0,l.jsxs)(`div`,{className:`mb-6 pr-32`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,l.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${zt.find(e=>e.text===A.color)?.bgCircle||`bg-accent`}`}),(0,l.jsx)(`span`,{className:`text-[11px] font-bold tracking-[0.2em] uppercase ${zt.find(e=>e.text===A.color)?.text||`text-accent`}`,children:`Event Details`})]}),(0,l.jsx)(`h3`,{className:`text-3xl font-black mb-3 tracking-tight leading-tight break-words ${zt.find(e=>e.text===A.color)?.text||`text-foreground`}`,children:A.title}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 mt-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.dt,{className:`w-4 h-4 text-foreground/50`})}),new Date(A.dateStr+`T12:00:00`).toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2.5 text-[14px] text-foreground/70 font-medium`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-foreground/5 border border-[var(--panel-border)] flex items-center justify-center shrink-0`,children:(0,l.jsx)(n.et,{className:`w-4 h-4 text-foreground/50`})}),pe(A.time),` `,(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[12px] ml-1`,children:[`(`,me(A.duration),`)`]})]})]}),ke(A)]}),(0,l.jsx)(`div`,{className:`w-full h-px bg-gradient-to-r from-[var(--panel-border)]/0 via-[var(--panel-border)] to-[var(--panel-border)]/0 mb-6`}),A.description?(0,l.jsx)(`div`,{className:`bg-foreground/[0.02] border border-[var(--panel-border)]/50 rounded-2xl py-3 px-4 mb-4 w-full overflow-hidden`,children:(0,l.jsx)(`div`,{className:`text-[14px] text-foreground/80 font-medium whitespace-pre-wrap leading-tight break-words`,children:A.description})}):(0,l.jsx)(`div`,{className:`p-4 mb-4 rounded-2xl border border-dashed border-[var(--panel-border)] bg-foreground/[0.01] text-center`,children:(0,l.jsx)(`p`,{className:`text-[12px] font-medium text-foreground/40`,children:`No description provided for this event.`})}),A.customFields&&Object.entries(A.customFields).filter(([,e])=>e).length>0&&(0,l.jsx)(`div`,{className:`flex flex-col gap-2 mb-2`,children:Object.entries(A.customFields).filter(([,e])=>e).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[13px]`,children:[(0,l.jsxs)(`span`,{className:`font-bold text-foreground/50 capitalize shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-foreground/80 font-medium break-words min-w-0`,children:t})]},e))})]})]},`view-modal`),O&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>k(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/80 backdrop-blur-xl cursor-pointer`}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`w-full max-w-[500px] p-6 sm:p-8 rounded-3xl glass-panel border border-[var(--panel-border)] shadow-2xl relative z-10 max-h-[90vh] overflow-y-auto styled-scrollbars`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1`,children:[R.id&&X({uid:R.uid})&&(0,l.jsx)(`button`,{onClick:()=>{k(!1),L({id:R.id,...R})},className:`p-2 rounded-xl text-foreground/30 hover:bg-red-500/10 hover:text-red-500 transition-all`,children:(0,l.jsx)(n.m,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>k(!1),className:`p-2 rounded-xl text-foreground/40 hover:bg-foreground/10 hover:text-foreground transition-all`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})})]}),(0,l.jsxs)(`div`,{className:`mb-6 pr-12`,children:[(0,l.jsx)(`h3`,{className:`text-2xl font-extrabold mb-1 tracking-tight`,children:R.id?`Edit Event`:`Add Event`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/50`,children:R.id?`Modify your scheduled calendar block.`:`Schedule a new calendar block.`})]}),(0,l.jsxs)(`form`,{onSubmit:De,className:`space-y-4`,children:[x===`public`&&!R.id&&(0,l.jsx)(n.r,{label:`Your Email`,type:`email`,value:R.guestEmail,onChange:e=>z({...R,guestEmail:e.target.value}),placeholder:`you@example.com`,required:!0}),(0,l.jsx)(n.r,{label:`Event Title`,value:R.title,onChange:e=>z({...R,title:e.target.value}),placeholder:`e.g. Design Sync`,required:!0}),(0,l.jsxs)(`div`,{className:`flex flex-col w-full relative`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Description`}),(0,l.jsx)(`textarea`,{value:R.description,onChange:e=>z({...R,description:e.target.value}),placeholder:`e.g. Discussing the new features...`,className:`block min-h-[80px] w-full rounded-xl text-[15px] text-foreground px-4 py-3 transition-all duration-300 placeholder:text-foreground/40 focus:outline-none focus:border-accent glow-focus glass-panel styled-scrollbars resize-none`})]}),b.map(e=>(0,l.jsx)(n.r,{label:e,value:R.customFields[e]||``,onChange:t=>z({...R,customFields:{...R.customFields,[e]:t.target.value}}),placeholder:`Enter ${e.toLowerCase()}...`},e)),(0,l.jsx)(`style`,{children:`
432
380
  input[type="date"]::-webkit-calendar-picker-indicator{background:transparent;bottom:0;color:transparent;cursor:pointer;height:auto;left:0;position:absolute;right:0;top:0;width:auto;z-index:10}
433
381
  input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
434
382
  input[type="number"]{-moz-appearance:textfield}
435
- `}),(0,l.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,l.jsx)(n.r,{type:`date`,label:`Date`,required:!0,value:I.dateStr,onChange:e=>L({...I,dateStr:e.target.value}),className:`pr-10`}),(0,l.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,l.jsx)(n.dt,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[Y?(0,l.jsx)(n.r,{type:`time`,label:`Time`,value:I.time,onChange:e=>L({...I,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=Z(I.time);return(0,l.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,l.jsxs)(`div`,{className:`flex items-center h-12 glass-panel border border-[var(--panel-border)] rounded-xl px-3 gap-1 focus-within:border-accent transition-colors`,children:[(0,l.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>L({...I,time:he(Math.min(12,Math.max(1,parseInt(e.target.value)||12)),t,n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,l.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,l.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>L({...I,time:he(e,Math.min(59,Math.max(0,parseInt(t.target.value)||0)),n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>L({...I,time:he(e,t,n===`AM`?`PM`:`AM`)}),className:`ml-auto px-2 py-0.5 rounded-md bg-accent/10 text-accent text-[11px] font-extrabold uppercase tracking-wider hover:bg-accent/20 transition-colors shrink-0`,children:n})]})]})})(),(0,l.jsx)(n.r,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:I.duration,onChange:e=>L({...I,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,l.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:zt.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>L({...I,color:I.color===e.text?``:e.text}),className:`w-6 h-6 rounded-full shrink-0 ${e.bgCircle} hover:scale-110 transition-transform flex items-center justify-center border border-[var(--panel-border)]`,children:I.color===e.text&&(0,l.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:M,className:`w-full py-3`,children:I.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,l.jsx)(te,{isOpen:!!F,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:F?.title}),` This action is permanent.`]}),onConfirm:Oe,onCancel:()=>{re(null)},isProcessing:ne,confirmText:`Yes, Delete`})]});return f?(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:d?.tabTitle||d?.tabName||e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[Pe(),$()]})]}),Ie()]}):(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[r?(0,l.jsxs)(u.Link,{to:r,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}):(0,l.jsx)(`div`,{}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:ce,className:`px-3 h-10 text-[12px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0 hover:bg-foreground/5 shadow-sm text-foreground/70`,children:Y?`24h`:`12h`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:le,className:`w-10 h-10 p-0 text-[14px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0`,children:S===`month`?(0,l.jsx)(n.F,{className:`w-4 h-4 text-foreground/70`}):(0,l.jsx)(n.dt,{className:`w-4 h-4 text-foreground/70`})}),Ne&&(0,l.jsxs)(n.n,{onClick:()=>Te(),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center gap-2`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Event`]})]})]}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col flex-1`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),$()]}),Ie()]})}var Ht={appName:`The main name of your application shown in headers and titles.`,defaultTheme:`Choose how the app starts immediately on load.`,showThemeToggle:`Allow users to manually toggle dark mode on/off.`,logoUrl:`Direct URL to your app's main logo. Need to upload one?`,faviconUrl:`Direct URL to your app's favicon. Need to upload one?`,background:`Main background canvas color under all content.`,foreground:`Primary typography color used across the app.`,accent:`The primary brand color for highlights, buttons, and links.`,panelBg:`Background color of glass cards and panels.`,panelBorder:`Borders of panels, inputs, and dropdowns.`,glowColor:`The global glow shadow applied to borders of focused inputs.`,buttonHoverGradient:`Start and end hex for primary button hover effects.`,textGradient:`Three tone gradient applied to large headers.`,buttonRadius:`Border radius for standard buttons.`,cardRadius:`Curvature of main content panels.`,inputRadius:`Rounding applied to form inputs.`,modalRadius:`Global popup containers and dashboard content cards.`,blurIntensity:`Glassmorphism backdrop-blur amounts.`,notificationIconColor:`Color applied to notification badging.`,fontFamily:`Choose the main typography of your brand.`,home:`Complete customization of the landing page settings.`,title:`Main heading displayed on the Landing Page or Form.`,subtitle:`Smaller colored overline text above the main title.`,text:`The descriptive paragraph text under the hero headers or buttons.`,primary:`Main call-to-action block settings.`,secondary:`Secondary ghost button block settings.`,sections:`Toggle visibility of landing page sectors.`,contactForm:`Customize the form wrapper and its labels.`,nameLabel:`Placeholder/Label for the Name input.`,emailLabel:`Placeholder/Label for the Email input.`,messageLabel:`Placeholder/Label for the Message textarea.`,submitText:`Text for the form submit button.`,action:`Where the button routes the user.`,form:`Which public form to open. Note: Form submissions will securely map to the Submissions tab in your admin dashboard.`,url:`External http link or internal /route destination.`},Ut=[{name:`Purple Standard`,preview:[`#2e1065`,`#cdc1ff`],dark:{buttonText:`#ffffff`,background:`#07070f`,backgroundSecondary:`#0a0a18`,accent:`#a78bfa`,gradient:[`#6d28d9`,`#a78bfa`],text:[`#f0eeff`,`#c4b5fd`,`#a78bfa`]},light:{buttonText:`#ffffff`,background:`#fcfaff`,backgroundSecondary:`#f7f3ff`,accent:`#7c3aed`,gradient:[`#5b21b6`,`#a78bfa`],text:[`#2e1065`,`#6d28d9`,`#cdc1ff`]}},{name:`Royal Navy`,preview:[`#1e3a8a`,`#60a5fa`],dark:{buttonText:`#ffffff`,background:`#050b14`,backgroundSecondary:`#0a192f`,accent:`#60a5fa`,gradient:[`#1d4ed8`,`#60a5fa`],text:[`#dbeafe`,`#93c5fd`,`#60a5fa`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#f1f5f9`,accent:`#2563eb`,gradient:[`#1e3a8a`,`#60a5fa`],text:[`#1e3a8a`,`#2563eb`,`#60a5fa`]}},{name:`Emerald Green`,preview:[`#064e3b`,`#10b981`],dark:{buttonText:`#ffffff`,background:`#050806`,backgroundSecondary:`#0a2218`,accent:`#34d399`,gradient:[`#047857`,`#34d399`],text:[`#d1fae5`,`#6ee7b7`,`#34d399`]},light:{buttonText:`#ffffff`,background:`#f6fbf8`,backgroundSecondary:`#eff7f2`,accent:`#059669`,gradient:[`#064e3b`,`#10b981`],text:[`#064e3b`,`#059669`,`#10b981`]}},{name:`Gold`,preview:[`#854d0e`,`#eab308`],dark:{buttonText:`#000000`,background:`#0f0905`,backgroundSecondary:`#1c1208`,accent:`#fcd34d`,gradient:[`#ca8a04`,`#facc15`],text:[`#fefce8`,`#fef08a`,`#facc15`]},light:{buttonText:`#ffffff`,background:`#fbfaf6`,backgroundSecondary:`#f5f2eb`,accent:`#d97706`,gradient:[`#854d0e`,`#eab308`],text:[`#854d0e`,`#ca8a04`,`#eab308`]}},{name:`Silver`,preview:[`#1e293b`,`#94a3b8`],dark:{buttonText:`#ffffff`,background:`#090e17`,backgroundSecondary:`#101725`,accent:`#cbd5e1`,gradient:[`#475569`,`#94a3b8`],text:[`#e2e8f0`,`#94a3b8`,`#cbd5e1`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#e2e8f0`,accent:`#64748b`,gradient:[`#1e293b`,`#94a3b8`],text:[`#1e293b`,`#475569`,`#94a3b8`]}},{name:`Barbie Pink`,preview:[`#d946ef`,`#f472b6`],dark:{buttonText:`#ffffff`,background:`#0c030a`,backgroundSecondary:`#1a0515`,accent:`#ff80ff`,gradient:[`#c026d3`,`#f472b6`],text:[`#ffeeff`,`#ffb3ff`,`#ff80ff`]},light:{buttonText:`#ffffff`,background:`#fcf5fa`,backgroundSecondary:`#f5ebf2`,accent:`#d946ef`,gradient:[`#c026d3`,`#ec4899`],text:[`#a21caf`,`#c026d3`,`#ec4899`]}},{name:`Orange`,preview:[`#7c2d12`,`#f97316`],dark:{buttonText:`#ffffff`,background:`#0a0200`,backgroundSecondary:`#1c0b05`,accent:`#fb923c`,gradient:[`#c2410c`,`#fb923c`],text:[`#fff7ed`,`#fdba74`,`#fb923c`]},light:{buttonText:`#ffffff`,background:`#fdf6f2`,backgroundSecondary:`#f5ebe4`,accent:`#ea580c`,gradient:[`#7c2d12`,`#f97316`],text:[`#7c2d12`,`#ea580c`,`#f97316`]}},{name:`Red`,preview:[`#7f1d1d`,`#ef4444`],dark:{buttonText:`#ffffff`,background:`#0a0000`,backgroundSecondary:`#2e0a0a`,accent:`#ef4444`,gradient:[`#b91c1c`,`#f87171`],text:[`#fef2f2`,`#fecaca`,`#f87171`]},light:{buttonText:`#ffffff`,background:`#fdf5f5`,backgroundSecondary:`#f5ebeb`,accent:`#dc2626`,gradient:[`#7f1d1d`,`#ef4444`],text:[`#7f1d1d`,`#dc2626`,`#ef4444`]}},{name:`Black & White`,preview:[`#ffffff`,`#000000`],dark:{buttonText:`#000000`,background:`#000000`,backgroundSecondary:`#111111`,accent:`#ffffff`,gradient:[`#ffffff`,`#e5e7eb`],text:[`#ffffff`,`#f3f4f6`,`#ffffff`]},light:{buttonText:`#ffffff`,background:`#ffffff`,backgroundSecondary:`#f3f4f6`,accent:`#000000`,gradient:[`#000000`,`#1f2937`],text:[`#000000`,`#1f2937`,`#374151`]}}],Wt={defaultTheme:[`system`,`light`,`dark`],cornerRounding:[`default`,`custom`],action:[`sign_in`,`register`,`redirect`,`form`],type:[`text`,`email`,`tel`,`textarea`],form:[`contact`],formType:[`public`,`private`],submitPage:[`submissions`,`requests`],fontFamily:[`Inter`,`Outfit`,`Roboto`,`Space Grotesk`,`Plus Jakarta Sans`,`System UI`]};n.Tt&&(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=[];e.forEach(e=>{e.data().formType!==`private`&&t.push(e.id)}),t.length>0&&Object.assign(Wt,{form:t})}).catch(()=>{});var Gt=({value:e,onChange:t,onBlur:n,onFocus:r,className:i,isNumber:o,handleBlurOrEnter:s,placeholder:c,disabled:u})=>{let[d,f]=a.default.useState(e),[p,m]=a.default.useState(!1),h=a.default.useRef(null);a.default.useEffect(()=>{f(e)},[e]),(0,a.useEffect)(()=>{!p&&h.current&&(h.current.scrollLeft=0)},[d,p]);let g=typeof i==`string`?i.match(/(?:max-w-\[[^\]]+\]|sm:max-w-\[[^\]]+\]|md:max-w-\[[^\]]+\])\s*/g):null,_=g?g.join(` `):`max-w-[200px] sm:max-w-[300px]`,v=typeof i==`string`?i.replace(/(?:max-w-\[[^\]]+\]|sm:max-w-\[[^\]]+\]|md:max-w-\[[^\]]+\]|text-ellipsis)\s*/g,``):``,y=v.trim();return(0,l.jsx)(`div`,{className:`relative inline-grid group/autoresize ${_}`,children:(0,l.jsxs)(`div`,{className:`col-start-1 row-start-1 overflow-x-auto overflow-y-hidden pb-[1px] styled-scrollbars-mini inline-grid items-center`,children:[(0,l.jsx)(`span`,{className:`${v} invisible whitespace-pre col-start-1 row-start-1 border-none p-0 inline-block px-[2px]`,"aria-hidden":`true`,children:d||c||(o?`0`:` `)}),(0,l.jsx)(`input`,{disabled:u,ref:h,type:o?`number`:`text`,value:d,placeholder:c,spellCheck:!1,className:`${y} col-start-1 row-start-1 w-full min-w-[20px] transition-all duration-200 ${u?`cursor-not-allowed opacity-50 select-none`:``} ${p?`relative z-50 bg-background shadow-md`:``}`,onDoubleClick:e=>{u||e.currentTarget.select()},onPaste:()=>{setTimeout(()=>{h.current&&(h.current.scrollLeft=0)},10)},onChange:e=>{u||f(e.target.value)},onKeyDown:n=>{if(!u&&n.key===`Enter`){let r=o?parseFloat(n.currentTarget.value)||0:n.currentTarget.value;r!==e&&t(r),s&&s(n),n.currentTarget.blur()}},onBlur:r=>{if(u)return;m(!1);let i=o?parseFloat(r.currentTarget.value)||0:r.currentTarget.value;i!==e&&t(i),s&&s(r),n&&n(r),r.currentTarget.scrollLeft=0},onFocus:e=>{u||(m(!0),r&&r(e))}})]})})},Kt=({objectKey:e,displayKey:r,value:i,onChange:o,depth:s=0,isLast:c=!1,keysToRender:d,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h=[],hideInnerLoader:g=!1,meta:_={}})=>{let v=r||e,y=typeof i==`object`&&!!i&&!Array.isArray(i),b=Array.isArray(i),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(e===`colors`||e===`fields`),[T,E]=(0,a.useState)(!1),[D,ee]=(0,a.useState)(!1),O=a.default.useRef(null),[k,A]=a.default.useState(null),te=a.default.useRef(null);(0,a.useEffect)(()=>{f||E(!1)},[f]);let j=e=>{O.current=e.currentTarget.value},M=e=>{`key`in e&&e.key===`Enter`&&e.currentTarget.blur(),(`type`in e&&e.type===`blur`||`key`in e&&e.key===`Enter`)&&(O.current!==null&&O.current!==e.currentTarget.value&&(g||E(!0)),O.current=null)};a.default.useEffect(()=>{A(null)},[i]);let N=p?.[e]||Ht[e],ne=m?.[e]||Wt[e],P=Array.isArray(h)&&h.includes(e),F=t=>(0,l.jsxs)(`div`,{className:`flex flex-col text-[14px] font-mono leading-relaxed my-0.5`,style:{marginLeft:s>0?32:0},children:[N&&(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[12px] font-mono italic select-none mt-2 mb-0.5 flex flex-wrap items-center gap-1`,children:[`// `,N.split(/(https?:\/\/[^\s,]+)/g).map((e,t)=>e.startsWith(`http`)?(0,l.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent hover:text-accentDeep underline underline-offset-2 cursor-pointer transition-colors pointer-events-auto`,children:e},t):(0,l.jsx)(`span`,{children:e},t)),(e===`logoUrl`||e===`faviconUrl`)&&(0,l.jsx)(u.Link,{to:`/drive/public`,className:`text-accent flex items-center gap-1 hover:text-accentDeep underline underline-offset-2 ml-1 cursor-pointer transition-colors`,children:`Open Drive / Public`})]}),t]});if(y){let t=d?[...d]:Object.keys(i);return t=t.filter(e=>!(e===`showThemeToggle`&&i.defaultTheme!==`system`||e===`cornerRadii`&&i.cornerRounding!==`custom`||e===`url`&&`action`in i&&i.action!==`redirect`||e===`form`&&`action`in i&&i.action!==`form`||e===`currencySymbol`&&i.type!==`currency`||e===`options`&&i.type!==`select`)),i.action===`redirect`&&!t.includes(`url`)&&i.showButton!==!1&&t.push(`url`),i.action===`form`&&!t.includes(`form`)&&i.showButton!==!1&&t.push(`form`),i.type===`currency`&&!t.includes(`currencySymbol`)&&t.push(`currencySymbol`),i.type===`select`&&!t.includes(`options`)&&t.push(`options`),F((0,l.jsxs)(`div`,{className:`flex flex-col group/obj`,children:[e?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-foreground/[0.04] rounded-lg pl-0.5 pr-2 py-0.5 -ml-[18px] w-fit transition-colors ${C?`cursor-pointer`:``}`,onClick:()=>C&&w(!1),children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w(!C)},className:`text-foreground/30 hover:text-foreground/80 transition-colors w-4 flex items-center justify-center font-black text-[10px]`,title:C?`Unfold`:`Fold`,children:C?`►`:`▼`}),(0,l.jsxs)(`span`,{className:`text-accent font-extrabold`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`:`}),` `,(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:C?`{...}`:`{`})]}):s>0?(0,l.jsx)(`div`,{className:`text-foreground/70 font-bold px-2`,children:`{`}):null,!C&&(0,l.jsx)(`div`,{className:`flex flex-col ${s>0?`border-l border-[var(--panel-border)]/30 ml-2 pl-1`:``}`,children:t.map((e,t,n)=>e===`subtitle`&&i.showSubtitle===!1||e===`url`&&`action`in i&&i.action!==`redirect`||e===`form`&&`action`in i&&i.action!==`form`?null:(0,l.jsx)(Kt,{objectKey:e,value:i[e],onChange:t=>{let n={...i,[e]:t};e===`action`&&t===`form`&&!n.form&&(n.form=`contact`),e===`action`&&t===`redirect`&&!n.url&&(n.url=`/`),e===`type`&&t===`currency`&&!n.currencySymbol&&(n.currencySymbol=`$`),e===`type`&&t===`select`&&!n.options&&(n.options=[`Option 1`,`Option 2`]),o(n)},depth:s+1,isLast:t===n.length-1,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h,hideInnerLoader:g,meta:_},e))}),e&&!C&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`}`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),e&&C&&!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 -mt-1 ml-2`,children:`,`})]}))}if(b)return F((0,l.jsxs)(`div`,{className:`flex flex-col group/arr`,children:[e?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-foreground/[0.04] rounded-lg pl-0.5 pr-2 py-0.5 -ml-[18px] w-fit transition-colors ${C?`cursor-pointer`:``}`,onClick:()=>C&&w(!1),children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w(!C)},className:`text-foreground/30 hover:text-foreground/80 transition-colors w-4 flex items-center justify-center font-black text-[10px]`,title:C?`Unfold`:`Fold`,children:C?`►`:`▼`}),(0,l.jsxs)(`span`,{className:`text-accent font-extrabold`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`:`}),` `,(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:C?`[...]`:`[`})]}):(0,l.jsx)(`div`,{className:`flex items-center gap-1 group-hover/arr:bg-foreground/[0.02] rounded-lg px-2 py-0.5 -ml-2 w-fit transition-colors`,children:(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`[`})}),!C&&(0,l.jsxs)(`div`,{className:`flex flex-col border-l border-[var(--panel-border)]/30 ml-2 mt-1 pl-1`,style:{marginLeft:32},children:[i.map((e,t)=>{if(typeof e==`object`&&e)return(0,l.jsxs)(`div`,{className:`pl-2 border-l border-[var(--panel-border)]/20 mt-1 mb-1 relative group/arr-item`,children:[(0,l.jsx)(`button`,{onClick:()=>{let e=[...i];e.splice(t,1),o(e)},className:`absolute -left-[11px] top-1.5 w-5 h-5 bg-background border border-[var(--panel-border)] text-red-500 hover:bg-red-500/10 rounded flex items-center justify-center opacity-0 group-hover/arr-item:opacity-100 transition-all font-bold text-[14px] leading-none z-20`,title:`Remove Item`,children:`×`}),(0,l.jsx)(Kt,{value:e,onChange:e=>{let n=[...i];n[t]=e,o(n)},depth:s+1,isLast:t===i.length-1,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h})]},t);let r=typeof e==`string`&&(e.startsWith(`#`)||e.startsWith(`rgba`)||e.startsWith(`rgb`));return(0,l.jsxs)(`div`,{className:`flex items-center gap-1 group/item w-fit relative z-10 my-0.5`,children:[(0,l.jsx)(`button`,{onClick:()=>{let e=[...i];e.splice(t,1),o(e)},className:`absolute -left-6 top-1/2 -translate-y-1/2 w-4 h-4 text-red-500 hover:bg-red-500/10 rounded flex items-center justify-center opacity-0 group-hover/item:opacity-100 transition-all font-bold text-[14px] leading-none`,title:`Remove Item`,children:`×`}),(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[11px] w-4 select-none font-bold`,children:[t,`:`]}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),r&&(0,l.jsxs)(`div`,{className:`relative w-5 h-5 rounded-full overflow-hidden border border-[var(--panel-border)] shrink-0 mx-1 group/item hover:border-accent transition-colors bg-[var(--background)]`,children:[(0,l.jsx)(`input`,{type:`color`,value:e.length===7&&e.startsWith(`#`)?e:`#000000`,onChange:e=>{let n=[...i];n[t]=e.target.value,o(n)},className:`absolute -inset-8 w-24 h-24 cursor-pointer opacity-0`}),(0,l.jsx)(`div`,{className:`absolute inset-0 pointer-events-none transition-transform group-hover/item:scale-110`,style:{backgroundColor:e}})]}),(0,l.jsx)(Gt,{value:e,isNumber:typeof e==`number`,onChange:e=>{let n=[...i];n[t]=e,o(n)},onFocus:j,handleBlurOrEnter:M,className:`no-glow bg-transparent text-foreground font-bold outline-none focus:outline-none focus:ring-0 p-0 m-0 transition-colors max-w-[200px] sm:max-w-[300px] text-ellipsis placeholder:text-foreground/20`}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:t<i.length-1?`,`:``}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 shrink-0`})]},t)}),(!(i.length>0&&typeof i[0]==`string`&&(i[0].startsWith(`#`)||i[0].startsWith(`rgba`)||i[0].startsWith(`color-mix`)))||i.length<6)&&(0,l.jsx)(`button`,{onClick:()=>{let t=[...i],n=``;if(e===`fields`){let e=t.map(e=>e.name);n=_?.formType===`private`?e.includes(`issue_type`)?e.includes(`urgency`)?e.includes(`description`)?e.includes(`device`)?e.includes(`subscribe`)?{type:`text`,name:`custom_field_${t.length}`,label:`Custom Field`,required:!1,placeholder:``}:{type:`checkbox`,name:`subscribe`,label:`Receive status updates via email`,required:!1}:{type:`text`,name:`device`,label:`Device / OS`,required:!1,placeholder:`e.g., iPhone 15, Windows 11`}:{type:`textarea`,name:`description`,label:`Description`,required:!0,placeholder:`Please provide detailed information...`}:{type:`select`,name:`urgency`,label:`Urgency Level`,required:!0,options:[`Low`,`Medium`,`High`,`Critical`]}:{type:`select`,name:`issue_type`,label:`Issue Type`,required:!0,options:[`Bug Report`,`Feature Request`,`Billing`,`General Question`]}:e.includes(`name`)?e.includes(`email`)?e.includes(`phone`)?e.includes(`questions`)?e.includes(`budget`)?e.includes(`service_type`)?e.includes(`subscribe`)?e.includes(`age`)?{type:`text`,name:`custom_field_${t.length}`,label:`Custom Field`,required:!1,placeholder:``}:{type:`age`,name:`age`,label:`Age`,required:!1,placeholder:`e.g. 25`}:{type:`checkbox`,name:`subscribe`,label:`Subscribe to newsletter`,required:!1}:{type:`select`,name:`service_type`,label:`Service Interested In`,required:!1,options:[`Consulting`,`Development`,`Design`]}:{type:`currency`,name:`budget`,label:`Budget`,required:!1,placeholder:`e.g. 5000`,currencySymbol:`$`}:{type:`textarea`,name:`questions`,label:`Questions`,required:!1,placeholder:`How can we help you?`}:{type:`tel`,name:`phone`,label:`Phone Number`,required:!1,placeholder:`+1 (555) 000-0000`}:{type:`email`,name:`email`,label:`Email Address`,required:!0,placeholder:`you@example.com`}:{type:`text`,name:`name`,label:`Full Name`,required:!0,placeholder:`Enter your name`}}else if(typeof t[0]==`string`)if(t[0].startsWith(`#`)||t[0].startsWith(`rgba`)||t[0].startsWith(`rgb`)||t[0].startsWith(`color-mix`))n=t[t.length-1];else{let e=[`Marketing`,`Support`,`Analysis`,`Strategy`,`Maintenance`];n=e[Math.min(t.length,e.length)-1]||`Option ${t.length+1}`}else n=t.length>0?JSON.parse(JSON.stringify(t[t.length-1])):``,n&&typeof n==`object`&&(n.name&&=`${n.name}_${t.length}`,n.label&&=`${n.label} ${t.length}`);t.push(n),o(t)},className:`mt-2 mb-1 w-fit flex items-center gap-1.5 px-3 py-1 bg-accent/10 hover:bg-accent/20 text-accent font-extrabold text-[11px] uppercase tracking-wider rounded-md transition-colors border border-accent/20`,children:`+ Add Item`})]}),e&&!C&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`]`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),!e&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`]`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),e&&C&&!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 -mt-1 ml-2`,children:`,`})]}));if(typeof i==`boolean`)return F((0,l.jsxs)(`div`,{className:`flex items-center gap-1 group w-fit relative z-10 my-0.5`,children:[(0,l.jsxs)(`span`,{className:`text-accent font-extrabold shrink-0`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`:`}),(0,l.jsx)(`button`,{disabled:P||T,onClick:()=>{g||E(!0),o(!i)},className:`px-3 py-1 rounded-md text-[12px] font-extrabold transition-colors ml-1 uppercase tracking-wider ${i?`bg-emerald-500/20 text-emerald-500`:`bg-red-500/20 text-red-500`} ${P||T?`opacity-50 cursor-not-allowed`:`hover:scale-[1.02] active:scale-[0.98]`}`,children:i?`true`:`false`}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}));let re=typeof i==`string`&&(i.startsWith(`#`)||i.startsWith(`rgba`)||i.startsWith(`rgb`)),I=typeof i==`string`&&e&&String(e).endsWith(`Url`);return F((0,l.jsxs)(`div`,{className:`flex items-center gap-1 group relative z-10 my-0.5 ${I?`w-full pr-0 sm:pr-8`:`w-fit`}`,children:[(0,l.jsxs)(`span`,{className:`text-accent font-extrabold shrink-0`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`:`}),ne?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 ml-1 relative group/enum`,ref:te,children:[(0,l.jsx)(`span`,{className:`text-foreground/40`,children:`"`}),(0,l.jsx)(`button`,{disabled:P||T,title:P?`Cannot be edited`:`Click to cycle options`,tabIndex:0,onClick:()=>{if(P)return;let e=k===null?i:k,t=ne[(ne.indexOf(e)+1)%ne.length];A(t),g||E(!0),o(t)},className:`${P||T?`bg-foreground/5 text-foreground/40 cursor-not-allowed opacity-50`:`bg-accent/10 hover:bg-accent/20 text-accent cursor-pointer shadow-sm hover:scale-[1.02] active:scale-[0.98]`} outline-none px-3 py-1 rounded-md transition-all font-extrabold uppercase tracking-wider text-[11px] border border-transparent`,children:k===null?i:k}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1`}),(0,l.jsx)(`span`,{className:`text-foreground/40`,children:`"`})]}):(0,l.jsxs)(`div`,{className:`flex items-center gap-0.5 ml-1 flex-1 min-w-0`,children:[(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),re&&(0,l.jsxs)(`div`,{className:`relative w-5 h-5 rounded-full overflow-hidden border border-[var(--panel-border)] shrink-0 mx-1 group/item hover:border-accent transition-colors bg-[var(--background)]`,children:[(0,l.jsx)(`input`,{type:`color`,value:i.length===7&&i.startsWith(`#`)?i:`#000000`,onFocus:j,onBlur:e=>{o(e.target.value),O.current=null},onChange:e=>o(e.target.value),className:`absolute -inset-8 w-24 h-24 cursor-pointer opacity-0`}),(0,l.jsx)(`div`,{className:`absolute inset-0 pointer-events-none transition-transform group-hover/item:scale-110`,style:{backgroundColor:i}})]}),(0,l.jsx)(Gt,{disabled:P,value:i,isNumber:typeof i==`number`,placeholder:I?`https://...`:void 0,className:`no-glow bg-transparent font-extrabold outline-none focus:outline-none focus:ring-0 p-0 m-0 transition-colors leading-none ${I?`text-accent/80 font-medium placeholder:text-accent/30`:`text-foreground`} ${P?`opacity-50 grayscale pointer-events-none`:``}`,onFocus:j,handleBlurOrEnter:e=>{let t=e.currentTarget.value;I&&t&&t!==`none`&&!t.includes(`http`)&&!t.includes(`www.`)&&!t.startsWith(`/`)&&(t=``,o(``),ee(!0),setTimeout(()=>ee(!1),2500)),O.current!==null&&O.current!==t&&E(!0),O.current=null,M(e)},onChange:e=>o(e)}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),D?(0,l.jsx)(`span`,{className:`text-red-500 font-bold ml-1.5 text-[10px] tracking-widest uppercase`,children:`invalid`}):T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1.5 shrink-0`}),(e===`logoUrl`||e===`faviconUrl`)&&(0,l.jsx)(`button`,{onClick:()=>o(e===`logoUrl`?t.t.logoUrl:t.t.faviconUrl),className:`w-4 h-4 ml-2 bg-red-500/10 hover:bg-red-500/20 text-red-500 rounded flex items-center justify-center transition-colors text-[10px] font-bold`,title:`Reset to default icon`,children:`✕`})]}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`,`}),e&&[`inputRadius`,`modalRadius`,`badgeRadius`,`buttonRadius`,`cardRadius`].includes(e)&&(0,l.jsxs)(`span`,{className:`text-foreground/30 text-[10px] font-medium ml-2 tracking-wide whitespace-nowrap hidden md:inline-block pointer-events-none`,children:[`// `,e===`inputRadius`?`Forms & text fields`:e===`modalRadius`?`Popups & dialogs`:e===`badgeRadius`?`Tags & pills`:e===`buttonRadius`?`Interactive buttons`:`Big panels & cards`]})]}))};function qt(){let{activeConfig:e}=n.xt(),t=n.Ct(),[r,i]=(0,a.useState)(null),[s,c]=(0,a.useState)(!1),[u,d]=(0,a.useState)(!1),f=a.default.useRef(null);(0,a.useEffect)(()=>{if(!r&&e){let t=JSON.parse(JSON.stringify(e));i(t),f.current=JSON.stringify(t)}},[e]);let[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{let e=sessionStorage.getItem(`fbos_theme_scrollY`);e&&requestAnimationFrame(()=>window.scrollTo(0,parseInt(e,10)))}catch{}let e=()=>{try{sessionStorage.setItem(`fbos_theme_scrollY`,String(window.scrollY))}catch{}};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),(0,a.useEffect)(()=>{if(!r)return;let e=JSON.stringify(r);if(e===f.current)return;let t=setTimeout(async()=>{c(!0);try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,`theme`),r),f.current=e}catch(e){console.error(`Auto-save failed`,e)}c(!1)},300);return()=>clearTimeout(t)},[r]);let _=async()=>{d(!0);try{let e=t?.themeConfig;e||=(await Promise.resolve().then(()=>require(`./theme.config-0Lvwt5Bo.cjs`)).then(e=>e.n)).themeConfig;let r=JSON.parse(JSON.stringify(e)),{deleteDoc:a}=await import(`firebase/firestore`);await a((0,o.doc)(n.Tt,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`),f.current=JSON.stringify(r),i(r)}catch{}setTimeout(()=>{d(!1),g(!1)},1e3)},v=e=>{if(!e)return`167, 139, 250`;let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16)),`${t}, ${n}, ${r}`},y=e=>{if(!r)return;let t=JSON.parse(JSON.stringify(r));if(t.colors&&t.colors.dark){let n=v(e.dark.accent);t.colors.dark.accent=e.dark.accent,t.colors.dark.buttonGradient=e.dark.gradient,t.colors.dark.buttonHoverGradient=e.dark.gradient,t.colors.dark.buttonText=e.dark.buttonText,t.colors.dark.notificationIconColor=e.dark.accent,t.colors.dark.textGradient=e.dark.text,t.colors.dark.foreground=e.dark.text[0],t.colors.dark.background=e.dark.background,t.colors.dark.backgroundSecondary=e.dark.backgroundSecondary,t.colors.dark.panelBg=`rgba(${n}, 0.05)`,t.colors.dark.panelBorder=`rgba(${n}, 0.15)`,t.colors.dark.glowColor=`rgba(${n}, 0.40)`,t.colors.dark.selectionBg=`rgba(${n}, 0.40)`,t.colors.dark.secondaryButton&&(t.colors.dark.secondaryButton.text=e.dark.text[0])}if(t.colors&&t.colors.light){let n=v(e.light.accent);t.colors.light.accent=e.light.accent,t.colors.light.buttonGradient=e.light.gradient,t.colors.light.buttonHoverGradient=e.light.gradient,t.colors.light.buttonText=e.light.buttonText,t.colors.light.notificationIconColor=e.light.accent,t.colors.light.textGradient=e.light.text,t.colors.light.foreground=e.light.text[0],t.colors.light.background=e.light.background,t.colors.light.backgroundSecondary=e.light.backgroundSecondary,t.colors.light.panelBg=`rgba(255, 255, 255, 0.70)`,t.colors.light.panelBorder=`rgba(${n}, 0.08)`,t.colors.light.glowColor=`rgba(${n}, 0.30)`,t.colors.light.selectionBg=`rgba(${n}, 0.30)`,t.colors.light.secondaryButton&&(t.colors.light.secondaryButton.text=e.light.text[0])}i(t)},b=()=>{if(r){let e=r,t=e.colors?.dark||{},n=e.colors?.light||{};e.fontCustomization;let i=e.cornerRadii||{},a=`/**
383
+ `}),(0,l.jsxs)(`div`,{className:`relative group/date flex flex-col w-full`,children:[(0,l.jsx)(n.r,{type:`date`,label:`Date`,required:!0,value:R.dateStr,onChange:e=>z({...R,dateStr:e.target.value}),className:`pr-10`}),(0,l.jsx)(`div`,{className:`absolute right-4 bottom-4 pointer-events-none group-focus-within/date:text-accent text-foreground/40 transition-colors`,children:(0,l.jsx)(n.dt,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[oe?(0,l.jsx)(n.r,{type:`time`,label:`Time`,value:R.time,onChange:e=>z({...R,time:e.target.value}),required:!0}):(()=>{let{h:e,m:t,ampm:n}=Z(R.time);return(0,l.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,l.jsx)(`label`,{className:`text-[13px] font-medium text-foreground/50 select-none mb-1.5 ml-1`,children:`Time`}),(0,l.jsxs)(`div`,{className:`flex items-center h-12 glass-panel border border-[var(--panel-border)] rounded-xl px-3 gap-1 focus-within:border-accent transition-colors`,children:[(0,l.jsx)(`input`,{type:`number`,min:1,max:12,value:e,onChange:e=>z({...R,time:he(Math.min(12,Math.max(1,parseInt(e.target.value)||12)),t,n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,l.jsx)(`span`,{className:`text-foreground/40 font-bold text-[15px] select-none`,children:`:`}),(0,l.jsx)(`input`,{type:`number`,min:0,max:59,value:t.toString().padStart(2,`0`),onChange:t=>z({...R,time:he(e,Math.min(59,Math.max(0,parseInt(t.target.value)||0)),n)}),className:`w-8 text-center bg-transparent focus:outline-none text-foreground font-bold text-[15px] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>z({...R,time:he(e,t,n===`AM`?`PM`:`AM`)}),className:`ml-auto px-2 py-0.5 rounded-md bg-accent/10 text-accent text-[11px] font-extrabold uppercase tracking-wider hover:bg-accent/20 transition-colors shrink-0`,children:n})]})]})})(),(0,l.jsx)(n.r,{type:`number`,min:`1`,max:`1440`,label:`Duration (min)`,value:R.duration,onChange:e=>z({...R,duration:e.target.value}),placeholder:`60`,required:!0})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,l.jsx)(`label`,{className:`text-[11px] font-bold text-foreground/50 uppercase tracking-widest mt-1`,children:`Event Color`}),(0,l.jsx)(`div`,{className:`flex gap-2 items-center relative z-10 w-full h-[46px]`,children:zt.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>z({...R,color:R.color===e.text?``:e.text}),className:`w-6 h-6 rounded-full shrink-0 ${e.bgCircle} hover:scale-110 transition-transform flex items-center justify-center border border-[var(--panel-border)]`,children:R.color===e.text&&(0,l.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-background`})},e.name))})]}),(0,l.jsx)(`div`,{className:`pt-2`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:M,className:`w-full py-3`,children:R.id?`Save Changes`:`Create Event`})})]})]})]},`edit-modal`),(0,l.jsx)(te,{isOpen:!!I,title:`Confirm Deletion`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:I?.title}),` This action is permanent.`]}),onConfirm:Oe,onCancel:()=>{L(null)},isProcessing:P,confirmText:`Yes, Delete`})]});return f?(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:d?.tabTitle||d?.tabName||e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[Pe(),$()]})]}),Ie()]}):(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e}),t&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),t]})]}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 border-b border-[var(--panel-border)] pb-6 relative z-20`,children:[r?(0,l.jsxs)(u.Link,{to:r,className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}):(0,l.jsx)(`div`,{}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:ce,className:`px-3 h-10 text-[12px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0 hover:bg-foreground/5 shadow-sm text-foreground/70`,children:oe?`24h`:`12h`}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:le,className:`w-10 h-10 p-0 text-[14px] font-bold rounded-xl flex items-center justify-center border-[var(--panel-border)] border shrink-0`,children:S===`month`?(0,l.jsx)(n.F,{className:`w-4 h-4 text-foreground/70`}):(0,l.jsx)(n.dt,{className:`w-4 h-4 text-foreground/70`})}),Ne&&(0,l.jsxs)(n.n,{onClick:()=>Te(),className:`px-6 py-2.5 text-[14px] font-bold rounded-xl shadow-lg flex items-center gap-2`,children:[(0,l.jsx)(n.C,{className:`w-4 h-4`}),` Event`]})]})]}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden shadow-2xl relative flex flex-col flex-1`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-accent/5 blur-[120px] rounded-full pointer-events-none -z-10`}),$()]}),Ie()]})}var Ht={appName:`The main name of your application shown in headers and titles.`,defaultTheme:`Choose how the app starts immediately on load.`,showThemeToggle:`Allow users to manually toggle dark mode on/off.`,logoUrl:`Direct URL to your app's main logo. Need to upload one?`,faviconUrl:`Direct URL to your app's favicon. Need to upload one?`,background:`Main background canvas color under all content.`,foreground:`Primary typography color used across the app.`,accent:`The primary brand color for highlights, buttons, and links.`,panelBg:`Background color of glass cards and panels.`,panelBorder:`Borders of panels, inputs, and dropdowns.`,glowColor:`The global glow shadow applied to borders of focused inputs.`,buttonHoverGradient:`Start and end hex for primary button hover effects.`,textGradient:`Three tone gradient applied to large headers.`,buttonRadius:`Border radius for standard buttons.`,cardRadius:`Curvature of main content panels.`,inputRadius:`Rounding applied to form inputs.`,modalRadius:`Global popup containers and dashboard content cards.`,blurIntensity:`Glassmorphism backdrop-blur amounts.`,notificationIconColor:`Color applied to notification badging.`,fontFamily:`Choose the main typography of your brand.`,home:`Complete customization of the landing page settings.`,title:`Main heading displayed on the Landing Page or Form.`,subtitle:`Smaller colored overline text above the main title.`,text:`The descriptive paragraph text under the hero headers or buttons.`,primary:`Main call-to-action block settings.`,secondary:`Secondary ghost button block settings.`,sections:`Toggle visibility of landing page sectors.`,contactForm:`Customize the form wrapper and its labels.`,nameLabel:`Placeholder/Label for the Name input.`,emailLabel:`Placeholder/Label for the Email input.`,messageLabel:`Placeholder/Label for the Message textarea.`,submitText:`Text for the form submit button.`,action:`Where the button routes the user.`,form:`Which public form to open. Note: Form submissions will securely map to the Submissions tab in your admin dashboard.`,url:`External http link or internal /route destination.`},Ut=[{name:`Purple Standard`,preview:[`#2e1065`,`#cdc1ff`],dark:{buttonText:`#ffffff`,background:`#07070f`,backgroundSecondary:`#0a0a18`,accent:`#a78bfa`,gradient:[`#6d28d9`,`#a78bfa`],text:[`#f0eeff`,`#c4b5fd`,`#a78bfa`]},light:{buttonText:`#ffffff`,background:`#fcfaff`,backgroundSecondary:`#f7f3ff`,accent:`#7c3aed`,gradient:[`#5b21b6`,`#a78bfa`],text:[`#2e1065`,`#6d28d9`,`#cdc1ff`]}},{name:`Royal Navy`,preview:[`#1e3a8a`,`#60a5fa`],dark:{buttonText:`#ffffff`,background:`#050b14`,backgroundSecondary:`#0a192f`,accent:`#60a5fa`,gradient:[`#1d4ed8`,`#60a5fa`],text:[`#dbeafe`,`#93c5fd`,`#60a5fa`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#f1f5f9`,accent:`#2563eb`,gradient:[`#1e3a8a`,`#60a5fa`],text:[`#1e3a8a`,`#2563eb`,`#60a5fa`]}},{name:`Emerald Green`,preview:[`#064e3b`,`#10b981`],dark:{buttonText:`#ffffff`,background:`#050806`,backgroundSecondary:`#0a2218`,accent:`#34d399`,gradient:[`#047857`,`#34d399`],text:[`#d1fae5`,`#6ee7b7`,`#34d399`]},light:{buttonText:`#ffffff`,background:`#f6fbf8`,backgroundSecondary:`#eff7f2`,accent:`#059669`,gradient:[`#064e3b`,`#10b981`],text:[`#064e3b`,`#059669`,`#10b981`]}},{name:`Gold`,preview:[`#854d0e`,`#eab308`],dark:{buttonText:`#000000`,background:`#0f0905`,backgroundSecondary:`#1c1208`,accent:`#fcd34d`,gradient:[`#ca8a04`,`#facc15`],text:[`#fefce8`,`#fef08a`,`#facc15`]},light:{buttonText:`#ffffff`,background:`#fbfaf6`,backgroundSecondary:`#f5f2eb`,accent:`#d97706`,gradient:[`#854d0e`,`#eab308`],text:[`#854d0e`,`#ca8a04`,`#eab308`]}},{name:`Silver`,preview:[`#1e293b`,`#94a3b8`],dark:{buttonText:`#ffffff`,background:`#090e17`,backgroundSecondary:`#101725`,accent:`#cbd5e1`,gradient:[`#475569`,`#94a3b8`],text:[`#e2e8f0`,`#94a3b8`,`#cbd5e1`]},light:{buttonText:`#ffffff`,background:`#f8fafc`,backgroundSecondary:`#e2e8f0`,accent:`#64748b`,gradient:[`#1e293b`,`#94a3b8`],text:[`#1e293b`,`#475569`,`#94a3b8`]}},{name:`Barbie Pink`,preview:[`#d946ef`,`#f472b6`],dark:{buttonText:`#ffffff`,background:`#0c030a`,backgroundSecondary:`#1a0515`,accent:`#ff80ff`,gradient:[`#c026d3`,`#f472b6`],text:[`#ffeeff`,`#ffb3ff`,`#ff80ff`]},light:{buttonText:`#ffffff`,background:`#fcf5fa`,backgroundSecondary:`#f5ebf2`,accent:`#d946ef`,gradient:[`#c026d3`,`#ec4899`],text:[`#a21caf`,`#c026d3`,`#ec4899`]}},{name:`Orange`,preview:[`#7c2d12`,`#f97316`],dark:{buttonText:`#ffffff`,background:`#0a0200`,backgroundSecondary:`#1c0b05`,accent:`#fb923c`,gradient:[`#c2410c`,`#fb923c`],text:[`#fff7ed`,`#fdba74`,`#fb923c`]},light:{buttonText:`#ffffff`,background:`#fdf6f2`,backgroundSecondary:`#f5ebe4`,accent:`#ea580c`,gradient:[`#7c2d12`,`#f97316`],text:[`#7c2d12`,`#ea580c`,`#f97316`]}},{name:`Red`,preview:[`#7f1d1d`,`#ef4444`],dark:{buttonText:`#ffffff`,background:`#0a0000`,backgroundSecondary:`#2e0a0a`,accent:`#ef4444`,gradient:[`#b91c1c`,`#f87171`],text:[`#fef2f2`,`#fecaca`,`#f87171`]},light:{buttonText:`#ffffff`,background:`#fdf5f5`,backgroundSecondary:`#f5ebeb`,accent:`#dc2626`,gradient:[`#7f1d1d`,`#ef4444`],text:[`#7f1d1d`,`#dc2626`,`#ef4444`]}},{name:`Black & White`,preview:[`#ffffff`,`#000000`],dark:{buttonText:`#000000`,background:`#000000`,backgroundSecondary:`#111111`,accent:`#ffffff`,gradient:[`#ffffff`,`#e5e7eb`],text:[`#ffffff`,`#f3f4f6`,`#ffffff`]},light:{buttonText:`#ffffff`,background:`#ffffff`,backgroundSecondary:`#f3f4f6`,accent:`#000000`,gradient:[`#000000`,`#1f2937`],text:[`#000000`,`#1f2937`,`#374151`]}}],Wt={defaultTheme:[`system`,`light`,`dark`],cornerRounding:[`default`,`custom`],action:[`sign_in`,`register`,`redirect`,`form`],type:[`text`,`email`,`tel`,`textarea`],form:[`contact`],formType:[`public`,`private`],submitPage:[`submissions`,`requests`],fontFamily:[`Inter`,`Outfit`,`Roboto`,`Space Grotesk`,`Plus Jakarta Sans`,`System UI`]};n.Tt&&(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=[];e.forEach(e=>{e.data().formType!==`private`&&t.push(e.id)}),t.length>0&&Object.assign(Wt,{form:t})}).catch(()=>{});var Gt=({value:e,onChange:t,onBlur:n,onFocus:r,className:i,isNumber:o,handleBlurOrEnter:s,placeholder:c,disabled:u})=>{let[d,f]=a.default.useState(e),[p,m]=a.default.useState(!1),h=a.default.useRef(null);a.default.useEffect(()=>{f(e)},[e]),(0,a.useEffect)(()=>{!p&&h.current&&(h.current.scrollLeft=0)},[d,p]);let g=typeof i==`string`?i.match(/(?:max-w-\[[^\]]+\]|sm:max-w-\[[^\]]+\]|md:max-w-\[[^\]]+\])\s*/g):null,_=g?g.join(` `):`max-w-[200px] sm:max-w-[300px]`,v=typeof i==`string`?i.replace(/(?:max-w-\[[^\]]+\]|sm:max-w-\[[^\]]+\]|md:max-w-\[[^\]]+\]|text-ellipsis)\s*/g,``):``,y=v.trim();return(0,l.jsx)(`div`,{className:`relative inline-grid group/autoresize ${_}`,children:(0,l.jsxs)(`div`,{className:`col-start-1 row-start-1 overflow-x-auto overflow-y-hidden pb-[1px] styled-scrollbars-mini inline-grid items-center`,children:[(0,l.jsx)(`span`,{className:`${v} invisible whitespace-pre col-start-1 row-start-1 border-none p-0 inline-block px-[2px]`,"aria-hidden":`true`,children:d||c||(o?`0`:` `)}),(0,l.jsx)(`input`,{disabled:u,ref:h,type:o?`number`:`text`,value:d,placeholder:c,spellCheck:!1,className:`${y} col-start-1 row-start-1 w-full min-w-[20px] transition-all duration-200 ${u?`cursor-not-allowed opacity-50 select-none`:``} ${p?`relative z-50 bg-background shadow-md`:``}`,onDoubleClick:e=>{u||e.currentTarget.select()},onPaste:()=>{setTimeout(()=>{h.current&&(h.current.scrollLeft=0)},10)},onChange:e=>{u||f(e.target.value)},onKeyDown:n=>{if(!u&&n.key===`Enter`){let r=o?parseFloat(n.currentTarget.value)||0:n.currentTarget.value;r!==e&&t(r),s&&s(n),n.currentTarget.blur()}},onBlur:r=>{if(u)return;m(!1);let i=o?parseFloat(r.currentTarget.value)||0:r.currentTarget.value;i!==e&&t(i),s&&s(r),n&&n(r),r.currentTarget.scrollLeft=0},onFocus:e=>{u||(m(!0),r&&r(e))}})]})})},Kt=({objectKey:e,displayKey:r,value:i,onChange:o,depth:s=0,isLast:c=!1,keysToRender:d,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h=[],hideInnerLoader:g=!1,meta:_={}})=>{let v=r||e,y=typeof i==`object`&&!!i&&!Array.isArray(i),b=Array.isArray(i),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(e===`colors`||e===`fields`),[T,E]=(0,a.useState)(!1),[D,ee]=(0,a.useState)(!1),O=a.default.useRef(null),[k,A]=a.default.useState(null),te=a.default.useRef(null);(0,a.useEffect)(()=>{f||E(!1)},[f]);let j=e=>{O.current=e.currentTarget.value},M=e=>{`key`in e&&e.key===`Enter`&&e.currentTarget.blur(),(`type`in e&&e.type===`blur`||`key`in e&&e.key===`Enter`)&&(O.current!==null&&O.current!==e.currentTarget.value&&(g||E(!0)),O.current=null)};a.default.useEffect(()=>{A(null)},[i]);let N=p?.[e]||Ht[e],P=m?.[e]||Wt[e],F=Array.isArray(h)&&h.includes(e),I=t=>(0,l.jsxs)(`div`,{className:`flex flex-col text-[14px] font-mono leading-relaxed my-0.5`,style:{marginLeft:s>0?32:0},children:[N&&(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[12px] font-mono italic select-none mt-2 mb-0.5 flex flex-wrap items-center gap-1`,children:[`// `,N.split(/(https?:\/\/[^\s,]+)/g).map((e,t)=>e.startsWith(`http`)?(0,l.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent hover:text-accentDeep underline underline-offset-2 cursor-pointer transition-colors pointer-events-auto`,children:e},t):(0,l.jsx)(`span`,{children:e},t)),(e===`logoUrl`||e===`faviconUrl`)&&(0,l.jsx)(u.Link,{to:`/drive/public`,className:`text-accent flex items-center gap-1 hover:text-accentDeep underline underline-offset-2 ml-1 cursor-pointer transition-colors`,children:`Open Drive / Public`})]}),t]});if(y){let t=d?[...d]:Object.keys(i);return t=t.filter(e=>!(e===`showThemeToggle`&&i.defaultTheme!==`system`||e===`cornerRadii`&&i.cornerRounding!==`custom`||e===`url`&&`action`in i&&i.action!==`redirect`||e===`form`&&`action`in i&&i.action!==`form`||e===`currencySymbol`&&i.type!==`currency`||e===`options`&&i.type!==`select`)),i.action===`redirect`&&!t.includes(`url`)&&i.showButton!==!1&&t.push(`url`),i.action===`form`&&!t.includes(`form`)&&i.showButton!==!1&&t.push(`form`),i.type===`currency`&&!t.includes(`currencySymbol`)&&t.push(`currencySymbol`),i.type===`select`&&!t.includes(`options`)&&t.push(`options`),I((0,l.jsxs)(`div`,{className:`flex flex-col group/obj`,children:[e?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-foreground/[0.04] rounded-lg pl-0.5 pr-2 py-0.5 -ml-[18px] w-fit transition-colors ${C?`cursor-pointer`:``}`,onClick:()=>C&&w(!1),children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w(!C)},className:`text-foreground/30 hover:text-foreground/80 transition-colors w-4 flex items-center justify-center font-black text-[10px]`,title:C?`Unfold`:`Fold`,children:C?`►`:`▼`}),(0,l.jsxs)(`span`,{className:`text-accent font-extrabold`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`:`}),` `,(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:C?`{...}`:`{`})]}):s>0?(0,l.jsx)(`div`,{className:`text-foreground/70 font-bold px-2`,children:`{`}):null,!C&&(0,l.jsx)(`div`,{className:`flex flex-col ${s>0?`border-l border-[var(--panel-border)]/30 ml-2 pl-1`:``}`,children:t.map((e,t,n)=>e===`subtitle`&&i.showSubtitle===!1||e===`url`&&`action`in i&&i.action!==`redirect`||e===`form`&&`action`in i&&i.action!==`form`?null:(0,l.jsx)(Kt,{objectKey:e,value:i[e],onChange:t=>{let n={...i,[e]:t};e===`action`&&t===`form`&&!n.form&&(n.form=`contact`),e===`action`&&t===`redirect`&&!n.url&&(n.url=`/`),e===`type`&&t===`currency`&&!n.currencySymbol&&(n.currencySymbol=`$`),e===`type`&&t===`select`&&!n.options&&(n.options=[`Option 1`,`Option 2`]),o(n)},depth:s+1,isLast:t===n.length-1,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h,hideInnerLoader:g,meta:_},e))}),e&&!C&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`}`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),e&&C&&!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 -mt-1 ml-2`,children:`,`})]}))}if(b)return I((0,l.jsxs)(`div`,{className:`flex flex-col group/arr`,children:[e?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 hover:bg-foreground/[0.04] rounded-lg pl-0.5 pr-2 py-0.5 -ml-[18px] w-fit transition-colors ${C?`cursor-pointer`:``}`,onClick:()=>C&&w(!1),children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w(!C)},className:`text-foreground/30 hover:text-foreground/80 transition-colors w-4 flex items-center justify-center font-black text-[10px]`,title:C?`Unfold`:`Fold`,children:C?`►`:`▼`}),(0,l.jsxs)(`span`,{className:`text-accent font-extrabold`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`:`}),` `,(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:C?`[...]`:`[`})]}):(0,l.jsx)(`div`,{className:`flex items-center gap-1 group-hover/arr:bg-foreground/[0.02] rounded-lg px-2 py-0.5 -ml-2 w-fit transition-colors`,children:(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`[`})}),!C&&(0,l.jsxs)(`div`,{className:`flex flex-col border-l border-[var(--panel-border)]/30 ml-2 mt-1 pl-1`,style:{marginLeft:32},children:[i.map((e,t)=>{if(typeof e==`object`&&e)return(0,l.jsxs)(`div`,{className:`pl-2 border-l border-[var(--panel-border)]/20 mt-1 mb-1 relative group/arr-item`,children:[(0,l.jsx)(`button`,{onClick:()=>{let e=[...i];e.splice(t,1),o(e)},className:`absolute -left-[11px] top-1.5 w-5 h-5 bg-background border border-[var(--panel-border)] text-red-500 hover:bg-red-500/10 rounded flex items-center justify-center opacity-0 group-hover/arr-item:opacity-100 transition-all font-bold text-[14px] leading-none z-20`,title:`Remove Item`,children:`×`}),(0,l.jsx)(Kt,{value:e,onChange:e=>{let n=[...i];n[t]=e,o(n)},depth:s+1,isLast:t===i.length-1,isGlobalSaving:f,customExplanations:p,customEnums:m,disabledKeys:h})]},t);let r=typeof e==`string`&&(e.startsWith(`#`)||e.startsWith(`rgba`)||e.startsWith(`rgb`));return(0,l.jsxs)(`div`,{className:`flex items-center gap-1 group/item w-fit relative z-10 my-0.5`,children:[(0,l.jsx)(`button`,{onClick:()=>{let e=[...i];e.splice(t,1),o(e)},className:`absolute -left-6 top-1/2 -translate-y-1/2 w-4 h-4 text-red-500 hover:bg-red-500/10 rounded flex items-center justify-center opacity-0 group-hover/item:opacity-100 transition-all font-bold text-[14px] leading-none`,title:`Remove Item`,children:`×`}),(0,l.jsxs)(`span`,{className:`text-foreground/40 text-[11px] w-4 select-none font-bold`,children:[t,`:`]}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),r&&(0,l.jsxs)(`div`,{className:`relative w-5 h-5 rounded-full overflow-hidden border border-[var(--panel-border)] shrink-0 mx-1 group/item hover:border-accent transition-colors bg-[var(--background)]`,children:[(0,l.jsx)(`input`,{type:`color`,value:e.length===7&&e.startsWith(`#`)?e:`#000000`,onChange:e=>{let n=[...i];n[t]=e.target.value,o(n)},className:`absolute -inset-8 w-24 h-24 cursor-pointer opacity-0`}),(0,l.jsx)(`div`,{className:`absolute inset-0 pointer-events-none transition-transform group-hover/item:scale-110`,style:{backgroundColor:e}})]}),(0,l.jsx)(Gt,{value:e,isNumber:typeof e==`number`,onChange:e=>{let n=[...i];n[t]=e,o(n)},onFocus:j,handleBlurOrEnter:M,className:`no-glow bg-transparent text-foreground font-bold outline-none focus:outline-none focus:ring-0 p-0 m-0 transition-colors max-w-[200px] sm:max-w-[300px] text-ellipsis placeholder:text-foreground/20`}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:t<i.length-1?`,`:``}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 shrink-0`})]},t)}),(!(i.length>0&&typeof i[0]==`string`&&(i[0].startsWith(`#`)||i[0].startsWith(`rgba`)||i[0].startsWith(`color-mix`)))||i.length<6)&&(0,l.jsx)(`button`,{onClick:()=>{let t=[...i],n=``;if(e===`fields`){let e=t.map(e=>e.name);n=_?.formType===`private`?e.includes(`issue_type`)?e.includes(`urgency`)?e.includes(`description`)?e.includes(`device`)?e.includes(`subscribe`)?{type:`text`,name:`custom_field_${t.length}`,label:`Custom Field`,required:!1,placeholder:``}:{type:`checkbox`,name:`subscribe`,label:`Receive status updates via email`,required:!1}:{type:`text`,name:`device`,label:`Device / OS`,required:!1,placeholder:`e.g., iPhone 15, Windows 11`}:{type:`textarea`,name:`description`,label:`Description`,required:!0,placeholder:`Please provide detailed information...`}:{type:`select`,name:`urgency`,label:`Urgency Level`,required:!0,options:[`Low`,`Medium`,`High`,`Critical`]}:{type:`select`,name:`issue_type`,label:`Issue Type`,required:!0,options:[`Bug Report`,`Feature Request`,`Billing`,`General Question`]}:e.includes(`name`)?e.includes(`email`)?e.includes(`phone`)?e.includes(`questions`)?e.includes(`budget`)?e.includes(`service_type`)?e.includes(`subscribe`)?e.includes(`age`)?{type:`text`,name:`custom_field_${t.length}`,label:`Custom Field`,required:!1,placeholder:``}:{type:`age`,name:`age`,label:`Age`,required:!1,placeholder:`e.g. 25`}:{type:`checkbox`,name:`subscribe`,label:`Subscribe to newsletter`,required:!1}:{type:`select`,name:`service_type`,label:`Service Interested In`,required:!1,options:[`Consulting`,`Development`,`Design`]}:{type:`currency`,name:`budget`,label:`Budget`,required:!1,placeholder:`e.g. 5000`,currencySymbol:`$`}:{type:`textarea`,name:`questions`,label:`Questions`,required:!1,placeholder:`How can we help you?`}:{type:`tel`,name:`phone`,label:`Phone Number`,required:!1,placeholder:`+1 (555) 000-0000`}:{type:`email`,name:`email`,label:`Email Address`,required:!0,placeholder:`you@example.com`}:{type:`text`,name:`name`,label:`Full Name`,required:!0,placeholder:`Enter your name`}}else if(typeof t[0]==`string`)if(t[0].startsWith(`#`)||t[0].startsWith(`rgba`)||t[0].startsWith(`rgb`)||t[0].startsWith(`color-mix`))n=t[t.length-1];else{let e=[`Marketing`,`Support`,`Analysis`,`Strategy`,`Maintenance`];n=e[Math.min(t.length,e.length)-1]||`Option ${t.length+1}`}else n=t.length>0?JSON.parse(JSON.stringify(t[t.length-1])):``,n&&typeof n==`object`&&(n.name&&=`${n.name}_${t.length}`,n.label&&=`${n.label} ${t.length}`);t.push(n),o(t)},className:`mt-2 mb-1 w-fit flex items-center gap-1.5 px-3 py-1 bg-accent/10 hover:bg-accent/20 text-accent font-extrabold text-[11px] uppercase tracking-wider rounded-md transition-colors border border-accent/20`,children:`+ Add Item`})]}),e&&!C&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`]`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),!e&&(0,l.jsxs)(`div`,{className:`px-2 mt-1`,children:[(0,l.jsx)(`span`,{className:`text-foreground/70 font-bold`,children:`]`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}),e&&C&&!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 -mt-1 ml-2`,children:`,`})]}));if(typeof i==`boolean`)return I((0,l.jsxs)(`div`,{className:`flex items-center gap-1 group w-fit relative z-10 my-0.5`,children:[(0,l.jsxs)(`span`,{className:`text-accent font-extrabold shrink-0`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`:`}),(0,l.jsx)(`button`,{disabled:F||T,onClick:()=>{g||E(!0),o(!i)},className:`px-3 py-1 rounded-md text-[12px] font-extrabold transition-colors ml-1 uppercase tracking-wider ${i?`bg-emerald-500/20 text-emerald-500`:`bg-red-500/20 text-red-500`} ${F||T?`opacity-50 cursor-not-allowed`:`hover:scale-[1.02] active:scale-[0.98]`}`,children:i?`true`:`false`}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1`}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50`,children:`,`})]}));let L=typeof i==`string`&&(i.startsWith(`#`)||i.startsWith(`rgba`)||i.startsWith(`rgb`)),R=typeof i==`string`&&e&&String(e).endsWith(`Url`);return I((0,l.jsxs)(`div`,{className:`flex items-center gap-1 group relative z-10 my-0.5 ${R?`w-full pr-0 sm:pr-8`:`w-fit`}`,children:[(0,l.jsxs)(`span`,{className:`text-accent font-extrabold shrink-0`,children:[`"`,v,`"`]}),(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`:`}),P?(0,l.jsxs)(`div`,{className:`flex items-center gap-1 ml-1 relative group/enum`,ref:te,children:[(0,l.jsx)(`span`,{className:`text-foreground/40`,children:`"`}),(0,l.jsx)(`button`,{disabled:F||T,title:F?`Cannot be edited`:`Click to cycle options`,tabIndex:0,onClick:()=>{if(F)return;let e=k===null?i:k,t=P[(P.indexOf(e)+1)%P.length];A(t),g||E(!0),o(t)},className:`${F||T?`bg-foreground/5 text-foreground/40 cursor-not-allowed opacity-50`:`bg-accent/10 hover:bg-accent/20 text-accent cursor-pointer shadow-sm hover:scale-[1.02] active:scale-[0.98]`} outline-none px-3 py-1 rounded-md transition-all font-extrabold uppercase tracking-wider text-[11px] border border-transparent`,children:k===null?i:k}),T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1`}),(0,l.jsx)(`span`,{className:`text-foreground/40`,children:`"`})]}):(0,l.jsxs)(`div`,{className:`flex items-center gap-0.5 ml-1 flex-1 min-w-0`,children:[(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),L&&(0,l.jsxs)(`div`,{className:`relative w-5 h-5 rounded-full overflow-hidden border border-[var(--panel-border)] shrink-0 mx-1 group/item hover:border-accent transition-colors bg-[var(--background)]`,children:[(0,l.jsx)(`input`,{type:`color`,value:i.length===7&&i.startsWith(`#`)?i:`#000000`,onFocus:j,onBlur:e=>{o(e.target.value),O.current=null},onChange:e=>o(e.target.value),className:`absolute -inset-8 w-24 h-24 cursor-pointer opacity-0`}),(0,l.jsx)(`div`,{className:`absolute inset-0 pointer-events-none transition-transform group-hover/item:scale-110`,style:{backgroundColor:i}})]}),(0,l.jsx)(Gt,{disabled:F,value:i,isNumber:typeof i==`number`,placeholder:R?`https://...`:void 0,className:`no-glow bg-transparent font-extrabold outline-none focus:outline-none focus:ring-0 p-0 m-0 transition-colors leading-none ${R?`text-accent/80 font-medium placeholder:text-accent/30`:`text-foreground`} ${F?`opacity-50 grayscale pointer-events-none`:``}`,onFocus:j,handleBlurOrEnter:e=>{let t=e.currentTarget.value;R&&t&&t!==`none`&&!t.includes(`http`)&&!t.includes(`www.`)&&!t.startsWith(`/`)&&(t=``,o(``),ee(!0),setTimeout(()=>ee(!1),2500)),O.current!==null&&O.current!==t&&E(!0),O.current=null,M(e)},onChange:e=>o(e)}),(0,l.jsx)(`span`,{className:`text-foreground/40 shrink-0`,children:`"`}),D?(0,l.jsx)(`span`,{className:`text-red-500 font-bold ml-1.5 text-[10px] tracking-widest uppercase`,children:`invalid`}):T&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40 ml-1.5 shrink-0`}),(e===`logoUrl`||e===`faviconUrl`)&&(0,l.jsx)(`button`,{onClick:()=>o(e===`logoUrl`?t.t.logoUrl:t.t.faviconUrl),className:`w-4 h-4 ml-2 bg-red-500/10 hover:bg-red-500/20 text-red-500 rounded flex items-center justify-center transition-colors text-[10px] font-bold`,title:`Reset to default icon`,children:`✕`})]}),!c&&(0,l.jsx)(`span`,{className:`text-foreground/50 shrink-0`,children:`,`}),e&&[`inputRadius`,`modalRadius`,`badgeRadius`,`buttonRadius`,`cardRadius`].includes(e)&&(0,l.jsxs)(`span`,{className:`text-foreground/30 text-[10px] font-medium ml-2 tracking-wide whitespace-nowrap hidden md:inline-block pointer-events-none`,children:[`// `,e===`inputRadius`?`Forms & text fields`:e===`modalRadius`?`Popups & dialogs`:e===`badgeRadius`?`Tags & pills`:e===`buttonRadius`?`Interactive buttons`:`Big panels & cards`]})]}))};function qt(){let{activeConfig:e}=n.xt(),t=n.Ct(),[r,i]=(0,a.useState)(null),[s,c]=(0,a.useState)(!1),[u,d]=(0,a.useState)(!1),f=a.default.useRef(null);(0,a.useEffect)(()=>{if(!r&&e){let t=JSON.parse(JSON.stringify(e));i(t),f.current=JSON.stringify(t)}},[e]);let[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{let e=sessionStorage.getItem(`fbos_theme_scrollY`);e&&requestAnimationFrame(()=>window.scrollTo(0,parseInt(e,10)))}catch{}let e=()=>{try{sessionStorage.setItem(`fbos_theme_scrollY`,String(window.scrollY))}catch{}};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),(0,a.useEffect)(()=>{if(!r)return;let e=JSON.stringify(r);if(e===f.current)return;let t=setTimeout(async()=>{c(!0);try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,`theme`),r),f.current=e}catch(e){console.error(`Auto-save failed`,e)}c(!1)},300);return()=>clearTimeout(t)},[r]);let _=async()=>{d(!0);try{let e=t?.themeConfig;e||=(await Promise.resolve().then(()=>require(`./theme.config-0Lvwt5Bo.cjs`)).then(e=>e.n)).themeConfig;let r=JSON.parse(JSON.stringify(e)),{deleteDoc:a}=await import(`firebase/firestore`);await a((0,o.doc)(n.Tt,`sys_configs`,`theme`)),localStorage.removeItem(`theme_config_cache`),f.current=JSON.stringify(r),i(r)}catch{}setTimeout(()=>{d(!1),g(!1)},1e3)},v=e=>{if(!e)return`167, 139, 250`;let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16)),`${t}, ${n}, ${r}`},y=e=>{if(!r)return;let t=JSON.parse(JSON.stringify(r));if(t.colors&&t.colors.dark){let n=v(e.dark.accent);t.colors.dark.accent=e.dark.accent,t.colors.dark.buttonGradient=e.dark.gradient,t.colors.dark.buttonHoverGradient=e.dark.gradient,t.colors.dark.buttonText=e.dark.buttonText,t.colors.dark.notificationIconColor=e.dark.accent,t.colors.dark.textGradient=e.dark.text,t.colors.dark.foreground=e.dark.text[0],t.colors.dark.background=e.dark.background,t.colors.dark.backgroundSecondary=e.dark.backgroundSecondary,t.colors.dark.panelBg=`rgba(${n}, 0.05)`,t.colors.dark.panelBorder=`rgba(${n}, 0.15)`,t.colors.dark.glowColor=`rgba(${n}, 0.40)`,t.colors.dark.selectionBg=`rgba(${n}, 0.40)`,t.colors.dark.secondaryButton&&(t.colors.dark.secondaryButton.text=e.dark.text[0])}if(t.colors&&t.colors.light){let n=v(e.light.accent);t.colors.light.accent=e.light.accent,t.colors.light.buttonGradient=e.light.gradient,t.colors.light.buttonHoverGradient=e.light.gradient,t.colors.light.buttonText=e.light.buttonText,t.colors.light.notificationIconColor=e.light.accent,t.colors.light.textGradient=e.light.text,t.colors.light.foreground=e.light.text[0],t.colors.light.background=e.light.background,t.colors.light.backgroundSecondary=e.light.backgroundSecondary,t.colors.light.panelBg=`rgba(255, 255, 255, 0.70)`,t.colors.light.panelBorder=`rgba(${n}, 0.08)`,t.colors.light.glowColor=`rgba(${n}, 0.30)`,t.colors.light.selectionBg=`rgba(${n}, 0.30)`,t.colors.light.secondaryButton&&(t.colors.light.secondaryButton.text=e.light.text[0])}i(t)},b=()=>{if(r){let e=r,t=e.colors?.dark||{},n=e.colors?.light||{};e.fontCustomization;let i=e.cornerRadii||{},a=`/**
436
384
  * THEME & BRANDING CONFIGURATION
437
385
  *
438
386
  * This is the central hub for customizing your app's look.
@@ -524,7 +472,7 @@ export const themeConfig = {
524
472
  cardRadius: ${i.cardRadius||1.5}, // 24px (2xl, 3xl)
525
473
  modalRadius: ${i.modalRadius||2.5}, // Global popups and main internal boxes
526
474
  }
527
- };`;navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!1),2e3)}};return(0,a.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`a`&&document.activeElement===document.body&&e.preventDefault(),(e.ctrlKey||e.metaKey)&&e.key===`c`&&!window.getSelection()?.toString()&&r&&b()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Theme`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/theme`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-6 md:p-10 shadow-2xl relative overflow-hidden bg-background flex flex-col min-h-[600px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Theme Config`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`Changes here immediately format natively. Save to update your Live Preview panel entirely.`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:_,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-xl flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:u?(0,l.jsx)(n.M,{className:`w-4 h-4 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-4 h-4 text-foreground/60 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:b,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors`,title:`Copy Config (Ctrl+C)`,children:p?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-4 h-4 text-foreground/60 hover:text-foreground transition-colors`})})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 w-full relative z-10 items-start`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-background/60 backdrop-blur-[2px] z-50 flex items-center justify-center rounded-3xl pointer-events-none transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}),(0,l.jsxs)(`div`,{className:`w-full glass-panel border border-[var(--panel-border)] rounded-3xl p-6 md:p-8 shadow-inner overflow-hidden relative bg-background`,children:[(0,l.jsx)(`h3`,{className:`text-lg font-extrabold text-foreground tracking-tight mb-4 flex items-center gap-3`,children:`Branding & Colours`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 overflow-x-auto hide-scrollbars pb-4 pt-2 mb-6 border-b border-[var(--panel-border)]/50 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-bold text-foreground/40 shrink-0 uppercase tracking-widest pl-1 mr-2`,children:`Presets`}),Ut.map(e=>{let t=r?.colors?.dark?.accent===e.dark.accent&&r?.colors?.dark?.buttonGradient?.[0]===e.dark.gradient[0],n=e.name===`Black & White`;return(0,l.jsx)(`button`,{onClick:()=>y(e),className:`w-9 h-9 rounded-full shrink-0 outline-none transition-all shadow-sm relative group overflow-visible ${t?`ring-[3px] ring-foreground ring-offset-2 ring-offset-[var(--background)] scale-110 z-10`:`opacity-80 hover:opacity-100 hover:ring-2 hover:ring-foreground/30 hover:ring-offset-2 hover:ring-offset-[var(--background)] hover:scale-105`}`,title:e.name,children:(0,l.jsx)(`div`,{className:`absolute inset-0 rounded-full`,style:n?{backgroundColor:`#ffffff`,border:`3px solid #000000`,boxShadow:`inset 0 0 0 1px rgba(0,0,0,0.1)`}:{backgroundImage:`linear-gradient(135deg, ${e.preview[0]}, ${e.preview[1]})`}})},e.name)})]}),(0,l.jsx)(`div`,{className:`w-full relative min-h-[100px]`,children:r?(0,l.jsxs)(`div`,{className:`flex flex-col pl-2`,children:[(0,l.jsxs)(`span`,{className:`text-yellow-500 font-mono text-[13px] mb-2`,children:[`export const themeConfig = `,`{`]}),(0,l.jsx)(Kt,{value:r,keysToRender:[`appName`,`defaultTheme`,`showThemeToggle`,`logoUrl`,`faviconUrl`,`cornerRounding`,`cornerRadii`,`fontFamily`],onChange:e=>i(e),isLast:!1,isGlobalSaving:s}),(0,l.jsx)(`div`,{className:`mt-4`,children:(0,l.jsx)(Kt,{objectKey:`colors`,value:r.colors,onChange:e=>i({...r,colors:e}),isLast:!1,isGlobalSaving:s})})]}):(0,l.jsx)(`div`,{className:`flex items-center justify-center w-full h-full text-foreground/40 font-mono text-[13px] animate-pulse py-10`,children:`Loading Data Tree...`})})]})]})]})]})]})}var Jt={route:`/page_1`,pageName:`New Public Page`,template:`none`,pageTitle:`My Custom Page`,copyPrompt:!0,showButton:!0,buttonText:`Open Form`,action:`form`,form:`contact`},Yt={tabName:`New Private Page`,iconName:``,route:`/new-private-page`,template:`none`,form:`support`,showPrompt:!0,tabTitle:`Private Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Xt={tabName:`Admin Tab`,iconName:``,route:`/admin-tab`,template:`none`,form:``,showPrompt:!0,tabTitle:`Admin Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Zt={tabName:`Shared Tab`,iconName:``,route:`/shared-tab`,template:`none`,form:``,showPrompt:!0,tabTitle:`Shared Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Qt=[{id:`home`,title:`Home Page`,path:`/`,type:`public`,isSystem:!0,enabled:!0}],$t=({enabled:e,onChange:t,disabled:r,className:i=``})=>(0,l.jsx)(`button`,{disabled:r,onClick:()=>t(!e),title:e?`Page Active`:`Page Hidden`,className:`p-1.5 transition-colors rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity ${i} ${e?`text-accent hover:bg-accent/10`:`text-foreground/40 hover:bg-foreground/5`} ${r?`!opacity-50 cursor-not-allowed`:`cursor-pointer`}`,children:e?(0,l.jsx)(n.K,{className:`w-4 h-4`}):(0,l.jsx)(n.q,{className:`w-4 h-4`})});function en(){let{userRole:e}=m(),t=(0,u.useLocation)(),r=n.Ct(),[i,s]=(0,a.useState)(Qt),[c,d]=(0,a.useState)(()=>{try{return sessionStorage.getItem(`fbos_pages_expandedId`)||null}catch{return null}}),f=(0,a.useRef)(c),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)({}),[v,y]=(0,a.useState)({}),[b,x]=(0,a.useState)({}),[C,w]=(0,a.useState)(null),[T,E]=(0,a.useState)(!1),D=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){D.current&&!D.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(!1),[M,N]=(0,a.useState)(!1),[ne,P]=(0,a.useState)(new Set),[F,re]=(0,a.useState)(new Set),[I,L]=(0,a.useState)([]),[R,ie]=(0,a.useState)([]),z=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden});(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{let t=z(e.exists()&&e.data().order||[]);L(t),P(new Set(t.filter(e=>e.hidden).map(e=>e.id)))}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{let t=z(e.exists()&&e.data().order||[]);ie(t),re(new Set(t.filter(e=>e.hidden).map(e=>e.id)))});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{let e=t.pathname.split(`/pages/`)[1]?.split(`/`)[0];e&&!c&&i.some(t=>t.id===e)&&d(e)},[t.pathname,i]),(0,a.useEffect)(()=>{f.current=c;try{c?sessionStorage.setItem(`fbos_pages_expandedId`,c):sessionStorage.removeItem(`fbos_pages_expandedId`)}catch{}},[c]);let B=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=B.current;if(!e)return;try{let t=sessionStorage.getItem(`fbos_pages_scrollY`);t&&(e.scrollTop=parseInt(t,10))}catch{}let t=()=>{try{sessionStorage.setItem(`fbos_pages_scrollY`,String(e.scrollTop))}catch{}};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,a.useEffect)(()=>{let e=(e,t)=>{if(!t)return e;let n=Object.fromEntries(Object.entries(t).filter(([e,t])=>t!=null&&t!==``));return{...e,...n}},t=r?.defaultConfigs?.home||S,i=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_pages`,`home`),n=>{n.exists()?k(e(t,n.data())):k(t)});return()=>{i()}},[r]),(0,a.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([(0,o.getDocs)((0,o.collection)(n.Tt,`sys_pages`)),(0,o.getDocs)((0,o.collection)(n.Tt,`sys_tabs`))]),r=[`home`,`contact`,`support`,`theme`,`page_order`,`tab_order`],i=[],a={};e.forEach(e=>{if(!r.includes(e.id)){let t=e.data();i.push({id:e.id,title:t.pageName||t.title||e.id,path:t.route||`/`+e.id,type:`public`,isSystem:!1,enabled:t.enabled!==!1}),a[e.id]=t}}),t.forEach(e=>{if(!r.includes(e.id)){let t=e.data(),n=t.pageType||`private`;i.push({id:e.id,title:t.tabName||t.title||e.id,path:t.route||`/`+e.id,type:n,isSystem:!1,enabled:t.enabled!==!1}),a[e.id]=t}}),i.length>0&&(s(e=>{let t=e.filter(e=>e.isSystem||e.id.startsWith(`draft_`)),n=i.filter(e=>!t.some(t=>t.id===e.id));return[...t,...n]}),_(e=>({...e,...a})))}catch(e){console.error(`Error loading custom pages`,e)}})()},[]);let[V,H]=(0,a.useState)([`contact`]),[U,W]=(0,a.useState)([`support`]);(0,a.useEffect)(()=>{(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=[],n=[];e.forEach(e=>{e.data().formType===`private`?n.push(e.id):t.push(e.id)}),t.length>0&&H(t),n.length>0&&W(n)}).catch(console.error)},[]);let[G,K]=(0,a.useState)(null),ae=(e,t)=>{let n;n=e===`home`?`export const defaultHomeConfig = ${JSON.stringify(t,null,2)};\n`:JSON.stringify(t,null,2),navigator.clipboard.writeText(n),K(e),setTimeout(()=>K(null),2e3)},q=async(e,t)=>{t.route&&!t.route.startsWith(`/`)&&(t.route=`/`+t.route);let r=i.find(t=>t.id===e)?.type,a=r===`public`?`sys_pages`:`sys_tabs`;r&&r!==`public`&&(t.pageType=r);let c=[`home`].includes(e)?e:t.route?t.route.replace(/^\/+/,``).replace(/[^a-zA-Z0-9_\-]/g,`_`).toLowerCase():e;e===`home`?j(!0):y(t=>({...t,[e]:!0,[c]:!0}));try{if(c!==e&&c.trim()!==``&&c!==`draft`){try{let{deleteDoc:t}=await import(`firebase/firestore`);await t((0,o.doc)(n.Tt,a,e))}catch{}await(0,o.setDoc)((0,o.doc)(n.Tt,a,c),t),s(n=>n.map(n=>n.id===e?{...n,id:c,_uiKey:n._uiKey||e,path:t.route,title:t.pageName||t.tabName||t.title||n.title}:n)),f.current===e&&(d(c),window.history.replaceState(null,``,`/pages/${c}`)),_(n=>{let r={...n};return r[c]=t,delete r[e],r});let i=r===`public`,l=i?`page_order`:`tab_order`,u=i?I:R;if(!u.some(e=>e.id===c)){let t=[{id:c,hidden:!1},...u.filter(t=>t.id!==e)];try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,l),{order:t})}catch(e){console.error(`Failed to update tab order:`,e)}}}else await(0,o.setDoc)((0,o.doc)(n.Tt,a,e),t),e===`home`?k(t):(_(n=>({...n,[e]:t})),s(n=>n.map(n=>n.id===e?{...n,path:t.route||n.path,title:t.pageName||t.tabName||t.title||n.title}:n)))}catch(t){console.error(`Failed to save ${e} config:`,t)}finally{setTimeout(()=>{e===`home`?j(!1):y(t=>({...t,[e]:!1,[c]:!1}))},500)}},J=async e=>{e.stopPropagation(),N(!0);try{let{deleteDoc:e}=await import(`firebase/firestore`);await e((0,o.doc)(n.Tt,`sys_pages`,`home`)),localStorage.removeItem(`fbos_home_config`),k(r?.defaultConfigs?.home||S)}catch(e){console.error(`Failed to reset home config:`,e)}setTimeout(()=>N(!1),500)},oe=async(e,t,n)=>{e.stopPropagation(),x(e=>({...e,[t]:!0})),await q(t,n),setTimeout(()=>x(e=>({...e,[t]:!1})),500)},Y=e=>{let t=`draft_`+Math.floor(Math.random()*1e4);s([...i,{id:t,title:`New Tab`,path:`/draft`,type:e,isSystem:!1,enabled:!0}]);let n=i.filter(t=>t.type===e&&!t.id.startsWith(`draft_`)).length+1,r={};e===`public`?r={...Jt,route:`/page-${n}`}:e===`private`?r={...Yt,route:`/private-tab-${n}`}:e===`admin`?r={...Xt,route:`/admin-tab-${n}`}:e===`shared`&&(r={...Zt,route:`/shared-tab-${n}`}),_(e=>({...e,[t]:r})),d(t),h(!1),q(t,{...r,pageType:e===`public`?void 0:e}),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView({behavior:`smooth`,block:`center`})},100)};if(e!==`admin`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1`,children:[(0,l.jsx)(n.v,{className:`w-12 h-12 text-red-500 mb-4`}),(0,l.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-foreground/60`,children:`You do not have permission to view pages configuration.`})]})});let se=async(e,t,r)=>{let a=r===`public`,c=a?`page_order`:`tab_order`,l=a?I:R,u=(a?ne:F).has(e);s(i.map(t=>t.id===e?{...t,enabled:u}:t));let d=[...l],f=d.findIndex(t=>t.id===e);f===-1?d.push({id:e,hidden:!0}):d[f]={...d[f],hidden:!u},await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,c),{order:d})},ce=(e,t)=>{t||w(e)},le=async()=>{if(C){E(!0);try{let{deleteDoc:e,collection:t,getDocs:r,doc:a,getDoc:o,query:l,where:u}=await import(`firebase/firestore`),{ref:f,deleteObject:p}=await import(`firebase/storage`),m=i.find(e=>e.id===C),h=m?.type===`public`?`sys_pages`:`sys_tabs`;if(h===`sys_tabs`&&m){let i=g[C];if(!i)try{let e=await o(a(n.Tt,`sys_tabs`,C));e.exists()&&(i=e.data())}catch{}let s=(i?.tabName||i?.pageId||C).toLowerCase().replace(/[^a-z0-9]+/g,`_`),c=[`admin_${s}_records`,`mem_${s}_records`,`user_${s}_records`],d={[`admin_${s}_records`]:{prefix:`admin_files`,driveCollection:`admin_files`},[`mem_${s}_records`]:{prefix:`mem_files`,driveCollection:`mem_files`},[`user_${s}_records`]:{prefix:`user_files`,driveCollection:`user_files`}};for(let i of c)try{let a=await r(t(n.Tt,i)),o=d[i];for(let i of a.docs){let a=i.data();if(a.recordType===`file`&&a.downloadURL&&o)try{let i=`${o.prefix}%2F`,s=a.downloadURL.split(i)[1]?.split(`?`)[0];s&&await p(f(n.Dt,`${o.prefix}/${decodeURIComponent(s)}`)).catch(()=>{});let c=await r(l(t(n.Tt,o.driveCollection),u(`downloadURL`,`==`,a.downloadURL)));for(let t of c.docs)await e(t.ref)}catch(e){console.error(`Error deleting storage file:`,e)}}let s=a.docs.map(t=>e(t.ref));await Promise.all(s);try{localStorage.removeItem(`fbos_records_${i}`)}catch{}}catch(e){console.error(`Error cleaning up collection ${i}:`,e)}for(let i of[`admin_files`,`mem_files`,`user_files`])try{let a=await r(l(t(n.Tt,i),u(`sourceTab`,`==`,s)));for(let t of a.docs){let r=t.data();if(r.downloadURL)try{let e=i.replace(`_files`,`_files`),t=`${e}%2F`,a=r.downloadURL.split(t)[1]?.split(`?`)[0];a&&await p(f(n.Dt,`${e}/${decodeURIComponent(a)}`)).catch(()=>{})}catch{}await e(t.ref)}}catch{}}await e(a(n.Tt,h,C));let _=h===`sys_pages`?`page_order`:`tab_order`,v=h===`sys_pages`?I:R,{setDoc:y}=await import(`firebase/firestore`),b=v.filter(e=>e.id!==C);await y(a(n.Tt,`sys_configs`,_),{order:b}),s(e=>e.filter(e=>e.id!==C)),c===C&&d(null)}catch(e){console.error(`Error deleting page:`,e)}E(!1),w(null)}},ue=e=>{let t=e.id+`_`+Math.floor(Math.random()*1e3),n={...e,id:t,title:`${e.title} (Copy)`,path:`${e.path}_copy`,isSystem:!1,enabled:!0};s(e=>[...e,n]);let r=g[e.id];!r&&e.id===`home`&&(r=O);let i={...r||{},route:n.path,pageName:n.title};n.type!==`public`&&(i.tabName=n.title,i.pageType=n.type),_(e=>({...e,[t]:i})),d(t),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView({behavior:`smooth`,block:`center`})},100)},de=[{id:`public`,title:`Public Pages`,icon:n.U,color:`bg-amber-500`,description:`Creates external menu items. Invisible to signed-in dashboard users.`,filter:e=>e.type===`public`},{id:`private`,title:`Private Pages`,icon:n.j,color:`bg-emerald-500`,description:`Internal dashboard tabs for regular users.`,filter:e=>e.type===`private`},{id:`shared`,title:`Shared Pages`,icon:n.K,color:`bg-blue-500`,description:`Dashboard tabs visible to all members, editors, and admins.`,filter:e=>e.type===`shared`},{id:`admin`,title:`Admin Pages`,icon:n.v,color:`bg-red-500`,description:`Internal dashboard tabs for admin users only.`,filter:e=>e.type===`admin`}],[fe,X]=(0,a.useState)(!1),[pe,me]=(0,a.useState)(!1);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Pages`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/pages`,c?`/${c}`:``]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-6 pt-6 md:px-10 md:pt-10`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Architecture`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`Manage the structure of your application tabs and public pages.`})]}),(0,l.jsxs)(`div`,{className:`relative z-50 shrink-0 flex items-center gap-1`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>X(!0),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Reset Defaults`,children:(0,l.jsx)(n.x,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>h(!p),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Add New Page`,children:(0,l.jsx)(n.C,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,l.jsx)(n.a,{children:p&&(0,l.jsx)(n.i.div,{ref:D,initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:`absolute top-full mt-2 right-0 w-48 glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-xl z-50 flex flex-col gap-1`,children:[`public`,`private`,`shared`,`admin`].map(e=>(0,l.jsxs)(`button`,{onClick:()=>{Y(e),h(!1)},className:`text-left px-3 py-2 text-[13px] font-bold uppercase tracking-wider text-foreground/70 hover:text-foreground hover:bg-foreground/5 rounded-lg transition-colors cursor-pointer`,children:[e,` Page`]},e))})})]})]})]}),(0,l.jsxs)(`div`,{ref:B,className:`px-6 md:px-10 pb-6 md:pb-10 flex flex-col pt-0 gap-10 overflow-y-auto mt-2 relative min-h-[400px]`,children:[(0,l.jsx)(n.a,{children:pe&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-[2px] rounded-3xl`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-6 glass-panel rounded-2xl shadow-xl`,children:[(0,l.jsx)(n.M,{className:`w-8 h-8 md:w-10 md:h-10 animate-spin text-accent mb-4`}),(0,l.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:`Synchronizing Architecture...`})]})})}),de.map((e,t)=>{let r=i.filter(e.filter),a=e.id===`public`?I:R,o=r.sort((e,t)=>{let n=a.findIndex(t=>t.id===e.id),r=a.findIndex(e=>e.id===t.id);return n===-1&&r===-1?0:n===-1?1:r===-1?-1:n-r}),s=e.icon,u=e=>e.type===`public`?ne.has(e.id):F.has(e.id),f=o.filter(e=>!u(e)),p=o.filter(e=>u(e)),m=e=>{if(!e)return[];let t=[`route`,`pageName`,`template`];return e.template===`none`?(t.push(`pageTitle`,`copyPrompt`),t.push(`showButton`),e.showButton!==!1&&(t.push(`buttonText`,`action`),e.action===`form`?t.push(`form`):e.action===`redirect`&&t.push(`redirectUrl`))):(e.template===`popup_form`||e.template===`inline_form`)&&(t.push(`showButton`),e.showButton!==!1&&t.push(`form`)),t},h=e=>{if(!e)return[];let t=[`tabName`,`iconName`,`route`,`template`];return e.template===`popup_form`||e.template===`inline_form`?(t.push(`showButton`),e.showButton!==!1&&t.push(`form`)):e.template===`none`?(t.push(`showPrompt`,`tabTitle`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonStyle`,`buttonText`,`buttonAction`),t.push(`storage`),e.storage!==!1&&t.push(`buttonStorageIcon`,`buttonStorageText`,`buttonStorageStyle`,`buttonStorageAction`)):e.template===`calendar`?(t.push(`tabTitle`,`showPrompt`),t.push(`defaultView`,`defaultTimeFormat`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`showViewsButton`),e.showViewsButton!==!1&&t.push(`viewsButtonStyle`)):e.template===`table`?(t.push(`tabTitle`,`showPrompt`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`showExportButton`),e.showExportButton!==!1&&t.push(`exportButtonIcon`)):e.template===`board`&&(t.push(`tabTitle`,`showPrompt`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`keyName`,`valueName`)),t},_=(t,r,i)=>{let a=t.id===`home`,o=c===t.id,s=a||!t.isSystem;return(0,l.jsxs)(`div`,{id:`page-${t.id}`,onClick:e=>{if(s){let e=o?null:t.id;d(e),window.history.replaceState(null,``,e?`/pages/${e}`:`/pages`)}},className:`group flex flex-col py-4 px-5 glass-panel border transition-all rounded-2xl hover:shadow-sm ${s?`cursor-pointer hover:border-accent/40`:``} ${i?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-between w-full gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 w-full flex-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground truncate`,children:t.title}),a&&A&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-accent ml-2`})]}),(0,l.jsxs)(`div`,{className:`text-[11px] font-medium font-mono px-2 py-0.5 rounded w-fit ml-6 border ${i?`text-foreground/50 border-foreground/10 bg-foreground/5`:`text-accent/70 bg-accent/5 border-accent/10`}`,children:[window.location.host,t.path]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-4 shrink-0`,children:[!t.isSystem||[`contact`,`support`,`templates`].includes(t.id)?(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(t)},className:`p-1.5 hover:bg-accent/10 text-foreground/40 hover:text-accent transition-colors rounded-lg flex items-center justify-center shrink-0`,title:`Duplicate Page`,children:(0,l.jsx)(n.Z,{className:`w-4 h-4`})}):(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}),(0,l.jsx)(`div`,{className:`flex items-center justify-end w-8 shrink-0`,children:t.id===`home`?(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}):(0,l.jsx)($t,{enabled:!u(t),onChange:()=>se(t.id,t.isSystem,t.type)})}),t.isSystem?(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}):(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ce(t.id,t.isSystem)},className:`p-1.5 hover:bg-red-500/10 text-foreground/30 hover:text-red-500 transition-colors rounded-lg flex items-center justify-center shrink-0`,title:`Delete Page`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),s?(0,l.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 shrink-0 ${o?`rotate-180`:``}`,children:(0,l.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,l.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}):(0,l.jsx)(`div`,{className:`w-[24px] shrink-0`})]})]}),(0,l.jsxs)(n.a,{children:[o&&a&&O&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-4`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 py-6 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:J,className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:M?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ae(`home`,O)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:G===`home`?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:O,keysToRender:[`hero`],onChange:e=>q(`home`,e),isLast:!0,isGlobalSaving:A,customEnums:{form:V},customExplanations:{form:`User can click to switch to any public form we have in the forms tab. Private forms are not an option here. Add a new form in forms with a link that actually works.`}})]})}),o&&!t.isSystem&&g[t.id]&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-4`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 py-6 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:e=>oe(e,t.id,t.type===`admin`?Xt:t.type===`shared`?Zt:t.type===`public`?Jt:Yt),className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:b[t.id]?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ae(t.id,g[t.id])},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:G===t.id?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:g[t.id],keysToRender:t.type===`public`?m(g[t.id]):h(g[t.id]),onChange:e=>q(t.id,e),isLast:!0,isGlobalSaving:v[t.id],customEnums:{form:t.type===`public`?V:U,template:t.type===`public`?[`none`,`popup_form`,`inline_form`]:t.type===`admin`||t.type===`shared`?[`none`,`calendar`,`table`,`board`]:[`none`,`calendar`,`table`,`board`,`popup_form`,`inline_form`],action:[`save_Info`,`form`],defaultTimeFormat:[`12h`,`24h`],defaultView:[`calendar`,`board`],buttonStyle:[`primary`,`secondary`],buttonAction:[`save_info`],viewsButtonStyle:[`primary`,`secondary`],buttonStorageStyle:[`primary`,`secondary`],buttonStorageAction:[`upload_file`]},customExplanations:{tabName:`Defines the tab label in the dashboard navigation.`,iconName:`Visit https://lucide.dev/icons/, find an icon, and paste its exact name (e.g. 'book-open', 'server', 'cloud-upload').`,route:`The URL path for this tab (e.g. '/my-tab'). Must start with /.`,template:`Page layout type. 'none' gives you a freeform dashboard with add/upload buttons.`,form:`Which form to display. Only applies to popup_form or inline_form templates. Go to /forms to edit forms.`,tabTitle:`The heading that appears at the top of the page content area.`,showPrompt:`Shows the developer AI prompt copy button in the header.`,showButton:`Toggles the + add record button in the header.`,buttonStyle:`Visual style of the add button: 'primary' (accent) or 'secondary' (subtle).`,buttonText:`Label on the add button. Use '+' for a minimal icon-only button.`,buttonAction:`'save_info' saves a name + note record to the tab's Firestore collection.`,storage:`Enables the file upload button for this tab.`,buttonStorageIcon:`Icon name from https://lucide.dev/icons/ for the upload button (e.g. 'upload', 'cloud-upload').`,buttonStorageText:`Label next to the upload icon. Leave empty for icon-only.`,buttonStorageStyle:`'primary' or 'secondary' visual style for the upload button.`,buttonStorageAction:t.type===`admin`?`'upload_file' uploads to admin_files/ in Storage and mirrors metadata to admin_files collection (Drive > Admin).`:t.type===`shared`?`'upload_file' uploads to mem_files/ in Storage and mirrors metadata to mem_files collection (Drive > Shared).`:`'upload_file' uploads to user_files/ in Storage and mirrors metadata to user_files collection (Drive > Private).`,defaultView:`Starting view: 'calendar' (month grid) or 'board' (event list). Users can switch between them.`,defaultTimeFormat:`12h or 24h time format. Users can toggle this in the toolbar.`,showViewsButton:`Show the calendar/board view toggle button in the toolbar.`,viewsButtonStyle:`'primary' or 'secondary' visual style for the view toggle.`,showExportButton:`Show the CSV export/download button in the table toolbar.`,exportButtonIcon:`Icon name from https://lucide.dev/icons/ for the export button (e.g. 'download', 'import').`,keyName:`Label for the key/title field in board items (e.g. 'Task', 'Name').`,valueName:`Label for the value/description field in board items (e.g. 'Notes', 'Details').`},hideInnerLoader:!0})]})})]})]},`${e.id}-${t._uiKey||t.id}`)};return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col relative`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3 mb-2 border-b border-[var(--panel-border)]/50 pb-4`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center -ml-1 shadow-sm`,children:(0,l.jsx)(s,{className:`w-4 h-4 text-accent`})}),(0,l.jsx)(`h2`,{className:`text-xl font-extrabold tracking-tight text-foreground`,children:e.title})]}),(0,l.jsx)(`p`,{className:`text-[13px] leading-relaxed text-foreground/50 font-medium max-w-3xl mb-4 ml-[2px]`,children:e.description}),o.length===0?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 opacity-40 glass-panel rounded-2xl border border-[var(--panel-border)]/50 border-dashed`,children:[(0,l.jsx)(n.L,{className:`w-5 h-5 mb-2`}),(0,l.jsx)(`p`,{className:`text-[12px] font-bold`,children:`This section is currently empty.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f.map(e=>_(e,o.findIndex(t=>t.id===e.id),!1)),p.length>0&&(0,l.jsxs)(`details`,{className:`mt-4 group/details`,children:[(0,l.jsxs)(`summary`,{className:`text-[11px] font-bold uppercase tracking-wider text-foreground/40 cursor-pointer list-none flex items-center gap-2 select-none hover:text-foreground/70 transition-colors w-fit pb-1 ml-1 outline-none`,children:[(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 group-open/details:-rotate-180 transition-transform`}),`Hidden pages (`,p.length,`)`]}),(0,l.jsx)(`div`,{className:`flex flex-col gap-4 mt-4`,children:p.map(e=>_(e,o.findIndex(t=>t.id===e.id),!0))})]})]}),t<de.length-1&&(0,l.jsx)(`div`,{className:`w-full border-t border-[var(--panel-border)]/70 my-10`})]},e.id)})]})]})]}),(0,l.jsx)(te,{isOpen:fe,onCancel:()=>X(!1),onConfirm:async()=>{me(!0);try{let{deleteDoc:e}=await import(`firebase/firestore`);await Promise.all([e((0,o.doc)(n.Tt,`sys_pages`,`home`))]),k(S)}catch(e){console.error(`Error resetting defaults:`,e)}setTimeout(()=>{me(!1),X(!1)},1e3)},title:`Reset System Pages`,message:`Are you sure you want to reset all system page configurations? Custom pages and their order will remain intact.`,confirmText:`Reset`,isProcessing:pe}),(0,l.jsx)(te,{isOpen:!!C,onCancel:()=>w(null),onConfirm:le,title:`Delete Page`,message:`Are you sure you want to delete this page? This action cannot be undone and will remove all associated configurations.`,confirmText:`Remove Page`,isProcessing:T})]})}var tn={contact:r.t,support:i.t};function nn(){let{userRole:e}=m(),t=(0,u.useNavigate)();(0,u.useLocation)();let[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)(!0),[d,f]=(0,a.useState)({}),p=n.Ct(),h=()=>({...tn,contact:p?.defaultConfigs?.contactForm||tn.contact,support:p?.defaultConfigs?.supportForm||tn.support}),[g,_]=(0,a.useState)(null),[v,y]=(0,a.useState)({}),[b,x]=(0,a.useState)(null),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(null),E=(e,t)=>{let n;n=e===`contact`?`export const contactFormConfig = ${JSON.stringify(t,null,2)};\n`:e===`support`?`export const supportFormConfig = ${JSON.stringify(t,null,2)};\n`:JSON.stringify(t,null,2),navigator.clipboard.writeText(n),T(e),setTimeout(()=>T(null),2e3)};(0,a.useEffect)(()=>{D()},[]);let D=async()=>{try{let e=await(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)),t={};e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let n=e.data();n._uiKey||=Math.random().toString(36).substring(7),t[e.id]=n}});try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,`pubForm`)),await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,`userForm`))}catch{}let r=h();for(let[e,i]of Object.entries(r))if(!t[e]){await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),i);let r={...i};r._uiKey=Math.random().toString(36).substring(7),t[e]=r}else if(!t[e].fields||t[e].fields.length===0){let i=r[e];t[e].fields=i.fields||[],await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),t[e])}let a=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];a&&t[a]&&y({[a]:!0}),i(t)}catch(e){console.error(`Failed to load forms:`,e)}finally{c(!1)}},O=async(e,t)=>{let a={...t};r[e]?._uiKey&&(a._uiKey=r[e]._uiKey),e===`contact`?(a.systemName=`contact`,a.formType=`public`,a.submitPage=`submissions`):e===`support`&&(a.systemName=`support`,a.formType=`private`,a.submitPage=`requests`);let s=a.systemName||e;if(s!==e&&s.trim()!==``){i(t=>{let n={};for(let r of Object.keys(t))r===e?n[s]=a:n[r]=t[r];return n}),v[e]&&y(t=>{let n={};for(let r of Object.keys(t))r===e?n[s]=t[r]:n[r]=t[r];return n}),f(e=>({...e,[s]:!0}));try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,s),a),await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e))}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{f(e=>({...e,[s]:!1}))},500)}}else{i(t=>({...t,[e]:a})),f(t=>({...t,[e]:!0}));try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),a)}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{f(t=>({...t,[e]:!1}))},500)}}},[k,A]=(0,a.useState)(!1),j=async()=>{if(k)return;A(!0);let e=`new_form_${Date.now().toString().slice(-4)}`,r={title:`New Custom Form`,systemName:e,formType:`public`,submitPage:`submissions`,redirectTo:``,submitText:`Submit`,fields:[],enabled:!0,_uiKey:Math.random().toString(36).substring(7)};try{f(t=>({...t,[e]:!0})),await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),r),i(t=>({[e]:r,...t})),y(t=>({[e]:!0,...t})),t(`/forms/${e}`)}catch(e){console.error(`Failed to create form`,e)}finally{f(t=>({...t,[e]:!1})),A(!1)}},M=async e=>{if(!(e===`contact`||e===`support`)){C(!0);try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e)),i(t=>{let n={...t};return delete n[e],n}),t(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{C(!1),x(null)}}};if(e!==`admin`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1`,children:[(0,l.jsx)(n.p,{className:`w-12 h-12 text-red-500 mb-4`}),(0,l.jsx)(`h2`,{className:`text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-br from-red-400 to-red-600`,children:`Access Restricted`}),(0,l.jsx)(`p`,{className:`text-foreground/60 max-w-sm text-center mt-2 font-medium leading-relaxed`,children:`This area is exclusively for system administrators.`})]})});let N=e=>{y(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},ne=Object.keys(v).find(e=>v[e]);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Forms`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/forms`,ne?`/${ne}`:``]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-6 pt-6 md:px-10 md:pt-10 bg-background/50`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Custom Forms`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`This is the central page where you configure and manage your application's forms. Easily add and customize the fields for your users.`})]}),(0,l.jsx)(`div`,{className:`relative z-50 shrink-0 flex items-center justify-end`,children:(0,l.jsx)(n.n,{variant:`secondary`,onClick:j,title:`Add Custom Form`,disabled:k,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,children:k?(0,l.jsx)(n.M,{className:`w-4 h-4 text-foreground/60 animate-spin`}):(0,l.jsx)(n.C,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})})})]}),(0,l.jsx)(`div`,{className:`p-6 md:p-8 flex flex-col gap-4 overflow-y-auto`,children:s?(0,l.jsx)(`div`,{className:`flex items-center justify-center p-12 glass-panel rounded-3xl border border-[var(--panel-border)]`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})}):Object.keys(r).length===0?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed opacity-50`,children:[(0,l.jsx)(n.S,{className:`w-6 h-6 mb-3 text-foreground/40`}),(0,l.jsx)(`p`,{className:`text-[13px] font-bold`,children:`No forms currently configured.`})]}):(0,l.jsx)(n.a,{children:Object.entries(r).map(([e,t])=>{let r=v[e],i=d[e];return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},onClick:()=>N(e),className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${r?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${t.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between w-full`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col gap-1 w-full sm:w-auto pr-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:t.title||`Untitled Form`}),i&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest border border-[var(--panel-border)] bg-foreground/5 text-foreground/60 px-2 py-0.5 rounded-md`,children:t.systemName||e}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest border px-2 py-0.5 rounded-md shrink-0 ${t.formType===`private`?`text-blue-500 bg-blue-500/10 border-blue-500/20`:`text-green-500 bg-green-500/10 border-green-500/20`}`,children:t.formType||`public`})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto justify-end mt-2 sm:mt-0 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),_(t)},className:`p-1.5 hover:bg-accent/10 text-foreground/40 hover:text-accent transition-colors rounded-lg flex items-center justify-center mr-2`,title:`Preview Form`,children:(0,l.jsx)(n.K,{className:`w-4 h-4`})}),e!==`contact`&&e!==`support`?(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),x(e)},className:`p-1.5 hover:bg-red-500/10 text-foreground/30 hover:text-red-500 transition-colors rounded-lg opacity-0 group-hover:opacity-100 flex items-center justify-center mr-2`,title:`Delete Form`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}):(0,l.jsx)(`div`,{className:`w-7 mr-2 shrink-0`}),(0,l.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 ${r?`rotate-180`:``}`,children:(0,l.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,l.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:async t=>{if(t.stopPropagation(),e===`contact`||e===`support`){f(t=>({...t,[e]:!0}));try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),await D()}catch(e){console.error(`Reset failed:`,e)}setTimeout(()=>f(t=>({...t,[e]:!1})),500)}else O(e,h()[e]||h().contact)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:i?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:n=>{n.stopPropagation(),E(e,t)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:w===e?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:{systemName:t.systemName||e,formType:t.formType||`public`,submitPage:t.submitPage||(t.formType===`private`?`requests`:`submissions`),redirectTo:t.redirectTo||``,title:t.title||``,buttonName:t.buttonName||t.submitText||``,fields:t.fields||[]},keysToRender:[`systemName`,`formType`,`submitPage`,`redirectTo`,`title`,`buttonName`,`fields`],meta:{formType:t.formType||`public`},onChange:n=>{n.formType===t.formType?n.submitPage!==t.submitPage&&(n.formType=n.submitPage===`requests`?`private`:`public`):n.submitPage=n.formType===`public`?`submissions`:`requests`,O(e,{...t,...n,submitText:n.buttonName})},isLast:!0,isGlobalSaving:i,disabledKeys:e===`contact`||e===`support`?[`systemName`,`formType`,`submitPage`]:[],customEnums:{type:[`text`,`email`,`tel`,`textarea`,`number`,`select`,`checkbox`,`currency`,`age`]},customExplanations:{formType:e===`contact`?`Public means its for not signed in users. Private is disabled for contact so don't allow the user to change it.`:e===`support`?`This means that the form is available to signed in users only.`:`Public means it's for non-signed in users.`,submitPage:e===`contact`?`Means the form submissions go to this folder. User can't change that since it's directly linked. Public is tied to submissions.`:e===`support`?`Can't change since all private forms go there.`:`Where to route data submissions.`,redirectTo:`If not added form will just show a success message. If added, in 30 seconds after success user is redirected.`}})]})})})]},t._uiKey||e)})})})]})]}),(0,l.jsx)(te,{isOpen:!!b,onCancel:()=>x(null),onConfirm:()=>{b&&M(b)},title:`Delete Form`,message:`Are you sure you want to permanently delete "${b}"? This action cannot be reversed.`,confirmText:`Delete form`,isProcessing:S}),g&&(0,l.jsx)(n.t,{formConfig:g,onClose:()=>_(null)})]})}function rn({config:e}){let{config:t}=n.xt(),[r,i]=(0,a.useState)(!1),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)([]);(0,a.useEffect)(()=>{document.title=e.pageName||e.pageTitle||t.appName||`Firebase OS`,(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{d(e.docs.filter(e=>e.data().formType===`public`).map(e=>e.id))})},[e.pageName,e.pageTitle,t.appName]);let f=B(e,u);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 relative min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.pageTitle||e.pageName||`New Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 pt-2 border-b border-[var(--panel-border)] pb-6 relative z-20 overflow-x-auto no-scrollbar gap-4`,children:[(0,l.jsxs)(`button`,{onClick:()=>window.history.back(),className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 cursor-pointer shadow-sm text-foreground/70 whitespace-nowrap shrink-0`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}),(0,l.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[e.copyPrompt&&(0,l.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),2e3)},title:`Copy Developer Prompt`,className:`px-6 py-2.5 rounded-xl border border-[var(--panel-border)] bg-background flex items-center gap-2 hover:bg-foreground/5 hover:text-accent transition-all cursor-pointer text-[14px] font-bold tracking-wide shadow-sm whitespace-nowrap`,children:[(0,l.jsx)(n.ft,{className:`w-4 h-4`}),(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:r?`Copied!`:`Copy Prompt`})]}),e.showButton&&(0,l.jsx)(`button`,{onClick:()=>{e.action===`redirect`?window.location.href=e.url||`/`:e.action===`form`&&c(e.form||`contact`)},className:`px-6 py-2.5 rounded-xl font-bold tracking-wide transition-all duration-300 flex items-center justify-center btn-primary shadow-xl hover:-translate-y-1 active:scale-95 text-[14px] whitespace-nowrap`,children:e.buttonText||`Action Button`})]})]}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative flex flex-col flex-1 bg-background/50 h-full min-h-[400px]`,children:(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center opacity-40 glass-panel border border-[var(--panel-border)]/50 border-dashed m-4 md:m-8 rounded-2xl p-8 py-20 text-center`,children:[(0,l.jsx)(n.ft,{className:`w-8 h-8 md:w-12 md:h-12 mb-4 text-foreground/80 opacity-50`}),(0,l.jsx)(`p`,{className:`text-[14px] font-bold mb-2`,children:`Click copy prompt at the top to start adding changes`}),(0,l.jsx)(`div`,{className:`mt-8 text-left bg-background p-6 rounded-2xl text-[12px] font-mono whitespace-pre-wrap max-w-2xl border border-[var(--panel-border)]/50 text-foreground/60 shadow-inner`,children:f})]})}),(0,l.jsx)(n.a,{children:s&&(0,l.jsx)(n.t,{onClose:()=>c(null),formId:s})})]})}function an({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[ne,P]=(0,a.useState)(!1),[F,re]=(0,a.useState)(null),[I,L]=(0,a.useState)(``),[R,ie]=(0,a.useState)(``),[z,B]=(0,a.useState)([]),V=(0,a.useRef)(null),[H,U]=(0,a.useState)([]),W=(e.tabName||e.pageId||`private_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),G=`user_${W}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`,(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{U(e.docs.filter(e=>e.data().formType===`private`).map(e=>e.id))})},[e.tabTitle,e.tabName,r.appName]),(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${G}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}});(async()=>{try{let r=e((await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,G),(0,o.where)(`uid`,`==`,t.uid),(0,o.limit)(150)))).docs);r.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(r),f(!1),localStorage.setItem(`fbos_records_${G}`,JSON.stringify(r))}catch(e){console.error(`Error fetching records:`,e),f(!1)}})()},[t,G]),(0,a.useEffect)(()=>{u||localStorage.setItem(`fbos_records_${G}`,JSON.stringify(i))},[i,u,G]);let K=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=await(0,o.addDoc)((0,o.collection)(n.Tt,G),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,createdAt:(0,o.serverTimestamp)()});s(n=>[{id:e.id,name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,createdAt:Date.now()},...n]),_(``),y(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)}},ae=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`user_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e);await(0,o.addDoc)((0,o.collection)(n.Tt,`user_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`user`,sourceTab:W,accessPrefix:`user_`,createdAt:(0,o.serverTimestamp)()});let a=await(0,o.addDoc)((0,o.collection)(n.Tt,G),{name:r.name,note:`${r.type||`File`} · ${Q(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,createdAt:(0,o.serverTimestamp)()});s(e=>[{id:a.id,name:r.name,note:`${r.type||`File`} · ${Q(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type,fileSize:r.size,downloadURL:i,createdAt:Date.now()},...e])}catch(e){console.error(`Error uploading file:`,e)}T(!1),V.current&&(V.current.value=``)}},q=async()=>{if(E){P(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,G,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`user_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`user_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`user_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up user file:`,e)}s(e=>e.filter(e=>e.id!==E)),D(null)}catch(e){console.error(`Error deleting record:`,e)}P(!1)}},[J,oe]=(0,a.useState)(null),[Y,se]=(0,a.useState)(``),[ce,le]=(0,a.useState)(!1),[de,fe]=(0,a.useState)(null),X=(0,a.useRef)([]),pe=e=>{if(e.recordType===`file`){oe(e.id),se(e.name);return}re(e.id),L(e.name),ie(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));B(n),X.current=n.map(e=>e.key)},me=async()=>{if(!J||!Y.trim()){oe(null);return}let e=i.find(e=>e.id===J);if(e&&e.name===Y.trim()){oe(null);return}le(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,G,J),{name:Y.trim()}),s(e=>e.map(e=>e.id===J?{...e,name:Y.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}le(!1),oe(null)},Z=async()=>{await he(),re(null)},he=async()=>{if(!F||!I.trim())return;x(!0);let e={};z.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=z.map(e=>e.key.trim()).filter(Boolean),r=X.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,G,F),{name:I.trim(),note:R.trim(),...e}),s(e=>e.map(e=>{if(e.id!==F)return e;let t={...e,name:I.trim(),note:R.trim()};return r.forEach(e=>{delete t[e]}),z.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),X.current=t}catch(e){console.error(`Error saving record:`,e)}x(!1)},ge=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),_e=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ve=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},Q=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},ye=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},be=ue(e,G,H),xe=()=>{navigator.clipboard.writeText(be),C(!0),setTimeout(()=>C(!1),2e3)},Se=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),Ce=e.buttonStyle!==`secondary`,we=e.buttonStorageStyle===`primary`;return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Private Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`}`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:xe,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:V,onChange:ae,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>V.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${we?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(Se,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Ce?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files to get started`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map((e,t)=>{let r=F===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:t*.03,duration:.25},onClick:()=>pe(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),fe(e.id),setTimeout(()=>fe(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:de===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),pe(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${_e(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?ge(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[J===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:Y,onChange:e=>se(e.target.value),onBlur:()=>me(),onKeyDown:e=>{e.key===`Enter`&&me(),e.key===`Escape`&&oe(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:ye(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e))]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Each user sees their own data only · Edit and delete available on all items · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:G}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`user_files`}),` → Drive / Private`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:K,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ve(j.fileType),` • `,Q(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),fe(`preview`),setTimeout(()=>fe(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:de===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),oe(j.id),se(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>Z(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>Z(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:R,onChange:e=>{ie(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>he(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),z.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...z];n[t].key=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...z];n[t].value=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>he(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>B(z.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>B([...z,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:q,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:ne})]})}function on({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[ne,P]=(0,a.useState)(!1),[F,re]=(0,a.useState)(null),[I,L]=(0,a.useState)(``),[R,ie]=(0,a.useState)(``),[z,B]=(0,a.useState)([]),V=(0,a.useRef)(null),[H,U]=(0,a.useState)(null),W=(0,a.useRef)([]),G=(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),K=`admin_${G}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`},[e.tabTitle,e.tabName,r.appName]);let ae=()=>({name:t.displayName||t.email?.split(`@`)[0]||`Admin`,email:t.email||``,avatar:t.photoURL||``});(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${K}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(150)),t=>{let n=e(t.docs);s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))},t=>{console.error(`Error listening to admin records:`,t);let r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))});return()=>r()});return()=>r()},[t,K]);let q=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=ae();await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,o.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving admin record:`,e)}x(!1)}},J=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`admin_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e),a=ae();await(0,o.addDoc)((0,o.collection)(n.Tt,`admin_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`admin`,sourceTab:G,accessPrefix:`admin_`,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()}),await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:r.name,note:`${r.type||`File`} · ${ve(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()})}catch(e){console.error(`Error uploading admin file:`,e)}T(!1),V.current&&(V.current.value=``)}},oe=async()=>{if(E){P(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,K,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`admin_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`admin_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`admin_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up admin file:`,e)}D(null)}catch(e){console.error(`Error deleting admin record:`,e)}P(!1)}},[Y,se]=(0,a.useState)(null),[ce,ue]=(0,a.useState)(``),[de,fe]=(0,a.useState)(!1),X=e=>{if(e.recordType===`file`){se(e.id),ue(e.name);return}re(e.id),L(e.name),ie(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));B(n),W.current=n.map(e=>e.key)},pe=async()=>{if(!Y||!ce.trim()){se(null);return}let e=i.find(e=>e.id===Y);if(e&&e.name===ce.trim()){se(null);return}fe(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,Y),{name:ce.trim()}),s(e=>e.map(e=>e.id===Y?{...e,name:ce.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}fe(!1),se(null)},me=async()=>{if(!F||!I.trim()){re(null);return}x(!0);let e={};z.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=z.map(e=>e.key.trim()).filter(Boolean),r=W.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,F),{name:I.trim(),note:R.trim(),...e}),s(e=>e.map(e=>{if(e.id!==F)return e;let t={...e,name:I.trim(),note:R.trim()};return r.forEach(e=>{delete t[e]}),z.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),W.current=t}catch(e){console.error(`Error updating record:`,e)}x(!1),re(null)},Z=async()=>{if(!F||!I.trim())return;let e={};z.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=z.map(e=>e.key.trim()).filter(Boolean),r=W.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,F),{name:I.trim(),note:R.trim(),...e}),s(e=>e.map(e=>{if(e.id!==F)return e;let t={...e,name:I.trim(),note:R.trim()};return r.forEach(e=>{delete t[e]}),z.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),W.current=t}catch(e){console.error(`Error silently saving record:`,e)}},he=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,_e=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},ye=le(e,K),be=()=>{navigator.clipboard.writeText(ye),C(!0),setTimeout(()=>C(!1),2e3)},xe=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),Se=e.buttonStyle!==`secondary`,Ce=e.buttonStorageStyle===`primary`,we=e=>e.uid===t?.uid,Te=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,l.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`}`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:be,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:V,onChange:J,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>V.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Ce?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All admins can view and contribute.`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map((e,t)=>{let r=F===e.id,i=we(e);return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>X(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),U(e.id),setTimeout(()=>U(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:H===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),i&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[Y===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:ce,onChange:e=>ue(e.target.value),onBlur:()=>pe(),onKeyDown:e=>{e.key===`Enter`&&pe(),e.key===`Escape`&&se(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Q(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,l.jsx)(Te,{record:e})]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Shared between all admins · Edit and delete available on your own items only · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:K}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`admin_files`}),` → Drive / Admin`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:q,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[_e(j.fileType),` • `,ve(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),U(`preview`),setTimeout(()=>U(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:H===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),se(j.id),ue(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>me(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>me(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:R,onChange:e=>{ie(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Z(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),z.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...z];n[t].key=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...z];n[t].value=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>B(z.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>B([...z,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:oe,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:ne})]})}function sn({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[ne,P]=(0,a.useState)(!1),[F,re]=(0,a.useState)(null),[I,L]=(0,a.useState)(``),[R,ie]=(0,a.useState)(``),[z,B]=(0,a.useState)([]),V=(0,a.useRef)(null),[H,U]=(0,a.useState)(null),W=(0,a.useRef)([]),G=(e.tabName||e.pageId||`shared_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),K=`mem_${G}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`},[e.tabTitle,e.tabName,r.appName]),(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${K}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(150)),t=>{let n=e(t.docs);s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))},t=>{console.error(`Error listening to shared records:`,t);let r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))});return()=>r()});return()=>r()},[t,K]);let ae=()=>({name:t.displayName||t.email?.split(`@`)[0]||`Member`,email:t.email||``,avatar:t.photoURL||``}),q=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=ae();await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,o.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}x(!1)}},J=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`mem_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e),a=ae();await(0,o.addDoc)((0,o.collection)(n.Tt,`mem_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`member`,sourceTab:G,accessPrefix:`mem_`,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()}),await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:r.name,note:`${r.type||`File`} · ${ve(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()})}catch(e){console.error(`Error uploading shared file:`,e)}T(!1),V.current&&(V.current.value=``)}},oe=async()=>{if(E){P(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,K,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`mem_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`mem_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`mem_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up shared file:`,e)}D(null)}catch(e){console.error(`Error deleting shared record:`,e)}P(!1)}},[Y,se]=(0,a.useState)(null),[le,ue]=(0,a.useState)(``),[de,fe]=(0,a.useState)(!1),X=e=>{if(e.recordType===`file`){se(e.id),ue(e.name);return}re(e.id),L(e.name),ie(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));B(n),W.current=n.map(e=>e.key)},pe=async()=>{if(!Y||!le.trim()){se(null);return}let e=i.find(e=>e.id===Y);if(e&&e.name===le.trim()){se(null);return}fe(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,Y),{name:le.trim()}),s(e=>e.map(e=>e.id===Y?{...e,name:le.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}fe(!1),se(null)},me=async()=>{await Z(),re(null)},Z=async()=>{if(!F||!I.trim())return;x(!0);let e={};z.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=z.map(e=>e.key.trim()).filter(Boolean),r=W.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,F),{name:I.trim(),note:R.trim(),...e}),s(e=>e.map(e=>{if(e.id!==F)return e;let t={...e,name:I.trim(),note:R.trim()};return r.forEach(e=>{delete t[e]}),z.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),W.current=t}catch(e){console.error(`Error saving record:`,e)}x(!1)},he=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,_e=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},ye=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),be=e.buttonStyle!==`secondary`,xe=e.buttonStorageStyle===`primary`,Se=e=>e.uid===t?.uid,Ce=ce(e,K),we=()=>{navigator.clipboard.writeText(Ce),C(!0),setTimeout(()=>C(!1),2e3)},Te=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,l.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Shared Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`} · Shared`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:we,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:V,onChange:J,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>V.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${xe?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(ye,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${be?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All team members can view and contribute.`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map(e=>{let t=F===e.id,r=Se(e);return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>r?X(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${r?`cursor-pointer`:``} ${t?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),U(e.id),setTimeout(()=>U(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:H===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[Y===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:le,onChange:e=>ue(e.target.value),onBlur:()=>pe(),onKeyDown:e=>{e.key===`Enter`&&pe(),e.key===`Escape`&&se(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Q(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,l.jsx)(Te,{record:e})]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Shared between all members · Edit and delete available on your own items only · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:K}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`mem_files`}),` → Drive / Shared`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:q,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[_e(j.fileType),` • `,ve(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),U(`preview`),setTimeout(()=>U(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:H===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),se(j.id),ue(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:F&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>me(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>me(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:R,onChange:e=>{ie(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Z(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),z.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...z];n[t].key=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...z];n[t].value=e.target.value,B(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>B(z.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>B([...z,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:oe,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:ne})]})}function cn(){let e=(0,u.useLocation)(),{user:t}=m(),r=n.Ct(),[i,s]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let t=!0,r=localStorage.getItem(`fbos_route_${e.pathname}`);if(r)try{let e=JSON.parse(r);s(e),d(!1);let t=e.pageName||e.tabName||e.title;t&&(document.title=t)}catch{}return(async()=>{try{let r=e.pathname;r.startsWith(`/`)&&(r=r.substring(1));let[i,a,c,l,u,f]=await Promise.allSettled([(0,o.getDoc)((0,o.doc)(n.Tt,`sys_pages`,r)),(0,o.getDoc)((0,o.doc)(n.Tt,`sys_tabs`,r)),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_pages`),(0,o.where)(`route`,`==`,e.pathname),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_pages`),(0,o.where)(`route`,`==`,r),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_tabs`),(0,o.where)(`route`,`==`,e.pathname),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_tabs`),(0,o.where)(`route`,`==`,r),(0,o.limit)(1)))]),p=null,m=null,h=(e,t)=>{if(!p&&e.status===`fulfilled`){if(e.value.exists&&e.value.exists()){let n=e.value.data();p={...n,isPrivate:t,isAdmin:n.pageType===`admin`,isShared:n.pageType===`shared`},m=e.value.id}else if(e.value.docs&&e.value.docs.length>0){let n=e.value.docs[0].data();p={...n,isPrivate:t,isAdmin:n.pageType===`admin`,isShared:n.pageType===`shared`},m=e.value.docs[0].id}}};if(h(i,!1),h(c,!1),h(l,!1),h(a,!0),h(u,!0),h(f,!0),p||(e.pathname===`/contact`?(p={route:`/contact`,template:`popup_form`,form:`contact`},m=`contact`):e.pathname===`/support`&&(p={route:`/support`,template:`popup_form`,form:`support`},m=`support`)),!t)return;if(p){if((m===`contact`||m===`support`)&&!p.form&&(p.form=m),p.pageId=m,localStorage.setItem(`fbos_route_${e.pathname}`,JSON.stringify(p)),p.form){try{let e=localStorage.getItem(`fbos_form_${p.form}`);e&&(p.formConfigOverride=JSON.parse(e))}catch{}(0,o.getDoc)((0,o.doc)(n.Tt,`sys_forms`,p.form)).then(async e=>{if(t)if(e.exists()){let t={...e.data(),id:e.id};s(e=>({...e,formConfigOverride:t})),localStorage.setItem(`fbos_form_${p.form}`,JSON.stringify(t))}else{let e;if(p.form===`contact`){let{contactFormConfig:t}=await Promise.resolve().then(()=>require(`./contactForm.config-CXyq-EbM.cjs`)).then(e=>e.n);e=t}else if(p.form===`support`){let{supportFormConfig:t}=await Promise.resolve().then(()=>require(`./supportForm.config-haLod4rv.cjs`)).then(e=>e.n);e=t}e&&(s(t=>({...t,formConfigOverride:e})),localStorage.setItem(`fbos_form_${p.form}`,JSON.stringify(e)))}})}let r=p.pageName||p.tabName||p.title;r&&(document.title=r),s(p),d(!1)}else s(`not-found`),d(!1),localStorage.removeItem(`fbos_route_${e.pathname}`)}catch{t&&c&&(s(`not-found`),d(!1))}})(),()=>{t=!1}},[e.pathname]);let[f,p]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{let e;return c?e=setTimeout(()=>p(!0),150):p(!1),()=>clearTimeout(e)},[c]),c)return f?t?(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(`div`,{className:`mb-6`,children:[(0,l.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,l.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsx)(`div`,{className:`flex-1 glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[60vh] z-10`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})}):null;if(i===`not-found`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 bg-red-500/10 text-red-500 rounded-full flex items-center justify-center mb-6`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-8 h-8`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,l.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,l.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,l.jsx)(`h2`,{className:`text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,l.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`})]})});if((i.pageId===`support`||i.isPrivate)&&!t)return(0,l.jsx)(u.Navigate,{to:`/login`,state:{from:e}});let h=r.customRoutes?.[e.pathname]||(i&&i.route?r.customRoutes?.[i.route]:null);if(h)return(0,l.jsx)(h,{config:i});let g=i.pageName?.toLowerCase().replace(/\s+/g,`_`)||i.pageId||`custom_page`,_=`pub_${g}`;if(i.template===`none`)return i.isAdmin?(0,l.jsx)(on,{config:i}):i.isShared?(0,l.jsx)(sn,{config:i}):i.isPrivate?(0,l.jsx)(an,{config:i}):(0,l.jsx)(rn,{config:i});if(i.template===`board`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateBoard||fe,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Board`,subtitle:i.route,tasksCollection:`${e}_tasks`,categoriesCollection:`${e}_categories`,config:i})}if(i.template===`table`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateTable||Rt,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Table`,subtitle:i.route,tableCollection:`${e}_table`,config:i})}if(i.template===`calendar`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateCalendar||Vt,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Calendar`,subtitle:i.route,eventsCollection:`${e}_events`,defaultTimeFormat:i.defaultTimeFormat||i.defaulttimeformat||`12h`,config:i})}return i.template===`inline_form`?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,l.jsx)(n.t,{isInline:!0,formId:i.form,formConfig:i.formConfigOverride})}):(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,l.jsx)(n.t,{formId:i.form,formConfig:i.formConfigOverride,onClose:()=>window.history.back()})})}var ln=a.default.createContext({}),un=Object.defineProperty,dn=Object.getOwnPropertySymbols,fn=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable,mn=(e,t,n)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hn=(e,t)=>{for(var n in t||={})fn.call(t,n)&&mn(e,n,t[n]);if(dn)for(var n of dn(t))pn.call(t,n)&&mn(e,n,t[n]);return e},gn=(0,a.forwardRef)((e,t)=>{let n=hn(hn({},a.useContext(ln)),e);return a.createElement(`svg`,hn({width:`1.5em`,height:`1.5em`,strokeWidth:1.5,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),a.createElement(`path`,{d:`M21.1679 8C19.6247 4.46819 16.1006 2 11.9999 2C6.81459 2 2.55104 5.94668 2.04932 11`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M17 8H21.4C21.7314 8 22 7.73137 22 7.4V3`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M2.88146 16C4.42458 19.5318 7.94874 22 12.0494 22C17.2347 22 21.4983 18.0533 22 13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M7.04932 16H2.64932C2.31795 16 2.04932 16.2686 2.04932 16.6V21`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),_n=Object.defineProperty,vn=Object.getOwnPropertySymbols,yn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,xn=(e,t,n)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||={})yn.call(t,n)&&xn(e,n,t[n]);if(vn)for(var n of vn(t))bn.call(t,n)&&xn(e,n,t[n]);return e},Cn=(0,a.forwardRef)((e,t)=>{let n=Sn(Sn({},a.useContext(ln)),e);return a.createElement(`svg`,Sn({width:`1.5em`,height:`1.5em`,viewBox:`0 0 24 24`,strokeWidth:1.5,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),a.createElement(`path`,{d:`M22 12C22 17.5228 17.5228 22 12 22C10.1786 22 8.47087 21.513 7 20.6622L2 21.5L2.83209 16C2.29689 14.7751 2 13.4222 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M12.9604 13.8683L15.0399 13.4624L17 14.2149V16.0385C17 16.6449 16.4783 17.1073 15.8901 16.9783C14.3671 16.6444 11.5997 15.8043 9.67826 13.8683C7.84859 12.0248 7.22267 9.45734 7.01039 8.04128C6.92535 7.47406 7.3737 7 7.94306 7H9.83707L10.572 8.96888L10.1832 11.0701`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),wn=`rules_version = '2';
475
+ };`;navigator.clipboard.writeText(a),m(!0),setTimeout(()=>m(!1),2e3)}};return(0,a.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key===`a`&&document.activeElement===document.body&&e.preventDefault(),(e.ctrlKey||e.metaKey)&&e.key===`c`&&!window.getSelection()?.toString()&&r&&b()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Theme`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/theme`]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`glass-panel border border-[var(--panel-border)] rounded-3xl p-6 md:p-10 shadow-2xl relative overflow-hidden bg-background flex flex-col min-h-[600px]`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Theme Config`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`Changes here immediately format natively. Save to update your Live Preview panel entirely.`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:_,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-xl flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:u?(0,l.jsx)(n.M,{className:`w-4 h-4 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-4 h-4 text-foreground/60 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(n.n,{variant:`secondary`,onClick:b,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors`,title:`Copy Config (Ctrl+C)`,children:p?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-4 h-4 text-foreground/60 hover:text-foreground transition-colors`})})]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 w-full relative z-10 items-start`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 bg-background/60 backdrop-blur-[2px] z-50 flex items-center justify-center rounded-3xl pointer-events-none transition-all duration-300`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 animate-spin text-accent`})}),(0,l.jsxs)(`div`,{className:`w-full glass-panel border border-[var(--panel-border)] rounded-3xl p-6 md:p-8 shadow-inner overflow-hidden relative bg-background`,children:[(0,l.jsx)(`h3`,{className:`text-lg font-extrabold text-foreground tracking-tight mb-4 flex items-center gap-3`,children:`Branding & Colours`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 overflow-x-auto hide-scrollbars pb-4 pt-2 mb-6 border-b border-[var(--panel-border)]/50 shrink-0`,children:[(0,l.jsx)(`div`,{className:`text-[12px] font-bold text-foreground/40 shrink-0 uppercase tracking-widest pl-1 mr-2`,children:`Presets`}),Ut.map(e=>{let t=r?.colors?.dark?.accent===e.dark.accent&&r?.colors?.dark?.buttonGradient?.[0]===e.dark.gradient[0],n=e.name===`Black & White`;return(0,l.jsx)(`button`,{onClick:()=>y(e),className:`w-9 h-9 rounded-full shrink-0 outline-none transition-all shadow-sm relative group overflow-visible ${t?`ring-[3px] ring-foreground ring-offset-2 ring-offset-[var(--background)] scale-110 z-10`:`opacity-80 hover:opacity-100 hover:ring-2 hover:ring-foreground/30 hover:ring-offset-2 hover:ring-offset-[var(--background)] hover:scale-105`}`,title:e.name,children:(0,l.jsx)(`div`,{className:`absolute inset-0 rounded-full`,style:n?{backgroundColor:`#ffffff`,border:`3px solid #000000`,boxShadow:`inset 0 0 0 1px rgba(0,0,0,0.1)`}:{backgroundImage:`linear-gradient(135deg, ${e.preview[0]}, ${e.preview[1]})`}})},e.name)})]}),(0,l.jsx)(`div`,{className:`w-full relative min-h-[100px]`,children:r?(0,l.jsxs)(`div`,{className:`flex flex-col pl-2`,children:[(0,l.jsxs)(`span`,{className:`text-yellow-500 font-mono text-[13px] mb-2`,children:[`export const themeConfig = `,`{`]}),(0,l.jsx)(Kt,{value:r,keysToRender:[`appName`,`defaultTheme`,`showThemeToggle`,`logoUrl`,`faviconUrl`,`cornerRounding`,`cornerRadii`,`fontFamily`],onChange:e=>i(e),isLast:!1,isGlobalSaving:s}),(0,l.jsx)(`div`,{className:`mt-4`,children:(0,l.jsx)(Kt,{objectKey:`colors`,value:r.colors,onChange:e=>i({...r,colors:e}),isLast:!1,isGlobalSaving:s})})]}):(0,l.jsx)(`div`,{className:`flex items-center justify-center w-full h-full text-foreground/40 font-mono text-[13px] animate-pulse py-10`,children:`Loading Data Tree...`})})]})]})]})]})]})}var Jt={route:`/page_1`,pageName:`New Public Page`,template:`none`,pageTitle:`My Custom Page`,copyPrompt:!0,showButton:!0,buttonText:`Open Form`,action:`form`,form:`contact`},Yt={tabName:`New Private Page`,iconName:``,route:`/new-private-page`,template:`none`,form:`support`,showPrompt:!0,tabTitle:`Private Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Xt={tabName:`Admin Tab`,iconName:``,route:`/admin-tab`,template:`none`,form:``,showPrompt:!0,tabTitle:`Admin Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Zt={tabName:`Shared Tab`,iconName:``,route:`/shared-tab`,template:`none`,form:``,showPrompt:!0,tabTitle:`Shared Dashboard`,showButton:!0,buttonStyle:`primary`,buttonText:`+`,buttonAction:`save_info`,storage:!0,buttonStorageIcon:`upload`,buttonStorageText:``,buttonStorageStyle:`secondary`,buttonStorageAction:`upload_file`,defaultView:`calendar`,defaultTimeFormat:`12h`,showViewsButton:!0,viewsButtonStyle:`secondary`,showExportButton:!0,exportButtonIcon:`download-square`,keyName:`key`,valueName:`value`},Qt=[{id:`home`,title:`Home Page`,path:`/`,type:`public`,isSystem:!0,enabled:!0}],$t=({enabled:e,onChange:t,disabled:r,className:i=``})=>(0,l.jsx)(`button`,{disabled:r,onClick:()=>t(!e),title:e?`Page Active`:`Page Hidden`,className:`p-1.5 transition-colors rounded-lg flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity ${i} ${e?`text-accent hover:bg-accent/10`:`text-foreground/40 hover:bg-foreground/5`} ${r?`!opacity-50 cursor-not-allowed`:`cursor-pointer`}`,children:e?(0,l.jsx)(n.K,{className:`w-4 h-4`}):(0,l.jsx)(n.q,{className:`w-4 h-4`})});function en(){let{userRole:e}=m(),t=(0,u.useLocation)(),r=n.Ct(),[i,s]=(0,a.useState)(Qt),[c,d]=(0,a.useState)(()=>{try{return sessionStorage.getItem(`fbos_pages_expandedId`)||null}catch{return null}}),f=(0,a.useRef)(c),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)({}),[v,y]=(0,a.useState)({}),[b,x]=(0,a.useState)({}),[C,w]=(0,a.useState)(null),[T,E]=(0,a.useState)(!1),D=(0,a.useRef)(null);(0,a.useEffect)(()=>{function e(e){D.current&&!D.current.contains(e.target)&&h(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(!1),[M,N]=(0,a.useState)(!1),[P,F]=(0,a.useState)(new Set),[I,L]=(0,a.useState)(new Set),[R,z]=(0,a.useState)([]),[B,ne]=(0,a.useState)([]),V=e=>(e||[]).map(e=>typeof e==`string`?{id:e,hidden:!1}:{id:String(e.id),hidden:!!e.hidden});(0,a.useEffect)(()=>{let e=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`page_order`),e=>{let t=V(e.exists()&&e.data().order||[]);z(t),F(new Set(t.filter(e=>e.hidden).map(e=>e.id)))}),t=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_configs`,`tab_order`),e=>{let t=V(e.exists()&&e.data().order||[]);ne(t),L(new Set(t.filter(e=>e.hidden).map(e=>e.id)))});return()=>{e(),t()}},[]),(0,a.useEffect)(()=>{let e=t.pathname.split(`/pages/`)[1]?.split(`/`)[0];e&&!c&&i.some(t=>t.id===e)&&d(e)},[t.pathname,i]),(0,a.useEffect)(()=>{f.current=c;try{c?sessionStorage.setItem(`fbos_pages_expandedId`,c):sessionStorage.removeItem(`fbos_pages_expandedId`)}catch{}},[c]);let H=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=H.current;if(!e)return;try{let t=sessionStorage.getItem(`fbos_pages_scrollY`);t&&(e.scrollTop=parseInt(t,10))}catch{}let t=()=>{try{sessionStorage.setItem(`fbos_pages_scrollY`,String(e.scrollTop))}catch{}};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,a.useEffect)(()=>{let e=(e,t)=>{if(!t)return e;let n=Object.fromEntries(Object.entries(t).filter(([e,t])=>t!=null&&t!==``));return{...e,...n}},t=r?.defaultConfigs?.home||S,i=(0,o.onSnapshot)((0,o.doc)(n.Tt,`sys_pages`,`home`),n=>{n.exists()?k(e(t,n.data())):k(t)});return()=>{i()}},[r]),(0,a.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.all([(0,o.getDocs)((0,o.collection)(n.Tt,`sys_pages`)),(0,o.getDocs)((0,o.collection)(n.Tt,`sys_tabs`))]),r=[`home`,`contact`,`support`,`theme`,`page_order`,`tab_order`],i=[],a={};e.forEach(e=>{if(!r.includes(e.id)){let t=e.data();i.push({id:e.id,title:t.pageName||t.title||e.id,path:t.route||`/`+e.id,type:`public`,isSystem:!1,enabled:t.enabled!==!1}),a[e.id]=t}}),t.forEach(e=>{if(!r.includes(e.id)){let t=e.data(),n=t.pageType||`private`;i.push({id:e.id,title:t.tabName||t.title||e.id,path:t.route||`/`+e.id,type:n,isSystem:!1,enabled:t.enabled!==!1}),a[e.id]=t}}),i.length>0&&(s(e=>{let t=e.filter(e=>e.isSystem||e.id.startsWith(`draft_`)),n=i.filter(e=>!t.some(t=>t.id===e.id));return[...t,...n]}),_(e=>({...e,...a})))}catch(e){console.error(`Error loading custom pages`,e)}})()},[]);let[U,W]=(0,a.useState)([`contact`]),[G,re]=(0,a.useState)([`support`]);(0,a.useEffect)(()=>{(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{let t=[],n=[];e.forEach(e=>{e.data().formType===`private`?n.push(e.id):t.push(e.id)}),t.length>0&&W(t),n.length>0&&re(n)}).catch(console.error)},[]);let[ie,K]=(0,a.useState)(null),q=(e,t)=>{let n;n=e===`home`?`export const defaultHomeConfig = ${JSON.stringify(t,null,2)};\n`:JSON.stringify(t,null,2),navigator.clipboard.writeText(n),K(e),setTimeout(()=>K(null),2e3)},J=async(e,t)=>{t.route&&!t.route.startsWith(`/`)&&(t.route=`/`+t.route);let r=i.find(t=>t.id===e)?.type,a=r===`public`?`sys_pages`:`sys_tabs`;r&&r!==`public`&&(t.pageType=r);let c=[`home`].includes(e)?e:t.route?t.route.replace(/^\/+/,``).replace(/[^a-zA-Z0-9_\-]/g,`_`).toLowerCase():e;e===`home`?j(!0):y(t=>({...t,[e]:!0,[c]:!0}));try{if(c!==e&&c.trim()!==``&&c!==`draft`){try{let{deleteDoc:t}=await import(`firebase/firestore`);await t((0,o.doc)(n.Tt,a,e))}catch{}await(0,o.setDoc)((0,o.doc)(n.Tt,a,c),t),s(n=>n.map(n=>n.id===e?{...n,id:c,_uiKey:n._uiKey||e,path:t.route,title:t.pageName||t.tabName||t.title||n.title}:n)),f.current===e&&(d(c),window.history.replaceState(null,``,`/pages/${c}`)),_(n=>{let r={...n};return r[c]=t,delete r[e],r});let i=r===`public`,l=i?`page_order`:`tab_order`,u=i?R:B;if(!u.some(e=>e.id===c)){let t=[{id:c,hidden:!1},...u.filter(t=>t.id!==e)];try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,l),{order:t})}catch(e){console.error(`Failed to update tab order:`,e)}}}else await(0,o.setDoc)((0,o.doc)(n.Tt,a,e),t),e===`home`?k(t):(_(n=>({...n,[e]:t})),s(n=>n.map(n=>n.id===e?{...n,path:t.route||n.path,title:t.pageName||t.tabName||t.title||n.title}:n)))}catch(t){console.error(`Failed to save ${e} config:`,t)}finally{setTimeout(()=>{e===`home`?j(!1):y(t=>({...t,[e]:!1,[c]:!1}))},500)}},Y=async e=>{e.stopPropagation(),N(!0);try{let{deleteDoc:e}=await import(`firebase/firestore`);await e((0,o.doc)(n.Tt,`sys_pages`,`home`)),localStorage.removeItem(`fbos_home_config`),k(r?.defaultConfigs?.home||S)}catch(e){console.error(`Failed to reset home config:`,e)}setTimeout(()=>N(!1),500)},ae=async(e,t,n)=>{e.stopPropagation(),x(e=>({...e,[t]:!0})),await J(t,n),setTimeout(()=>x(e=>({...e,[t]:!1})),500)},oe=e=>{let t=`draft_`+Math.floor(Math.random()*1e4);s([...i,{id:t,title:`New Tab`,path:`/draft`,type:e,isSystem:!1,enabled:!0}]);let n=i.filter(t=>t.type===e&&!t.id.startsWith(`draft_`)).length+1,r={};e===`public`?r={...Jt,route:`/page-${n}`}:e===`private`?r={...Yt,route:`/private-tab-${n}`}:e===`admin`?r={...Xt,route:`/admin-tab-${n}`}:e===`shared`&&(r={...Zt,route:`/shared-tab-${n}`}),_(e=>({...e,[t]:r})),d(t),h(!1),J(t,{...r,pageType:e===`public`?void 0:e}),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView({behavior:`smooth`,block:`center`})},100)};if(e!==`admin`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1`,children:[(0,l.jsx)(n.v,{className:`w-12 h-12 text-red-500 mb-4`}),(0,l.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-foreground/60`,children:`You do not have permission to view pages configuration.`})]})});let se=async(e,t,r)=>{let a=r===`public`,c=a?`page_order`:`tab_order`,l=a?R:B,u=(a?P:I).has(e);s(i.map(t=>t.id===e?{...t,enabled:u}:t));let d=[...l],f=d.findIndex(t=>t.id===e);f===-1?d.push({id:e,hidden:!0}):d[f]={...d[f],hidden:!u},await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_configs`,c),{order:d})},ce=(e,t)=>{t||w(e)},le=async()=>{if(C){E(!0);try{let{deleteDoc:e,collection:t,getDocs:r,doc:a,getDoc:o,query:l,where:u}=await import(`firebase/firestore`),{ref:f,deleteObject:p}=await import(`firebase/storage`),m=i.find(e=>e.id===C),h=m?.type===`public`?`sys_pages`:`sys_tabs`;if(h===`sys_tabs`&&m){let i=g[C];if(!i)try{let e=await o(a(n.Tt,`sys_tabs`,C));e.exists()&&(i=e.data())}catch{}let s=(i?.tabName||i?.pageId||C).toLowerCase().replace(/[^a-z0-9]+/g,`_`),c=[`admin_${s}_records`,`mem_${s}_records`,`user_${s}_records`],d={[`admin_${s}_records`]:{prefix:`admin_files`,driveCollection:`admin_files`},[`mem_${s}_records`]:{prefix:`mem_files`,driveCollection:`mem_files`},[`user_${s}_records`]:{prefix:`user_files`,driveCollection:`user_files`}};for(let i of c)try{let a=await r(t(n.Tt,i)),o=d[i];for(let i of a.docs){let a=i.data();if(a.recordType===`file`&&a.downloadURL&&o)try{let i=`${o.prefix}%2F`,s=a.downloadURL.split(i)[1]?.split(`?`)[0];s&&await p(f(n.Dt,`${o.prefix}/${decodeURIComponent(s)}`)).catch(()=>{});let c=await r(l(t(n.Tt,o.driveCollection),u(`downloadURL`,`==`,a.downloadURL)));for(let t of c.docs)await e(t.ref)}catch(e){console.error(`Error deleting storage file:`,e)}}let s=a.docs.map(t=>e(t.ref));await Promise.all(s);try{localStorage.removeItem(`fbos_records_${i}`)}catch{}}catch(e){console.error(`Error cleaning up collection ${i}:`,e)}for(let i of[`admin_files`,`mem_files`,`user_files`])try{let a=await r(l(t(n.Tt,i),u(`sourceTab`,`==`,s)));for(let t of a.docs){let r=t.data();if(r.downloadURL)try{let e=i.replace(`_files`,`_files`),t=`${e}%2F`,a=r.downloadURL.split(t)[1]?.split(`?`)[0];a&&await p(f(n.Dt,`${e}/${decodeURIComponent(a)}`)).catch(()=>{})}catch{}await e(t.ref)}}catch{}}await e(a(n.Tt,h,C));let _=h===`sys_pages`?`page_order`:`tab_order`,v=h===`sys_pages`?R:B,{setDoc:y}=await import(`firebase/firestore`),b=v.filter(e=>e.id!==C);await y(a(n.Tt,`sys_configs`,_),{order:b}),s(e=>e.filter(e=>e.id!==C)),c===C&&d(null)}catch(e){console.error(`Error deleting page:`,e)}E(!1),w(null)}},ue=e=>{let t=e.id+`_`+Math.floor(Math.random()*1e3),n={...e,id:t,title:`${e.title} (Copy)`,path:`${e.path}_copy`,isSystem:!1,enabled:!0};s(e=>[...e,n]);let r=g[e.id];!r&&e.id===`home`&&(r=O);let i={...r||{},route:n.path,pageName:n.title};n.type!==`public`&&(i.tabName=n.title,i.pageType=n.type),_(e=>({...e,[t]:i})),d(t),setTimeout(()=>{document.getElementById(`page-${t}`)?.scrollIntoView({behavior:`smooth`,block:`center`})},100)},de=[{id:`public`,title:`Public Pages`,icon:n.U,color:`bg-amber-500`,description:`Creates external menu items. Invisible to signed-in dashboard users.`,filter:e=>e.type===`public`},{id:`private`,title:`Private Pages`,icon:n.j,color:`bg-emerald-500`,description:`Internal dashboard tabs for regular users.`,filter:e=>e.type===`private`},{id:`shared`,title:`Shared Pages`,icon:n.K,color:`bg-blue-500`,description:`Dashboard tabs visible to all members, editors, and admins.`,filter:e=>e.type===`shared`},{id:`admin`,title:`Admin Pages`,icon:n.v,color:`bg-red-500`,description:`Internal dashboard tabs for admin users only.`,filter:e=>e.type===`admin`}],[fe,X]=(0,a.useState)(!1),[pe,me]=(0,a.useState)(!1);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Pages`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/pages`,c?`/${c}`:``]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-6 pt-6 md:px-10 md:pt-10`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Architecture`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`Manage the structure of your application tabs and public pages.`})]}),(0,l.jsxs)(`div`,{className:`relative z-50 shrink-0 flex items-center gap-1`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>X(!0),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Reset Defaults`,children:(0,l.jsx)(n.x,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsx)(n.n,{variant:`secondary`,onClick:()=>h(!p),className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,title:`Add New Page`,children:(0,l.jsx)(n.C,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})}),(0,l.jsx)(n.a,{children:p&&(0,l.jsx)(n.i.div,{ref:D,initial:{opacity:0,y:10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},className:`absolute top-full mt-2 right-0 w-48 glass-panel border border-[var(--panel-border)] rounded-2xl p-2 shadow-xl z-50 flex flex-col gap-1`,children:[`public`,`private`,`shared`,`admin`].map(e=>(0,l.jsxs)(`button`,{onClick:()=>{oe(e),h(!1)},className:`text-left px-3 py-2 text-[13px] font-bold uppercase tracking-wider text-foreground/70 hover:text-foreground hover:bg-foreground/5 rounded-lg transition-colors cursor-pointer`,children:[e,` Page`]},e))})})]})]})]}),(0,l.jsxs)(`div`,{ref:H,className:`px-6 md:px-10 pb-6 md:pb-10 flex flex-col pt-0 gap-10 overflow-y-auto mt-2 relative min-h-[400px]`,children:[(0,l.jsx)(n.a,{children:pe&&(0,l.jsx)(n.i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-[2px] rounded-3xl`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-6 glass-panel rounded-2xl shadow-xl`,children:[(0,l.jsx)(n.M,{className:`w-8 h-8 md:w-10 md:h-10 animate-spin text-accent mb-4`}),(0,l.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:`Synchronizing Architecture...`})]})})}),de.map((e,t)=>{let r=i.filter(e.filter),a=e.id===`public`?R:B,o=r.sort((e,t)=>{let n=a.findIndex(t=>t.id===e.id),r=a.findIndex(e=>e.id===t.id);return n===-1&&r===-1?0:n===-1?1:r===-1?-1:n-r}),s=e.icon,u=e=>e.type===`public`?P.has(e.id):I.has(e.id),f=o.filter(e=>!u(e)),p=o.filter(e=>u(e)),m=e=>{if(!e)return[];let t=[`route`,`pageName`,`template`];return e.template===`none`?(t.push(`pageTitle`,`copyPrompt`),t.push(`showButton`),e.showButton!==!1&&(t.push(`buttonText`,`action`),e.action===`form`?t.push(`form`):e.action===`redirect`&&t.push(`redirectUrl`))):(e.template===`popup_form`||e.template===`inline_form`)&&(t.push(`showButton`),e.showButton!==!1&&t.push(`form`)),t},h=e=>{if(!e)return[];let t=[`tabName`,`iconName`,`route`,`template`];return e.template===`popup_form`||e.template===`inline_form`?(t.push(`showButton`),e.showButton!==!1&&t.push(`form`)):e.template===`none`?(t.push(`showPrompt`,`tabTitle`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonStyle`,`buttonText`,`buttonAction`),t.push(`storage`),e.storage!==!1&&t.push(`buttonStorageIcon`,`buttonStorageText`,`buttonStorageStyle`,`buttonStorageAction`)):e.template===`calendar`?(t.push(`tabTitle`,`showPrompt`),t.push(`defaultView`,`defaultTimeFormat`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`showViewsButton`),e.showViewsButton!==!1&&t.push(`viewsButtonStyle`)):e.template===`table`?(t.push(`tabTitle`,`showPrompt`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`showExportButton`),e.showExportButton!==!1&&t.push(`exportButtonIcon`)):e.template===`board`&&(t.push(`tabTitle`,`showPrompt`),t.push(`showButton`),e.showButton!==!1&&t.push(`buttonText`,`buttonStyle`),t.push(`keyName`,`valueName`)),t},_=(t,r,i)=>{let a=t.id===`home`,o=c===t.id,s=a||!t.isSystem;return(0,l.jsxs)(`div`,{id:`page-${t.id}`,onClick:e=>{if(s){let e=o?null:t.id;d(e),window.history.replaceState(null,``,e?`/pages/${e}`:`/pages`)}},className:`group flex flex-col py-4 px-5 glass-panel border transition-all rounded-2xl hover:shadow-sm ${s?`cursor-pointer hover:border-accent/40`:``} ${i?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:`border-transparent hover:border-[var(--panel-border)]`}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-between w-full gap-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-1 w-full flex-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground truncate`,children:t.title}),a&&A&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-accent ml-2`})]}),(0,l.jsxs)(`div`,{className:`text-[11px] font-medium font-mono px-2 py-0.5 rounded w-fit ml-6 border ${i?`text-foreground/50 border-foreground/10 bg-foreground/5`:`text-accent/70 bg-accent/5 border-accent/10`}`,children:[window.location.host,t.path]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-4 shrink-0`,children:[!t.isSystem||[`contact`,`support`,`templates`].includes(t.id)?(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(t)},className:`p-1.5 hover:bg-accent/10 text-foreground/40 hover:text-accent transition-colors rounded-lg flex items-center justify-center shrink-0`,title:`Duplicate Page`,children:(0,l.jsx)(n.Z,{className:`w-4 h-4`})}):(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}),(0,l.jsx)(`div`,{className:`flex items-center justify-end w-8 shrink-0`,children:t.id===`home`?(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}):(0,l.jsx)($t,{enabled:!u(t),onChange:()=>se(t.id,t.isSystem,t.type)})}),t.isSystem?(0,l.jsx)(`div`,{className:`w-[28px] shrink-0`}):(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ce(t.id,t.isSystem)},className:`p-1.5 hover:bg-red-500/10 text-foreground/30 hover:text-red-500 transition-colors rounded-lg flex items-center justify-center shrink-0`,title:`Delete Page`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),s?(0,l.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 shrink-0 ${o?`rotate-180`:``}`,children:(0,l.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,l.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}):(0,l.jsx)(`div`,{className:`w-[24px] shrink-0`})]})]}),(0,l.jsxs)(n.a,{children:[o&&a&&O&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-4`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 py-6 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:Y,className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:M?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),q(`home`,O)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:ie===`home`?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:O,keysToRender:[`hero`],onChange:e=>J(`home`,e),isLast:!0,isGlobalSaving:A,customEnums:{form:U},customExplanations:{form:`User can click to switch to any public form we have in the forms tab. Private forms are not an option here. Add a new form in forms with a link that actually works.`}})]})}),o&&!t.isSystem&&g[t.id]&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50 pb-4`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 py-6 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:e=>ae(e,t.id,t.type===`admin`?Xt:t.type===`shared`?Zt:t.type===`public`?Jt:Yt),className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:b[t.id]?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),q(t.id,g[t.id])},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:ie===t.id?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:g[t.id],keysToRender:t.type===`public`?m(g[t.id]):h(g[t.id]),onChange:e=>J(t.id,e),isLast:!0,isGlobalSaving:v[t.id],customEnums:{form:t.type===`public`?U:G,template:t.type===`public`?[`none`,`popup_form`,`inline_form`]:t.type===`admin`||t.type===`shared`?[`none`,`calendar`,`table`,`board`]:[`none`,`calendar`,`table`,`board`,`popup_form`,`inline_form`],action:[`save_Info`,`form`],defaultTimeFormat:[`12h`,`24h`],defaultView:[`calendar`,`board`],buttonStyle:[`primary`,`secondary`],buttonAction:[`save_info`],viewsButtonStyle:[`primary`,`secondary`],buttonStorageStyle:[`primary`,`secondary`],buttonStorageAction:[`upload_file`]},customExplanations:{tabName:`Defines the tab label in the dashboard navigation.`,iconName:`Visit https://lucide.dev/icons/, find an icon, and paste its exact name (e.g. 'book-open', 'server', 'cloud-upload').`,route:`The URL path for this tab (e.g. '/my-tab'). Must start with /.`,template:`Page layout type. 'none' gives you a freeform dashboard with add/upload buttons.`,form:`Which form to display. Only applies to popup_form or inline_form templates. Go to /forms to edit forms.`,tabTitle:`The heading that appears at the top of the page content area.`,showPrompt:`Shows the developer AI prompt copy button in the header.`,showButton:`Toggles the + add record button in the header.`,buttonStyle:`Visual style of the add button: 'primary' (accent) or 'secondary' (subtle).`,buttonText:`Label on the add button. Use '+' for a minimal icon-only button.`,buttonAction:`'save_info' saves a name + note record to the tab's Firestore collection.`,storage:`Enables the file upload button for this tab.`,buttonStorageIcon:`Icon name from https://lucide.dev/icons/ for the upload button (e.g. 'upload', 'cloud-upload').`,buttonStorageText:`Label next to the upload icon. Leave empty for icon-only.`,buttonStorageStyle:`'primary' or 'secondary' visual style for the upload button.`,buttonStorageAction:t.type===`admin`?`'upload_file' uploads to admin_files/ in Storage and mirrors metadata to admin_files collection (Drive > Admin).`:t.type===`shared`?`'upload_file' uploads to mem_files/ in Storage and mirrors metadata to mem_files collection (Drive > Shared).`:`'upload_file' uploads to user_files/ in Storage and mirrors metadata to user_files collection (Drive > Private).`,defaultView:`Starting view: 'calendar' (month grid) or 'board' (event list). Users can switch between them.`,defaultTimeFormat:`12h or 24h time format. Users can toggle this in the toolbar.`,showViewsButton:`Show the calendar/board view toggle button in the toolbar.`,viewsButtonStyle:`'primary' or 'secondary' visual style for the view toggle.`,showExportButton:`Show the CSV export/download button in the table toolbar.`,exportButtonIcon:`Icon name from https://lucide.dev/icons/ for the export button (e.g. 'download', 'import').`,keyName:`Label for the key/title field in board items (e.g. 'Task', 'Name').`,valueName:`Label for the value/description field in board items (e.g. 'Notes', 'Details').`},hideInnerLoader:!0})]})})]})]},`${e.id}-${t._uiKey||t.id}`)};return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex flex-col relative`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3 mb-2 border-b border-[var(--panel-border)]/50 pb-4`,children:[(0,l.jsx)(`div`,{className:`w-8 h-8 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center -ml-1 shadow-sm`,children:(0,l.jsx)(s,{className:`w-4 h-4 text-accent`})}),(0,l.jsx)(`h2`,{className:`text-xl font-extrabold tracking-tight text-foreground`,children:e.title})]}),(0,l.jsx)(`p`,{className:`text-[13px] leading-relaxed text-foreground/50 font-medium max-w-3xl mb-4 ml-[2px]`,children:e.description}),o.length===0?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 opacity-40 glass-panel rounded-2xl border border-[var(--panel-border)]/50 border-dashed`,children:[(0,l.jsx)(n.L,{className:`w-5 h-5 mb-2`}),(0,l.jsx)(`p`,{className:`text-[12px] font-bold`,children:`This section is currently empty.`})]}):(0,l.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f.map(e=>_(e,o.findIndex(t=>t.id===e.id),!1)),p.length>0&&(0,l.jsxs)(`details`,{className:`mt-4 group/details`,children:[(0,l.jsxs)(`summary`,{className:`text-[11px] font-bold uppercase tracking-wider text-foreground/40 cursor-pointer list-none flex items-center gap-2 select-none hover:text-foreground/70 transition-colors w-fit pb-1 ml-1 outline-none`,children:[(0,l.jsx)(n.st,{className:`w-3.5 h-3.5 group-open/details:-rotate-180 transition-transform`}),`Hidden pages (`,p.length,`)`]}),(0,l.jsx)(`div`,{className:`flex flex-col gap-4 mt-4`,children:p.map(e=>_(e,o.findIndex(t=>t.id===e.id),!0))})]})]}),t<de.length-1&&(0,l.jsx)(`div`,{className:`w-full border-t border-[var(--panel-border)]/70 my-10`})]},e.id)})]})]})]}),(0,l.jsx)(te,{isOpen:fe,onCancel:()=>X(!1),onConfirm:async()=>{me(!0);try{let{deleteDoc:e}=await import(`firebase/firestore`);await Promise.all([e((0,o.doc)(n.Tt,`sys_pages`,`home`))]),k(S)}catch(e){console.error(`Error resetting defaults:`,e)}setTimeout(()=>{me(!1),X(!1)},1e3)},title:`Reset System Pages`,message:`Are you sure you want to reset all system page configurations? Custom pages and their order will remain intact.`,confirmText:`Reset`,isProcessing:pe}),(0,l.jsx)(te,{isOpen:!!C,onCancel:()=>w(null),onConfirm:le,title:`Delete Page`,message:`Are you sure you want to delete this page? This action cannot be undone and will remove all associated configurations.`,confirmText:`Remove Page`,isProcessing:T})]})}var tn={contact:r.t,support:i.t};function nn(){let{userRole:e}=m(),t=(0,u.useNavigate)();(0,u.useLocation)();let[r,i]=(0,a.useState)({}),[s,c]=(0,a.useState)(!0),[d,f]=(0,a.useState)({}),p=n.Ct(),h=()=>({...tn,contact:p?.defaultConfigs?.contactForm||tn.contact,support:p?.defaultConfigs?.supportForm||tn.support}),[g,_]=(0,a.useState)(null),[v,y]=(0,a.useState)({}),[b,x]=(0,a.useState)(null),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(null),E=(e,t)=>{let n;n=e===`contact`?`export const contactFormConfig = ${JSON.stringify(t,null,2)};\n`:e===`support`?`export const supportFormConfig = ${JSON.stringify(t,null,2)};\n`:JSON.stringify(t,null,2),navigator.clipboard.writeText(n),T(e),setTimeout(()=>T(null),2e3)};(0,a.useEffect)(()=>{D()},[]);let D=async()=>{try{let e=await(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)),t={};e.forEach(e=>{if(e.id!==`pubForm`&&e.id!==`userForm`){let n=e.data();n._uiKey||=Math.random().toString(36).substring(7),t[e.id]=n}});try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,`pubForm`)),await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,`userForm`))}catch{}let r=h();for(let[e,i]of Object.entries(r))if(!t[e]){await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),i);let r={...i};r._uiKey=Math.random().toString(36).substring(7),t[e]=r}else if(!t[e].fields||t[e].fields.length===0){let i=r[e];t[e].fields=i.fields||[],await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),t[e])}let a=window.location.pathname.split(`/forms/`)[1]?.split(`/`)[0];a&&t[a]&&y({[a]:!0}),i(t)}catch(e){console.error(`Failed to load forms:`,e)}finally{c(!1)}},O=async(e,t)=>{let a={...t};r[e]?._uiKey&&(a._uiKey=r[e]._uiKey),e===`contact`?(a.systemName=`contact`,a.formType=`public`,a.submitPage=`submissions`):e===`support`&&(a.systemName=`support`,a.formType=`private`,a.submitPage=`requests`);let s=a.systemName||e;if(s!==e&&s.trim()!==``){i(t=>{let n={};for(let r of Object.keys(t))r===e?n[s]=a:n[r]=t[r];return n}),v[e]&&y(t=>{let n={};for(let r of Object.keys(t))r===e?n[s]=t[r]:n[r]=t[r];return n}),f(e=>({...e,[s]:!0}));try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,s),a),await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e))}catch(e){console.error(`Failed to migrate form map ID:`,e)}finally{setTimeout(()=>{f(e=>({...e,[s]:!1}))},500)}}else{i(t=>({...t,[e]:a})),f(t=>({...t,[e]:!0}));try{await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),a)}catch(e){console.error(`Failed to save form:`,e)}finally{setTimeout(()=>{f(t=>({...t,[e]:!1}))},500)}}},[k,A]=(0,a.useState)(!1),j=async()=>{if(k)return;A(!0);let e=`new_form_${Date.now().toString().slice(-4)}`,r={title:`New Custom Form`,systemName:e,formType:`public`,submitPage:`submissions`,redirectTo:``,submitText:`Submit`,fields:[],enabled:!0,_uiKey:Math.random().toString(36).substring(7)};try{f(t=>({...t,[e]:!0})),await(0,o.setDoc)((0,o.doc)(n.Tt,`sys_forms`,e),r),i(t=>({[e]:r,...t})),y(t=>({[e]:!0,...t})),t(`/forms/${e}`)}catch(e){console.error(`Failed to create form`,e)}finally{f(t=>({...t,[e]:!1})),A(!1)}},M=async e=>{if(!(e===`contact`||e===`support`)){C(!0);try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e)),i(t=>{let n={...t};return delete n[e],n}),t(`/forms`)}catch(e){console.error(`Failed to delete form`,e)}finally{C(!1),x(null)}}};if(e!==`admin`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1`,children:[(0,l.jsx)(n.p,{className:`w-12 h-12 text-red-500 mb-4`}),(0,l.jsx)(`h2`,{className:`text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-br from-red-400 to-red-600`,children:`Access Restricted`}),(0,l.jsx)(`p`,{className:`text-foreground/60 max-w-sm text-center mt-2 font-medium leading-relaxed`,children:`This area is exclusively for system administrators.`})]})});let N=e=>{y(t=>{let n={...t,[e]:!t[e]};if(n[e])window.history.replaceState(null,``,`/forms/${e}`);else{let e=Object.keys(n).filter(e=>n[e]);e.length>0?window.history.replaceState(null,``,`/forms/${e[0]}`):window.history.replaceState(null,``,`/forms`)}return n})},P=Object.keys(v).find(e=>v[e]);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:`Forms`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/forms`,P?`/${P}`:``]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(`div`,{className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-6 mb-6 pb-6 border-b border-[var(--panel-border)]/50 relative z-10 shrink-0 px-6 pt-6 md:px-10 md:pt-10 bg-background/50`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight`,children:`Custom Forms`}),(0,l.jsx)(`p`,{className:`text-[14px] font-medium text-foreground/60 mt-2 leading-relaxed`,children:`This is the central page where you configure and manage your application's forms. Easily add and customize the fields for your users.`})]}),(0,l.jsx)(`div`,{className:`relative z-50 shrink-0 flex items-center justify-end`,children:(0,l.jsx)(n.n,{variant:`secondary`,onClick:j,title:`Add Custom Form`,disabled:k,className:`w-10 h-10 p-0 border-transparent bg-transparent hover:bg-foreground/5 rounded-xl flex items-center justify-center shrink-0 transition-colors group cursor-pointer`,children:k?(0,l.jsx)(n.M,{className:`w-4 h-4 text-foreground/60 animate-spin`}):(0,l.jsx)(n.C,{className:`w-4 h-4 text-foreground/60 group-hover:text-foreground transition-colors`})})})]}),(0,l.jsx)(`div`,{className:`p-6 md:p-8 flex flex-col gap-4 overflow-y-auto`,children:s?(0,l.jsx)(`div`,{className:`flex items-center justify-center p-12 glass-panel rounded-3xl border border-[var(--panel-border)]`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})}):Object.keys(r).length===0?(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 glass-panel rounded-3xl border border-[var(--panel-border)] border-dashed opacity-50`,children:[(0,l.jsx)(n.S,{className:`w-6 h-6 mb-3 text-foreground/40`}),(0,l.jsx)(`p`,{className:`text-[13px] font-bold`,children:`No forms currently configured.`})]}):(0,l.jsx)(n.a,{children:Object.entries(r).map(([e,t])=>{let r=v[e],i=d[e];return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},onClick:()=>N(e),className:`group flex flex-col p-3 px-4 glass-panel border transition-all rounded-2xl hover:shadow-sm cursor-pointer hover:border-accent/40 ${r?`border-[var(--panel-border)] bg-background/50`:`border-transparent hover:border-[var(--panel-border)]`} flex-shrink-0 ${t.enabled===!1?`opacity-40 grayscale bg-foreground/[0.01] border-[var(--panel-border)]/50`:``}`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between w-full`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col gap-1 w-full sm:w-auto pr-4`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`h3`,{className:`text-[14px] font-bold text-foreground break-words ml-1 leading-snug`,children:t.title||`Untitled Form`}),i&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-accent ml-2 shrink-0`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5 ml-1`,children:[(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest border border-[var(--panel-border)] bg-foreground/5 text-foreground/60 px-2 py-0.5 rounded-md`,children:t.systemName||e}),(0,l.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest border px-2 py-0.5 rounded-md shrink-0 ${t.formType===`private`?`text-blue-500 bg-blue-500/10 border-blue-500/20`:`text-green-500 bg-green-500/10 border-green-500/20`}`,children:t.formType||`public`})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-4 w-full sm:w-auto justify-end mt-2 sm:mt-0 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:e=>{e.stopPropagation(),_(t)},className:`p-1.5 hover:bg-accent/10 text-foreground/40 hover:text-accent transition-colors rounded-lg flex items-center justify-center mr-2`,title:`Preview Form`,children:(0,l.jsx)(n.K,{className:`w-4 h-4`})}),e!==`contact`&&e!==`support`?(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),x(e)},className:`p-1.5 hover:bg-red-500/10 text-foreground/30 hover:text-red-500 transition-colors rounded-lg opacity-0 group-hover:opacity-100 flex items-center justify-center mr-2`,title:`Delete Form`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}):(0,l.jsx)(`div`,{className:`w-7 mr-2 shrink-0`}),(0,l.jsx)(`div`,{className:`p-1.5 transition-transform duration-300 text-foreground/40 ${r?`rotate-180`:``}`,children:(0,l.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,l.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})]})]}),(0,l.jsx)(n.a,{children:r&&(0,l.jsx)(n.i.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden mt-4 pt-4 border-t border-[var(--panel-border)]/50`,onClick:e=>e.stopPropagation(),children:(0,l.jsxs)(`div`,{className:`flex flex-col font-mono text-[13px] leading-relaxed relative bg-background/50 p-4 rounded-xl border border-[var(--panel-border)] shadow-inner`,children:[(0,l.jsxs)(`div`,{className:`absolute top-4 right-4 flex items-center gap-1 z-20`,children:[(0,l.jsx)(`button`,{onClick:async t=>{if(t.stopPropagation(),e===`contact`||e===`support`){f(t=>({...t,[e]:!0}));try{await(0,o.deleteDoc)((0,o.doc)(n.Tt,`sys_forms`,e)),localStorage.removeItem(`fbos_form_${e}`),await D()}catch(e){console.error(`Reset failed:`,e)}setTimeout(()=>f(t=>({...t,[e]:!1})),500)}else O(e,h()[e]||h().contact)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-red-500/10 rounded-lg flex items-center justify-center shrink-0 transition-colors group`,title:`Reset to Defaults`,children:i?(0,l.jsx)(n.M,{className:`w-3.5 h-3.5 text-red-500 animate-spin`}):(0,l.jsx)(n.x,{className:`w-3.5 h-3.5 text-foreground/40 group-hover:text-red-500 transition-colors`})}),(0,l.jsx)(`button`,{onClick:n=>{n.stopPropagation(),E(e,t)},className:`w-8 h-8 p-0 border-transparent bg-transparent hover:bg-foreground/10 rounded-lg flex items-center justify-center shrink-0 transition-colors`,title:`Copy JSON`,children:w===e?(0,l.jsx)(n.nt,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.Z,{className:`w-3.5 h-3.5 text-foreground/40 hover:text-foreground transition-colors`})})]}),(0,l.jsx)(Kt,{value:{systemName:t.systemName||e,formType:t.formType||`public`,submitPage:t.submitPage||(t.formType===`private`?`requests`:`submissions`),redirectTo:t.redirectTo||``,title:t.title||``,buttonName:t.buttonName||t.submitText||``,fields:t.fields||[]},keysToRender:[`systemName`,`formType`,`submitPage`,`redirectTo`,`title`,`buttonName`,`fields`],meta:{formType:t.formType||`public`},onChange:n=>{n.formType===t.formType?n.submitPage!==t.submitPage&&(n.formType=n.submitPage===`requests`?`private`:`public`):n.submitPage=n.formType===`public`?`submissions`:`requests`,O(e,{...t,...n,submitText:n.buttonName})},isLast:!0,isGlobalSaving:i,disabledKeys:e===`contact`||e===`support`?[`systemName`,`formType`,`submitPage`]:[],customEnums:{type:[`text`,`email`,`tel`,`textarea`,`number`,`select`,`checkbox`,`currency`,`age`]},customExplanations:{formType:e===`contact`?`Public means its for not signed in users. Private is disabled for contact so don't allow the user to change it.`:e===`support`?`This means that the form is available to signed in users only.`:`Public means it's for non-signed in users.`,submitPage:e===`contact`?`Means the form submissions go to this folder. User can't change that since it's directly linked. Public is tied to submissions.`:e===`support`?`Can't change since all private forms go there.`:`Where to route data submissions.`,redirectTo:`If not added form will just show a success message. If added, in 30 seconds after success user is redirected.`}})]})})})]},t._uiKey||e)})})})]})]}),(0,l.jsx)(te,{isOpen:!!b,onCancel:()=>x(null),onConfirm:()=>{b&&M(b)},title:`Delete Form`,message:`Are you sure you want to permanently delete "${b}"? This action cannot be reversed.`,confirmText:`Delete form`,isProcessing:S}),g&&(0,l.jsx)(n.t,{formConfig:g,onClose:()=>_(null)})]})}function rn({config:e}){let{config:t}=n.xt(),[r,i]=(0,a.useState)(!1),[s,c]=(0,a.useState)(null),[u,d]=(0,a.useState)([]);(0,a.useEffect)(()=>{document.title=e.pageName||e.pageTitle||t.appName||`Firebase OS`,(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{d(e.docs.filter(e=>e.data().formType===`public`).map(e=>e.id))})},[e.pageName,e.pageTitle,t.appName]);let f=H(e,u);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 relative min-h-screen`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-4`,children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.pageTitle||e.pageName||`New Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]}),(0,l.jsxs)(`div`,{className:`flex justify-between items-center mb-6 pt-2 border-b border-[var(--panel-border)] pb-6 relative z-20 overflow-x-auto no-scrollbar gap-4`,children:[(0,l.jsxs)(`button`,{onClick:()=>window.history.back(),className:`px-5 py-2 border border-[var(--panel-border)] rounded-xl text-[13px] font-bold hover:bg-foreground/5 transition-all flex items-center gap-2 cursor-pointer shadow-sm text-foreground/70 whitespace-nowrap shrink-0`,children:[(0,l.jsx)(n.gt,{className:`w-4 h-4`}),` Go Back`]}),(0,l.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[e.copyPrompt&&(0,l.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),2e3)},title:`Copy Developer Prompt`,className:`px-6 py-2.5 rounded-xl border border-[var(--panel-border)] bg-background flex items-center gap-2 hover:bg-foreground/5 hover:text-accent transition-all cursor-pointer text-[14px] font-bold tracking-wide shadow-sm whitespace-nowrap`,children:[(0,l.jsx)(n.ft,{className:`w-4 h-4`}),(0,l.jsx)(`span`,{className:`hidden sm:inline`,children:r?`Copied!`:`Copy Prompt`})]}),e.showButton&&(0,l.jsx)(`button`,{onClick:()=>{e.action===`redirect`?window.location.href=e.url||`/`:e.action===`form`&&c(e.form||`contact`)},className:`px-6 py-2.5 rounded-xl font-bold tracking-wide transition-all duration-300 flex items-center justify-center btn-primary shadow-xl hover:-translate-y-1 active:scale-95 text-[14px] whitespace-nowrap`,children:e.buttonText||`Action Button`})]})]}),(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`glass-panel border border-[var(--panel-border)] rounded-3xl shadow-2xl relative flex flex-col flex-1 bg-background/50 h-full min-h-[400px]`,children:(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center opacity-40 glass-panel border border-[var(--panel-border)]/50 border-dashed m-4 md:m-8 rounded-2xl p-8 py-20 text-center`,children:[(0,l.jsx)(n.ft,{className:`w-8 h-8 md:w-12 md:h-12 mb-4 text-foreground/80 opacity-50`}),(0,l.jsx)(`p`,{className:`text-[14px] font-bold mb-2`,children:`Click copy prompt at the top to start adding changes`}),(0,l.jsx)(`div`,{className:`mt-8 text-left bg-background p-6 rounded-2xl text-[12px] font-mono whitespace-pre-wrap max-w-2xl border border-[var(--panel-border)]/50 text-foreground/60 shadow-inner`,children:f})]})}),(0,l.jsx)(n.a,{children:s&&(0,l.jsx)(n.t,{onClose:()=>c(null),formId:s})})]})}function an({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(``),[B,ne]=(0,a.useState)(``),[V,H]=(0,a.useState)([]),U=(0,a.useRef)(null),W=(e.tabName||e.pageId||`private_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),G=`user_${W}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`,(0,o.getDocs)((0,o.collection)(n.Tt,`sys_forms`)).then(e=>{})},[e.tabTitle,e.tabName,r.appName]),(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${G}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}});(async()=>{try{let r=e((await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,G),(0,o.where)(`uid`,`==`,t.uid),(0,o.limit)(150)))).docs);r.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(r),f(!1),localStorage.setItem(`fbos_records_${G}`,JSON.stringify(r))}catch(e){console.error(`Error fetching records:`,e),f(!1)}})()},[t,G]),(0,a.useEffect)(()=>{u||localStorage.setItem(`fbos_records_${G}`,JSON.stringify(i))},[i,u,G]);let re=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=await(0,o.addDoc)((0,o.collection)(n.Tt,G),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,createdAt:(0,o.serverTimestamp)()});s(n=>[{id:e.id,name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,createdAt:Date.now()},...n]),_(``),y(``),h(!1)}catch(e){console.error(`Error saving record:`,e)}x(!1)}},ie=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`user_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e);await(0,o.addDoc)((0,o.collection)(n.Tt,`user_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`user`,sourceTab:W,accessPrefix:`user_`,createdAt:(0,o.serverTimestamp)()});let a=await(0,o.addDoc)((0,o.collection)(n.Tt,G),{name:r.name,note:`${r.type||`File`} · ${_e(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,createdAt:(0,o.serverTimestamp)()});s(e=>[{id:a.id,name:r.name,note:`${r.type||`File`} · ${_e(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type,fileSize:r.size,downloadURL:i,createdAt:Date.now()},...e])}catch(e){console.error(`Error uploading file:`,e)}T(!1),U.current&&(U.current.value=``)}},K=async()=>{if(E){F(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,G,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`user_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`user_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`user_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up user file:`,e)}s(e=>e.filter(e=>e.id!==E)),D(null)}catch(e){console.error(`Error deleting record:`,e)}F(!1)}},[q,J]=(0,a.useState)(null),[Y,ae]=(0,a.useState)(``),[oe,se]=(0,a.useState)(!1),[ce,le]=(0,a.useState)(null),de=(0,a.useRef)([]),fe=e=>{if(e.recordType===`file`){J(e.id),ae(e.name);return}L(e.id),z(e.name),ne(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));H(n),de.current=n.map(e=>e.key)},X=async()=>{if(!q||!Y.trim()){J(null);return}let e=i.find(e=>e.id===q);if(e&&e.name===Y.trim()){J(null);return}se(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,G,q),{name:Y.trim()}),s(e=>e.map(e=>e.id===q?{...e,name:Y.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}se(!1),J(null)},pe=async()=>{await me(),L(null)},me=async()=>{if(!I||!R.trim())return;x(!0);let e={};V.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=V.map(e=>e.key.trim()).filter(Boolean),r=de.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,G,I),{name:R.trim(),note:B.trim(),...e}),s(e=>e.map(e=>{if(e.id!==I)return e;let t={...e,name:R.trim(),note:B.trim()};return r.forEach(e=>{delete t[e]}),V.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),de.current=t}catch(e){console.error(`Error saving record:`,e)}x(!1)},Z=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),he=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,ge=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},_e=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},ve=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},Q=ue(e,G),ye=()=>{navigator.clipboard.writeText(Q),C(!0),setTimeout(()=>C(!1),2e3)},be=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),xe=e.buttonStyle!==`secondary`,Se=e.buttonStorageStyle===`primary`;return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Private Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`}`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:ye,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:U,onChange:ie,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>U.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(be,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${xe?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files to get started`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map((e,t)=>{let r=I===e.id;return(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:t*.03,duration:.25},onClick:()=>fe(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),le(e.id),setTimeout(()=>le(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:ce===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),fe(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${he(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?Z(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[q===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:Y,onChange:e=>ae(e.target.value),onBlur:()=>X(),onKeyDown:e=>{e.key===`Enter`&&X(),e.key===`Escape`&&J(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:ve(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e))]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Each user sees their own data only · Edit and delete available on all items · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:G}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`user_files`}),` → Drive / Private`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:re,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[ge(j.fileType),` • `,_e(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),le(`preview`),setTimeout(()=>le(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:ce===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),J(j.id),ae(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:I&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>pe(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>pe(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:B,onChange:e=>{ne(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>me(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),V.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...V];n[t].key=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...V];n[t].value=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>me(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>H(V.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>H([...V,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:K,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:P})]})}function on({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(``),[B,ne]=(0,a.useState)(``),[V,H]=(0,a.useState)([]),U=(0,a.useRef)(null),[W,G]=(0,a.useState)(null),re=(0,a.useRef)([]),ie=(e.tabName||e.pageId||`admin_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),K=`admin_${ie}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`},[e.tabTitle,e.tabName,r.appName]);let q=()=>({name:t.displayName||t.email?.split(`@`)[0]||`Admin`,email:t.email||``,avatar:t.photoURL||``});(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${K}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(150)),t=>{let n=e(t.docs);s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))},t=>{console.error(`Error listening to admin records:`,t);let r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))});return()=>r()});return()=>r()},[t,K]);let J=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=q();await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,o.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving admin record:`,e)}x(!1)}},Y=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`admin_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e),a=q();await(0,o.addDoc)((0,o.collection)(n.Tt,`admin_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`admin`,sourceTab:ie,accessPrefix:`admin_`,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()}),await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:r.name,note:`${r.type||`File`} · ${ve(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()})}catch(e){console.error(`Error uploading admin file:`,e)}T(!1),U.current&&(U.current.value=``)}},ae=async()=>{if(E){F(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,K,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`admin_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`admin_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`admin_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up admin file:`,e)}D(null)}catch(e){console.error(`Error deleting admin record:`,e)}F(!1)}},[oe,se]=(0,a.useState)(null),[ce,ue]=(0,a.useState)(``),[de,fe]=(0,a.useState)(!1),X=e=>{if(e.recordType===`file`){se(e.id),ue(e.name);return}L(e.id),z(e.name),ne(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));H(n),re.current=n.map(e=>e.key)},pe=async()=>{if(!oe||!ce.trim()){se(null);return}let e=i.find(e=>e.id===oe);if(e&&e.name===ce.trim()){se(null);return}fe(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,oe),{name:ce.trim()}),s(e=>e.map(e=>e.id===oe?{...e,name:ce.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}fe(!1),se(null)},me=async()=>{if(!I||!R.trim()){L(null);return}x(!0);let e={};V.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=V.map(e=>e.key.trim()).filter(Boolean),r=re.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,I),{name:R.trim(),note:B.trim(),...e}),s(e=>e.map(e=>{if(e.id!==I)return e;let t={...e,name:R.trim(),note:B.trim()};return r.forEach(e=>{delete t[e]}),V.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),re.current=t}catch(e){console.error(`Error updating record:`,e)}x(!1),L(null)},Z=async()=>{if(!I||!R.trim())return;let e={};V.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=V.map(e=>e.key.trim()).filter(Boolean),r=re.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,I),{name:R.trim(),note:B.trim(),...e}),s(e=>e.map(e=>{if(e.id!==I)return e;let t={...e,name:R.trim(),note:B.trim()};return r.forEach(e=>{delete t[e]}),V.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),re.current=t}catch(e){console.error(`Error silently saving record:`,e)}},he=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,_e=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},ye=le(e,K),be=()=>{navigator.clipboard.writeText(ye),C(!0),setTimeout(()=>C(!1),2e3)},xe=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),Se=e.buttonStyle!==`secondary`,Ce=e.buttonStorageStyle===`primary`,we=e=>e.uid===t?.uid,Te=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Admin`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,l.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Admin Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`}`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:be,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:U,onChange:Y,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>U.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${Ce?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(xe,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${Se?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All admins can view and contribute.`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map((e,t)=>{let r=I===e.id,i=we(e);return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>X(e),className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative cursor-pointer ${r?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),G(e.id),setTimeout(()=>G(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:W===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),i&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[oe===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:ce,onChange:e=>ue(e.target.value),onBlur:()=>pe(),onKeyDown:e=>{e.key===`Enter`&&pe(),e.key===`Escape`&&se(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Q(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,l.jsx)(Te,{record:e})]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Shared between all admins · Edit and delete available on your own items only · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:K}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`admin_files`}),` → Drive / Admin`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:J,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[_e(j.fileType),` • `,ve(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),G(`preview`),setTimeout(()=>G(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:W===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),se(j.id),ue(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:I&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>me(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>me(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:B,onChange:e=>{ne(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Z(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),V.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...V];n[t].key=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...V];n[t].value=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>H(V.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>H([...V,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:ae,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:P})]})}function sn({config:e}){let{user:t}=m(),{config:r}=n.xt(),[i,s]=(0,a.useState)([]),[u,f]=(0,a.useState)(!0),[p,h]=(0,a.useState)(!1),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null),[O,k]=(0,a.useState)(null),A=e=>{if(k(e),e){let t=e.fileType||``;N(t.startsWith(`image/`)||t.startsWith(`video/`)||t===`application/pdf`)}},j=O,[M,N]=(0,a.useState)(!0),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(``),[B,ne]=(0,a.useState)(``),[V,H]=(0,a.useState)([]),U=(0,a.useRef)(null),[W,G]=(0,a.useState)(null),re=(0,a.useRef)([]),ie=(e.tabName||e.pageId||`shared_page`).toLowerCase().replace(/[^a-z0-9]+/g,`_`),K=`mem_${ie}_records`;(0,a.useEffect)(()=>{document.title=e.tabTitle||e.tabName||r.appName||`Firebase OS`},[e.tabTitle,e.tabName,r.appName]),(0,a.useEffect)(()=>{if(!t)return;try{let e=localStorage.getItem(`fbos_records_${K}`);e?(s(JSON.parse(e)),f(!1)):f(!0)}catch{}let e=e=>e.map(e=>{let t=e.data();return{id:e.id,...t,createdAt:t.createdAt?.toMillis?t.createdAt.toMillis():t.createdAt}}),r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.orderBy)(`createdAt`,`desc`),(0,o.limit)(150)),t=>{let n=e(t.docs);s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))},t=>{console.error(`Error listening to shared records:`,t);let r=(0,o.onSnapshot)((0,o.query)((0,o.collection)(n.Tt,K),(0,o.limit)(150)),t=>{let n=e(t.docs);n.sort((e,t)=>(t.createdAt||0)-(e.createdAt||0)),s(n),f(!1),localStorage.setItem(`fbos_records_${K}`,JSON.stringify(n))});return()=>r()});return()=>r()},[t,K]);let q=()=>({name:t.displayName||t.email?.split(`@`)[0]||`Member`,email:t.email||``,avatar:t.photoURL||``}),J=async e=>{if(e.preventDefault(),!(!t||!g.trim())){x(!0);try{let e=q();await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:g.trim(),note:v.trim(),uid:t.uid,recordType:`record`,creatorName:e.name,creatorEmail:e.email,creatorAvatar:e.avatar,createdAt:(0,o.serverTimestamp)()}),_(``),y(``),h(!1)}catch(e){console.error(`Error saving shared record:`,e)}x(!1)}},Y=async e=>{let r=e.target.files?.[0];if(!(!r||!t)){T(!0);try{let e=(0,c.ref)(n.Dt,`mem_files/${`${Date.now()}_${r.name.replace(/[^a-zA-Z0-9.-]/g,`_`)}`}`);await(0,c.uploadBytes)(e,r,{customMetadata:{ownerId:t.uid}});let i=await(0,c.getDownloadURL)(e),a=q();await(0,o.addDoc)((0,o.collection)(n.Tt,`mem_files`),{fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,uid:t.uid,uploaderEmail:t.email||`member`,sourceTab:ie,accessPrefix:`mem_`,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()}),await(0,o.addDoc)((0,o.collection)(n.Tt,K),{name:r.name,note:`${r.type||`File`} · ${ve(r.size)}`,uid:t.uid,recordType:`file`,fileName:r.name,fileType:r.type||`unknown`,fileSize:r.size,downloadURL:i,creatorName:a.name,creatorEmail:a.email,creatorAvatar:a.avatar,createdAt:(0,o.serverTimestamp)()})}catch(e){console.error(`Error uploading shared file:`,e)}T(!1),U.current&&(U.current.value=``)}},ae=async()=>{if(E){F(!0);try{let e=i.find(e=>e.id===E);if(await(0,o.deleteDoc)((0,o.doc)(n.Tt,K,E)),e?.recordType===`file`&&e.downloadURL)try{let t=e.downloadURL.split(`mem_files%2F`)[1]?.split(`?`)[0];t&&await(0,c.deleteObject)((0,c.ref)(n.Dt,`mem_files/${decodeURIComponent(t)}`)).catch(()=>{});let r=await(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`mem_files`),(0,o.where)(`downloadURL`,`==`,e.downloadURL)));for(let e of r.docs)await(0,o.deleteDoc)(e.ref)}catch(e){console.error(`Error cleaning up shared file:`,e)}D(null)}catch(e){console.error(`Error deleting shared record:`,e)}F(!1)}},[oe,se]=(0,a.useState)(null),[le,ue]=(0,a.useState)(``),[de,fe]=(0,a.useState)(!1),X=e=>{if(e.recordType===`file`){se(e.id),ue(e.name);return}L(e.id),z(e.name),ne(e.note||``);let t=[`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`],n=Object.entries(e).filter(([e])=>!t.includes(e)&&e!==`id`).map(([e,t])=>({key:e,value:String(t??``)}));H(n),re.current=n.map(e=>e.key)},pe=async()=>{if(!oe||!le.trim()){se(null);return}let e=i.find(e=>e.id===oe);if(e&&e.name===le.trim()){se(null);return}fe(!0);try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,oe),{name:le.trim()}),s(e=>e.map(e=>e.id===oe?{...e,name:le.trim()}:e))}catch(e){console.error(`Error renaming file:`,e)}fe(!1),se(null)},me=async()=>{await Z(),L(null)},Z=async()=>{if(!I||!R.trim())return;x(!0);let e={};V.forEach(({key:t,value:n})=>{t.trim()&&(e[t.trim()]=n)});let t=V.map(e=>e.key.trim()).filter(Boolean),r=re.current.filter(e=>!t.includes(e));r.forEach(t=>{e[t]=(0,o.deleteField)()});try{await(0,o.updateDoc)((0,o.doc)(n.Tt,K,I),{name:R.trim(),note:B.trim(),...e}),s(e=>e.map(e=>{if(e.id!==I)return e;let t={...e,name:R.trim(),note:B.trim()};return r.forEach(e=>{delete t[e]}),V.forEach(({key:e,value:n})=>{e.trim()&&(t[e.trim()]=n)}),t})),re.current=t}catch(e){console.error(`Error saving record:`,e)}x(!1)},he=(e,t)=>e?e.startsWith(`image/`)?t?(0,l.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-cover bg-center shrink-0`,style:{backgroundImage:`url(${t})`}}):(0,l.jsx)(n.V,{className:`w-4 h-4`}):e.startsWith(`video/`)||e.startsWith(`audio/`)?(0,l.jsx)(n.l,{className:`w-4 h-4`}):e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?(0,l.jsx)(n.G,{className:`w-4 h-4`}):e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?(0,l.jsx)(n._t,{className:`w-4 h-4`}):e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?(0,l.jsx)(n.Q,{className:`w-4 h-4`}):(0,l.jsx)(n.W,{className:`w-4 h-4`}):(0,l.jsx)(n.G,{className:`w-4 h-4`}),ge=e=>e?e.startsWith(`image/`)?`bg-emerald-500/10 text-emerald-500`:e.startsWith(`video/`)||e.startsWith(`audio/`)?`bg-purple-500/10 text-purple-500`:e.includes(`pdf`)||e.includes(`word`)||e.includes(`text`)?`bg-blue-500/10 text-blue-500`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`archive`)?`bg-yellow-500/10 text-yellow-500`:e.includes(`html`)||e.includes(`csv`)||e.includes(`json`)?`bg-emerald-500/10 text-emerald-500`:`bg-foreground/5 text-foreground/40`:`bg-foreground/5 text-foreground/40`,_e=e=>{if(!e)return`FILE`;let t={"application/pdf":`PDF`,"application/zip":`ZIP`,"application/x-zip-compressed":`ZIP`,"application/x-rar-compressed":`RAR`,"application/x-7z-compressed":`7Z`,"application/json":`JSON`,"application/xml":`XML`,"application/javascript":`JS`,"application/typescript":`TS`,"application/msword":`DOC`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`DOCX`,"application/vnd.ms-excel":`XLS`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`XLSX`,"application/vnd.ms-powerpoint":`PPT`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`PPTX`,"application/rtf":`RTF`,"application/x-tar":`TAR`,"application/gzip":`GZ`,"text/plain":`TXT`,"text/html":`HTML`,"text/css":`CSS`,"text/csv":`CSV`,"text/markdown":`MD`},n=e.toLowerCase();if(t[n])return t[n];let r=n.split(`/`);return r[r.length-1].replace(/^x-/,``).replace(/^vnd\..*\./,``).toUpperCase().slice(0,10)},ve=e=>{if(!e)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**+r).toFixed(2))+` `+n[r]},Q=e=>{if(!e)return``;let t=e.toMillis?e.toMillis():e;return new Date(t).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})},ye=(()=>{let t=(e.buttonStorageIcon||`upload`).trim(),r=t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return n.o[r]?n.o[r]:n.o[t]?n.o[t]:n.f||n.C})(),be=e.buttonStyle!==`secondary`,xe=e.buttonStorageStyle===`primary`,Se=e=>e.uid===t?.uid,Ce=ce(e,K),we=()=>{navigator.clipboard.writeText(Ce),C(!0),setTimeout(()=>C(!1),2e3)},Te=({record:e})=>{let t=e.creatorName||e.creatorEmail?.split(`@`)[0]||`Member`,n=e.creatorEmail||``,r=e.creatorAvatar||``,i=t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 pt-2 border-t border-[var(--panel-border)]/30`,children:[r?(0,l.jsx)(`img`,{src:r,alt:``,className:`w-5 h-5 rounded-full object-cover shrink-0`}):(0,l.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-accent/15 text-accent flex items-center justify-center text-[8px] font-extrabold shrink-0`,children:i}),(0,l.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/40 truncate`,children:t}),n&&(0,l.jsxs)(`span`,{className:`text-[10px] text-foreground/25 truncate`,children:[`· `,n]})]})]})};return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsx)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-6 flex items-center justify-between`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:e.tabTitle||e.tabName||`Shared Page`}),e.route&&(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),e.route]})]})}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:`flex flex-col glass-panel border border-[var(--panel-border)] rounded-3xl overflow-hidden flex-1 shadow-2xl bg-background`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 p-6 md:px-8 md:py-6 border-b border-[var(--panel-border)]/50 bg-background/50 shrink-0`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h2`,{className:`text-xl font-extrabold text-foreground tracking-tight truncate`,children:e.tabTitle||e.tabName||`Dashboard`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/50 mt-1`,children:u?`Loading…`:`${i.length} ${i.length===1?`item`:`items`} · Shared`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.showPrompt&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:we,title:S?`Copied!`:`Copy Developer Prompt`,className:`w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-300 cursor-pointer ${S?`bg-emerald-500/10 text-emerald-500`:`btn-secondary`}`,children:S?(0,l.jsx)(n.ct,{className:`w-4 h-4`}):(0,l.jsx)(n.ft,{className:`w-4 h-4`})}),e.storage!==!1&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`input`,{type:`file`,ref:U,onChange:Y,className:`hidden`}),(0,l.jsxs)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>U.current?.click(),disabled:w,title:e.buttonStorageText||`Upload File`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed ${e.buttonStorageText?`px-4`:`w-10`} ${xe?`btn-primary`:`btn-secondary`}`,children:[w?(0,l.jsx)(n.M,{className:`w-4 h-4 animate-spin`}):(0,l.jsx)(ye,{className:`w-4 h-4`}),e.buttonStorageText&&(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonStorageText})]})]}),e.showButton!==!1&&(0,l.jsx)(n.i.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>h(!0),title:`Add New`,className:`h-10 flex items-center justify-center gap-2 rounded-xl transition-all duration-300 cursor-pointer ${e.buttonText&&e.buttonText!==`+`?`px-5`:`w-10`} ${be?`btn-primary`:`btn-secondary`}`,children:e.buttonText===`+`||!e.buttonText?(0,l.jsx)(n.C,{className:`w-4 h-4`}):(0,l.jsx)(`span`,{className:`text-[13px] font-bold`,children:e.buttonText})})]})]}),(0,l.jsxs)(`div`,{className:`p-6 md:p-8 flex-1 overflow-y-auto relative min-h-[400px]`,children:[u&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/50 backdrop-blur-sm`,children:(0,l.jsx)(n.M,{className:`w-8 h-8 text-accent animate-spin`})}),!u&&i.length===0&&(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`flex-1 flex flex-col items-center justify-center border border-[var(--panel-border)]/50 border-dashed rounded-2xl p-8 py-20 text-center min-h-[350px]`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-accent/5 border border-accent/10 flex items-center justify-center mb-5`,children:(0,l.jsx)(n.C,{className:`w-6 h-6 text-accent/40`})}),(0,l.jsx)(`p`,{className:`text-[15px] font-bold mb-1.5 text-foreground/50`,children:`No items yet`}),(0,l.jsx)(`p`,{className:`text-[13px] font-medium text-foreground/35 max-w-xs leading-relaxed`,children:`Use the buttons above to add records or upload files. All team members can view and contribute.`})]}),!u&&i.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:(0,l.jsx)(n.a,{children:i.map(e=>{let t=I===e.id,r=Se(e);return(0,l.jsxs)(n.i.div,{initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},onClick:()=>r?X(e):null,className:`group flex flex-col bg-background border rounded-2xl p-5 transition-all relative ${r?`cursor-pointer`:``} ${t?`border-accent/40 shadow-lg ring-1 ring-accent/20`:`border-[var(--panel-border)] hover:border-accent/30 hover:shadow-lg`}`,children:[(0,l.jsxs)(`div`,{className:`absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all z-10`,children:[e.recordType===`file`&&e.downloadURL&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.downloadURL),G(e.id),setTimeout(()=>G(null),2e3)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-emerald-500 hover:bg-emerald-500/10 transition-all cursor-pointer`,title:`Copy Link`,children:W===e.id?(0,l.jsx)(n.ct,{className:`w-3.5 h-3.5 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`a`,{href:e.downloadURL,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg text-foreground/25 hover:text-blue-500 hover:bg-blue-500/10 transition-all`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-3.5 h-3.5`})})]}),r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),X(e)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-accent hover:bg-accent/10 transition-all cursor-pointer`,title:`Edit`,children:(0,l.jsx)(n.w,{className:`w-3.5 h-3.5`})}),(0,l.jsx)(`button`,{onClick:t=>{t.stopPropagation(),D(e.id)},className:`p-1.5 rounded-lg text-foreground/25 hover:text-red-500 hover:bg-red-500/10 transition-all cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-3.5 h-3.5`})})]})]}),(0,l.jsxs)(`div`,{className:`flex items-start gap-3 mb-2`,children:[(0,l.jsx)(`div`,{onClick:t=>{t.stopPropagation(),e.recordType===`file`&&A(e)},className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.recordType===`file`?`cursor-pointer hover:scale-105 transition-transform ${ge(e.fileType)}`:`bg-accent/10 text-accent`}`,children:e.recordType===`file`?he(e.fileType,e.downloadURL):(0,l.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-current`})}),(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1 relative`,children:[oe===e.id?(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:le,onChange:e=>ue(e.target.value),onBlur:()=>pe(),onKeyDown:e=>{e.key===`Enter`&&pe(),e.key===`Escape`&&se(null)},onClick:e=>e.stopPropagation(),className:`no-glow text-[14px] font-bold text-foreground bg-transparent border-b border-accent/30 outline-none pb-0.5 w-full pr-12`}):(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground truncate pr-12`,children:e.name}),e.recordType===`file`&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-0 cursor-pointer`,onClick:()=>A(e)}),(0,l.jsx)(`span`,{className:`text-[11px] text-foreground/35 font-bold uppercase tracking-wider mt-0.5`,children:Q(e.createdAt)})]})]}),e.note&&(0,l.jsx)(`p`,{className:`text-[13px] text-foreground/55 font-medium leading-relaxed line-clamp-3 mb-1`,children:e.note}),Object.entries(e).filter(([e])=>![`name`,`note`,`uid`,`recordType`,`fileName`,`fileType`,`fileSize`,`downloadURL`,`createdAt`,`creatorName`,`creatorEmail`,`creatorAvatar`].includes(e)&&e!==`id`).slice(0,3).map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,l.jsxs)(`span`,{className:`text-[10px] font-bold text-foreground/30 uppercase tracking-wider shrink-0`,children:[e,`:`]}),(0,l.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground/60 truncate`,children:String(t)})]},e)),(0,l.jsx)(Te,{record:e})]},e.id)})})})]}),(0,l.jsx)(`div`,{className:`px-6 md:px-8 py-4 border-t border-[var(--panel-border)]/30 bg-background/30 shrink-0`,children:(0,l.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-foreground/30 font-medium leading-relaxed`,children:[(0,l.jsx)(n.B,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),(0,l.jsxs)(`span`,{children:[`Shared between all members · Edit and delete available on your own items only · Records: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:K}),` · Files: `,(0,l.jsx)(`code`,{className:`text-foreground/40 font-mono text-[10px]`,children:`mem_files`}),` → Drive / Shared`]})]})})]})]}),(0,l.jsx)(n.a,{children:p&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>!b&&h(!1),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[360px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`form`,{onSubmit:J,className:`p-5 flex flex-col gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`New Record`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>!b&&h(!1),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer p-0.5`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,required:!0,value:g,onChange:e=>_(e.target.value),placeholder:`Name *`,disabled:b,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-semibold text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`Note (optional)`,disabled:b,rows:2,className:`w-full bg-foreground/[0.03] border border-[var(--panel-border)] px-3.5 py-2.5 text-[13px] font-medium text-foreground outline-none focus:border-accent transition-colors placeholder:text-foreground/30 resize-none`,style:{borderRadius:`var(--input-radius, 0.75rem)`}}),(0,l.jsx)(`div`,{className:`flex justify-end pt-1`,children:(0,l.jsx)(n.n,{type:`submit`,isLoading:b,className:`px-5 py-2 text-[12px] font-bold shadow-md`,children:b?`Saving…`:`Save`})})]})})]})}),typeof window<`u`&&(0,d.createPortal)((0,l.jsx)(n.a,{children:j&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 md:p-12`,children:[(0,l.jsx)(n.i.div,{onClick:()=>A(null),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/95 backdrop-blur-xl cursor-pointer`}),(0,l.jsx)(`button`,{onClick:()=>A(null),className:`absolute top-6 right-6 z-[160] w-12 h-12 bg-foreground/10 hover:bg-foreground/20 text-foreground rounded-full flex items-center justify-center backdrop-blur-md transition-all cursor-pointer outline-none`,children:(0,l.jsx)(n.c,{className:`w-5 h-5`})}),(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:`relative z-10 w-full max-w-6xl max-h-[85vh] flex flex-col pointer-events-auto shadow-2xl rounded-3xl overflow-hidden glass-panel border border-[var(--panel-border)]`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between p-6 bg-background/80 backdrop-blur-md border-b border-[var(--panel-border)] shrink-0 shadow-sm z-20`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col min-w-0 pr-4`,children:[(0,l.jsx)(`span`,{className:`text-xl font-extrabold text-foreground truncate`,children:j.fileName||j.name}),(0,l.jsxs)(`span`,{className:`text-[12px] text-foreground/70 font-bold uppercase tracking-wider mt-1`,children:[_e(j.fileType),` • `,ve(j.fileSize||0)]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,l.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(j.downloadURL),G(`preview`),setTimeout(()=>G(null),2e3)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 transition-colors rounded-xl shadow-sm hover:text-emerald-500 cursor-pointer`,title:`Copy Link`,children:W===`preview`?(0,l.jsx)(n.ct,{className:`w-4 h-4 text-emerald-500`}):(0,l.jsx)(n.N,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),se(j.id),ue(j.name)},className:`p-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground/70 hover:text-accent transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Rename`,children:(0,l.jsx)(n.w,{className:`w-4 h-4`})}),(0,l.jsx)(`button`,{onClick:()=>{A(null),D(j.id)},className:`p-2.5 bg-red-500/10 hover:bg-red-500/20 text-red-500 transition-colors rounded-xl shadow-sm cursor-pointer`,title:`Delete`,children:(0,l.jsx)(n.h,{className:`w-4 h-4`})}),(0,l.jsx)(`a`,{href:j.downloadURL,download:!0,target:`_blank`,rel:`noreferrer`,className:`p-2.5 btn-primary transition-colors rounded-xl shadow-lg ml-1`,title:`Download`,children:(0,l.jsx)(n.Y,{className:`w-4 h-4`})})]})]}),(0,l.jsx)(`div`,{className:`flex-1 w-full relative bg-foreground/[0.02] min-h-[50vh] md:min-h-[600px]`,onClick:()=>A(null),children:(0,l.jsxs)(`div`,{className:`absolute inset-x-4 inset-y-8 md:inset-x-12 md:inset-y-12 flex items-center justify-center`,children:[M&&(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-lg z-50 pointer-events-none`,children:(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-background/80 backdrop-blur-md shadow-xl flex items-center justify-center border border-[var(--panel-border)]/50`,children:(0,l.jsx)(n.M,{className:`w-5 h-5 text-accent animate-spin`})})}),j.fileType?.startsWith(`image/`)?(0,l.jsx)(`img`,{onLoad:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,alt:j.fileName||j.name,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full object-contain drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] rounded-lg pointer-events-auto transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType?.startsWith(`video/`)?(0,l.jsx)(`video`,{onLoadedData:()=>N(!1),onError:()=>N(!1),src:j.downloadURL,controls:!0,autoPlay:!0,className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-auto h-auto max-w-full max-h-full outline-none bg-black/40 rounded-lg pointer-events-auto drop-shadow-[0_0_40px_rgba(0,0,0,0.5)] transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,onClick:e=>e.stopPropagation()}):j.fileType===`application/pdf`?(0,l.jsx)(`iframe`,{onLoad:()=>N(!1),src:j.downloadURL,className:`w-full h-full border-none rounded-lg relative z-10 transition-opacity duration-500 ${M?`opacity-0`:`opacity-100`}`,style:{backgroundColor:`white`},title:`PDF Preview`,onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center text-foreground/40 text-center relative z-10`,onClick:e=>{e.stopPropagation(),N(!1)},children:[(0,l.jsx)(n.G,{className:`w-24 h-24 mb-6 opacity-40 drop-shadow-sm`}),(0,l.jsx)(`span`,{className:`text-[20px] font-extrabold text-foreground`,children:`Preview Unavailable`}),(0,l.jsx)(`span`,{className:`text-[14px] mt-2 text-foreground/60 font-medium max-w-xs`,children:`This file format cannot be previewed. Please download it instead.`})]})]})})]})]})}),document.body),(0,l.jsx)(n.a,{children:I&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4`,children:[(0,l.jsx)(n.i.div,{onClick:()=>me(),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`absolute inset-0 bg-background/60 backdrop-blur-sm cursor-pointer`}),(0,l.jsx)(n.i.div,{initial:{opacity:0,scale:.97,y:6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.97,y:6},transition:{duration:.2},className:`w-full max-w-[440px] border-[var(--panel-border)] border rounded-2xl relative z-10 glass-panel shadow-2xl bg-background overflow-hidden`,children:(0,l.jsxs)(`div`,{className:`p-5 flex flex-col gap-3 max-h-[80vh] overflow-y-auto`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between mb-2 mt-2 px-1`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`span`,{className:`text-[14px] font-bold text-foreground`,children:`Edit Record`}),b&&(0,l.jsx)(n.M,{className:`w-3 h-3 animate-spin text-foreground/40`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>me(),className:`text-foreground/30 hover:text-foreground/60 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-4 h-4`})})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-0 max-h-[70vh] overflow-y-auto no-scrollbar px-1`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NAME`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`input`,{autoFocus:!0,required:!0,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),placeholder:`Name *`,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{readOnly:!0,value:`NOTE`,className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none pt-3 pb-0.5`}),(0,l.jsx)(`textarea`,{ref:e=>{e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},value:B,onChange:e=>{ne(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.target.blur())},onBlur:()=>Z(),placeholder:`Add a note...`,rows:1,className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pb-1 caret-foreground/50 resize-none overflow-hidden`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`})]}),V.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex flex-col relative group/field`,children:[(0,l.jsx)(`input`,{placeholder:`FIELD NAME`,value:e.key,onChange:e=>{let n=[...V];n[t].key=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[10px] font-bold text-foreground/30 uppercase tracking-[0.15em] outline-none placeholder:text-foreground/15 pt-3 pb-0.5 caret-foreground/40`}),(0,l.jsx)(`input`,{placeholder:`Field value...`,value:e.value,onChange:e=>{let n=[...V];n[t].value=e.target.value,H(n)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur())},onBlur:()=>Z(),className:`no-glow bg-transparent text-[13px] font-medium text-foreground outline-none placeholder:text-foreground/15 pt-1.5 pb-1 caret-foreground/50`}),(0,l.jsx)(`div`,{className:`border-b border-dashed border-[var(--panel-border)]/60`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>H(V.filter((e,n)=>n!==t)),className:`absolute top-3 right-0 p-1 text-foreground/0 group-hover/field:text-foreground/20 hover:!text-red-400 transition-colors cursor-pointer`,children:(0,l.jsx)(n.c,{className:`w-3 h-3`})})]},t)),(0,l.jsxs)(`button`,{type:`button`,onClick:()=>H([...V,{key:``,value:``}]),className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground/25 hover:text-foreground/40 transition-colors cursor-pointer mt-4 mb-4`,children:[(0,l.jsx)(n.C,{className:`w-3 h-3`}),` Add Field`]})]})]})})]})}),(0,l.jsx)(te,{isOpen:!!E,onCancel:()=>D(null),onConfirm:ae,title:`Delete Record`,message:(0,l.jsxs)(l.Fragment,{children:[`Are you sure you want to delete `,(0,l.jsx)(`strong`,{className:`text-foreground block my-0.5 text-left overflow-hidden text-ellipsis whitespace-nowrap max-w-full`,children:i.find(e=>e.id===E)?.name}),` This action cannot be undone.`]}),confirmText:`Delete`,isProcessing:P})]})}function cn(){let e=(0,u.useLocation)(),{user:t}=m(),r=n.Ct(),[i,s]=(0,a.useState)(null),[c,d]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let t=!0,r=localStorage.getItem(`fbos_route_${e.pathname}`);if(r)try{let e=JSON.parse(r);s(e),d(!1);let t=e.pageName||e.tabName||e.title;t&&(document.title=t)}catch{}return(async()=>{try{let r=e.pathname;r.startsWith(`/`)&&(r=r.substring(1));let[i,a,c,l,u,f]=await Promise.allSettled([(0,o.getDoc)((0,o.doc)(n.Tt,`sys_pages`,r)),(0,o.getDoc)((0,o.doc)(n.Tt,`sys_tabs`,r)),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_pages`),(0,o.where)(`route`,`==`,e.pathname),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_pages`),(0,o.where)(`route`,`==`,r),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_tabs`),(0,o.where)(`route`,`==`,e.pathname),(0,o.limit)(1))),(0,o.getDocs)((0,o.query)((0,o.collection)(n.Tt,`sys_tabs`),(0,o.where)(`route`,`==`,r),(0,o.limit)(1)))]),p=null,m=null,h=(e,t)=>{if(!p&&e.status===`fulfilled`){if(e.value.exists&&e.value.exists()){let n=e.value.data();p={...n,isPrivate:t,isAdmin:n.pageType===`admin`,isShared:n.pageType===`shared`},m=e.value.id}else if(e.value.docs&&e.value.docs.length>0){let n=e.value.docs[0].data();p={...n,isPrivate:t,isAdmin:n.pageType===`admin`,isShared:n.pageType===`shared`},m=e.value.docs[0].id}}};if(h(i,!1),h(c,!1),h(l,!1),h(a,!0),h(u,!0),h(f,!0),p||(e.pathname===`/contact`?(p={route:`/contact`,template:`popup_form`,form:`contact`},m=`contact`):e.pathname===`/support`&&(p={route:`/support`,template:`popup_form`,form:`support`},m=`support`)),!t)return;if(p){if((m===`contact`||m===`support`)&&!p.form&&(p.form=m),p.pageId=m,localStorage.setItem(`fbos_route_${e.pathname}`,JSON.stringify(p)),p.form){try{let e=localStorage.getItem(`fbos_form_${p.form}`);e&&(p.formConfigOverride=JSON.parse(e))}catch{}(0,o.getDoc)((0,o.doc)(n.Tt,`sys_forms`,p.form)).then(async e=>{if(t)if(e.exists()){let t={...e.data(),id:e.id};s(e=>({...e,formConfigOverride:t})),localStorage.setItem(`fbos_form_${p.form}`,JSON.stringify(t))}else{let e;if(p.form===`contact`){let{contactFormConfig:t}=await Promise.resolve().then(()=>require(`./contactForm.config-CXyq-EbM.cjs`)).then(e=>e.n);e=t}else if(p.form===`support`){let{supportFormConfig:t}=await Promise.resolve().then(()=>require(`./supportForm.config-haLod4rv.cjs`)).then(e=>e.n);e=t}e&&(s(t=>({...t,formConfigOverride:e})),localStorage.setItem(`fbos_form_${p.form}`,JSON.stringify(e)))}})}let r=p.pageName||p.tabName||p.title;r&&(document.title=r),s(p),d(!1)}else s(`not-found`),d(!1),localStorage.removeItem(`fbos_route_${e.pathname}`)}catch{t&&c&&(s(`not-found`),d(!1))}})(),()=>{t=!1}},[e.pathname]);let[f,p]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{let e;return c?e=setTimeout(()=>p(!0),150):p(!1),()=>clearTimeout(e)},[c]),c)return f?t?(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(`div`,{className:`mb-6`,children:[(0,l.jsx)(`div`,{className:`h-10 w-56 rounded-xl bg-foreground/5 animate-pulse mt-1`}),(0,l.jsx)(`div`,{className:`h-3 w-24 rounded bg-foreground/5 animate-pulse mt-3`})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-6 flex-1 pb-16`,children:[(0,l.jsx)(ee,{}),(0,l.jsx)(`div`,{className:`flex-1 glass-panel border border-[var(--panel-border)] rounded-3xl flex items-center justify-center min-h-[400px] bg-background shadow-2xl`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})})]})]}):(0,l.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-[60vh] z-10`,children:(0,l.jsx)(n.M,{className:`w-6 h-6 animate-spin text-accent`})}):null;if(i===`not-found`)return(0,l.jsx)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col pt-12 min-h-screen`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center flex-1 text-center`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 bg-red-500/10 text-red-500 rounded-full flex items-center justify-center mb-6`,children:(0,l.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`w-8 h-8`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,l.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,l.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]})}),(0,l.jsx)(`h2`,{className:`text-3xl font-bold mb-3 text-foreground`,children:`Page Not Found`}),(0,l.jsx)(`p`,{className:`text-foreground/60 max-w-md`,children:`The route you are looking for does not exist or has been removed.`})]})});if((i.pageId===`support`||i.isPrivate)&&!t)return(0,l.jsx)(u.Navigate,{to:`/login`,state:{from:e}});let h=r.customRoutes?.[e.pathname]||(i&&i.route?r.customRoutes?.[i.route]:null);if(h)return(0,l.jsx)(h,{config:i});let g=i.pageName?.toLowerCase().replace(/\s+/g,`_`)||i.pageId||`custom_page`,_=`pub_${g}`;if(i.template===`none`)return i.isAdmin?(0,l.jsx)(on,{config:i}):i.isShared?(0,l.jsx)(sn,{config:i}):i.isPrivate?(0,l.jsx)(an,{config:i}):(0,l.jsx)(rn,{config:i});if(i.template===`board`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateBoard||fe,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Board`,subtitle:i.route,tasksCollection:`${e}_tasks`,categoriesCollection:`${e}_categories`,config:i})}if(i.template===`table`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateTable||Rt,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Table`,subtitle:i.route,tableCollection:`${e}_table`,config:i})}if(i.template===`calendar`){let e=i.isAdmin?`admin_${i.pageId||g}`:i.isShared?`mem_${i.pageId||g}`:i.isPrivate?`user_${i.pageId||g}`:_;return(0,l.jsx)(r.components?.TemplateCalendar||Vt,{title:i.tabTitle||i.tabName||i.title||i.pageName||`Calendar`,subtitle:i.route,eventsCollection:`${e}_events`,defaultTimeFormat:i.defaultTimeFormat||i.defaulttimeformat||`12h`,config:i})}return i.template===`inline_form`?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-start mt-8 relative z-10 w-full min-h-[60vh]`,children:(0,l.jsx)(n.t,{isInline:!0,formId:i.form,formConfig:i.formConfigOverride})}):(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 w-full min-h-[60vh]`,children:(0,l.jsx)(n.t,{formId:i.form,formConfig:i.formConfigOverride,onClose:()=>window.history.back()})})}var ln=a.default.createContext({}),un=Object.defineProperty,dn=Object.getOwnPropertySymbols,fn=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable,mn=(e,t,n)=>t in e?un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hn=(e,t)=>{for(var n in t||={})fn.call(t,n)&&mn(e,n,t[n]);if(dn)for(var n of dn(t))pn.call(t,n)&&mn(e,n,t[n]);return e},gn=(0,a.forwardRef)((e,t)=>{let n=hn(hn({},a.useContext(ln)),e);return a.createElement(`svg`,hn({width:`1.5em`,height:`1.5em`,strokeWidth:1.5,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),a.createElement(`path`,{d:`M21.1679 8C19.6247 4.46819 16.1006 2 11.9999 2C6.81459 2 2.55104 5.94668 2.04932 11`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M17 8H21.4C21.7314 8 22 7.73137 22 7.4V3`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M2.88146 16C4.42458 19.5318 7.94874 22 12.0494 22C17.2347 22 21.4983 18.0533 22 13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M7.04932 16H2.64932C2.31795 16 2.04932 16.2686 2.04932 16.6V21`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),_n=Object.defineProperty,vn=Object.getOwnPropertySymbols,yn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,xn=(e,t,n)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||={})yn.call(t,n)&&xn(e,n,t[n]);if(vn)for(var n of vn(t))bn.call(t,n)&&xn(e,n,t[n]);return e},Cn=(0,a.forwardRef)((e,t)=>{let n=Sn(Sn({},a.useContext(ln)),e);return a.createElement(`svg`,Sn({width:`1.5em`,height:`1.5em`,viewBox:`0 0 24 24`,strokeWidth:1.5,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,color:`currentColor`,ref:t},n),a.createElement(`path`,{d:`M22 12C22 17.5228 17.5228 22 12 22C10.1786 22 8.47087 21.513 7 20.6622L2 21.5L2.83209 16C2.29689 14.7751 2 13.4222 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}),a.createElement(`path`,{d:`M12.9604 13.8683L15.0399 13.4624L17 14.2149V16.0385C17 16.6449 16.4783 17.1073 15.8901 16.9783C14.3671 16.6444 11.5997 15.8043 9.67826 13.8683C7.84859 12.0248 7.22267 9.45734 7.01039 8.04128C6.92535 7.47406 7.3737 7 7.94306 7H9.83707L10.572 8.96888L10.1832 11.0701`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}))}),wn=`rules_version = '2';
528
476
  service cloud.firestore {
529
477
  match /databases/{database}/documents {
530
478
 
@@ -636,4 +584,4 @@ VITE_ADMIN_EMAILS=your@email.com,other@email.com`;function Nn({code:e,label:t}){
636
584
  storageBucket: "myproject.firebasestorage.app",
637
585
  messagingSenderId: "123456789012",
638
586
  appId: "1:123456789012:web:abcdef123456"
639
- };`})})]}),(0,l.jsxs)(Fn,{title:`Configure your .env or Google AI Studio Secrets`,children:[(0,l.jsxs)(`p`,{className:`mb-3 text-foreground/80`,children:[`Configure your `,(0,l.jsx)(`code`,{className:`text-accent font-bold text-[13px]`,children:`.env`}),` file `,(0,l.jsx)(`strong`,{children:`OR`}),` add each variable as a secret to Google AI Studio (you will see a popup to add these variables). Map the keys from your Firebase Web SDK to the `,(0,l.jsx)(`code`,{className:`bg-foreground/5 rounded px-2 py-0.5 font-mono text-[11px]`,children:`VITE_ FIREBASE_`}),` variables.`]}),(0,l.jsxs)(`p`,{className:`text-[13px] bg-accent/10 border border-accent/20 p-3 rounded-xl mb-2 text-foreground/80`,children:[(0,l.jsx)(`strong`,{children:`Important:`}),` Provide your own emails in `,(0,l.jsx)(`code`,{className:`bg-background/80 rounded px-1.5 py-0.5 font-mono text-[11px]`,children:`VITE_ADMIN_EMAILS`}),` separated by commas. These users will automatically get full admin privileges upon their first registration. No quotes or spaces!`]}),(0,l.jsx)(Pn,{code:Mn})]}),(0,l.jsx)(Fn,{title:`Enable Authentication`,children:(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,l.jsxs)(`li`,{children:[`In Firebase console Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Security`}),` → `,(0,l.jsx)(`strong`,{children:`Authentication`}),`. Click `,(0,l.jsx)(`strong`,{children:`Get Started`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Click the `,(0,l.jsx)(`strong`,{children:`Sign-in method`}),` tab.`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Email/Password`}),` (no need to enable email links).`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Google`}),` (make sure to select the support email and save).`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Anonymous`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Head over to `,(0,l.jsx)(`strong`,{children:`Templates`}),` at the top, click on the pencil icon next to the from address and click `,(0,l.jsx)(`strong`,{children:`Customise Domain`}),`. Enter the records into your domain registrar. This is necessary for emails not to go to spam.`]}),(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`strong`,{children:`If testing in AI Studio:`}),` Head over to `,(0,l.jsx)(`strong`,{children:`Settings`}),` → `,(0,l.jsx)(`strong`,{children:`Authorized domains`}),`. Right-click any link in the menu (e.g. Templates) and copy the link. Click `,(0,l.jsx)(`strong`,{children:`Add domain`}),`, paste the link (it will look something like `,(0,l.jsx)(`code`,{className:`text-[12px]`,children:`ais-dev-...run.app`}),`), and save.`]})]})}),(0,l.jsxs)(Fn,{title:`Create Firestore Database`,children:[(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,l.jsxs)(`li`,{children:[`In the Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Database and Storage`}),` → `,(0,l.jsx)(`strong`,{children:`Firestore`}),`. Click `,(0,l.jsx)(`strong`,{children:`Create database`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Select `,(0,l.jsx)(`strong`,{children:`Standard Edition`}),` (if asked), choose a Database ID and a location closest to your users. Start in `,(0,l.jsx)(`strong`,{children:`Production mode`}),` and click Continue.`]}),(0,l.jsxs)(`li`,{children:[`Go to the `,(0,l.jsx)(`strong`,{children:`Rules`}),` tab, paste the rules below, and click `,(0,l.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,l.jsx)(Nn,{code:An,label:`Copy Firestore Rules`})]}),(0,l.jsxs)(Fn,{title:`Configure Storage`,children:[(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,l.jsxs)(`li`,{children:[`In the Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Database and Storage`}),` → `,(0,l.jsx)(`strong`,{children:`Storage`}),`. Before getting started, you must upgrade your project. Click `,(0,l.jsx)(`strong`,{children:`Upgrade Project`}),` to upgrade to the pay-as-you-go `,(0,l.jsx)(`strong`,{children:`Blaze plan`}),` (it only costs $0.026 per GB a month, which is extremely cheap for profile photos, and you pay per amount of storage). Create a cloud billing account or select an already configured one. Add a budget amount (e.g., $20 USD), link the billing account, and continue.`]}),(0,l.jsxs)(`li`,{children:[`Now click `,(0,l.jsx)(`strong`,{children:`Get started`}),`. Choose a no cost location and continue. Start in `,(0,l.jsx)(`strong`,{children:`Production mode`}),` and click `,(0,l.jsx)(`strong`,{children:`Create`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Once created, copy the bucket URL (e.g. `,(0,l.jsx)(`code`,{className:`text-[12px] bg-foreground/5 rounded px-1.5 py-0.5`,children:`your-project.firebasestorage.app`}),`) and paste it into `,(0,l.jsx)(`code`,{className:`text-[12px] bg-foreground/5 rounded px-1.5 py-0.5`,children:`VITE_FIREBASE_STORAGE_BUCKET`}),` in your `,(0,l.jsx)(`code`,{className:`text-[13px] font-bold`,children:`.env`}),`. If using AI Studio, go to the settings icon → Secrets and paste it there.`]}),(0,l.jsxs)(`li`,{children:[`Go to the `,(0,l.jsx)(`strong`,{children:`Rules`}),` tab, paste the rules below, and click `,(0,l.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,l.jsx)(Nn,{code:jn,label:`Copy Storage Rules`})]})]})]})})]})}function Ln(){let{user:e}=m(),t=(e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],r=t.charAt(0).toUpperCase()+t.slice(1);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsxs)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:[`Welcome back, `,r,`.`]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl p-8 md:p-12 flex items-center justify-center relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/10 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(n.a,{mode:`wait`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3},className:`text-center z-10`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.X,{className:`w-6 h-6`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No data added here yet`}),(0,l.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var Rn=()=>(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mb-6 shadow-xl`,children:(0,l.jsx)(n.X,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,l.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]})]});function zn({children:e}){let{user:t,loading:n,userInactive:r,signOut:i,roleResolved:a}=m(),o=(0,u.useLocation)();return n||!a?(0,l.jsx)(Rn,{}):t?r?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,l.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border border-red-500/20 text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-red-500/5`}),(0,l.jsx)(`h2`,{className:`text-2xl font-black text-red-500 mb-3 relative z-10 tracking-tight`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:`You don't have access to this app. Please contact the administrator.`}),(0,l.jsx)(`button`,{onClick:()=>i(),className:`w-full relative z-10 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Sign Out`})]})}):t.emailVerified?(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/verify`}):(0,l.jsx)(u.Navigate,{to:`/login?from=${encodeURIComponent(o.pathname)}`})}function Bn({children:e}){let{user:t,loading:n,roleResolved:r}=m(),[i]=(0,u.useSearchParams)();return n||!r?(0,l.jsx)(Rn,{}):t&&t.emailVerified?(0,l.jsx)(u.Navigate,{to:i.get(`from`)||`/dashboard`,replace:!0}):(0,l.jsx)(l.Fragment,{children:e})}function Vn({children:e}){let{user:t,loading:n,roleResolved:r}=m();return n||!r?(0,l.jsx)(Rn,{}):t?t.emailVerified?(0,l.jsx)(u.Navigate,{to:`/dashboard`}):(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/`})}function Hn({children:e}){let{user:t,userRole:n,loading:r,userInactive:i,signOut:a,roleResolved:o}=m(),s=(0,u.useLocation)();return r||!o?(0,l.jsx)(Rn,{}):t?i?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,l.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border border-red-500/20 text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-red-500/5`}),(0,l.jsx)(`h2`,{className:`text-2xl font-black text-red-500 mb-3 relative z-10 tracking-tight`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:`You don't have access to this app. Please contact the administrator.`}),(0,l.jsx)(`button`,{onClick:()=>a(),className:`w-full relative z-10 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Sign Out`})]})}):t.emailVerified?n===`admin`?(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/dashboard`}):(0,l.jsx)(u.Navigate,{to:`/verify`}):(0,l.jsx)(u.Navigate,{to:`/login?from=${encodeURIComponent(s.pathname)}`})}function Un(){return(0,l.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,l.jsx)(n.i.div,{animate:{scale:[1,1.1,1],opacity:[.6,1,.6]},transition:{duration:12,repeat:1/0,ease:`easeInOut`},className:`absolute -top-[30%] md:-top-[400px] -right-[10%] md:-right-[200px] w-[500px] md:w-[800px] h-[500px] md:h-[800px] rounded-full bg-decorator-1 blur-[80px] md:blur-[120px]`}),(0,l.jsx)(n.i.div,{animate:{scale:[1,1.2,1],opacity:[.5,.9,.5]},transition:{duration:18,repeat:1/0,ease:`easeInOut`,delay:2},className:`absolute -bottom-[20%] md:-bottom-[300px] -left-[10%] md:-left-[100px] w-[400px] md:w-[600px] h-[400px] md:h-[600px] rounded-full bg-decorator-2 blur-[60px] md:blur-[100px]`})]})}function Wn(){let e=n.Ct().components?.Home||C;return(0,l.jsx)(p,{children:(0,l.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,l.jsx)(x,{}),(0,l.jsxs)(u.Routes,{children:[(0,l.jsx)(u.Route,{path:`/`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(e,{})})}),(0,l.jsx)(u.Route,{path:`/register`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(w,{})})}),(0,l.jsx)(u.Route,{path:`/login`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(T,{})})}),(0,l.jsx)(u.Route,{path:`/reset-password`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(k,{})})}),(0,l.jsx)(u.Route,{path:`/verify`,element:(0,l.jsx)(Vn,{children:(0,l.jsx)(E,{})})}),(0,l.jsx)(u.Route,{path:`/templates`,element:(0,l.jsx)(L,{})}),(0,l.jsx)(u.Route,{path:`/templates/inline_form`,element:(0,l.jsx)(R,{})}),(0,l.jsx)(u.Route,{path:`/templates/popup_form`,element:(0,l.jsx)(ie,{})}),(0,l.jsx)(u.Route,{path:`/templates/confirmation`,element:(0,l.jsx)(z,{})}),(0,l.jsx)(u.Route,{path:`/templates/board`,element:(0,l.jsx)(fe,{})}),(0,l.jsx)(u.Route,{path:`/templates/table`,element:(0,l.jsx)(Rt,{})}),(0,l.jsx)(u.Route,{path:`/templates/calendar`,element:(0,l.jsx)(Vt,{})}),(0,l.jsx)(u.Route,{path:`/users`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(A,{})})}),(0,l.jsx)(u.Route,{path:`/users/:id`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(A,{})})}),(0,l.jsx)(u.Route,{path:`/submissions`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(F,{})})}),(0,l.jsx)(u.Route,{path:`/requests`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(re,{})})}),(0,l.jsx)(u.Route,{path:`/drive/*`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(I,{})})}),(0,l.jsx)(u.Route,{path:`/theme`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(qt,{})})}),(0,l.jsx)(u.Route,{path:`/pages/*`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(en,{})})}),(0,l.jsx)(u.Route,{path:`/forms/*`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(nn,{})})}),(0,l.jsx)(u.Route,{path:`/settings`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(P,{})})}),(0,l.jsx)(u.Route,{path:`/profile`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(O,{})})}),(0,l.jsx)(u.Route,{path:`/dashboard`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(Ln,{})})}),(0,l.jsx)(u.Route,{path:`/setup`,element:(0,l.jsx)(In,{})}),(0,l.jsx)(u.Route,{path:`*`,element:(0,l.jsx)(cn,{})})]}),(0,l.jsx)(Un,{})]})})}function Gn(){return(0,l.jsx)(u.BrowserRouter,{children:(0,l.jsx)(Kn,{})})}function Kn(){let e=n.Ct();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||kn()?(0,l.jsx)(Wn,{}):(0,l.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,l.jsx)(x,{standalone:!0}),(0,l.jsx)(In,{standalone:!0}),(0,l.jsx)(Un,{})]})}function qn(e){let t=e.firebaseConfig;return t&&t.apiKey&&t.apiKey.trim()!==``&&t.projectId&&t.projectId.trim()!==``&&n.Et(t),(0,l.jsx)(n.St,{config:{firebaseConfig:e.firebaseConfig,adminEmails:e.adminEmails,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,defaultConfigs:e.defaultConfigs},children:(0,l.jsx)(n.bt,{children:(0,l.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,l.jsx)(Gn,{})})})})}exports.ContactPopup=n.t,exports.FirebaseOS=qn,Object.defineProperty(exports,`auth`,{enumerable:!0,get:function(){return n.wt}}),Object.defineProperty(exports,`db`,{enumerable:!0,get:function(){return n.Tt}}),exports.defaultHomeConfig=S,Object.defineProperty(exports,`storage`,{enumerable:!0,get:function(){return n.Dt}}),exports.useAuth=m,exports.useConfig=n.Ct,exports.useTheme=n.xt;
587
+ };`})})]}),(0,l.jsxs)(Fn,{title:`Configure your .env or Google AI Studio Secrets`,children:[(0,l.jsxs)(`p`,{className:`mb-3 text-foreground/80`,children:[`Configure your `,(0,l.jsx)(`code`,{className:`text-accent font-bold text-[13px]`,children:`.env`}),` file `,(0,l.jsx)(`strong`,{children:`OR`}),` add each variable as a secret to Google AI Studio (you will see a popup to add these variables). Map the keys from your Firebase Web SDK to the `,(0,l.jsx)(`code`,{className:`bg-foreground/5 rounded px-2 py-0.5 font-mono text-[11px]`,children:`VITE_ FIREBASE_`}),` variables.`]}),(0,l.jsxs)(`p`,{className:`text-[13px] bg-accent/10 border border-accent/20 p-3 rounded-xl mb-2 text-foreground/80`,children:[(0,l.jsx)(`strong`,{children:`Important:`}),` Provide your own emails in `,(0,l.jsx)(`code`,{className:`bg-background/80 rounded px-1.5 py-0.5 font-mono text-[11px]`,children:`VITE_ADMIN_EMAILS`}),` separated by commas. These users will automatically get full admin privileges upon their first registration. No quotes or spaces!`]}),(0,l.jsx)(Pn,{code:Mn})]}),(0,l.jsx)(Fn,{title:`Enable Authentication`,children:(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80`,children:[(0,l.jsxs)(`li`,{children:[`In Firebase console Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Security`}),` → `,(0,l.jsx)(`strong`,{children:`Authentication`}),`. Click `,(0,l.jsx)(`strong`,{children:`Get Started`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Click the `,(0,l.jsx)(`strong`,{children:`Sign-in method`}),` tab.`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Email/Password`}),` (no need to enable email links).`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Google`}),` (make sure to select the support email and save).`]}),(0,l.jsxs)(`li`,{children:[`Enable `,(0,l.jsx)(`strong`,{children:`Anonymous`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Head over to `,(0,l.jsx)(`strong`,{children:`Templates`}),` at the top, click on the pencil icon next to the from address and click `,(0,l.jsx)(`strong`,{children:`Customise Domain`}),`. Enter the records into your domain registrar. This is necessary for emails not to go to spam.`]}),(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`strong`,{children:`If testing in AI Studio:`}),` Head over to `,(0,l.jsx)(`strong`,{children:`Settings`}),` → `,(0,l.jsx)(`strong`,{children:`Authorized domains`}),`. Right-click any link in the menu (e.g. Templates) and copy the link. Click `,(0,l.jsx)(`strong`,{children:`Add domain`}),`, paste the link (it will look something like `,(0,l.jsx)(`code`,{className:`text-[12px]`,children:`ais-dev-...run.app`}),`), and save.`]})]})}),(0,l.jsxs)(Fn,{title:`Create Firestore Database`,children:[(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,l.jsxs)(`li`,{children:[`In the Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Database and Storage`}),` → `,(0,l.jsx)(`strong`,{children:`Firestore`}),`. Click `,(0,l.jsx)(`strong`,{children:`Create database`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Select `,(0,l.jsx)(`strong`,{children:`Standard Edition`}),` (if asked), choose a Database ID and a location closest to your users. Start in `,(0,l.jsx)(`strong`,{children:`Production mode`}),` and click Continue.`]}),(0,l.jsxs)(`li`,{children:[`Go to the `,(0,l.jsx)(`strong`,{children:`Rules`}),` tab, paste the rules below, and click `,(0,l.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,l.jsx)(Nn,{code:An,label:`Copy Firestore Rules`})]}),(0,l.jsxs)(Fn,{title:`Configure Storage`,children:[(0,l.jsxs)(`ol`,{className:`space-y-2 list-decimal list-inside text-foreground/80 mb-4`,children:[(0,l.jsxs)(`li`,{children:[`In the Sidebar, go to `,(0,l.jsx)(`strong`,{children:`Database and Storage`}),` → `,(0,l.jsx)(`strong`,{children:`Storage`}),`. Before getting started, you must upgrade your project. Click `,(0,l.jsx)(`strong`,{children:`Upgrade Project`}),` to upgrade to the pay-as-you-go `,(0,l.jsx)(`strong`,{children:`Blaze plan`}),` (it only costs $0.026 per GB a month, which is extremely cheap for profile photos, and you pay per amount of storage). Create a cloud billing account or select an already configured one. Add a budget amount (e.g., $20 USD), link the billing account, and continue.`]}),(0,l.jsxs)(`li`,{children:[`Now click `,(0,l.jsx)(`strong`,{children:`Get started`}),`. Choose a no cost location and continue. Start in `,(0,l.jsx)(`strong`,{children:`Production mode`}),` and click `,(0,l.jsx)(`strong`,{children:`Create`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Once created, copy the bucket URL (e.g. `,(0,l.jsx)(`code`,{className:`text-[12px] bg-foreground/5 rounded px-1.5 py-0.5`,children:`your-project.firebasestorage.app`}),`) and paste it into `,(0,l.jsx)(`code`,{className:`text-[12px] bg-foreground/5 rounded px-1.5 py-0.5`,children:`VITE_FIREBASE_STORAGE_BUCKET`}),` in your `,(0,l.jsx)(`code`,{className:`text-[13px] font-bold`,children:`.env`}),`. If using AI Studio, go to the settings icon → Secrets and paste it there.`]}),(0,l.jsxs)(`li`,{children:[`Go to the `,(0,l.jsx)(`strong`,{children:`Rules`}),` tab, paste the rules below, and click `,(0,l.jsx)(`strong`,{children:`Publish`}),`.`]})]}),(0,l.jsx)(Nn,{code:jn,label:`Copy Storage Rules`})]})]})]})})]})}function Ln(){let{user:e}=m(),t=(e?.displayName||e?.email?.split(`@`)[0]||`there`).split(` `)[0],r=t.charAt(0).toUpperCase()+t.slice(1);return(0,l.jsxs)(`main`,{className:`flex-1 w-full max-w-7xl mx-auto p-4 md:p-8 z-10 flex flex-col`,children:[(0,l.jsxs)(n.i.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`mb-8`,children:[(0,l.jsxs)(`h1`,{className:`w-fit inline-block text-3xl md:text-4xl lg:text-5xl font-extrabold tracking-tight mb-3 text-gradient mt-1`,children:[`Welcome back, `,r,`.`]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground/40 font-bold uppercase tracking-[0.2em] text-[11px]`,children:[(0,l.jsx)(`span`,{className:`w-8 h-[1px] bg-foreground/10`}),`/dashboard`]})]}),(0,l.jsxs)(`div`,{className:`flex flex-col gap-4 flex-1 min-h-[500px]`,children:[(0,l.jsx)(`div`,{className:`flex justify-start`,children:(0,l.jsx)(ee,{})}),(0,l.jsxs)(`div`,{className:`w-full flex-1 glass-panel rounded-3xl p-8 md:p-12 flex items-center justify-center relative overflow-hidden border border-[var(--panel-border)] shadow-2xl bg-[var(--panel-bg)]`,children:[(0,l.jsx)(`div`,{className:`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-accent/10 blur-[100px] rounded-full pointer-events-none`}),(0,l.jsx)(n.a,{mode:`wait`,children:(0,l.jsxs)(n.i.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.3},className:`text-center z-10`,children:[(0,l.jsx)(`div`,{className:`w-16 h-16 rounded-3xl bg-accent/10 border border-accent/20 flex items-center justify-center text-accent mx-auto mb-6 shadow-inner`,children:(0,l.jsx)(n.X,{className:`w-6 h-6`})}),(0,l.jsx)(`h2`,{className:`text-2xl font-extrabold text-foreground mb-2`,children:`No data added here yet`}),(0,l.jsx)(`p`,{className:`text-foreground/40 font-medium`,children:`Keep moving forward, your data will appear here.`})]})})]})]})]})}var Rn=()=>(0,l.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[60vh] z-10 animate-in fade-in duration-500`,children:[(0,l.jsx)(`div`,{className:`w-12 h-12 rounded-xl glass-panel border border-[var(--panel-border)] flex items-center justify-center mb-6 shadow-xl`,children:(0,l.jsx)(n.X,{className:`w-6 h-6 text-accent animate-pulse`})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 glass-panel px-5 py-2.5 rounded-full border border-[var(--panel-border)]`,children:[(0,l.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent border-t-transparent rounded-full animate-spin`}),(0,l.jsx)(`span`,{className:`text-[13px] font-bold tracking-widest uppercase text-foreground/70`,children:`Connecting`})]})]});function zn({children:e}){let{user:t,loading:n,userInactive:r,signOut:i,roleResolved:a}=m(),o=(0,u.useLocation)();return n||!a?(0,l.jsx)(Rn,{}):t?r?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,l.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border border-red-500/20 text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-red-500/5`}),(0,l.jsx)(`h2`,{className:`text-2xl font-black text-red-500 mb-3 relative z-10 tracking-tight`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:`You don't have access to this app. Please contact the administrator.`}),(0,l.jsx)(`button`,{onClick:()=>i(),className:`w-full relative z-10 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Sign Out`})]})}):t.emailVerified?(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/verify`}):(0,l.jsx)(u.Navigate,{to:`/login?from=${encodeURIComponent(o.pathname)}`})}function Bn({children:e}){let{user:t,loading:n,roleResolved:r}=m(),[i]=(0,u.useSearchParams)();return n||!r?(0,l.jsx)(Rn,{}):t&&t.emailVerified?(0,l.jsx)(u.Navigate,{to:i.get(`from`)||`/dashboard`,replace:!0}):(0,l.jsx)(l.Fragment,{children:e})}function Vn({children:e}){let{user:t,loading:n,roleResolved:r}=m();return n||!r?(0,l.jsx)(Rn,{}):t?t.emailVerified?(0,l.jsx)(u.Navigate,{to:`/dashboard`}):(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/`})}function Hn({children:e}){let{user:t,userRole:n,loading:r,userInactive:i,signOut:a,roleResolved:o}=m(),s=(0,u.useLocation)();return r||!o?(0,l.jsx)(Rn,{}):t?i?(0,l.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center relative z-10 min-h-[60vh] animate-in fade-in duration-500`,children:(0,l.jsxs)(`div`,{className:`glass-panel p-8 md:p-10 rounded-3xl border border-red-500/20 text-center shadow-xl max-w-sm w-full relative overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-red-500/5`}),(0,l.jsx)(`h2`,{className:`text-2xl font-black text-red-500 mb-3 relative z-10 tracking-tight`,children:`Access Denied`}),(0,l.jsx)(`p`,{className:`text-[14px] text-foreground/70 font-medium leading-relaxed relative z-10 mb-6`,children:`You don't have access to this app. Please contact the administrator.`}),(0,l.jsx)(`button`,{onClick:()=>a(),className:`w-full relative z-10 py-2.5 bg-foreground/5 hover:bg-foreground/10 text-foreground text-[14px] font-bold rounded-xl transition-colors`,children:`Sign Out`})]})}):t.emailVerified?n===`admin`?(0,l.jsx)(l.Fragment,{children:e}):(0,l.jsx)(u.Navigate,{to:`/dashboard`}):(0,l.jsx)(u.Navigate,{to:`/verify`}):(0,l.jsx)(u.Navigate,{to:`/login?from=${encodeURIComponent(s.pathname)}`})}function Un(){return(0,l.jsxs)(`div`,{className:`fixed top-0 left-0 w-full h-full pointer-events-none -z-0 overflow-hidden`,children:[(0,l.jsx)(n.i.div,{animate:{scale:[1,1.1,1],opacity:[.6,1,.6]},transition:{duration:12,repeat:1/0,ease:`easeInOut`},className:`absolute -top-[30%] md:-top-[400px] -right-[10%] md:-right-[200px] w-[500px] md:w-[800px] h-[500px] md:h-[800px] rounded-full bg-decorator-1 blur-[80px] md:blur-[120px]`}),(0,l.jsx)(n.i.div,{animate:{scale:[1,1.2,1],opacity:[.5,.9,.5]},transition:{duration:18,repeat:1/0,ease:`easeInOut`,delay:2},className:`absolute -bottom-[20%] md:-bottom-[300px] -left-[10%] md:-left-[100px] w-[400px] md:w-[600px] h-[400px] md:h-[600px] rounded-full bg-decorator-2 blur-[60px] md:blur-[100px]`})]})}function Wn(){let e=n.Ct().components?.Home||C;return(0,l.jsx)(p,{children:(0,l.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,l.jsx)(x,{}),(0,l.jsxs)(u.Routes,{children:[(0,l.jsx)(u.Route,{path:`/`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(e,{})})}),(0,l.jsx)(u.Route,{path:`/register`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(w,{})})}),(0,l.jsx)(u.Route,{path:`/login`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(T,{})})}),(0,l.jsx)(u.Route,{path:`/reset-password`,element:(0,l.jsx)(Bn,{children:(0,l.jsx)(k,{})})}),(0,l.jsx)(u.Route,{path:`/verify`,element:(0,l.jsx)(Vn,{children:(0,l.jsx)(E,{})})}),(0,l.jsx)(u.Route,{path:`/templates`,element:(0,l.jsx)(z,{})}),(0,l.jsx)(u.Route,{path:`/templates/inline_form`,element:(0,l.jsx)(B,{})}),(0,l.jsx)(u.Route,{path:`/templates/popup_form`,element:(0,l.jsx)(ne,{})}),(0,l.jsx)(u.Route,{path:`/templates/confirmation`,element:(0,l.jsx)(V,{})}),(0,l.jsx)(u.Route,{path:`/templates/board`,element:(0,l.jsx)(fe,{})}),(0,l.jsx)(u.Route,{path:`/templates/table`,element:(0,l.jsx)(Rt,{})}),(0,l.jsx)(u.Route,{path:`/templates/calendar`,element:(0,l.jsx)(Vt,{})}),(0,l.jsx)(u.Route,{path:`/users`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(A,{})})}),(0,l.jsx)(u.Route,{path:`/users/:id`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(A,{})})}),(0,l.jsx)(u.Route,{path:`/submissions`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(I,{})})}),(0,l.jsx)(u.Route,{path:`/requests`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(L,{})})}),(0,l.jsx)(u.Route,{path:`/drive/*`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(R,{})})}),(0,l.jsx)(u.Route,{path:`/theme`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(qt,{})})}),(0,l.jsx)(u.Route,{path:`/pages/*`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(en,{})})}),(0,l.jsx)(u.Route,{path:`/forms/*`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(nn,{})})}),(0,l.jsx)(u.Route,{path:`/settings`,element:(0,l.jsx)(Hn,{children:(0,l.jsx)(F,{})})}),(0,l.jsx)(u.Route,{path:`/profile`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(O,{})})}),(0,l.jsx)(u.Route,{path:`/dashboard`,element:(0,l.jsx)(zn,{children:(0,l.jsx)(Ln,{})})}),(0,l.jsx)(u.Route,{path:`/setup`,element:(0,l.jsx)(In,{})}),(0,l.jsx)(u.Route,{path:`*`,element:(0,l.jsx)(cn,{})})]}),(0,l.jsx)(Un,{})]})})}function Gn(){return(0,l.jsx)(u.BrowserRouter,{children:(0,l.jsx)(Kn,{})})}function Kn(){let e=n.Ct();return e.firebaseConfig&&e.firebaseConfig.apiKey&&e.firebaseConfig.apiKey.trim()!==``&&e.firebaseConfig.projectId&&e.firebaseConfig.projectId.trim()!==``||kn()?(0,l.jsx)(Wn,{}):(0,l.jsxs)(`div`,{className:`min-h-screen relative flex flex-col overflow-x-hidden`,children:[(0,l.jsx)(x,{standalone:!0}),(0,l.jsx)(In,{standalone:!0}),(0,l.jsx)(Un,{})]})}function qn(e){let t=e.firebaseConfig;return t&&t.apiKey&&t.apiKey.trim()!==``&&t.projectId&&t.projectId.trim()!==``&&n.Et(t),(0,l.jsx)(n.St,{config:{firebaseConfig:e.firebaseConfig,adminEmails:e.adminEmails,basename:e.basename,onAuthChange:e.onAuthChange,themeConfig:e.themeConfig,components:e.components,customRoutes:e.customRoutes,defaultConfigs:e.defaultConfigs},children:(0,l.jsx)(n.bt,{children:(0,l.jsx)(`div`,{className:`firebase-os flex-1 flex flex-col min-h-screen`,style:{background:`var(--bg-gradient)`,color:`var(--fg-color)`},children:(0,l.jsx)(Gn,{})})})})}exports.ContactPopup=n.t,exports.FirebaseOS=qn,Object.defineProperty(exports,`auth`,{enumerable:!0,get:function(){return n.wt}}),Object.defineProperty(exports,`db`,{enumerable:!0,get:function(){return n.Tt}}),exports.defaultHomeConfig=S,Object.defineProperty(exports,`storage`,{enumerable:!0,get:function(){return n.Dt}}),exports.useAuth=m,exports.useConfig=n.Ct,exports.useTheme=n.xt;