@kyro-cms/admin 0.12.11 → 0.12.16

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import na,{createContext,lazy,useState,useRef,useEffect,useCallback,useContext,useMemo,Suspense,Component}from'react';import {create,useStore}from'zustand';import {persist,createJSONStorage}from'zustand/middleware';import*as _c from'lucide-react';import {Video,Mail,Clock,Database,Users,Tag,Image,Activity,CircleHelp,Sparkles,Blocks,Columns3,Link2,ListOrdered,Box,Star,AlignLeft,ChevronDown,File,Code,List,Heading1,GripVertical,Copy,Check,ClipboardCopy,X,Plus,ChevronRight,ClipboardPaste,Search,LoaderCircle,ChevronUp,CodeXml,FileText,Music,Film,Undo,Redo,Bold,Italic,Underline,Strikethrough,Highlighter,Palette,CheckSquare,Quote,Terminal,Minus,AlignCenter,AlignRight,Link,Maximize2,Minimize2,Grid3X3,Filter,FolderPlus,FolderInput,Folder,Trash2,Archive,Download,Crop,Server,MousePointerClick,RefreshCcw,Eye,Pencil,Info,TriangleAlert,ShieldAlert,CircleCheck,EllipsisVertical,Send,History,CheckCircle2,User,GitCompare,Undo2,ExternalLink,RefreshCw,Settings,Shield,Hexagon,Network,Sun,Moon,LogOut,ArrowRight,LayoutDashboard,ArrowUpRight,Webhook,Zap,XCircle,Pause,Play,Key,Lock,EyeOff,CirclePlay,Save,UserPlus,LockOpen}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useSyncExternalStore}from'use-sync-external-store/shim';import {mediaCollections,authCollections,minimalCollections,starterCollections,blogCollections,ecommerceCollections,kitchenSinkCollections,allSettingsGlobals,coreSettingsGlobals}from'@kyro-cms/core/templates';import {projectConfig}from'virtual:kyro-plugins';import {createStorage}from'unstorage';import Pf from'unstorage/drivers/indexedb';import {createPortal}from'react-dom';import {useEditor,EditorContent}from'@tiptap/react';import ag from'@tiptap/starter-kit';import {marked}from'marked';import sg from'@tiptap/extension-link';import ig from'@tiptap/extension-image';import lg from'@tiptap/extension-text-align';import dg from'@tiptap/extension-underline';import cg from'@tiptap/extension-highlight';import ug from'@tiptap/extension-task-list';import pg from'@tiptap/extension-task-item';import {TextStyle}from'@tiptap/extension-text-style';import fg from'@tiptap/extension-color';import Gf from'react-image-crop';import'react-image-crop/dist/ReactCrop.css';import {githubLight}from'@uiw/codemirror-theme-github';import {aura}from'@uiw/codemirror-theme-aura';import {useSensors,useSensor,PointerSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter,DragOverlay,useDraggable}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,horizontalListSortingStrategy}from'@dnd-kit/sortable';import {CSS}from'@dnd-kit/utilities';import {createStore}from'zustand/vanilla';import bv from'@uiw/react-codemirror';import {json}from'@codemirror/lang-json';import'@kyro-cms/core/client';var qp=Object.create;var Il=Object.defineProperty;var Jp=Object.getOwnPropertyDescriptor;var Xp=Object.getOwnPropertyNames;var Yp=Object.getPrototypeOf,Qp=Object.prototype.hasOwnProperty;var Zp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var em=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Xp(t))!Qp.call(e,a)&&a!==r&&Il(e,a,{get:()=>t[a],enumerable:!(o=Jp(t,a))||o.enumerable});return e};var tm=(e,t,r)=>(r=e!=null?qp(Yp(e)):{},em(!e||!e.__esModule?Il(r,"default",{value:e,enumerable:true}):r,e));var Bd=Zp((d0,Ed)=>{Ed.exports={area:true,base:true,br:true,col:true,embed:true,hr:true,img:true,input:true,link:true,meta:true,param:true,source:true,track:true,wbr:true};});var _e=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",Dr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Ye(e){if(e.startsWith("http")||e.startsWith(Dr))return e;if(e.startsWith("/api/"))return Dr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${Dr}${t}${e}`}function ri(e){return e.startsWith("http")||e.startsWith(_e)?e:e.startsWith("/admin/")?_e+e.slice(6):e.startsWith("/")?_e+e:e}function Ua(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var rm={admin:_e,api:Dr,resolveApi:Ye,resolveAdmin:ri,resolveMedia:Ua};var Zr=create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Zt=create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),j={success:e=>Zt.getState().addToast("success",e),error:e=>Zt.getState().addToast("error",e),warning:e=>Zt.getState().addToast("warning",e),info:e=>Zt.getState().addToast("info",e)};create()(persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var vt=create(e=>({sidebarOpen:true,toggleSidebar:()=>e(t=>({sidebarOpen:!t.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),modal:{open:false,config:null},confirm:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default"}}}),alert:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default",confirmLabel:t.confirmLabel||"OK",onConfirm:()=>e(r=>({modal:{...r.modal,open:false}}))}}}),closeModal:()=>e(t=>({modal:{...t.modal,open:false},activeModal:null})),activeModal:null,openModal:t=>e({activeModal:t})}));create(e=>({editor:null,setEditor:t=>e({editor:t}),blockDrawerOpen:false,openBlockDrawer:t=>e({blockDrawerOpen:true,pendingInsert:{pos:null,column:t?.targetColumn??null}}),closeBlockDrawer:()=>e({blockDrawerOpen:false,pendingInsert:{pos:null,column:null}}),toggleBlockDrawer:()=>e(t=>({blockDrawerOpen:!t.blockDrawerOpen})),selectedBlock:null,setSelectedBlock:t=>e({selectedBlock:t}),pendingInsert:{pos:null,column:null},setPendingInsert:(t,r)=>e({pendingInsert:{pos:t,column:r??null}}),clearPendingInsert:()=>e({pendingInsert:{pos:null,column:null}})}));create((e,t)=>({cache:{},setCache:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:o,loading:false,error:null,lastFetch:Date.now()}}})),setLoading:(r,o)=>e(a=>({cache:{...a.cache,[r]:{...a.cache[r],loading:o,error:null}}})),setError:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:null,loading:false,error:o,lastFetch:null}}})),getCache:r=>t().cache[r]||null,invalidateCache:r=>e(o=>{if(r){let{[r]:a,...n}=o.cache;return {cache:n}}return {cache:{}}})}));var am="/api/auth/refresh";async function Ll(){try{return (await fetch(Ye(am),{method:"POST",credentials:"include"})).ok}catch{return false}}async function ct(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),r["x-kyro-admin"]="true",Object.assign(r,t.headers);let o=await fetch(Ye(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Ll()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(Ye(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Me(e,t){let{autoToast:r=true,...o}=t||{},a=await ct(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&j.error(n),new Error(n)}return a.json()}async function ut(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let i=`POST Failed: ${n.status}`;try{let s=await n.json();s.error&&(i=s.error);}catch{}throw o&&j.error(i),new Error(i)}return n.json()}async function er(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let i=`Update Failed: ${n.status}`;try{let s=await n.json();s.error&&(i=s.error);}catch{}throw o&&j.error(i),new Error(i)}return n.json()}async function Dt(e,t){let{autoToast:r=true,...o}={},a=await ct(e,{method:"DELETE",...o});if(!a.ok){let i=`Delete Failed: ${a.status}`;try{let s=await a.json();s.error&&(i=s.error);}catch{}throw r&&j.error(i),new Error(i)}let n=await a.text();return n?JSON.parse(n):{}}function eo(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function Tn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function Dn(e,t,r){if(!r){let o=await ct(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",Ye(e)),n.withCredentials=true,n.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Ll().then(i=>{if(!i){a(new Error(`Upload Error: ${n.status}`));return}let s=new XMLHttpRequest;s.open("POST",Ye(e)),s.withCredentials=true,s.upload.addEventListener("progress",l=>{l.lengthComputable&&r(Math.round(l.loaded/l.total*100));}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300)try{o(JSON.parse(s.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${s.status}`));}),s.addEventListener("error",()=>a(new Error("Network error"))),s.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function lr({size:e="md",className:t=""}){return jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}var Lt=(e,t)=>{typeof window>"u"||import('astro:transitions/client').then(r=>{r&&r.navigate?r.navigate(e,t):window.location.href=e;}).catch(()=>{window.location.href=e;});};function Wt({variant:e,count:t=1,className:r=""}){let o={text:"h-3 rounded-md",circle:"size-10 rounded-full",rect:"h-10 rounded-xl",card:"h-32 rounded-2xl","table-row":"h-14 rounded-xl","media-card":"aspect-square rounded-2xl","stat-card":"h-24 rounded-2xl"};return jsx(Fragment,{children:Array.from({length:t}).map((a,n)=>jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function vd({back:e}){return e.href?jsx("a",{href:e.href,onClick:t=>{e.onClick&&(t.preventDefault(),e.onClick());},className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsx("button",{type:"button",onClick:e.onClick,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function sm({breadcrumbs:e}){return e?.map((t,r)=>jsxs(na.Fragment,{children:[r>0&&jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsx("a",{href:t.href,onClick:o=>{t.onClick&&(o.preventDefault(),t.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:t.label}):jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function bd({actions:e}){return Array.isArray(e)?jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>{let o=`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all ${t.variant==="outline"?"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":t.variant==="ghost"?"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] shadow-none":"kyro-btn-primary hover:opacity-90"} ${t.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${t.className||""}`;return t.href&&!t.disabled?jsxs("a",{href:t.href,className:o,children:[t.icon&&jsx(t.icon,{className:"w-4 h-4"}),t.label]},r):jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:o,children:[t.icon&&jsx(t.icon,{className:"w-4 h-4"}),t.label]},r)})}):jsx(Fragment,{children:e})}function hd({action:e}){let t=`kyro-btn kyro-btn-primary flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`;return e.href&&!e.disabled?jsxs("a",{href:e.href,className:t,children:[e.icon&&jsx(e.icon,{className:"w-4 h-4"}),e.label]}):jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:t,children:[e.icon&&jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function jt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:i,actions:s,children:l}){let d=o?.[o.length-1];return jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxs("div",{className:"flex items-center gap-2",children:[n&&jsx(vd,{back:n}),jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsx("svg",{className:"w-3 h-3 text-[var(--kyro-text-secondary)] opacity-40 group-open:rotate-180 transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsx("div",{className:"flex items-center gap-2",children:o.map((c,u)=>jsxs(na.Fragment,{children:[u>0&&jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsx("a",{href:c.href,onClick:p=>{c.onClick&&(p.preventDefault(),c.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:c.label}):jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},u))}),a&&jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,u)=>jsx(na.Fragment,{children:c},u))}),l]})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[r&&jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxs(na.Fragment,{children:[u===0&&jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))})]})]}),jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsx(vd,{back:n}),o&&jsx(sm,{breadcrumbs:o})]}),jsxs("div",{className:"flex items-center gap-3",children:[r&&jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxs(na.Fragment,{children:[u===0&&(t||u>0)&&jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))}),l]})]}),jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[s&&jsx(bd,{actions:s}),i&&jsx(hd,{action:i})]})]}),(s||i)&&jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[i&&jsx(hd,{action:i}),s&&jsx(bd,{actions:s})]})]})}var lm={draft:{class:"bg-gray-100 text-gray-600",label:"Draft"},published:{class:"bg-green-100 text-green-700",label:"Published"},scheduled:{class:"bg-blue-100 text-blue-700",label:"Scheduled"},archived:{class:"bg-yellow-100 text-yellow-700",label:"Archived"},active:{class:"bg-green-100 text-green-700",label:"Active"},inactive:{class:"bg-gray-100 text-gray-600",label:"Inactive"},pending:{class:"bg-yellow-100 text-yellow-700",label:"Pending"},completed:{class:"bg-green-100 text-green-700",label:"Completed"},cancelled:{class:"bg-red-100 text-red-700",label:"Cancelled"}};function Et({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",i=lm[n],s=i?i.class:`kyro-badge-${n}`;return jsxs("span",{className:`kyro-badge ${s} ${r}`,children:[a&&jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||i?.label||n]})}function pi({count:e,max:t=99}){return e===0?null:jsx("span",{className:"inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium bg-gray-200 text-gray-700 rounded-full",children:e>t?`${t}+`:e})}function mi({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...i}){let s="kyro-btn",l=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxs("button",{type:"button",className:`${s} ${l} ${d} ${a}`,disabled:n||r,...i,children:[r?jsx("span",{className:"kyro-btn-loading",children:jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function kd({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxs("div",{className:"surface-tile flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-[var(--kyro-border)]",children:[r!==void 0&&o?jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Showing ",(e-1)*o+1," to ",Math.min(e*o,r)," of ",r]}):jsx("span",{}),jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxs("select",{value:o,onChange:i=>n(Number(i.target.value)),className:"text-xs border border-[var(--kyro-border)] rounded-lg px-2 py-1 bg-[var(--kyro-bg)] text-[var(--kyro-text-secondary)]",children:[jsx("option",{value:10,children:"10/page"}),jsx("option",{value:25,children:"25/page"}),jsx("option",{value:50,children:"50/page"}),jsx("option",{value:100,children:"100/page"})]}),jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxs("div",{className:"flex gap-1",children:[jsx(mi,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsx(mi,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var be=e=>typeof e=="string",Ga=()=>{let e,t,r=new Promise((o,a)=>{e=o,t=a;});return r.resolve=e,r.reject=t,r},wd=e=>e==null?"":String(e),um=(e,t,r)=>{e.forEach(o=>{t[o]&&(r[o]=t[o]);});},pm=/###/g,Nd=e=>e&&e.includes("###")?e.replace(pm,"."):e,Cd=e=>!e||be(e),Wa=(e,t,r)=>{let o=be(t)?t.split("."):t,a=0;for(;a<o.length-1;){if(Cd(e))return {};let n=Nd(o[a]);!e[n]&&r&&(e[n]=new r),Object.prototype.hasOwnProperty.call(e,n)?e=e[n]:e={},++a;}return Cd(e)?{}:{obj:e,k:Nd(o[a])}},Sd=(e,t,r)=>{let{obj:o,k:a}=Wa(e,t,Object);if(o!==void 0||t.length===1){o[a]=r;return}let n=t[t.length-1],i=t.slice(0,t.length-1),s=Wa(e,i,Object);for(;s.obj===void 0&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),s=Wa(e,i,Object),s?.obj&&typeof s.obj[`${s.k}.${n}`]<"u"&&(s.obj=void 0);s.obj[`${s.k}.${n}`]=r;},mm=(e,t,r,o)=>{let{obj:a,k:n}=Wa(e,t,Object);a[n]=a[n]||[],a[n].push(r);},Qn=(e,t)=>{let{obj:r,k:o}=Wa(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},fm=(e,t,r)=>{let o=Qn(e,r);return o!==void 0?o:Qn(t,r)},Fd=(e,t,r)=>{for(let o in t)o!=="__proto__"&&o!=="constructor"&&(Object.prototype.hasOwnProperty.call(e,o)?be(e[o])||e[o]instanceof String||be(t[o])||t[o]instanceof String?r&&(e[o]=t[o]):Fd(e[o],t[o],r):e[o]=t[o]);return e},Hr=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),gm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},ym=e=>be(e)?e.replace(/[&<>"'\/]/g,t=>gm[t]):e,yi=class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[];}getRegExp(t){let r=this.regExpMap.get(t);if(r!==void 0)return r;let o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}},vm=[" ",",","?","!",";"],bm=new yi(20),hm=(e,t,r)=>{t=t||"",r=r||"";let o=vm.filter(i=>!t.includes(i)&&!r.includes(i));if(o.length===0)return true;let a=bm.getRegExp(`(${o.map(i=>i==="?"?"\\?":i).join("|")})`),n=!a.test(e);if(!n){let i=e.indexOf(r);i>0&&!a.test(e.substring(0,i))&&(n=true);}return n},vi=(e,t,r=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let o=t.split(r),a=e;for(let n=0;n<o.length;){if(!a||typeof a!="object")return;let i,s="";for(let l=n;l<o.length;++l)if(l!==n&&(s+=r),s+=o[l],i=a[s],i!==void 0){if(["string","number","boolean"].includes(typeof i)&&l<o.length-1)continue;n+=l-n+1;break}a=i;}return a},qa=e=>e?.replace(/_/g,"-"),xm={type:"logger",log(e){this.output("log",e);},warn(e){this.output("warn",e);},error(e){this.output("error",e);},output(e,t){console?.[e]?.apply?.(console,t);}},bi=class e{constructor(t,r={}){this.init(t,r);}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||xm,this.options=r,this.debug=r.debug;}log(...t){return this.forward(t,"log","",true)}warn(...t){return this.forward(t,"warn","",true)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",true)}forward(t,r,o,a){return a&&!this.debug?null:(t=t.map(n=>be(n)?n.replace(/[\r\n\x00-\x1F\x7F]/g," "):n),be(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},Rr=new bi,oa=class{constructor(){this.observers={};}on(t,r){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);let a=this.observers[o].get(r)||0;this.observers[o].set(r,a+1);}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t].delete(r);}}once(t,r){let o=(...a)=>{r(...a),this.off(t,o);};return this.on(t,o),this}emit(t,...r){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([a,n])=>{for(let i=0;i<n;i++)a(...r);}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,n])=>{for(let i=0;i<n;i++)a(t,...r);});}},Zn=class extends oa{constructor(t,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=true);}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t);}removeNamespaces(t){let r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1);}getResource(t,r,o,a={}){let n=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,s;t.includes(".")?s=t.split("."):(s=[t,r],o&&(Array.isArray(o)?s.push(...o):be(o)&&n?s.push(...o.split(n)):s.push(o)));let l=Qn(this.data,s);return !l&&!r&&!o&&t.includes(".")&&(t=s[0],r=s[1],o=s.slice(2).join(".")),l||!i||!be(o)?l:vi(this.data?.[t]?.[r],o,n)}addResource(t,r,o,a,n={silent:false}){let i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,s=[t,r];o&&(s=s.concat(i?o.split(i):o)),t.includes(".")&&(s=t.split("."),a=r,r=s[1]),this.addNamespaces(r),Sd(this.data,s,a),n.silent||this.emit("added",t,r,o,a);}addResources(t,r,o,a={silent:false}){for(let n in o)(be(o[n])||Array.isArray(o[n]))&&this.addResource(t,r,n,o[n],{silent:true});a.silent||this.emit("added",t,r,o);}addResourceBundle(t,r,o,a,n,i={silent:false,skipCopy:false}){let s=[t,r];t.includes(".")&&(s=t.split("."),a=o,o=r,r=s[1]),this.addNamespaces(r);let l=Qn(this.data,s)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),a?Fd(l,o,n):l={...l,...o},Sd(this.data,s,l),i.silent||this.emit("added",t,r,o);}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r);}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){let r=this.getDataByLanguage(t);return !!(r&&Object.keys(r)||[]).find(a=>r[a]&&Object.keys(r[a]).length>0)}toJSON(){return this.data}},Id={processors:{},addPostProcessor(e){this.processors[e.name]=e;},handle(e,t,r,o,a){return e.forEach(n=>{t=this.processors[n]?.process(t,r,o,a)??t;}),t}},Ld=Symbol("i18next/PATH_KEY");function km(){let e=[],t=Object.create(null),r;return t.get=(o,a)=>(r?.revoke?.(),a===Ld?e:(e.push(a),r=Proxy.revocable(o,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Fo(e,t){let{[Ld]:r}=e(km()),o=t?.keySeparator??".",a=t?.nsSeparator??":",n=t?.enableSelector==="strict";if(r.length>1&&a){let i=t?.ns,s=n?Array.isArray(i)?i:i?[i]:null:Array.isArray(i)?i:null;if(s&&(n?s:s.length>1?s.slice(1):[]).includes(r[0]))return `${r[0]}${a}${r.slice(1).join(o)}`}return r.join(o)}var fi=e=>!be(e)&&typeof e!="boolean"&&typeof e!="number",es=class e extends oa{constructor(t,r={}){super(),um(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Rr.create("translator"),this.checkedLoadedFor={};}changeLanguage(t){t&&(this.language=t);}exists(t,r={interpolation:{}}){let o={...r};if(t==null)return false;let a=this.resolve(t,o);if(a?.res===void 0)return false;let n=fi(a.res);return !(o.returnObjects===false&&n)}extractFromKey(t,r){let o=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");let a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,n=r.ns||this.options.defaultNS||[],i=o&&t.includes(o),s=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!hm(t,o,a);if(i&&!s){let l=t.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return {key:t,namespaces:be(n)?[n]:n};let d=t.split(o);(o!==a||o===a&&this.options.ns.includes(d[0]))&&(n=d.shift()),t=d.join(a);}return {key:t,namespaces:be(n)?[n]:n}}translate(t,r,o){let a=typeof r=="object"?{...r}:r;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),t==null)return "";typeof t=="function"&&(t=Fo(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(E=>typeof E=="function"?Fo(E,{...this.options,...a}):String(E));let n=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:s,namespaces:l}=this.extractFromKey(t[t.length-1],a),d=l[l.length-1],c=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;c===void 0&&(c=":");let u=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?n?{res:`${d}${c}${s}`,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:`${d}${c}${s}`:n?{res:s,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:s;let f=this.resolve(t,a),m=f?.res,y=f?.usedKey||s,v=f?.exactUsedKey||s,x=["[object Number]","[object Function]","[object RegExp]"],h=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,N=a.count!==void 0&&!be(a.count),V=e.hasDefaultValue(a),P=N?this.pluralResolver.getSuffix(u,a.count,a):"",k=a.ordinal&&N?this.pluralResolver.getSuffix(u,a.count,{ordinal:false}):"",g=N&&!a.ordinal&&a.count===0,b=g&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${P}`]||a[`defaultValue${k}`]||a.defaultValue,w=m;S&&!m&&V&&(w=b);let D=fi(w),F=Object.prototype.toString.apply(w);if(S&&w&&D&&!x.includes(F)&&!(be(h)&&Array.isArray(w))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,w,{...a,ns:l}):`key '${s} (${this.language})' returned an object instead of string.`;return n?(f.res=E,f.usedParams=this.getUsedParamsDetails(a),f):E}if(i){let E=Array.isArray(w),R=E?[]:{},M=E?v:y;for(let z in w)if(Object.prototype.hasOwnProperty.call(w,z)){let I=`${M}${i}${z}`;V&&!m?R[z]=this.translate(I,{...a,defaultValue:fi(b)?b[z]:void 0,joinArrays:false,ns:l}):R[z]=this.translate(I,{...a,joinArrays:false,ns:l}),R[z]===I&&(R[z]=w[z]);}m=R;}}else if(S&&be(h)&&Array.isArray(m))m=m.join(h),m&&(m=this.extendTranslation(m,t,a,o));else {let E=false,R=false;!this.isValidLookup(m)&&V&&(E=true,m=b),this.isValidLookup(m)||(R=true,m=s);let z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:m,I=V&&b!==m&&this.options.updateMissing;if(R||E||I){if(this.logger.log(I?"updateKey":"missingKey",u,d,N&&!I?`${s}${this.pluralResolver.getSuffix(u,a.count,a)}`:s,I?b:m),i){let Y=this.resolve(s,{...a,keySeparator:false});Y&&Y.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");}let J=[],Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let Y=0;Y<Z.length;Y++)J.push(Z[Y]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(a.lng||this.language):J.push(a.lng||this.language);let te=(Y,ae,ue)=>{let he=V&&ue!==m?ue:z;this.options.missingKeyHandler?this.options.missingKeyHandler(Y,d,ae,he,I,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Y,d,ae,he,I,a),this.emit("missingKey",Y,d,ae,m);};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?J.forEach(Y=>{let ae=this.pluralResolver.getSuffixes(Y,a);g&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!ae.includes(`${this.options.pluralSeparator}zero`)&&ae.push(`${this.options.pluralSeparator}zero`),ae.forEach(ue=>{te([Y],s+ue,a[`defaultValue${ue}`]||b);});}):te(J,s,b));}m=this.extendTranslation(m,t,a,f,o),R&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${d}${c}${s}`),(R||E)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${c}${s}`:s,E?m:void 0,a));}return n?(f.res=m,f.usedParams=this.getUsedParamsDetails(a),f):m}extendTranslation(t,r,o,a,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});let l=be(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),d;if(l){let u=t.match(this.interpolator.nestingRegexp);d=u&&u.length;}let c=o.replace&&!be(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,o.lng||this.language||a.usedLng,o),l){let u=t.match(this.interpolator.nestingRegexp),p=u&&u.length;d<p&&(o.nest=false);}!o.lng&&a&&a.res&&(o.lng=this.language||a.usedLng),o.nest!==false&&(t=this.interpolator.nest(t,(...u)=>n?.[0]===u[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${r[0]}`),null):this.translate(...u,r),o)),o.interpolation&&this.interpolator.reset();}let i=o.postProcess||this.options.postProcess,s=be(i)?[i]:i;return t!=null&&s?.length&&o.applyPostProcessor!==false&&(t=Id.handle(s,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,r={}){let o,a,n,i,s;return be(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(l=>typeof l=="function"?Fo(l,{...this.options,...r}):l)),t.forEach(l=>{if(this.isValidLookup(o))return;let d=this.extractFromKey(l,r),c=d.key;a=c;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let p=r.count!==void 0&&!be(r.count),f=p&&!r.ordinal&&r.count===0,m=r.context!==void 0&&(be(r.context)||typeof r.context=="number")&&r.context!=="",y=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach(v=>{this.isValidLookup(o)||(s=v,!this.checkedLoadedFor[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${y[0]}-${v}`]=true,this.logger.warn(`key "${a}" for languages "${y.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(x=>{if(this.isValidLookup(o))return;i=x;let h=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(h,c,x,v,r);else {let N;p&&(N=this.pluralResolver.getSuffix(x,r.count,r));let V=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&N.startsWith(P)&&h.push(c+N.replace(P,this.options.pluralSeparator)),h.push(c+N),f&&h.push(c+V)),m){let k=`${c}${this.options.contextSeparator||"_"}${r.context}`;h.push(k),p&&(r.ordinal&&N.startsWith(P)&&h.push(k+N.replace(P,this.options.pluralSeparator)),h.push(k+N),f&&h.push(k+V));}}let S;for(;S=h.pop();)this.isValidLookup(o)||(n=S,o=this.getResource(x,v,S,r));}));});}),{res:o,usedKey:a,exactUsedKey:n,usedLng:i,usedNS:s}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,o,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,r,o,a):this.resourceStore.getResource(t,r,o,a)}getUsedParamsDetails(t={}){let r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!be(t.replace),a=o?t.replace:t;if(o&&typeof t.count<"u"&&(a={...a,count:t.count}),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!o){a={...a};for(let n of r)delete a[n];}return a}static hasDefaultValue(t){let r="defaultValue";for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&o.startsWith(r)&&t[o]!==void 0)return true;return false}},ts=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||false,this.logger=Rr.create("languageUtils");}getScriptPartFromCode(t){if(t=qa(t),!t||!t.includes("-"))return null;let r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=qa(t),!t||!t.includes("-"))return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(be(t)&&t.includes("-")){let r;try{r=Intl.getCanonicalLocales(t)[0];}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return (this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(o=>{if(r)return;let a=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(a))&&(r=a);}),!r&&this.options.supportedLngs&&t.forEach(o=>{if(r)return;let a=this.getScriptPartFromCode(o);if(this.isSupportedCode(a))return r=a;let n=this.getLanguagePartFromCode(o);if(this.isSupportedCode(n))return r=n;r=this.options.supportedLngs.find(i=>i===n?true:!i.includes("-")&&!n.includes("-")?false:!!(i.includes("-")&&!n.includes("-")&&i.slice(0,i.indexOf("-"))===n||i.startsWith(n)&&n.length>1));}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return [];if(typeof t=="function"&&(t=t(r)),be(t)&&(t=[t]),Array.isArray(t))return t;if(!r)return t.default||[];let o=t[r];return o||(o=t[this.getScriptPartFromCode(r)]),o||(o=t[this.formatLanguageCode(r)]),o||(o=t[this.getLanguagePartFromCode(r)]),o||(o=t.default),o||[]}toResolveHierarchy(t,r){let o=this.getFallbackCodes((r===false?[]:r)||this.options.fallbackLng||[],t),a=[],n=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`));};return be(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(t))):be(t)&&n(this.formatLanguageCode(t)),o.forEach(i=>{a.includes(i)||n(this.formatLanguageCode(i));}),a}},Ad={zero:0,one:1,two:2,few:3,many:4,other:5},Td={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},hi=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=Rr.create("pluralResolver"),this.pluralRulesCache={};}clearCache(){this.pluralRulesCache={};}getRule(t,r={}){let o=qa(t==="dev"?"en":t),a=r.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:o,type:a});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let i;try{i=new Intl.PluralRules(o,{type:a});}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Td;if(!t.match(/-|_/))return Td;let l=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(l,r);}return this.pluralRulesCache[n]=i,i}needsPlural(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,r,o={}){return this.getSuffixes(t,o).map(a=>`${r}${a}`)}getSuffixes(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?o.resolvedOptions().pluralCategories.sort((a,n)=>Ad[a]-Ad[n]).map(a=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(t,r,o={}){let a=this.getRule(t,o);return a?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${a.select(r)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",r,o))}},Dd=(e,t,r,o=".",a=true)=>{let n=fm(e,t,r);return !n&&a&&be(r)&&(n=vi(e,r,o),n===void 0&&(n=vi(t,r,o))),n},wm=e=>e.replace(/\$/g,"$$$$"),rs=class{constructor(t={}){this.logger=Rr.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(r=>r),this.init(t);}init(t={}){t.interpolation||(t.interpolation={escapeValue:true});let{escape:r,escapeValue:o,useRawValueToEscape:a,prefix:n,prefixEscaped:i,suffix:s,suffixEscaped:l,formatSeparator:d,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:f,nestingSuffix:m,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:h}=t.interpolation;this.escape=r!==void 0?r:ym,this.escapeValue=o!==void 0?o:true,this.useRawValueToEscape=a!==void 0?a:false,this.prefix=n?Hr(n):i||"{{",this.suffix=s?Hr(s):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=c?"":u?Hr(u):"-",this.unescapeSuffix=this.unescapePrefix?"":c?Hr(c):"",this.nestingPrefix=p?Hr(p):f||Hr("$t("),this.nestingSuffix=m?Hr(m):y||Hr(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=h!==void 0?h:false,this.resetRegExp();}reset(){this.options&&this.init(this.options);}resetRegExp(){let t=(r,o)=>r?.source===o?(r.lastIndex=0,r):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);}interpolate(t,r,o,a){let n,i,s,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=f=>{if(!f.includes(this.formatSeparator)){let x=Dd(r,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,o,{...a,...r,interpolationkey:f}):x}let m=f.split(this.formatSeparator),y=m.shift().trim(),v=m.join(this.formatSeparator).trim();return this.format(Dd(r,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,o,{...a,...r,interpolationkey:y})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false \u2014 if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return [{regex:this.regexpUnescape,safeValue:f=>f},{regex:this.regexp,safeValue:f=>this.escapeValue?this.escape(f):f}].forEach(f=>{for(s=0;n=f.regex.exec(t);){let m=n[1].trim();if(i=d(m),i===void 0)if(typeof c=="function"){let v=c(t,n,a);i=be(v)?v:"";}else if(a&&Object.prototype.hasOwnProperty.call(a,m))i="";else if(u){i=n[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${t}`),i="";else !be(i)&&!this.useRawValueToEscape&&(i=wd(i));let y=f.safeValue(i);if(t=t.replace(n[0],wm(y)),u?(f.regex.lastIndex+=y.length,f.regex.lastIndex-=n[0].length):f.regex.lastIndex=0,s++,s>=this.maxReplaces)break}}),t}nest(t,r,o={}){let a,n,i,s=(l,d)=>{let c=this.nestingOptionsSeparator;if(!l.includes(c))return l;let u=l.split(new RegExp(`${Hr(c)}[ ]*{`)),p=`{${u[1]}`;l=u[0],p=this.interpolate(p,i);let f=p.match(/'/g),m=p.match(/"/g);((f?.length??0)%2===0&&!m||(m?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),d&&(i={...d,...i});}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${c}${p}`}return i.defaultValue&&i.defaultValue.includes(this.prefix)&&delete i.defaultValue,l};for(;a=this.nestingRegexp.exec(t);){let l=[];i={...o},i=i.replace&&!be(i.replace)?i.replace:i,i.applyPostProcessor=false,delete i.defaultValue;let d=/{.*}/s.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(d!==-1&&(l=a[1].slice(d).split(this.formatSeparator).map(c=>c.trim()).filter(Boolean),a[1]=a[1].slice(0,d)),n=r(s.call(this,a[1].trim(),i),i),n&&a[0]===t&&!be(n))return n;be(n)||(n=wd(n)),n||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),n=""),l.length&&(n=l.reduce((c,u)=>this.format(c,u,o.lng,{...o,interpolationkey:a[1].trim()}),n.trim())),t=t.replace(a[0],n),this.regexp.lastIndex=0;}return t}},Nm=e=>{let t=e.toLowerCase().trim(),r={};if(e.includes("(")){let o=e.split("(");t=o[0].toLowerCase().trim();let a=o[1].slice(0,-1);t==="currency"&&!a.includes(":")?r.currency||(r.currency=a.trim()):t==="relativetime"&&!a.includes(":")?r.range||(r.range=a.trim()):a.split(";").forEach(i=>{if(i){let[s,...l]=i.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),c=s.trim();r[c]||(r[c]=d),d==="false"&&(r[c]=false),d==="true"&&(r[c]=true),isNaN(d)||(r[c]=parseInt(d,10));}});}return {formatName:t,formatOptions:r}},Pd=e=>{let t={};return (r,o,a)=>{let n=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(n={...n,[a.interpolationkey]:void 0});let i=o+JSON.stringify(n),s=t[i];return s||(s=e(qa(o),a),t[i]=s),s(r)}},Cm=e=>(t,r,o)=>e(qa(r),o)(t),xi=class{constructor(t={}){this.logger=Rr.create("formatter"),this.options=t,this.init(t);}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let o=r.cacheInBuiltFormats?Pd:Cm;this.formats={number:o((a,n)=>{let i=new Intl.NumberFormat(a,{...n});return s=>i.format(s)}),currency:o((a,n)=>{let i=new Intl.NumberFormat(a,{...n,style:"currency"});return s=>i.format(s)}),datetime:o((a,n)=>{let i=new Intl.DateTimeFormat(a,{...n});return s=>i.format(s)}),relativetime:o((a,n)=>{let i=new Intl.RelativeTimeFormat(a,{...n});return s=>i.format(s,n.range||"day")}),list:o((a,n)=>{let i=new Intl.ListFormat(a,{...n});return s=>i.format(s)})};}add(t,r){this.formats[t.toLowerCase().trim()]=r;}addCached(t,r){this.formats[t.toLowerCase().trim()]=Pd(r);}format(t,r,o,a={}){if(!r||t==null)return t;let n=r.split(this.formatSeparator),i=[];for(let l=0;l<n.length;l++){let d=n[l];for(;d.indexOf("(")>-1&&!d.includes(")")&&l+1<n.length;)d=`${d}${this.formatSeparator}${n[++l]}`;i.push(d);}return i.reduce((l,d)=>{let{formatName:c,formatOptions:u}=Nm(d);if(this.formats[c]){let p=l;try{let f=a?.formatParams?.[a.interpolationkey]||{},m=f.locale||f.lng||a.locale||a.lng||o;p=this.formats[c](l,m,{...u,...a,...f});}catch(f){this.logger.warn(f);}return p}else this.logger.warn(`there was no format function for ${c}`);return l},t)}},Sm=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--);},ki=class extends oa{constructor(t,r,o,a={}){super(),this.backend=t,this.store=r,this.services=o,this.languageUtils=o.languageUtils,this.options=a,this.logger=Rr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,a.backend,a);}queueLoad(t,r,o,a){let n={},i={},s={},l={};return t.forEach(d=>{let c=true;r.forEach(u=>{let p=`${d}|${u}`;!o.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?i[p]===void 0&&(i[p]=true):(this.state[p]=1,c=false,i[p]===void 0&&(i[p]=true),n[p]===void 0&&(n[p]=true),l[u]===void 0&&(l[u]=true)));}),c||(s[d]=true);}),(Object.keys(n).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(n),pending:Object.keys(i),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}loaded(t,r,o){let a=t.split("|"),n=a[0],i=a[1];r&&this.emit("failedLoading",n,i,r),!r&&o&&this.store.addResourceBundle(n,i,o,void 0,void 0,{skipCopy:true}),this.state[t]=r?-1:2,r&&o&&(this.state[t]=0);let s={};this.queue.forEach(l=>{mm(l.loaded,[n],i),Sm(l,t),r&&l.errors.push(r),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{s[d]||(s[d]={});let c=l.loaded[d];c.length&&c.forEach(u=>{s[d][u]===void 0&&(s[d][u]=true);});}),l.done=true,l.errors.length?l.callback(l.errors):l.callback());}),this.emit("loaded",s),this.queue=this.queue.filter(l=>!l.done);}read(t,r,o,a=0,n=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:o,tried:a,wait:n,callback:i});return}this.readingCalls++;let s=(d,c)=>{if(this.readingCalls--,this.waitingReads.length>0){let u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback);}if(d&&c&&a<this.maxRetries){setTimeout(()=>{this.read(t,r,o,a+1,n*2,i);},n);return}i(d,c);},l=this.backend[o].bind(this.backend);if(l.length===2){try{let d=l(t,r);d&&typeof d.then=="function"?d.then(c=>s(null,c)).catch(s):s(null,d);}catch(d){s(d);}return}return l(t,r,s)}prepareLoading(t,r,o={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();be(t)&&(t=this.languageUtils.toResolveHierarchy(t)),be(r)&&(r=[r]);let n=this.queueLoad(t,r,o,a);if(!n.toLoad.length)return n.pending.length||a(),null;n.toLoad.forEach(i=>{this.loadOne(i);});}load(t,r,o){this.prepareLoading(t,r,{},o);}reload(t,r,o){this.prepareLoading(t,r,{reload:true},o);}loadOne(t,r=""){let o=t.split("|"),a=o[0],n=o[1];this.read(a,n,"read",void 0,void 0,(i,s)=>{i&&this.logger.warn(`${r}loading namespace ${n} for language ${a} failed`,i),!i&&s&&this.logger.log(`${r}loaded namespace ${n} for language ${a}`,s),this.loaded(t,i,s);});}saveMissing(t,r,o,a,n,i={},s=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${o}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){let l={...i,isUpdate:n},d=this.backend.create.bind(this.backend);if(d.length<6)try{let c;d.length===5?c=d(t,r,o,a,l):c=d(t,r,o,a),c&&typeof c.then=="function"?c.then(u=>s(null,u)).catch(s):s(null,c);}catch(c){s(c);}else d(t,r,o,a,s,l);}!t||!t[0]||this.store.addResource(t[0],r,o,a);}}},gi=()=>({debug:false,initAsync:true,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:false,supportedLngs:false,nonExplicitSupportedLngs:false,load:"all",preload:false,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:false,partialBundledLanguages:false,saveMissing:false,updateMissing:false,saveMissingTo:"fallback",saveMissingPlurals:true,missingKeyHandler:false,missingInterpolationHandler:false,postProcess:false,postProcessPassResolved:false,returnNull:false,returnEmptyString:true,returnObjects:false,joinArrays:false,returnedObjectHandler:false,parseMissingKeyHandler:false,appendNamespaceToMissingKey:false,appendNamespaceToCIMode:false,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),be(e[1])&&(t.defaultValue=e[1]),be(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){let r=e[3]||e[2];Object.keys(r).forEach(o=>{t[o]=r[o];});}return t},interpolation:{escapeValue:true,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:true},cacheInBuiltFormats:true}),Rd=e=>(be(e.ns)&&(e.ns=[e.ns]),be(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),be(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Yn=()=>{},Am=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e));});},wi=class e extends oa{constructor(t={},r){if(super(),this.options=Rd(t),this.services={},this.logger=Rr,this.modules={external:[]},Am(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,r),this;setTimeout(()=>{this.init(t,r);},0);}}init(t={},r){this.isInitializing=true,typeof t=="function"&&(r=t,t={}),t.defaultNS==null&&t.ns&&(be(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));let o=gi();this.options={...o,...this.options,...Rd(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler);let a=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Rr.init(a(this.modules.logger),this.options):Rr.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=xi;let c=new ts(this.options);this.store=new Zn(this.options.resources,this.options);let u=this.services;u.logger=Rr,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new hi(c,{prepend:this.options.pluralSeparator}),d&&(u.formatter=a(d),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new rs(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new ki(a(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.languageDetector&&(u.languageDetector=a(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=a(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new es(this.services,this.options),this.translator.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.external.forEach(p=>{p.init&&p.init(this);});}if(this.format=this.options.interpolation.format,r||(r=Yn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0]);}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...c)=>this.store[d](...c);}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...c)=>(this.store[d](...c),this);});let s=Ga(),l=()=>{let d=(c,u)=>{this.isInitializing=false,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=true,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),s.resolve(u),r(c,u);};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d);};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),s}loadResources(t,r=Yn){let o=r,a=be(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();let n=[],i=s=>{if(!s||s==="cimode")return;this.services.languageUtils.toResolveHierarchy(s).forEach(d=>{d!=="cimode"&&(n.includes(d)||n.push(d));});};a?i(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>i(l)),this.options.preload?.forEach?.(s=>i(s)),this.services.backendConnector.load(n,this.options.ns,s=>{!s&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(s);});}else o(null);}reloadResources(t,r,o){let a=Ga();return typeof t=="function"&&(o=t,t=void 0),typeof r=="function"&&(o=r,r=void 0),t||(t=this.languages),r||(r=this.options.ns),o||(o=Yn),this.services.backendConnector.reload(t,r,n=>{a.resolve(),o(n);}),a}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Id.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let r=0;r<this.languages.length;r++){let o=this.languages[r];if(!["cimode","dev"].includes(o)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t));}}changeLanguage(t,r){this.isLanguageChangingTo=t;let o=Ga();this.emit("languageChanging",t);let a=s=>{this.language=s,this.languages=this.services.languageUtils.toResolveHierarchy(s),this.resolvedLanguage=void 0,this.setResolvedLanguage(s);},n=(s,l)=>{l?this.isLanguageChangingTo===t&&(a(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),r&&r(s,(...d)=>this.t(...d));},i=s=>{!t&&!s&&this.services.languageDetector&&(s=[]);let l=be(s)?s:s&&s[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(be(s)?[s]:s);d&&(this.language||a(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,c=>{n(c,d);});};return !t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),o}getFixedT(t,r,o,a){let n=a?.scopeNs,i=(s,l,...d)=>{let c;typeof l!="object"?c=this.options.overloadTranslationOptionHandler([s,l].concat(d)):c={...l},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs;let u=c.ns!==void 0&&c.ns!==null;c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||i.keyPrefix);let p={...this.options,...c};Array.isArray(n)&&!u&&(p.ns=n),typeof c.keyPrefix=="function"&&(c.keyPrefix=Fo(c.keyPrefix,p));let f=this.options.keySeparator||".",m;return c.keyPrefix&&Array.isArray(s)?m=s.map(y=>(typeof y=="function"&&(y=Fo(y,p)),`${c.keyPrefix}${f}${y}`)):(typeof s=="function"&&(s=Fo(s,p)),m=c.keyPrefix?`${c.keyPrefix}${f}${s}`:s),this.t(m,c)};return be(t)?i.lng=t:i.lngs=t,i.ns=r,i.keyPrefix=o,i}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t;}hasLoadedNamespace(t,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),false;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),false;let o=r.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:false,n=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return true;let i=(s,l)=>{let d=this.services.backendConnector.state[`${s}|${l}`];return d===-1||d===0||d===2};if(r.precheck){let s=r.precheck(this,i);if(s!==void 0)return s}return !!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(o,t)&&(!a||i(n,t)))}loadNamespaces(t,r){let o=Ga();return this.options.ns?(be(t)&&(t=[t]),t.forEach(a=>{this.options.ns.includes(a)||this.options.ns.push(a);}),this.loadResources(a=>{o.resolve(),r&&r(a);}),o):(r&&r(),Promise.resolve())}loadLanguages(t,r){let o=Ga();be(t)&&(t=[t]);let a=this.options.preload||[],n=t.filter(i=>!a.includes(i)&&this.services.languageUtils.isSupportedCode(i));return n.length?(this.options.preload=a.concat(n),this.loadResources(i=>{o.resolve(),r&&r(i);}),o):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return "rtl";try{let a=new Intl.Locale(t);if(a&&a.getTextInfo){let n=a.getTextInfo();if(n&&n.direction)return n.direction}}catch{}let r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new ts(gi());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},r){let o=new e(t,r);return o.createInstance=e.createInstance,o}cloneInstance(t={},r=Yn){let o=t.forkResourceStore;o&&delete t.forkResourceStore;let a={...this.options,...t,isClone:true},n=new e(a);if((t.debug!==void 0||t.prefix!==void 0)&&(n.logger=n.logger.clone(t)),["store","services","language"].forEach(s=>{n[s]=this[s];}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},o){let s=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},l[d]=Object.keys(l[d]).reduce((c,u)=>(c[u]={...l[d][u]},c),l[d]),l),{});n.store=new Zn(s,a),n.services.resourceStore=n.store;}if(t.interpolation){let l={...gi().interpolation,...this.options.interpolation,...t.interpolation},d={...a,interpolation:l};n.services.interpolator=new rs(d);}return n.translator=new es(n.services,a),n.translator.on("*",(s,...l)=>{n.emit(s,...l);}),n.init(a,r),n.translator.options=a,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return {options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Bt=wi.createInstance();Bt.createInstance;Bt.dir;Bt.init;Bt.loadResources;Bt.reloadResources;Bt.use;Bt.changeLanguage;Bt.getFixedT;Bt.t;Bt.exists;Bt.setDefaultNamespace;Bt.hasLoadedNamespace;Bt.loadNamespaces;Bt.loadLanguages;tm(Bd());var os=(e,t,r,o)=>{let a=[r,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(a,"warn","react-i18next::",true);vr(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...a):console?.warn&&console.warn(...a);},Md={},oo=(e,t,r,o)=>{vr(r)&&Md[r]||(vr(r)&&(Md[r]=new Date),os(e,t,r,o));},$d=(e,t)=>()=>{if(e.isInitialized)t();else {let r=()=>{setTimeout(()=>{e.off("initialized",r);},0),t();};e.on("initialized",r);}},as=(e,t,r)=>{e.loadNamespaces(t,$d(e,r));},Ni=(e,t,r,o)=>{if(vr(r)&&(r=[r]),e.options.preload&&e.options.preload.indexOf(t)>-1)return as(e,r,o);r.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a);}),e.loadLanguages(t,$d(e,o));},Od=(e,t,r={})=>!t.languages||!t.languages.length?(oo(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),true):t.hasLoadedNamespace(e,{lng:r.lng,precheck:(o,a)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!a(o.isLanguageChangingTo,e))return false}});var vr=e=>typeof e=="string",Ci=e=>typeof e=="object"&&e!==null;var Dm=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Pm={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"\xA9","&#169;":"\xA9","&reg;":"\xAE","&#174;":"\xAE","&hellip;":"\u2026","&#8230;":"\u2026","&#x2F;":"/","&#47;":"/"},Rm=e=>Pm[e],Si=e=>e.replace(Dm,Rm);var Ai={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:true,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:true,unescape:Si,transDefaultProps:void 0},ns=(e={})=>{Ai={...Ai,...e};},Ja=()=>Ai;var Vd,ss=e=>{Vd=e;},br=()=>Vd;var is={type:"3rdParty",init(e){ns(e.options.react),ss(e);}};var ao=createContext(),ls=class{constructor(){this.usedNamespaces={};}addUsedNamespaces(t){t.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=true);});}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}};var jd={"&nbsp;":"\xA0","&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&copy;":"\xA9","&reg;":"\xAE","&trade;":"\u2122","&hellip;":"\u2026","&ndash;":"\u2013","&mdash;":"\u2014","&lsquo;":"\u2018","&rsquo;":"\u2019","&sbquo;":"\u201A","&ldquo;":"\u201C","&rdquo;":"\u201D","&bdquo;":"\u201E","&dagger;":"\u2020","&Dagger;":"\u2021","&bull;":"\u2022","&prime;":"\u2032","&Prime;":"\u2033","&lsaquo;":"\u2039","&rsaquo;":"\u203A","&sect;":"\xA7","&para;":"\xB6","&middot;":"\xB7","&ensp;":"\u2002","&emsp;":"\u2003","&thinsp;":"\u2009","&euro;":"\u20AC","&pound;":"\xA3","&yen;":"\xA5","&cent;":"\xA2","&curren;":"\xA4","&times;":"\xD7","&divide;":"\xF7","&minus;":"\u2212","&plusmn;":"\xB1","&ne;":"\u2260","&le;":"\u2264","&ge;":"\u2265","&asymp;":"\u2248","&equiv;":"\u2261","&infin;":"\u221E","&int;":"\u222B","&sum;":"\u2211","&prod;":"\u220F","&radic;":"\u221A","&part;":"\u2202","&permil;":"\u2030","&deg;":"\xB0","&micro;":"\xB5","&larr;":"\u2190","&uarr;":"\u2191","&rarr;":"\u2192","&darr;":"\u2193","&harr;":"\u2194","&crarr;":"\u21B5","&lArr;":"\u21D0","&uArr;":"\u21D1","&rArr;":"\u21D2","&dArr;":"\u21D3","&hArr;":"\u21D4","&alpha;":"\u03B1","&beta;":"\u03B2","&gamma;":"\u03B3","&delta;":"\u03B4","&epsilon;":"\u03B5","&zeta;":"\u03B6","&eta;":"\u03B7","&theta;":"\u03B8","&iota;":"\u03B9","&kappa;":"\u03BA","&lambda;":"\u03BB","&mu;":"\u03BC","&nu;":"\u03BD","&xi;":"\u03BE","&omicron;":"\u03BF","&pi;":"\u03C0","&rho;":"\u03C1","&sigma;":"\u03C3","&tau;":"\u03C4","&upsilon;":"\u03C5","&phi;":"\u03C6","&chi;":"\u03C7","&psi;":"\u03C8","&omega;":"\u03C9","&Alpha;":"\u0391","&Beta;":"\u0392","&Gamma;":"\u0393","&Delta;":"\u0394","&Epsilon;":"\u0395","&Zeta;":"\u0396","&Eta;":"\u0397","&Theta;":"\u0398","&Iota;":"\u0399","&Kappa;":"\u039A","&Lambda;":"\u039B","&Mu;":"\u039C","&Nu;":"\u039D","&Xi;":"\u039E","&Omicron;":"\u039F","&Pi;":"\u03A0","&Rho;":"\u03A1","&Sigma;":"\u03A3","&Tau;":"\u03A4","&Upsilon;":"\u03A5","&Phi;":"\u03A6","&Chi;":"\u03A7","&Psi;":"\u03A8","&Omega;":"\u03A9","&Agrave;":"\xC0","&Aacute;":"\xC1","&Acirc;":"\xC2","&Atilde;":"\xC3","&Auml;":"\xC4","&Aring;":"\xC5","&AElig;":"\xC6","&Ccedil;":"\xC7","&Egrave;":"\xC8","&Eacute;":"\xC9","&Ecirc;":"\xCA","&Euml;":"\xCB","&Igrave;":"\xCC","&Iacute;":"\xCD","&Icirc;":"\xCE","&Iuml;":"\xCF","&ETH;":"\xD0","&Ntilde;":"\xD1","&Ograve;":"\xD2","&Oacute;":"\xD3","&Ocirc;":"\xD4","&Otilde;":"\xD5","&Ouml;":"\xD6","&Oslash;":"\xD8","&Ugrave;":"\xD9","&Uacute;":"\xDA","&Ucirc;":"\xDB","&Uuml;":"\xDC","&Yacute;":"\xDD","&THORN;":"\xDE","&szlig;":"\xDF","&agrave;":"\xE0","&aacute;":"\xE1","&acirc;":"\xE2","&atilde;":"\xE3","&auml;":"\xE4","&aring;":"\xE5","&aelig;":"\xE6","&ccedil;":"\xE7","&egrave;":"\xE8","&eacute;":"\xE9","&ecirc;":"\xEA","&euml;":"\xEB","&igrave;":"\xEC","&iacute;":"\xED","&icirc;":"\xEE","&iuml;":"\xEF","&eth;":"\xF0","&ntilde;":"\xF1","&ograve;":"\xF2","&oacute;":"\xF3","&ocirc;":"\xF4","&otilde;":"\xF5","&ouml;":"\xF6","&oslash;":"\xF8","&ugrave;":"\xF9","&uacute;":"\xFA","&ucirc;":"\xFB","&uuml;":"\xFC","&yacute;":"\xFD","&thorn;":"\xFE","&yuml;":"\xFF","&iexcl;":"\xA1","&iquest;":"\xBF","&fnof;":"\u0192","&circ;":"\u02C6","&tilde;":"\u02DC","&OElig;":"\u0152","&oelig;":"\u0153","&Scaron;":"\u0160","&scaron;":"\u0161","&Yuml;":"\u0178","&ordf;":"\xAA","&ordm;":"\xBA","&macr;":"\xAF","&acute;":"\xB4","&cedil;":"\xB8","&sup1;":"\xB9","&sup2;":"\xB2","&sup3;":"\xB3","&frac14;":"\xBC","&frac12;":"\xBD","&frac34;":"\xBE","&spades;":"\u2660","&clubs;":"\u2663","&hearts;":"\u2665","&diams;":"\u2666","&loz;":"\u25CA","&oline;":"\u203E","&frasl;":"\u2044","&weierp;":"\u2118","&image;":"\u2111","&real;":"\u211C","&alefsym;":"\u2135"};new RegExp(Object.keys(jd).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"g");var Um=(e,t)=>{if(vr(t))return t;if(Ci(t)&&vr(t.defaultValue))return t.defaultValue;if(typeof e=="function")return "";if(Array.isArray(e)){let r=e[e.length-1];return typeof r=="function"?"":r}return e},zm={t:Um,ready:false},Hm=()=>()=>{},H=(e,t={})=>{let{i18n:r}=t,{i18n:o,defaultNS:a}=useContext(ao)||{},n=r||o||br();n&&!n.reportNamespaces&&(n.reportNamespaces=new ls),n||oo(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");let i=useMemo(()=>({...Ja(),...n?.options?.react,...t}),[n,t]),{useSuspense:s,keyPrefix:l}=i,d=a||n?.options?.defaultNS,c=vr(d)?[d]:d||["translation"],u=useMemo(()=>c,c);n?.reportNamespaces?.addUsedNamespaces?.(u);let p=useRef(0),f=useCallback(b=>{if(!n)return Hm;let{bindI18n:w,bindI18nStore:D}=i,F=()=>{p.current+=1,b();};return w&&n.on(w,F),D&&n.store.on(D,F),()=>{w&&w.split(" ").forEach(E=>n.off(E,F)),D&&D.split(" ").forEach(E=>n.store.off(E,F));}},[n,i]),m=useRef(),y=useCallback(()=>{if(!n)return zm;let b=!!(n.isInitialized||n.initializedStoreOnce)&&u.every(M=>Od(M,n,i)),w=t.lng||n.language,D=p.current,F=m.current;if(F&&F.ready===b&&F.lng===w&&F.keyPrefix===l&&F.revision===D)return F;let R={t:n.getFixedT(w,i.nsMode==="fallback"?u:u[0],l,{scopeNs:u}),ready:b,lng:w,keyPrefix:l,revision:D};return m.current=R,R},[n,u,l,i,t.lng]),[v,x]=useState(0),{t:h,ready:S}=useSyncExternalStore(f,y,y);useEffect(()=>{if(n&&!S&&!s){let b=()=>x(w=>w+1);t.lng?Ni(n,t.lng,u,b):as(n,u,b);}},[n,t.lng,u,S,s,v]);let N=n||{},V=useRef(null),P=useRef(),k=b=>{let w=Object.getOwnPropertyDescriptors(b);w.__original&&delete w.__original;let D=Object.create(Object.getPrototypeOf(b),w);if(!Object.prototype.hasOwnProperty.call(D,"__original"))try{Object.defineProperty(D,"__original",{value:b,writable:!1,enumerable:!1,configurable:!1});}catch{}return D},g=useMemo(()=>{let b=N,w=b?.language,D=b;b&&(V.current&&V.current.__original===b?P.current!==w?(D=k(b),V.current=D,P.current=w):D=V.current:(D=k(b),V.current=D,P.current=w));let F=!S&&!s?(...R)=>(oo(n,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),h(...R)):h,E=[F,D,S];return E.t=F,E.i18n=D,E.ready=S,E},[h,N,S,N.resolvedLanguage,N.language,N.languages]);if(n&&s&&!S)throw new Promise(b=>{let w=()=>b();t.lng?Ni(n,t.lng,u,w):as(n,u,w);});return g};var{slice:Wm,forEach:qm}=[];function Jm(e){return qm.call(Wm.call(arguments,1),t=>{if(t)for(let r in t)e[r]===void 0&&(e[r]=t[r]);}),e}function Xm(e){return typeof e!="string"?false:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(e))}var Gd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ym=function(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(t),n=`${e}=${a}`;if(o.maxAge>0){let i=o.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");n+=`; Max-Age=${Math.floor(i)}`;}if(o.domain){if(!Gd.test(o.domain))throw new TypeError("option domain is invalid");n+=`; Domain=${o.domain}`;}if(o.path){if(!Gd.test(o.path))throw new TypeError("option path is invalid");n+=`; Path=${o.path}`;}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");n+=`; Expires=${o.expires.toUTCString()}`;}if(o.httpOnly&&(n+="; HttpOnly"),o.secure&&(n+="; Secure"),o.sameSite)switch(typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite){case true:n+="; SameSite=Strict";break;case "lax":n+="; SameSite=Lax";break;case "strict":n+="; SameSite=Strict";break;case "none":n+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o.partitioned&&(n+="; Partitioned"),n},Wd={create(e,t,r,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+r*60*1e3)),o&&(a.domain=o),document.cookie=Ym(e,t,a);},read(e){let t=`${e}=`,r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},remove(e,t){this.create(e,"",-1,t);}},Qm={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<"u")return Wd.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:r,cookieMinutes:o,cookieDomain:a,cookieOptions:n}=t;r&&typeof document<"u"&&Wd.create(r,e,o,a,n);}},Zm={name:"querystring",lookup(e){let{lookupQuerystring:t}=e,r;if(typeof window<"u"){let{search:o}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(o=window.location.hash.substring(window.location.hash.indexOf("?")));let n=o.substring(1).split("&");for(let i=0;i<n.length;i++){let s=n[i].indexOf("=");s>0&&n[i].substring(0,s)===t&&(r=n[i].substring(s+1));}}return r}},ef={name:"hash",lookup(e){let{lookupHash:t,lookupFromHashIndex:r}=e,o;if(typeof window<"u"){let{hash:a}=window.location;if(a&&a.length>2){let n=a.substring(1);if(t){let i=n.split("&");for(let s=0;s<i.length;s++){let l=i[s].indexOf("=");l>0&&i[s].substring(0,l)===t&&(o=i[s].substring(l+1));}}if(o)return o;if(!o&&r>-1){let i=a.match(/\/([a-zA-Z-]*)/g);return Array.isArray(i)?i[typeof r=="number"?r:0]?.replace("/",""):void 0}}}return o}},sa=null,qd=()=>{if(sa!==null)return sa;try{if(sa=typeof window<"u"&&window.localStorage!==null,!sa)return !1;let e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e);}catch{sa=false;}return sa},tf={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&qd())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:r}=t;r&&qd()&&window.localStorage.setItem(r,e);}},ia=null,Jd=()=>{if(ia!==null)return ia;try{if(ia=typeof window<"u"&&window.sessionStorage!==null,!ia)return !1;let e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e);}catch{ia=false;}return ia},rf={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&Jd())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:r}=t;r&&Jd()&&window.sessionStorage.setItem(r,e);}},of={name:"navigator",lookup(e){let t=[];if(typeof navigator<"u"){let{languages:r,userLanguage:o,language:a}=navigator;if(r)for(let n=0;n<r.length;n++)t.push(r[n]);o&&t.push(o),a&&t.push(a);}return t.length>0?t:void 0}},af={name:"htmlTag",lookup(e){let{htmlTag:t}=e,r,o=t||(typeof document<"u"?document.documentElement:null);return o&&typeof o.getAttribute=="function"&&(r=o.getAttribute("lang")),r}},nf={name:"path",lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>"u")return;let r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?r[typeof t=="number"?t:0]?.replace("/",""):void 0}},sf={name:"subdomain",lookup(e){let{lookupFromSubdomainIndex:t}=e,r=typeof t=="number"?t+1:1,o=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(o)return o[r]}},Xd=false;try{document.cookie,Xd=!0;}catch{}var Yd=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Xd||Yd.splice(1,1);var lf=()=>({order:Yd,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),Xa=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,r);}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Jm(r,this.options||{},lf()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(Qm),this.addDetector(Zm),this.addDetector(tf),this.addDetector(rf),this.addDetector(of),this.addDetector(af),this.addDetector(nf),this.addDetector(sf),this.addDetector(ef);}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return t.forEach(o=>{if(this.detectors[o]){let a=this.detectors[o].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(r=r.concat(a));}}),r=r.filter(o=>o!=null&&!Xm(o)).map(o=>this.options.convertDetectedLanguage(o)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(o=>{this.detectors[o]&&this.detectors[o].cacheUserLanguage(t,this.options);}));}};Xa.type="languageDetector";var Qd={actions:{cancel:"Cancel",create:"Create {{item}}",delete:"Delete",deleteDocument:"Delete Document",deleteEntry:"Delete Entry",deleting:"Deleting...",duplicateDocument:"Duplicate Document",duplicating:"Duplicating...",edit:"Edit",new:"New",newDocument:"New Document",signOut:"Sign Out",view:"View"},common:{na:"N/A",no:"No",yes:"Yes"},dashboard:{activeUsers:"Active Users",authService:"Auth Service",cloudApi:"Cloud API",contentGrowth:"Content Growth",contentGrowthDesc:"Snapshot of document velocity over the last 7 days",dbNode:"Database Node",description:"Everything looks great in your command center today.",mediaAssets:"Media Assets",mediaCdn:"Media CDN",mediaLibrary:"Media Library",mediaLibraryDesc:"Manage high-fidelity assets with our liquid masonry gallery.",newAction:"New {{item}}",noCollections:"No collections available for creation.",openAssets:"Open Assets",quickLinks:"Quick Links",recentActivity:"Recent Activity",statusActive:"Active",statusHealthy:"Healthy",statusOptimal:"Optimal",statusSecure:"Secure",systemHealth:"System Health",systemStatus:"System Status",totalContent:"Total Content",viewAuditLogs:"View Audit Logs",welcome:"Welcome back, {{name}}"},days:{fri:"Fri",mon:"Mon",sat:"Sat",sun:"Sun",thu:"Thu",tue:"Tue",wed:"Wed"},detailView:{collections:"Collections",coreConfiguration:"Core Configuration",dateCreated:"Date Created",deleteMessage:"This action cannot be undone.",deleteTitle:"Delete {{label}}?",dynamicStatus:"Dynamic Status",generatingPreview:"Generating preview URL...",globals:"Globals",justNow:"Just now",lastModified:"Last Modified",metadata:"Metadata",newDocument:"New {{label}}",openPreview:"Open Preview in New Tab",publicAt:"Public At",quickLinks:"Quick Links"},listView:{actionsCol:"Actions",addFilter:"Add Filter",advancedFilters:"Advanced Filters",clearAll:"Clear All",columns:"Columns",createdCol:"Created",deleteBulkMessage_one:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkMessage_other:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkTitle:"Delete Documents",deleteMessage:"Are you sure you want to delete this document? This cannot be undone.",deleteSelected:"Delete Selected",deleteTitle:"Delete Document",filters:"Filters",getStartedCreate:"Get started by creating your first {{item}}.",lastModifiedCol:"Last Modified",noDocuments:"No documents found",noFilters:'No filters applied. Click "Add Filter" to create one.',searchPlaceholder:"Search...",selectedCount_one:"{{count}} selected",selectedCount_other:"{{count}} selected",toggleColumns:"Toggle Columns",tryAdjustingFilters:"Try adjusting your filters or search query."},login:{confirmPassword:"Confirm Password",createAccount:"Create Account",createAccountDesc:"Create an account to access the admin",createAdminAccount:"Create Admin Account",creatingAccount:"Creating account...",email:"Email",enterCredentials:"Enter your credentials to access the admin",hasAccount:"Already have an account?",noAccount:"Don't have an account?",password:"Password",setupAdmin:"Set up your admin account to get started",signIn:"Sign In",signInAction:"Sign in",signingIn:"Signing in...",signUp:"Sign up"},nav:{dashboard:"Dashboard",media:"Media",users:"Users",plugins:"Plugins",settings:"Settings",content:"Content",developer:"Developer",resources:"Resources"},sidebar:{darkMode:"Dark Mode",lightMode:"Light Mode"},toast:{accountCreated:"Account created!",connectionFailed:"Connection failed",copyError:"Failed to copy document data",dataCopied:"Document data copied to clipboard",dataPasted:"Document data pasted",draftSaved:"Draft saved",duplicated:"Document duplicated",duplicateError:"Failed to duplicate document",pasteError:"Clipboard does not contain valid document JSON",published:"Published successfully",publishError:"Failed to publish",saveError:"Failed to save changes",unpublished:"Document unpublished",unpublishError:"Failed to unpublish",updated:"Updated",welcomeBack:"Welcome back!"},userMenu:{account:"Account",apiExplorer:"API Explorer",apiKeys:"API Keys",auditLogs:"Audit Logs",developer:"Developer",documentation:"Documentation",getSupport:"Get Support",graphqlPlayground:"GraphQL Playground",permissions:"Permissions",profileSettings:"Profile Settings",resources:"Resources",sessions:"Sessions",webHooks:"Web Hooks"}};var Zd={actions:{cancel:"Annuler",create:"Cr\xE9er {{item}}",delete:"Supprimer",deleteDocument:"Supprimer le document",deleteEntry:"Supprimer l'entr\xE9e",deleting:"Suppression...",duplicateDocument:"Dupliquer le document",duplicating:"Duplication...",edit:"Modifier",new:"Nouveau",newDocument:"Nouveau Document",signOut:"D\xE9connexion",view:"Voir"},common:{na:"N/D",no:"Non",yes:"Oui"},dashboard:{activeUsers:"Utilisateurs Actifs",authService:"Service d'Authentification",cloudApi:"API Cloud",contentGrowth:"Croissance du Contenu",contentGrowthDesc:"Aper\xE7u de la vitesse des documents sur les 7 derniers jours",dbNode:"N\u0153ud de Base de Donn\xE9es",description:"Tout semble parfait dans votre centre de contr\xF4le aujourd'hui.",mediaAssets:"Ressources Multim\xE9dias",mediaCdn:"CDN Multim\xE9dia",mediaLibrary:"M\xE9diath\xE8que",mediaLibraryDesc:"G\xE9rez des ressources haute fid\xE9lit\xE9 avec notre galerie fluide.",newAction:"Nouveau {{item}}",noCollections:"Aucune collection disponible \xE0 cr\xE9er.",openAssets:"Ouvrir les Ressources",quickLinks:"Liens Rapides",recentActivity:"Activit\xE9 R\xE9cente",statusActive:"Actif",statusHealthy:"Sain",statusOptimal:"Optimal",statusSecure:"S\xE9curis\xE9",systemHealth:"Sant\xE9 du Syst\xE8me",systemStatus:"\xC9tat du Syst\xE8me",totalContent:"Contenu Total",viewAuditLogs:"Voir les Journaux d'Audit",welcome:"Bon retour, {{name}}"},days:{fri:"Ven",mon:"Lun",sat:"Sam",sun:"Dim",thu:"Jeu",tue:"Mar",wed:"Mer"},detailView:{collections:"Collections",coreConfiguration:"Configuration Principale",dateCreated:"Date de Cr\xE9ation",deleteMessage:"Cette action est irr\xE9versible.",deleteTitle:"Supprimer {{label}} ?",dynamicStatus:"Statut Dynamique",generatingPreview:"G\xE9n\xE9ration de l'URL d'aper\xE7u...",globals:"Variables Globales",justNow:"\xC0 l'instant",lastModified:"Derni\xE8re Modification",metadata:"M\xE9tadonn\xE9es",newDocument:"Nouveau {{label}}",openPreview:"Ouvrir l'Aper\xE7u",publicAt:"Public \xE0",quickLinks:"Liens Rapides"},listView:{actionsCol:"Actions",addFilter:"Ajouter un Filtre",advancedFilters:"Filtres Avanc\xE9s",clearAll:"Tout Effacer",columns:"Colonnes",createdCol:"Cr\xE9\xE9",deleteBulkMessage_one:"Voulez-vous vraiment supprimer {{count}} document ? C'est irr\xE9versible.",deleteBulkMessage_other:"Voulez-vous vraiment supprimer {{count}} documents ? C'est irr\xE9versible.",deleteBulkTitle:"Supprimer des Documents",deleteMessage:"Voulez-vous vraiment supprimer ce document ? C'est irr\xE9versible.",deleteSelected:"Supprimer la S\xE9lection",deleteTitle:"Supprimer le Document",filters:"Filtres",getStartedCreate:"Commencez par cr\xE9er votre premier {{item}}.",lastModifiedCol:"Derni\xE8re Modification",noDocuments:"Aucun document trouv\xE9",noFilters:'Aucun filtre appliqu\xE9. Cliquez sur "Ajouter un Filtre" pour en cr\xE9er un.',searchPlaceholder:"Rechercher...",selectedCount_one:"{{count}} s\xE9lectionn\xE9",selectedCount_other:"{{count}} s\xE9lectionn\xE9s",toggleColumns:"Afficher/Masquer les Colonnes",tryAdjustingFilters:"Essayez de modifier vos filtres ou votre requ\xEAte de recherche."},login:{confirmPassword:"Confirmer le Mot de Passe",createAccount:"Cr\xE9er un Compte",createAccountDesc:"Cr\xE9ez un compte pour acc\xE9der \xE0 l'administration",createAdminAccount:"Cr\xE9er un Compte Administrateur",creatingAccount:"Cr\xE9ation du compte...",email:"Email",enterCredentials:"Entrez vos identifiants pour acc\xE9der \xE0 l'administration",hasAccount:"Vous avez d\xE9j\xE0 un compte ?",noAccount:"Vous n'avez pas de compte ?",password:"Mot de Passe",setupAdmin:"Configurez votre compte administrateur pour commencer",signIn:"Se Connecter",signInAction:"Se connecter",signingIn:"Connexion...",signUp:"S'inscrire"},nav:{content:"Contenu",dashboard:"Tableau de Bord",developer:"D\xE9veloppeur",media:"M\xE9dias",plugins:"Extensions",resources:"Ressources",settings:"Param\xE8tres",users:"Utilisateurs"},sidebar:{darkMode:"Mode Sombre",lightMode:"Mode Clair"},toast:{accountCreated:"Compte cr\xE9\xE9 !",connectionFailed:"\xC9chec de la connexion",copyError:"\xC9chec de la copie des donn\xE9es",dataCopied:"Donn\xE9es copi\xE9es dans le presse-papiers",dataPasted:"Donn\xE9es coll\xE9es",draftSaved:"Brouillon enregistr\xE9",duplicated:"Document dupliqu\xE9",duplicateError:"\xC9chec de la duplication du document",pasteError:"Le presse-papiers ne contient pas de JSON valide",published:"Publi\xE9 avec succ\xE8s",publishError:"\xC9chec de la publication",saveError:"\xC9chec de l'enregistrement",unpublished:"Document d\xE9publi\xE9",unpublishError:"\xC9chec de la d\xE9publication",updated:"Mise \xE0 jour r\xE9ussie",welcomeBack:"Bon retour !"},userMenu:{account:"Compte",apiExplorer:"Explorateur d'API",apiKeys:"Cl\xE9s d'API",auditLogs:"Journaux d'Audit",developer:"D\xE9veloppeur",documentation:"Documentation",getSupport:"Obtenir de l'Aide",graphqlPlayground:"Playground GraphQL",permissions:"Permissions",profileSettings:"Param\xE8tres du Profil",resources:"Ressources",sessions:"Sessions",webHooks:"Webhooks"}};var ec={actions:{cancel:"Cancelar",create:"Crear {{item}}",delete:"Eliminar",deleteDocument:"Eliminar Documento",deleteEntry:"Eliminar Entrada",deleting:"Eliminando...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Nuevo",newDocument:"Nuevo Documento",signOut:"Cerrar Sesi\xF3n",view:"Ver"},common:{na:"N/D",no:"No",yes:"S\xED"},dashboard:{activeUsers:"Usuarios Activos",authService:"Servicio de Autenticaci\xF3n",cloudApi:"API en la Nube",contentGrowth:"Crecimiento de Contenido",contentGrowthDesc:"Instant\xE1nea de la velocidad de los documentos en los \xFAltimos 7 d\xEDas",dbNode:"Nodo de Base de Datos",description:"Todo se ve genial en tu centro de comando hoy.",mediaAssets:"Recursos Multimedia",mediaCdn:"CDN Multimedia",mediaLibrary:"Biblioteca Multimedia",mediaLibraryDesc:"Administre recursos de alta fidelidad con nuestra galer\xEDa fluida.",newAction:"Nuevo {{item}}",noCollections:"No hay colecciones disponibles para crear.",openAssets:"Abrir Recursos",quickLinks:"Enlaces R\xE1pidos",recentActivity:"Actividad Reciente",statusActive:"Activo",statusHealthy:"Saludable",statusOptimal:"\xD3ptimo",statusSecure:"Seguro",systemHealth:"Salud del Sistema",systemStatus:"Estado del Sistema",totalContent:"Contenido Total",viewAuditLogs:"Ver Registros de Auditor\xEDa",welcome:"Bienvenido, {{name}}"},days:{fri:"Vie",mon:"Lun",sat:"S\xE1b",sun:"Dom",thu:"Jue",tue:"Mar",wed:"Mi\xE9"},detailView:{collections:"Colecciones",coreConfiguration:"Configuraci\xF3n Principal",dateCreated:"Fecha de Creaci\xF3n",deleteMessage:"Esta acci\xF3n no se puede deshacer.",deleteTitle:"\xBFEliminar {{label}}?",dynamicStatus:"Estado Din\xE1mico",generatingPreview:"Generando URL de vista previa...",globals:"Variables Globales",justNow:"Justo ahora",lastModified:"\xDAltima Modificaci\xF3n",metadata:"Metadatos",newDocument:"Nuevo {{label}}",openPreview:"Abrir Vista Previa",publicAt:"P\xFAblico a las",quickLinks:"Enlaces R\xE1pidos"},listView:{actionsCol:"Acciones",addFilter:"A\xF1adir Filtro",advancedFilters:"Filtros Avanzados",clearAll:"Borrar Todo",columns:"Columnas",createdCol:"Creado",deleteBulkMessage_one:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documento? Esto no se puede deshacer.",deleteBulkMessage_other:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documentos? Esto no se puede deshacer.",deleteBulkTitle:"Eliminar Documentos",deleteMessage:"\xBFEst\xE1s seguro de que quieres eliminar este documento? Esto no se puede deshacer.",deleteSelected:"Eliminar Selecci\xF3n",deleteTitle:"Eliminar Documento",filters:"Filtros",getStartedCreate:"Comienza creando tu primer {{item}}.",lastModifiedCol:"\xDAltima Modificaci\xF3n",noDocuments:"No se encontraron documentos",noFilters:'No hay filtros aplicados. Haz clic en "A\xF1adir Filtro" para crear uno.',searchPlaceholder:"Buscar...",selectedCount_one:"{{count}} seleccionado",selectedCount_other:"{{count}} seleccionados",toggleColumns:"Mostrar/Ocultar Columnas",tryAdjustingFilters:"Intenta ajustar tus filtros o consulta de b\xFAsqueda."},login:{confirmPassword:"Confirmar Contrase\xF1a",createAccount:"Crear Cuenta",createAccountDesc:"Crea una cuenta para acceder a la administraci\xF3n",createAdminAccount:"Crear Cuenta de Administrador",creatingAccount:"Creando cuenta...",email:"Correo Electr\xF3nico",enterCredentials:"Ingresa tus credenciales para acceder a la administraci\xF3n",hasAccount:"\xBFYa tienes una cuenta?",noAccount:"\xBFNo tienes una cuenta?",password:"Contrase\xF1a",setupAdmin:"Configura tu cuenta de administrador para empezar",signIn:"Iniciar Sesi\xF3n",signInAction:"Iniciar sesi\xF3n",signingIn:"Iniciando sesi\xF3n...",signUp:"Registrarse"},nav:{content:"Contenido",dashboard:"Panel de Control",developer:"Desarrollador",media:"Multimedia",plugins:"Complementos",resources:"Recursos",settings:"Ajustes",users:"Usuarios"},sidebar:{darkMode:"Modo Oscuro",lightMode:"Modo Claro"},toast:{accountCreated:"\xA1Cuenta creada!",connectionFailed:"Error de conexi\xF3n",copyError:"Error al copiar los datos del documento",dataCopied:"Datos del documento copiados al portapapeles",dataPasted:"Datos del documento pegados",draftSaved:"Borrador guardado",duplicated:"Documento duplicado",duplicateError:"Error al duplicar el documento",pasteError:"El portapapeles no contiene un JSON de documento v\xE1lido",published:"Publicado con \xE9xito",publishError:"Error al publicar",saveError:"Error al guardar los cambios",unpublished:"Documento despublicado",unpublishError:"Error al despublicar",updated:"Actualizado",welcomeBack:"\xA1Bienvenido de nuevo!"},userMenu:{account:"Cuenta",apiExplorer:"Explorador de API",apiKeys:"Claves de API",auditLogs:"Registros de Auditor\xEDa",developer:"Desarrollador",documentation:"Documentaci\xF3n",getSupport:"Obtener Soporte",graphqlPlayground:"Playground de GraphQL",permissions:"Permisos",profileSettings:"Ajustes de Perfil",resources:"Recursos",sessions:"Sesiones",webHooks:"Webhooks"}};var tc={actions:{cancel:"Abbrechen",create:"{{item}} Erstellen",delete:"L\xF6schen",deleteDocument:"Dokument L\xF6schen",deleteEntry:"Eintrag L\xF6schen",deleting:"Wird gel\xF6scht...",duplicateDocument:"Dokument Duplizieren",duplicating:"Wird dupliziert...",edit:"Bearbeiten",new:"Neu",newDocument:"Neues Dokument",signOut:"Abmelden",view:"Ansehen"},common:{na:"k.A.",no:"Nein",yes:"Ja"},dashboard:{activeUsers:"Aktive Benutzer",authService:"Authentifizierungsdienst",cloudApi:"Cloud API",contentGrowth:"Inhaltswachstum",contentGrowthDesc:"\xDCbersicht der Dokumentgeschwindigkeit in den letzten 7 Tagen",dbNode:"Datenbankknoten",description:"Alles sieht in Ihrer Kommandozentrale heute gro\xDFartig aus.",mediaAssets:"Medieninhalte",mediaCdn:"Medien CDN",mediaLibrary:"Mediathek",mediaLibraryDesc:"Verwalten Sie hochaufl\xF6sende Assets mit unserer fl\xFCssigen Galerie.",newAction:"Neues {{item}}",noCollections:"Keine Sammlungen zur Erstellung verf\xFCgbar.",openAssets:"Assets \xD6ffnen",quickLinks:"Schnellzugriff",recentActivity:"Letzte Aktivit\xE4ten",statusActive:"Aktiv",statusHealthy:"Gesund",statusOptimal:"Optimal",statusSecure:"Sicher",systemHealth:"Systemgesundheit",systemStatus:"Systemstatus",totalContent:"Gesamter Inhalt",viewAuditLogs:"Audit-Protokolle ansehen",welcome:"Willkommen zur\xFCck, {{name}}"},days:{fri:"Fr",mon:"Mo",sat:"Sa",sun:"So",thu:"Do",tue:"Di",wed:"Mi"},detailView:{collections:"Sammlungen",coreConfiguration:"Kernkonfiguration",dateCreated:"Erstellungsdatum",deleteMessage:"Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteTitle:"{{label}} l\xF6schen?",dynamicStatus:"Dynamischer Status",generatingPreview:"Vorschau-URL wird generiert...",globals:"Globale Variablen",justNow:"Gerade eben",lastModified:"Zuletzt Ge\xE4ndert",metadata:"Metadaten",newDocument:"Neues {{label}}",openPreview:"Vorschau in neuem Tab \xF6ffnen",publicAt:"\xD6ffentlich um",quickLinks:"Schnellzugriff"},listView:{actionsCol:"Aktionen",addFilter:"Filter hinzuf\xFCgen",advancedFilters:"Erweiterte Filter",clearAll:"Alles l\xF6schen",columns:"Spalten",createdCol:"Erstellt",deleteBulkMessage_one:"Sind Sie sicher, dass Sie {{count}} Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkMessage_other:"Sind Sie sicher, dass Sie {{count}} Dokumente l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkTitle:"Dokumente L\xF6schen",deleteMessage:"Sind Sie sicher, dass Sie dieses Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteSelected:"Auswahl l\xF6schen",deleteTitle:"Dokument l\xF6schen",filters:"Filter",getStartedCreate:"Beginnen Sie mit der Erstellung Ihres ersten {{item}}.",lastModifiedCol:"Zuletzt Ge\xE4ndert",noDocuments:"Keine Dokumente gefunden",noFilters:'Keine Filter angewendet. Klicken Sie auf "Filter hinzuf\xFCgen", um einen zu erstellen.',searchPlaceholder:"Suchen...",selectedCount_one:"{{count}} ausgew\xE4hlt",selectedCount_other:"{{count}} ausgew\xE4hlt",toggleColumns:"Spalten umschalten",tryAdjustingFilters:"Versuchen Sie, Ihre Filter oder die Suchanfrage anzupassen."},login:{confirmPassword:"Passwort best\xE4tigen",createAccount:"Konto erstellen",createAccountDesc:"Erstellen Sie ein Konto, um auf die Verwaltung zuzugreifen",createAdminAccount:"Admin-Konto erstellen",creatingAccount:"Konto wird erstellt...",email:"E-Mail",enterCredentials:"Geben Sie Ihre Anmeldedaten ein, um auf die Verwaltung zuzugreifen",hasAccount:"Haben Sie bereits ein Konto?",noAccount:"Sie haben noch kein Konto?",password:"Passwort",setupAdmin:"Richten Sie Ihr Admin-Konto ein, um loszulegen",signIn:"Anmelden",signInAction:"Anmelden",signingIn:"Wird angemeldet...",signUp:"Registrieren"},nav:{content:"Inhalt",dashboard:"Dashboard",developer:"Entwickler",media:"Medien",plugins:"Plugins",resources:"Ressourcen",settings:"Einstellungen",users:"Benutzer"},sidebar:{darkMode:"Dunkler Modus",lightMode:"Heller Modus"},toast:{accountCreated:"Konto erstellt!",connectionFailed:"Verbindung fehlgeschlagen",copyError:"Fehler beim Kopieren der Dokumentdaten",dataCopied:"Dokumentdaten in die Zwischenablage kopiert",dataPasted:"Dokumentdaten eingef\xFCgt",draftSaved:"Entwurf gespeichert",duplicated:"Dokument dupliziert",duplicateError:"Fehler beim Duplizieren des Dokuments",pasteError:"Die Zwischenablage enth\xE4lt kein g\xFCltiges Dokument-JSON",published:"Erfolgreich ver\xF6ffentlicht",publishError:"Fehler beim Ver\xF6ffentlichen",saveError:"Fehler beim Speichern der \xC4nderungen",unpublished:"Ver\xF6ffentlichung r\xFCckg\xE4ngig gemacht",unpublishError:"Fehler beim R\xFCckg\xE4ngigmachen der Ver\xF6ffentlichung",updated:"Aktualisiert",welcomeBack:"Willkommen zur\xFCck!"},userMenu:{account:"Konto",apiExplorer:"API Explorer",apiKeys:"API-Schl\xFCssel",auditLogs:"Audit-Protokolle",developer:"Entwickler",documentation:"Dokumentation",getSupport:"Hilfe erhalten",graphqlPlayground:"GraphQL Playground",permissions:"Berechtigungen",profileSettings:"Profileinstellungen",resources:"Ressourcen",sessions:"Sitzungen",webHooks:"Webhooks"}};var rc={actions:{cancel:"Cancelar",create:"Criar {{item}}",delete:"Excluir",deleteDocument:"Excluir Documento",deleteEntry:"Excluir Entrada",deleting:"Excluindo...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Novo",newDocument:"Novo Documento",signOut:"Sair",view:"Ver"},common:{na:"N/A",no:"N\xE3o",yes:"Sim"},dashboard:{activeUsers:"Usu\xE1rios Ativos",authService:"Servi\xE7o de Autentica\xE7\xE3o",cloudApi:"API em Nuvem",contentGrowth:"Crescimento de Conte\xFAdo",contentGrowthDesc:"Vis\xE3o geral da velocidade dos documentos nos \xFAltimos 7 dias",dbNode:"N\xF3 de Banco de Dados",description:"Tudo parece \xF3timo no seu centro de comando hoje.",mediaAssets:"Ativos de M\xEDdia",mediaCdn:"CDN de M\xEDdia",mediaLibrary:"Biblioteca de M\xEDdia",mediaLibraryDesc:"Gerencie ativos de alta fidelidade com nossa galeria fluida.",newAction:"Novo {{item}}",noCollections:"Nenhuma cole\xE7\xE3o dispon\xEDvel para cria\xE7\xE3o.",openAssets:"Abrir Ativos",quickLinks:"Links R\xE1pidos",recentActivity:"Atividade Recente",statusActive:"Ativo",statusHealthy:"Saud\xE1vel",statusOptimal:"Ideal",statusSecure:"Seguro",systemHealth:"Sa\xFAde do Sistema",systemStatus:"Status do Sistema",totalContent:"Conte\xFAdo Total",viewAuditLogs:"Ver Registros de Auditoria",welcome:"Bem-vindo de volta, {{name}}"},days:{fri:"Sex",mon:"Seg",sat:"S\xE1b",sun:"Dom",thu:"Qui",tue:"Ter",wed:"Qua"},detailView:{collections:"Cole\xE7\xF5es",coreConfiguration:"Configura\xE7\xE3o Principal",dateCreated:"Data de Cria\xE7\xE3o",deleteMessage:"Esta a\xE7\xE3o n\xE3o pode ser desfeita.",deleteTitle:"Excluir {{label}}?",dynamicStatus:"Status Din\xE2mico",generatingPreview:"Gerando URL de visualiza\xE7\xE3o...",globals:"Vari\xE1veis Globais",justNow:"Agora mesmo",lastModified:"\xDAltima Modifica\xE7\xE3o",metadata:"Metadados",newDocument:"Novo {{label}}",openPreview:"Abrir Visualiza\xE7\xE3o em Nova Guia",publicAt:"P\xFAblico \xE0s",quickLinks:"Links R\xE1pidos"},listView:{actionsCol:"A\xE7\xF5es",addFilter:"Adicionar Filtro",advancedFilters:"Filtros Avan\xE7ados",clearAll:"Limpar Tudo",columns:"Colunas",createdCol:"Criado",deleteBulkMessage_one:"Tem certeza de que deseja excluir {{count}} documento? Isso n\xE3o pode ser desfeito.",deleteBulkMessage_other:"Tem certeza de que deseja excluir {{count}} documentos? Isso n\xE3o pode ser desfeito.",deleteBulkTitle:"Excluir Documentos",deleteMessage:"Tem certeza de que deseja excluir este documento? Isso n\xE3o pode ser desfeito.",deleteSelected:"Excluir Selecionados",deleteTitle:"Excluir Documento",filters:"Filtros",getStartedCreate:"Comece criando seu primeiro {{item}}.",lastModifiedCol:"\xDAltima Modifica\xE7\xE3o",noDocuments:"Nenhum documento encontrado",noFilters:'Nenhum filtro aplicado. Clique em "Adicionar Filtro" para criar um.',searchPlaceholder:"Pesquisar...",selectedCount_one:"{{count}} selecionado",selectedCount_other:"{{count}} selecionados",toggleColumns:"Alternar Colunas",tryAdjustingFilters:"Tente ajustar seus filtros ou a consulta de pesquisa."},login:{confirmPassword:"Confirmar Senha",createAccount:"Criar Conta",createAccountDesc:"Crie uma conta para acessar a administra\xE7\xE3o",createAdminAccount:"Criar Conta de Administrador",creatingAccount:"Criando conta...",email:"E-mail",enterCredentials:"Insira suas credenciais para acessar a administra\xE7\xE3o",hasAccount:"J\xE1 tem uma conta?",noAccount:"N\xE3o tem uma conta?",password:"Senha",setupAdmin:"Configure sua conta de administrador para come\xE7ar",signIn:"Entrar",signInAction:"Entrar",signingIn:"Entrando...",signUp:"Inscrever-se"},nav:{content:"Conte\xFAdo",dashboard:"Painel de Controle",developer:"Desenvolvedor",media:"M\xEDdia",plugins:"Plugins",resources:"Recursos",settings:"Configura\xE7\xF5es",users:"Usu\xE1rios"},sidebar:{darkMode:"Modo Escuro",lightMode:"Modo Claro"},toast:{accountCreated:"Conta criada!",connectionFailed:"Falha na conex\xE3o",copyError:"Falha ao copiar os dados do documento",dataCopied:"Dados do documento copiados para a \xE1rea de transfer\xEAncia",dataPasted:"Dados do documento colados",draftSaved:"Rascunho salvo",duplicated:"Documento duplicado",duplicateError:"Falha ao duplicar documento",pasteError:"A \xE1rea de transfer\xEAncia n\xE3o cont\xE9m um JSON de documento v\xE1lido",published:"Publicado com sucesso",publishError:"Falha ao publicar",saveError:"Falha ao salvar as altera\xE7\xF5es",unpublished:"Documento despublicado",unpublishError:"Falha ao despublicar",updated:"Atualizado",welcomeBack:"Bem-vindo de volta!"},userMenu:{account:"Conta",apiExplorer:"Explorador de API",apiKeys:"Chaves de API",auditLogs:"Registros de Auditoria",developer:"Desenvolvedor",documentation:"Documenta\xE7\xE3o",getSupport:"Obter Suporte",graphqlPlayground:"Playground GraphQL",permissions:"Permiss\xF5es",profileSettings:"Configura\xE7\xF5es de Perfil",resources:"Recursos",sessions:"Sess\xF5es",webHooks:"Webhooks"}};var ff={en:{translation:Qd},fr:{translation:Zd},es:{translation:ec},de:{translation:tc},pt:{translation:rc}},oc=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";Bt.use(Xa).use(is).init({resources:ff,fallbackLng:oc,lng:oc,interpolation:{escapeValue:false}});function Io(e,t,r){return r in t?t[r]:Di(e,t,r)}function Di(e,t,r){for(let o of e)if(o.name){if(o.type==="tabs"&&"tabs"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.tabs?.flatMap(i=>i.fields||[])||[],a,r);if(n!==void 0)return n}}if((o.type==="group"||o.type==="collapsible")&&"fields"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.fields||[],a,r);if(n!==void 0)return n}}}}function Fi({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:i}){let{t:s}=H(),l=t||e.slug,{permissions:d}=Zr(),c=d?.collections?.[l]?.create!==false,u=d?.collections?.[l]?.delete!==false,p=d?.collections?.[l]?.update!==false,f=()=>{if(c)if(a)a();else {let $=`${_e}/${l}/new`;Lt($);}},m=$=>{if(n)n($);else {let ne=`${_e}/${l}/${$}`;Lt(ne);}},[y,v]=useState(r),[x,h]=useState(o),[S,N]=useState(false),[V,P]=useState(1),[k,g]=useState(10),[b,w]=useState(new Set),[D,F]=useState(""),[E,R]=useState(""),[M,z]=useState([]);useEffect(()=>{let $=setTimeout(()=>{R(D),P(1);},300);return ()=>clearTimeout($)},[D]);let{confirm:I,alert:J}=vt(),Z=()=>{z([...M,{field:"",operator:"equals",value:""}]);},te=()=>{F(""),z([]),he(null);},Y=$=>{z(M.filter((ne,pe)=>pe!==$));},ae=($,ne)=>{z(M.map((pe,Ht)=>Ht===$?{...pe,...ne}:pe));},[ue,he]=useState(null),[U,K]=useState(false),[_,xe]=useState(false);function Be($){let ne=[];for(let pe of $||[])if(!(pe.hidden===true||pe.admin?.hidden||pe.name==="id"))if(pe.type==="tabs"&&pe.tabs)for(let Ht of pe.tabs)Ht.fields&&ne.push(...Be(Ht.fields));else if((pe.type==="row"||pe.type==="collapsible")&&pe.fields)ne.push(...Be(pe.fields));else {if(!pe.name)continue;ne.push(pe);}return ne}let we=useMemo(()=>Be(e.fields),[e.fields]),C=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:we.find($=>$.type!=="group"&&typeof $.name=="string")?.name,[G,Ne]=useState(()=>{let $;return e.admin?.defaultColumns?$=[...e.admin?.defaultColumns||[]]:$=we.slice(0,4).map(ne=>ne.name).filter(ne=>!!ne),C&&$.includes(C)&&($=[C,...$.filter(ne=>ne!==C)]),$.includes("updatedAt")||$.push("updatedAt"),new Set($)}),Oe=useCallback($=>{Ne(ne=>{let pe=new Set(ne);return pe.has($)?pe.delete($):pe.add($),pe});},[]);function Ve($){let ne=we.find(pe=>pe.name===$);return ne&&ne.type==="group"&&ne.fields?.[0]?.name?`${$}.${ne.fields[0].name}`:$}let Fe=useCallback($=>{let ne=Ve($);he(pe=>pe&&pe.field===ne?{field:ne,direction:pe.direction==="asc"?"desc":"asc"}:{field:ne,direction:"asc"});},[]),mt=useMemo(()=>{let $=[];for(let ne of Array.from(G))if(ne==="status")$.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let pe=we.find(Ht=>Ht.name===ne);pe&&pe.name&&$.push(pe);}return $},[we,G]);function Cr($){return !$.name||!C?false:$.name===C||$.type==="group"&&$.fields?.[0]?.name===C}function oe($,ne){return ne.name?Io(e.fields,$,ne.name)??null:null}let O=useCallback(async()=>{N(true);try{let $=new URLSearchParams({page:V.toString(),limit:k.toString(),depth:"1"});E&&$.append("search",E),ue&&$.append("sort",ue.field),ue&&$.append("order",ue.direction),M.length>0&&$.append("filters",JSON.stringify(M));let ne=await Me(eo(`/api/${l}?${$}`),{autoToast:!1});v(ne.docs||[]),h(ne.totalDocs||0);}catch($){console.error("Failed to load docs:",$);}finally{N(false);}},[l,V,k,E,ue,M]);useEffect(()=>{y.length===0&&o===0&&O();},[]);let X$1=useRef(true);useEffect(()=>{if(X$1.current){X$1.current=false;return}O();},[V,k,E,ue,M]);let de=()=>{b.size===y.length?w(new Set):w(new Set(y.map($=>$.id)));},Ie=$=>{let ne=new Set(b);ne.has($)?ne.delete($):ne.add($),w(ne);},ze=()=>{I({title:s("listView.deleteBulkTitle",{defaultValue:"Delete Documents"}),message:s("listView.deleteBulkMessage",{defaultValue:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",count:b.size}),variant:"danger",onConfirm:async()=>{try{for(let $ of Array.from(b))await Dt(`/api/${l}/${$}`);w(new Set),O(),j.success("Documents deleted");}catch($){console.error("Bulk delete failed:",$),j.error("Failed to delete some documents");}}});},Tt=$=>{I({title:s("listView.deleteTitle",{defaultValue:"Delete Document"}),message:s("listView.deleteMessage",{defaultValue:"Are you sure you want to delete this document? This cannot be undone."}),variant:"danger",onConfirm:async()=>{try{await Dt(`/api/${l}/${$}`),O(),j.success("Document deleted");}catch(ne){console.error("Delete failed:",ne),j.error("Failed to delete document");}}});},gr=Math.ceil(x/k),Or=D||M.length>0||ue;return jsxs("div",{className:"space-y-6",children:[jsx(jt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:x>0?[jsxs("span",{className:"text-xs font-bold opacity-60",children:[x," documents"]},"count")]:void 0,action:c?{label:s("actions.create",{defaultValue:"Create {{item}}",item:e.singularLabel||e.label||l}),href:a?void 0:`${_e}/${l}/new`,onClick:a?f:void 0,icon:Plus}:void 0}),jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",placeholder:s("listView.searchPlaceholder",{defaultValue:"Search..."}),value:D,onChange:$=>F($.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxs("button",{type:"button",onClick:()=>K(!U),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${U||M.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(Filter,{className:"w-4 h-4"}),s("listView.filters",{defaultValue:"Filters"}),M.length>0&&jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[var(--kyro-sidebar-text-active)] text-[var(--kyro-sidebar-active)] rounded-full text-xs",children:M.length})]}),jsxs("div",{className:"relative",children:[jsxs("button",{type:"button",onClick:()=>xe(!_),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsx(Columns3,{className:"w-4 h-4"}),s("listView.columns",{defaultValue:"Columns"})]}),_&&jsxs("div",{className:"absolute right-0 top-full mt-2 w-56 surface-tile border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 overflow-hidden",children:[jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:s("listView.toggleColumns",{defaultValue:"Toggle Columns"})})}),jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:we.map($=>$.name?jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsx("input",{type:"checkbox",checked:G.has($.name),onChange:()=>Oe($.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:$.label||$.name})]},$.name):null)})]})]}),Or&&jsx("button",{type:"button",onClick:te,className:"px-4 py-2 rounded-xl font-bold text-sm text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 transition-all",children:s("listView.clearAll",{defaultValue:"Clear All"})})]})]}),U&&jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:s("listView.advancedFilters",{defaultValue:"Advanced Filters"})}),jsxs("button",{type:"button",onClick:Z,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsx(Plus,{className:"w-4 h-4"}),s("listView.addFilter",{defaultValue:"Add Filter"})]})]}),jsxs("div",{className:"space-y-3",children:[M.map(($,ne)=>jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsx("select",{value:$.field,onChange:pe=>ae(ne,{field:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:we.map(pe=>jsx("option",{value:pe.name,children:pe.label||pe.name},pe.name))}),jsxs("select",{value:$.operator,onChange:pe=>ae(ne,{operator:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsx("option",{value:"equals",children:"Equals"}),jsx("option",{value:"contains",children:"Contains"}),jsx("option",{value:"gt",children:"Greater than"}),jsx("option",{value:"lt",children:"Less than"}),jsx("option",{value:"gte",children:"Greater or equal"}),jsx("option",{value:"lte",children:"Less or equal"})]}),jsx("input",{type:"text",value:$.value,onChange:pe=>ae(ne,{value:pe.target.value}),placeholder:s("fields.value",{defaultValue:"Value..."}),className:"flex-1 min-w-[150px] px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]"}),jsx("button",{type:"button",onClick:()=>Y(ne),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsx(X,{className:"w-4 h-4"})})]},ne)),M.length===0&&jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:s("listView.noFilters",{defaultValue:'No filters applied. Click "Add Filter" to create one.'})})]})]}),b.size>0&&jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:s("listView.selectedCount",{defaultValue:"{{count}} selected",count:b.size})}),jsxs("div",{className:"flex gap-2",children:[u&&jsxs("button",{type:"button",onClick:ze,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsx(Trash2,{className:"w-4 h-4"}),s("listView.deleteSelected",{defaultValue:"Delete Selected"})]}),jsx("button",{type:"button",onClick:()=>w(new Set),className:"px-4 py-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] font-bold text-sm transition-all",children:s("actions.cancel",{defaultValue:"Cancel"})})]})]}),jsx("div",{className:"surface-tile overflow-hidden",children:S?jsx("div",{className:"space-y-2 p-4",children:jsx(Wt,{variant:"table-row",count:8})}):y.length===0?jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsx(Archive,{className:"w-4 h-4"})}),jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:s("listView.noDocuments",{defaultValue:"No documents found"})}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Or?s("listView.tryAdjustingFilters",{defaultValue:"Try adjusting your filters or search query."}):s("listView.getStartedCreate",{defaultValue:"Get started by creating your first {{item}}.",item:(e.singularLabel||e.label||l).toLowerCase()})}),!Or&&c&&jsxs("button",{type:"button",onClick:f,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsx(Plus,{className:"w-4 h-4"}),s("actions.create",{defaultValue:"Create {{item}}",item:String(e.singularLabel||e.label||l)})]})]}):jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsx("th",{className:"px-4 py-4 w-10",children:jsx("input",{type:"checkbox",checked:b.size===y.length&&y.length>0,onChange:de,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),mt.map($=>jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Fe($.name),children:jsxs("div",{className:"flex items-center gap-2",children:[vf(mt,$.type)??($.label||$.name),ue&&ue.field===$.name&&jsx(ChevronUp,{className:"w-4 h-4"})]})},$.name)),e.timestamps?jsx("th",{className:"px-4 py-4",children:s("listView.createdCol",{defaultValue:"Created"})}):null,e.timestamps?jsx("th",{className:"px-4 py-4",children:s("listView.lastModifiedCol",{defaultValue:"Last Modified"})}):null,jsx("th",{className:"px-4 py-4 text-right",children:s("listView.actionsCol",{defaultValue:"Actions"})})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:y.map($=>jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>m($.id),children:[jsx("td",{className:"px-4 py-3",onClick:ne=>ne.stopPropagation(),children:jsx("input",{type:"checkbox",checked:b.has($.id),onChange:()=>Ie($.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),mt.map(ne=>{let pe=oe($,ne),Ht=ne.type==="select"&&pe&&Array.isArray(ne.options)?ne.options.find(Wo=>Wo.value===pe)?.label||pe:yf(pe,ne.type,s);return jsx("td",{className:`px-4 py-3 ${Cr(ne)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Ht},ne.name)}),e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.createdAt?new Date($.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.updatedAt?new Date($.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsx("td",{className:"px-4 py-3 text-right",onClick:ne=>ne.stopPropagation(),children:jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>m($.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:p?s("actions.edit",{defaultValue:"Edit"}):s("actions.view",{defaultValue:"View"}),children:jsx(Pencil,{className:"w-4 h-4"})}),u&&jsx("button",{type:"button",onClick:()=>Tt($.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:s("actions.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-4 h-4"})})]})})]},$.id))})]})})}),jsx(kd,{page:V,totalPages:gr,totalDocs:x,limit:k,onPageChange:P,onLimitChange:$=>{g($),P(1);}})]})}function yf(e,t,r){if(e==null)return "\u2014";if(typeof e=="boolean")return e?r?r("common.yes",{defaultValue:"Yes"}):"Yes":r?r("common.no",{defaultValue:"No"}):"No";if(t==="number"||t==="price")return String(e);if(t==="date"||t==="datetime")return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});if(Array.isArray(e))return e.map(o=>{if(o&&typeof o=="object"){let a="value"in o&&typeof o.value=="object"&&o.value!==null?o.value:o,n=a.firstName||a.lastName?`${a.firstName||""} ${a.lastName||""}`.trim():void 0;return a.fullName||n||a.title||a.name||a.label||a.email||a.filename||a.slug||a.id||JSON.stringify(a).slice(0,30)}return String(o??"").slice(0,30)}).filter(Boolean).join(", ");if(typeof e=="object"){let o="value"in e&&typeof e.value=="object"&&e.value!==null?e.value:e,a=o.firstName||o.lastName?`${o.firstName||""} ${o.lastName||""}`.trim():void 0,n=o.fullName||a||o.title||o.name||o.label||o.email||o.filename||o.slug;return n?String(n):o.id?String(o.id):JSON.stringify(o).slice(0,50)}return String(e).slice(0,60)}function vf(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}function Qa(e){return e?Array.isArray(e)?e:Object.values(e):[]}function ps(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function ms(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ya(e,t){let r=new Set(e.map(o=>o.slug));for(let o of t)r.has(o.slug)||(e.push(o),r.add(o.slug));}var hf={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function Lo(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let i of e){if(i.name===a)if(n){if(i.fields&&Array.isArray(i.fields))return Lo(i.fields,n,r);if(i.type==="tabs"&&i.tabs&&Array.isArray(i.tabs)){for(let l of i.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,n,r))return true;return false}if(i.type==="blocks"&&i.blocks&&Array.isArray(i.blocks)){let l=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of i.blocks)if(c.slug===l&&c.fields&&Array.isArray(c.fields))return Lo(c.fields,d,r);return false}return i.type==="array"&&i.fields&&Array.isArray(i.fields)?Lo(i.fields,n,r):false}else return Object.assign(i,r),true;if(!i.name||i.type==="tabs"||i.type==="row"||i.type==="collapsible"){if(i.fields&&Array.isArray(i.fields)&&Lo(i.fields,t,r))return true;if(i.type==="tabs"&&i.tabs&&Array.isArray(i.tabs)){for(let l of i.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,t,r))return true}}}return false}function xf(e,t){for(let[r,o]of Object.entries(e)){let a=hf[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:i,...s}=n;if(o.admin={...o.admin,...s},i&&o.fields&&Array.isArray(o.fields))for(let[l,d]of Object.entries(i))Lo(o.fields,l,d);}}}function kf(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(minimalCollections)),r.push(...coreSettingsGlobals);break;case "starter":t.push(...Object.values(starterCollections)),r.push(...coreSettingsGlobals);break;case "blog":t.push(...Object.values(blogCollections)),r.push(...coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(ecommerceCollections)),r.push(...allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(minimalCollections),...Object.values(starterCollections),...Object.values(blogCollections),...Object.values(ecommerceCollections),...Object.values(kitchenSinkCollections)),r.push(...allSettingsGlobals);break}return Ya(t,Object.values(mediaCollections)),Ya(t,Object.values(authCollections)),{collections:ps(t),globals:ms(r)}}function wf(e){let t=Qa(e.collections),r=Qa(e.globals);if(t.length===0&&r.length===0)return kf("kitchen-sink");let o=[];return Ya(o,Object.values(mediaCollections)),Ya(o,Object.values(authCollections)),Ya(o,t),{collections:ps(o),globals:ms(r)}}function Nf(){return projectConfig?projectConfig:null}var mc=Nf()||{collections:[],globals:[]},fc=wf(mc);xf(fc.collections,mc.collectionOverrides||{});var gc=fc,la=gc.collections,yc=gc.globals,Li=["users","audit_logs"];Object.values(la).filter(e=>!Li.includes(e.slug)&&e.admin?.hidden!==true);function fs({icon:e,title:t,description:r,action:o}){return jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function qt(e,t=false){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>qt(r,false));if(typeof e=="object"){let r=e,o=Object.keys(r),a="id"in r&&(typeof r.id=="string"||r.id===null),n="url"in r&&("filename"in r||"mimeType"in r);if(!t&&a&&n&&o.length<=25)return r.id;if(!t&&"relationTo"in r&&"value"in r&&typeof r.value=="object"&&r.value!==null){let s=r.value;if("id"in s&&(typeof s.id=="string"||typeof s.id=="number"))return {relationTo:r.relationTo,value:s.id}}if(!t&&a&&"createdAt"in r&&"updatedAt"in r)return r.id;let i={};for(let s of o)i[s]=qt(r[s],false);return i}return e}function Eo(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Eo(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id"),o=Object.keys(t).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id");if(r.length!==o.length)return false;for(let a of r)if(!o.includes(a)||!Eo(e[a],t[a]))return false;return true}function Bi(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}var gs=null,vc=false,Mi=async()=>(gs&&vc||(gs=createStorage({driver:Pf({dbName:"kyro-autosave",storeName:"autosave"})}),vc=true),gs),Rf=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Mi()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Mi()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Mi()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ye=create()(persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),i=qt(o),s=qt(a.lastSavedData[r]);Bi(i)&&Bi(s)||Eo(i,s)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),i={...a.formData},s=i;for(let l=0;l<n.length-1;l++){s[n[l]]===void 0&&(s[n[l]]={});let d=s[n[l]];s[n[l]]={...d},s=s[n[l]];}return s[n[n.length-1]]=o,{formData:i}});},setActiveTab:r=>e({activeTab:r}),setIsSlugLocked:r=>e(o=>({isSlugLocked:typeof r=="function"?r(o.isSlugLocked):r})),setView:r=>e({view:r}),setIsDropdownOpen:r=>e(o=>({isDropdownOpen:typeof r=="function"?r(o.isDropdownOpen):r})),setVersions:r=>e({versions:r}),setLoadingVersions:r=>e({loadingVersions:r}),setShowPreview:r=>e(o=>({showPreview:typeof r=="function"?r(o.showPreview):r})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[i,s]of Object.entries(a))o-new Date(s.draftUpdatedAt).getTime()<6048e5&&(n[i]=s);e({draftCache:n});},setDraftCache:(r,o)=>e(a=>({draftCache:{...a.draftCache,[r]:o}})),getDraftCache:r=>t().draftCache[r]||null,clearDraftCache:r=>e(o=>{let a={...o.draftCache};return delete a[r],{draftCache:a}})}),{name:"kyro-autoform-storage",storage:createJSONStorage(()=>Rf()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));var bc="other";function hc(){return bc}function ys(e){bc=e;}function vs(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function kc(){let e=useRef([]),t=useRef(false);return {queueTask:useCallback((o,a)=>{e.current.push(o);async function n(){if(!t.current&&!(typeof a?.beforeProcess=="function"&&a.beforeProcess()===false))for(;e.current.length>0;){let i=e.current.pop();e.current=[],t.current=true;try{i&&await i();}catch(s){console.error("Error in queued function:",s);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function wc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:i,onActionError:s}){let l=ye(),{confirm:d}=vt(),{formData:c,setFormData:u,setField:p,lastSavedData:f,setLastSavedData:m,setHasUnsavedChanges:y,isSlugLocked:v,loadDocument:x,setIsAutoSaving:h,setAutoSaveStatus:S,setVersions:N,setLoadingVersions:V,sidebarCollapsed:P,setSidebarCollapsed:k,getDraftCache:g,setDraftCache:b,clearDraftCache:w,resetForm:D}=l,F=!!e?.versions,E=o||t?.id||a||r,R=useRef(false);!o&&E&&c&&Object.keys(c).length>0&&c.id!==E&&(R.current=true),useEffect(()=>{R.current&&(R.current=false,D());},[D]);let M=useRef(null),z=useRef(null),I=useRef(null),J=useRef(typeof navigator<"u"?navigator.onLine:true),Z=useRef(0),te=useRef(false),Y=useRef(null),ae=useRef(""),ue=useRef(""),{queueTask:he}=kc(),U=useCallback(oe=>o?`global:${o}`:r&&oe?`${r}:${oe}`:null,[r,o]),K=useCallback((oe,O,X)=>{b(oe,{data:O,baseUpdatedAt:f.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:X?.lastSyncedAt??null});},[f.updatedAt,b]),_=useCallback(async()=>{let oe=o?Ye(`/api/globals/${o}/versions`):r&&c.id?Ye(`/api/${r}/${c.id}/versions`):null;if(oe){V(true);try{let X=await(await ct(oe)).json();N(X.docs||[]);}catch(O){console.error("Failed to fetch versions:",O);}finally{V(false);}}},[c.id,r,o,V,N]),xe=useCallback(()=>{let oe=ye.getState(),O=oe.formData;if(te.current||!r||!O.id||!oe.hasDirtyFields())return;let X=U(O.id);X&&K(X,O);},[r,U,K]),Be=useCallback(async oe=>{let O=ye.getState(),X=O.formData,de=O.lastSavedData;if(te.current||!o&&(!r||!X.id)||!O.hasDirtyFields())return;let Ie=U(X.id);if(Ie&&K(Ie,X),!J.current){S("offline");return}h(true),S("saving"),O.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let ze=o?Ye(`/api/globals/${o}?autosave=true`):Ye(`/api/${r}/${X.id}?autosave=true`),Tt=await ct(ze,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:oe?.keepalive,body:JSON.stringify({...qt(X,!0),baseUpdatedAt:de.updatedAt??null})});if(Tt.ok)Z.current=Date.now(),O.setRetryCount(0),O.setLastSavedAt(Date.now()),I.current&&clearTimeout(I.current),Ie&&b(Ie,{data:X,baseUpdatedAt:de.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),S("success"),setTimeout(()=>{ye.getState().autoSaveStatus==="success"&&S("idle");},2e3);else if(Tt.status===409)S("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch(ze){console.error("Auto-save failed:",ze);let Tt=ye.getState(),gr=Tt.retryCount;if(gr<5){Tt.setRetryCount(gr+1),S("retrying");let Or=Math.min(1e3*Math.pow(2,gr),6e4);I.current&&clearTimeout(I.current),I.current=setTimeout(()=>we(oe),Or);}else S("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),h(false),ye.getState().setBackgroundProcessing(false);}},[r,U,o,K,S,b,h,F]),we=useCallback(oe=>{he(()=>Be(oe),{beforeProcess:()=>true,afterProcess:()=>{}});},[Be,he]),C=useCallback(async(oe,O=true)=>{let X=ye.getState(),de=oe||X.formData,Ie=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${de.id}`),ze=await ct(Ie,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(O)},body:JSON.stringify({...qt(de,true),baseUpdatedAt:X.lastSavedData.updatedAt??null})});return ze.status===409&&S("conflict"),ze},[r,o,S]),G=useCallback(async(oe=true)=>{let O=ye.getState(),X=O.formData,de=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${X.id}`),Ie=await ct(de,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(oe)},body:JSON.stringify({...qt(X,true)})});if(Ie.ok){let Tt=(await Ie.json()).data||X;O.loadDocument(Tt,Tt),S("success"),setTimeout(()=>{ye.getState().autoSaveStatus==="success"&&S("idle");},2e3);}return Ie},[r,o,S]);useEffect(()=>{let oe=()=>{k(!P);};return window.addEventListener("toggle-sidebar",oe),()=>window.removeEventListener("toggle-sidebar",oe)},[P,k]);let Ne=useRef(null),Oe=useRef(""),Ve=useRef(false);useEffect(()=>{let oe=o||t?.id,O=JSON.stringify(t);Ve.current&&Ne.current===oe&&Oe.current===O||(x(t||{},t||{}),Ve.current=true,Ne.current=oe,Oe.current=O);},[r,c.id,o,t,x]),useEffect(()=>{if(!r||!t?.id)return;let oe=U(c.id);if(!oe||Y.current===oe)return;let O=false;return (async()=>{if(!F)return;let de=g(oe);if(de){if(JSON.stringify(de.data)===JSON.stringify(t)){w(oe);return}Y.current=oe,d({title:"Restore draft?",message:"A newer autosaved draft was found for this document. Restore it or discard it and continue with the saved version.",confirmLabel:"Restore draft",cancelLabel:"Discard draft",onConfirm:async()=>{if(O)return;let ze={...ye.getState().formData,...de.data};u(ze),i?.("Recovered autosaved draft");},onCancel:async()=>{w(oe);}});}})(),()=>{O=true;}},[w,r,d,U,g,t,i,u,F]);function Fe(oe,O){for(let X of oe){if(X.name===O&&X.admin?.autoGenerate==="title")return X;if(X.type==="tabs"&&"tabs"in X)for(let de of X.tabs){let Ie=Fe(de.fields,O);if(Ie)return Ie}if((X.type==="group"||X.type==="collapsible")&&"fields"in X){let de=Fe(X.fields,O);if(de)return de}}}useEffect(()=>{if(!e?.fields)return;let oe=e.fields;if(!Fe(oe,"metaTitle"))return;let X=Io(oe,c,"title"),de=X?String(X):"";de&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&p("metaTitle",de);},[c,e?.fields,p]),useEffect(()=>{let oe=e?.fields,O=oe?.find(Ie=>Ie.name==="slug"&&Ie.admin?.autoGenerate);if(!O?.admin?.autoGenerate)return;let X=O.admin.autoGenerate,de=Io(oe,c,X);if(v&&typeof de=="string"){let Ie=vs(de);Ie!==c.slug&&p("slug",Ie);}},[c,v,e?.fields,p]),useEffect(()=>{if(P||!o&&(!r||!c.id)||!ye.getState().hasDirtyFields()||hc()!=="keystroke")return;ys("other");let O=JSON.stringify(c);O!==ae.current&&(M.current&&clearTimeout(M.current),M.current=setTimeout(xe,1500),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{ae.current=O,we();},8e3));},[c,P,r,o,xe,we]),useEffect(()=>{if(!o&&(!r||!c.id))return;let oe=()=>{te.current||!ye.getState().hasDirtyFields()||we({keepalive:true});},O=()=>{document.hidden&&oe();},X=()=>{J.current=true,oe();},de=()=>{J.current=false;let Ie=ye.getState();Ie.hasDirtyFields()&&Ie.setAutoSaveStatus("offline");};return window.addEventListener("blur",oe),window.addEventListener("pagehide",oe),window.addEventListener("online",X),window.addEventListener("offline",de),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("blur",oe),window.removeEventListener("pagehide",oe),window.removeEventListener("online",X),window.removeEventListener("offline",de),document.removeEventListener("visibilitychange",O);}},[r,o,c.id,we]),useEffect(()=>{let oe=JSON.stringify(c);if(oe===ue.current)return;ue.current=oe;let O=document.getElementById("form-data");O&&(O.value=oe),n?.(c);},[c,n]),useEffect(()=>{(o||c.id)&&_();},[c.id,o,_]);let mt=!c.id&&!o?"draft":F&&c.status||"published",Cr=(!!c.id||!!o)&&mt==="draft";return {...l,fetchVersions:_,performAutoSave:we,saveDocument:C,forceSave:G,autoSaveSkipRef:te,lastAutoSaveTimeRef:Z,documentStatus:mt,hasUnpublishedChanges:Cr,versionsEnabled:F}}var Za=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:i=false})=>{let{t:s}=H(),[l,d]=useState(false),[c,u]=useState(""),[p,f]=useState([]),[m,y]=useState(false),[v,x]=useState([]),[h,S]=useState(true);useEffect(()=>{Me("/api/collections").then(F=>{x((F.collections||[]).map(E=>E.slug||E.name||E)),S(false);}).catch(()=>S(false));},[]);let N=(F="")=>{y(true);let E=`/api/${e}?${Tn(F,[a],20)}`;Me(E).then(R=>{f(R.docs||[]),y(false);}).catch(()=>y(false));};useEffect(()=>{l&&N(c);},[l,c,e,a]);let V=F=>F?.[a]||F?.title||F?.name||F?.label||F?.filename||F?.slug||F?.id||"Untitled",P=t?r:o?[o]:[],k=F=>{t?P.includes(F.id)?n("selectedIds",P.filter(E=>E!==F.id)):n("selectedIds",[...P,F.id]):(n("selectedId",F.id),n("selectedIds",[F.id]),d(false));},g=F=>P.includes(F),b=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",w=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",D=e&&typeof e=="string"&&e.length>0;return jsxs("div",{className:i?"space-y-2":"space-y-4",children:[jsxs("div",{className:i?"flex items-center gap-2":"space-y-3",children:[!D&&jsx(Fragment,{children:h?jsx("div",{className:w+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxs("select",{value:e,onChange:F=>n("relationTo",F.target.value),className:w,children:[jsx("option",{value:"",children:"Select collection..."}),v.map(F=>jsx("option",{value:F,children:F},F))]})}),!i&&jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:t,onChange:F=>n("hasMany",F.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxs("div",{className:"relative",children:[jsxs("div",{className:"relative",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",value:c,onChange:F=>{u(F.target.value),d(true);},onFocus:()=>d(true),onBlur:()=>setTimeout(()=>d(false),200),placeholder:`Search ${e}...`,className:`${b} pl-9`}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:m&&jsx(LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:m?jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):p.length===0?jsx(fs,{title:s("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:p.map(F=>jsxs("button",{type:"button",onMouseDown:E=>E.preventDefault(),onClick:()=>k(F),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${g(F.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsx("span",{children:V(F)}),g(F.id)&&jsx("span",{children:"\u2713"})]},F.id))})})]}),P.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(F=>{let E=p.find(R=>R.id===F)||{id:F};return jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[V(E),jsx("button",{type:"button",onMouseDown:R=>R.preventDefault(),onClick:()=>{t?n("selectedIds",P.filter(R=>R!==F)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]},F)})})]})};var $i=(e,t)=>{let r=e?.toLowerCase()||"",o=t?.toLowerCase()||"";return r.startsWith("image/")||o.match(/\.(jpe?g|png|gif|webp|avif|svg)$/i)?"image":r.startsWith("video/")||o.match(/\.(mp4|webm|ogg|mov)$/i)?"video":r.startsWith("audio/")||o.match(/\.(mp3|wav|ogg|m4a)$/i)?"audio":r.includes("pdf")||o.endsWith(".pdf")?"pdf":o.match(/\.(doc|docx|txt|rtf|odt)$/i)?"document":o.match(/\.(xls|xlsx|csv)$/i)?"spreadsheet":o.match(/\.(zip|tar|gz|7z|rar)$/i)?"archive":"other"},Tc=({type:e,className:t})=>{switch(e){case "image":return jsx(Image,{className:t});case "video":return jsx(Film,{className:t});case "audio":return jsx(Music,{className:t});case "pdf":case "document":return jsx(FileText,{className:t});default:return jsx(File,{className:t})}};function hr({field:e,value:t,onChange:r,disabled:o}){let a=useRef(null),n=useRef(null),[i,s]=useState(false),[l,d]=useState(false),[c,u]=useState(false),[p,f]=useState([]),[m,y]=useState([]),[v,x]=useState(""),[h,S]=useState(false),[N,V]=useState(""),[P,k]=useState(false),[g,b]=useState(""),[w,D]=useState(""),[F,E]=useState([]),R=e?.label||e?.name||"File",M=e.maxCount??(e.hasMany?999:1),z=M>1,I=Array.isArray(t)?t:t?[t]:[],J=I.length<M,[Z,te]=useState({});useEffect(()=>{(async()=>{let G=I.filter(Fe=>typeof Fe=="string").map(Fe=>Fe),Ne=I.filter(Fe=>typeof Fe=="object"&&Fe!==null&&typeof Fe.id=="string"&&!Fe.url&&!Fe.filename&&!Fe.mimeType).map(Fe=>Fe.id),Ve=[...G,...Ne].filter(Fe=>!Z[Fe]);if(Ve.length!==0)try{let Fe=await Promise.all(Ve.map(mt=>Me(`/api/media/${mt}`)));te(mt=>{let Cr={...mt};return Fe.forEach(oe=>{oe&&oe.id&&(Cr[oe.id]=oe);}),Cr});}catch(Fe){console.error("Failed to fetch media details:",Fe);}})();},[t,Z]),useEffect(()=>{l&&(Y(),ae());},[l,v]);let Y=async()=>{try{let C=await Me(eo("/api/media/folders"));y(C.folders||[]);}catch{y([]);}},ae=async()=>{S(true);try{let C=eo("/api/media?limit=60&sortBy=createdAt&sortDir=desc");v&&(C+="&folder="+encodeURIComponent(v));let G=await Me(C);f(G.docs||[]);}catch{f([]);}finally{S(false);}},ue=async C=>{s(true);try{let G=new FormData;G.append("file",C),v&&G.append("folder",v);let Ne=await Dn("/api/media/upload",G),Oe=Ne.data||Ne.doc||Ne,Ve={...Oe,id:Oe.id,filename:Oe.filename,originalName:Oe.originalName??C.name,url:Oe.url,mimeType:Oe.mimeType||C.type};r(z?[...I,Ve]:Ve),j.success(`Asset synchronized: ${Ve.filename}`);}catch(G){console.error("Upload failed:",G),j.error(`Upload failed: ${G instanceof Error?G.message:"Unknown error"}`);}finally{s(false);}},he=async()=>{let C=g.trim();if(C){D("");try{let G=await ut("/api/media/upload",{url:C}),Ne=(()=>{try{return new URL(C).pathname.split("/").pop()||G.originalName||"url-image"}catch{return G.originalName||"url-image"}})(),Oe={id:G.id,filename:G.filename,originalName:Ne,url:G.url,mimeType:G.mimeType||"image/*"};r(z?[...I,Oe]:Oe),j.success(`URL asset established: ${Oe.filename}`),b(""),k(!1);}catch(G){let Ne=G instanceof Error?G.message:"Invalid URL";D(Ne);}}},U=C=>({id:C.id,filename:C.filename,url:C.url,mimeType:C.mimeType}),K=C=>{z?E(G=>G.find(Oe=>Oe.id===C.id)?G.filter(Oe=>Oe.id!==C.id):[...G,C]):(r(U(C)),d(false),V(""));},_=()=>{if(F.length>0){let C=[...I,...F.map(U)];r(C);}E([]),d(false),V("");},xe=C=>{let G=[...I];G.splice(C,1),r(z?G:G[0]||null);},Be=useMemo(()=>p.filter(C=>!N||C.filename?.toLowerCase().includes(N.toLowerCase())||C.title?.toLowerCase().includes(N.toLowerCase())),[p,N]);if(i)return jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let we=(C,G)=>{if(!C)return null;let Ne=typeof C=="string"?C:C.id,Oe=Z[Ne]||(typeof C=="object"?C:{}),Ve=$i(Oe.mimeType,Oe.filename||Oe.url);return jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] group",children:[jsx("div",{className:"w-10 h-10 rounded-md overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex items-center justify-center flex-shrink-0",children:Ve==="image"?jsx("img",{src:Ua(Oe.url),alt:Oe.filename||"Preview",className:"w-full h-full object-cover"}):jsx(Tc,{type:Ve,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:Oe.originalName||Oe.filename||"Unnamed File"}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:R})]}),jsx("button",{type:"button",onClick:()=>G!==void 0?xe(G):r(null),disabled:o,className:"p-1.5 rounded-md text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)] transition-all opacity-0 group-hover:opacity-100",children:jsx(X,{className:"w-4 h-4"})})]},G)};return jsxs("div",{className:"space-y-2 relative",children:[jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:C=>{let G=C.target.files?.[0];G&&ue(G);},disabled:o,className:"hidden"}),I.length>0&&jsx("div",{className:z?"grid grid-cols-2 gap-2":"space-y-2",children:I.map((C,G)=>we(C,G))}),(!I.length||J)&&jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxs("button",{type:"button",onClick:()=>a.current?.click(),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:["+ Upload ",R]}),jsx("button",{type:"button",onClick:()=>{E([]),d(true);},disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"Library"}),jsx("button",{type:"button",onClick:()=>k(!P),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"URL"})]}),P&&jsxs("div",{className:"flex gap-2 items-center",children:[jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:g,onChange:C=>{b(C.target.value),D("");},onKeyDown:C=>C.key==="Enter"&&he(),disabled:o,className:"flex-1 px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),jsx("button",{type:"button",onClick:he,disabled:o||!g.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),w&&jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:w})]}),l&&(c?createPortal(jsx(Ac,{isFullscreen:true,isMultiple:z,selectedItems:F,pickerSearch:N,setPickerSearch:V,folders:m,selectedFolder:v,setSelectedFolder:x,mediaLoading:h,filteredMedia:Be,selectFromLibrary:K,onDone:_,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsx(Ac,{isFullscreen:false,isMultiple:z,selectedItems:F,pickerSearch:N,setPickerSearch:V,folders:m,selectedFolder:v,setSelectedFolder:x,mediaLoading:h,filteredMedia:Be,selectFromLibrary:K,onDone:_,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Ac({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:i,setSelectedFolder:s,mediaLoading:l,filteredMedia:d,selectFromLibrary:c,onDone:u,setIsPickerFullscreen:p,setShowPicker:f}){let{t:m}=H(),y=v=>r.some(x=>x.id===v);return jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsx("input",{type:"text",placeholder:m("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:v=>a(v.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsx("button",{type:"button",onClick:()=>s(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(v=>jsx("button",{type:"button",onClick:()=>s(v.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===v.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:v.name},v.path))]})]}),jsx("div",{className:"flex-1 overflow-auto p-2",children:l?jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(v=>{let x=y(v.id);return jsxs("button",{type:"button",onClick:()=>c(v),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${x?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:$i(v.mimeType,v.filename)==="image"?jsx("img",{src:Ua(v.thumbnailUrl||v.url),alt:v.filename,className:"w-full h-full object-cover"}):jsx(Tc,{type:$i(v.mimeType,v.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&x&&jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsx(Check,{className:"w-3 h-3 text-white"})})]},v.id)})})}),jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxs("button",{type:"button",onClick:u,className:"kyro-btn kyro-btn-primary px-3 py-1 text-xs font-semibold rounded cursor-pointer hover:opacity-90 transition-opacity",children:["Done",r.length>0?` (${r.length})`:""]}),jsx("button",{type:"button",onClick:()=>p(!e),className:"p-1.5 rounded text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",title:e?"Exit fullscreen":"Fullscreen",children:e?jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}):jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsx("button",{type:"button",onClick:()=>{f(false),p(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function pt({field:e,error:t,children:r,hideLabel:o=false}){return jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsx("div",{className:"flex justify-between items-end mb-1",children:jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin?.description}),t&&jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function xr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:i}){let s=useRef(null),[l,d]=useState(false);useEffect(()=>{d(true);},[]),useEffect(()=>{let u=p=>{p.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow="";}},[e,t]);let c={sm:"w-full sm:w-[320px]",md:"w-full sm:w-[400px]",lg:"w-full sm:w-[550px]",xl:"w-full sm:w-[700px]"};return !e||!l?null:createPortal(jsxs(Fragment,{children:[n&&jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxs("div",{ref:s,"data-kyro-slide-panel":"true","data-kyro-slide-width":a,className:`fixed right-0 top-0 bottom-0 z-[99999] ${c[a]} bg-[var(--kyro-surface)] ${i?`border-l-2 ${i}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsx("style",{children:`
1
+ import na,{createContext,lazy,useState,useRef,useEffect,useCallback,useContext,useMemo,Suspense,Component}from'react';import {create,useStore}from'zustand';import {persist,createJSONStorage}from'zustand/middleware';import*as _c from'lucide-react';import {Video,Mail,Clock,Database,Users,Tag,Image,Activity,CircleHelp,Sparkles,Blocks,Columns3,Link2,ListOrdered,Box,Star,AlignLeft,ChevronDown,File,Code,List,Heading1,GripVertical,Copy,Check,ClipboardCopy,X,Plus,ChevronRight,ClipboardPaste,Search,LoaderCircle,ChevronUp,CodeXml,FileText,Music,Film,Undo,Redo,Bold,Italic,Underline,Strikethrough,Highlighter,Palette,CheckSquare,Quote,Terminal,Minus,AlignCenter,AlignRight,Link,Maximize2,Minimize2,Grid3X3,Filter,FolderPlus,FolderInput,Folder,Trash2,Archive,Download,Crop,Server,MousePointerClick,RefreshCcw,Eye,Pencil,Info,TriangleAlert,ShieldAlert,CircleCheck,EllipsisVertical,Send,History,CheckCircle2,User,GitCompare,Undo2,ExternalLink,RefreshCw,Settings,Shield,Hexagon,Network,Sun,Moon,LogOut,ArrowRight,LayoutDashboard,ArrowUpRight,Webhook,Zap,XCircle,Pause,Play,Key,Lock,EyeOff,CirclePlay,Save,UserPlus,LockOpen}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useSyncExternalStore}from'use-sync-external-store/shim';import {mediaCollections,authCollections,minimalCollections,starterCollections,blogCollections,ecommerceCollections,kitchenSinkCollections,allSettingsGlobals,coreSettingsGlobals}from'@kyro-cms/core/templates';import {projectConfig}from'virtual:kyro-plugins';import {createStorage}from'unstorage';import Pf from'unstorage/drivers/indexedb';import {createPortal}from'react-dom';import {useEditor,EditorContent}from'@tiptap/react';import ag from'@tiptap/starter-kit';import {marked}from'marked';import sg from'@tiptap/extension-link';import ig from'@tiptap/extension-image';import lg from'@tiptap/extension-text-align';import dg from'@tiptap/extension-underline';import cg from'@tiptap/extension-highlight';import ug from'@tiptap/extension-task-list';import pg from'@tiptap/extension-task-item';import {TextStyle}from'@tiptap/extension-text-style';import fg from'@tiptap/extension-color';import Gf from'react-image-crop';import'react-image-crop/dist/ReactCrop.css';import {githubLight}from'@uiw/codemirror-theme-github';import {aura}from'@uiw/codemirror-theme-aura';import {useSensors,useSensor,PointerSensor,TouchSensor,KeyboardSensor,DndContext,closestCenter,DragOverlay,useDraggable}from'@dnd-kit/core';import {useSortable,SortableContext,verticalListSortingStrategy,horizontalListSortingStrategy}from'@dnd-kit/sortable';import {CSS}from'@dnd-kit/utilities';import {createStore}from'zustand/vanilla';import bv from'@uiw/react-codemirror';import {json}from'@codemirror/lang-json';import'@kyro-cms/core/client';var qp=Object.create;var Il=Object.defineProperty;var Jp=Object.getOwnPropertyDescriptor;var Xp=Object.getOwnPropertyNames;var Yp=Object.getPrototypeOf,Qp=Object.prototype.hasOwnProperty;var Zp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var em=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Xp(t))!Qp.call(e,a)&&a!==r&&Il(e,a,{get:()=>t[a],enumerable:!(o=Jp(t,a))||o.enumerable});return e};var tm=(e,t,r)=>(r=e!=null?qp(Yp(e)):{},em(!e||!e.__esModule?Il(r,"default",{value:e,enumerable:true}):r,e));var Bd=Zp((d0,Ed)=>{Ed.exports={area:true,base:true,br:true,col:true,embed:true,hr:true,img:true,input:true,link:true,meta:true,param:true,source:true,track:true,wbr:true};});var _e=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",Dr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Ye(e){if(e.startsWith("http")||e.startsWith(Dr))return e;if(e.startsWith("/api/"))return Dr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${Dr}${t}${e}`}function ri(e){return e.startsWith("http")||e.startsWith(_e)?e:e.startsWith("/admin/")?_e+e.slice(6):e.startsWith("/")?_e+e:e}function Ua(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var rm={admin:_e,api:Dr,resolveApi:Ye,resolveAdmin:ri,resolveMedia:Ua};var eo=create(e=>({user:null,permissions:null,isAuthenticated:false,isLoading:true,error:null,setUser:(t,r=null)=>e({user:t,permissions:r,isAuthenticated:!!t,isLoading:false,error:null}),setLoading:t=>e({isLoading:t}),setError:t=>e({error:t,isLoading:false,isAuthenticated:false,user:null,permissions:null}),logout:()=>e({user:null,permissions:null,isAuthenticated:false,isLoading:false,error:null})}));var Zt=create(e=>({toasts:[],addToast:(t,r)=>{let o=Math.random().toString(36).substring(7);e(a=>({toasts:[...a.toasts,{id:o,type:t,message:r}]}));},removeToast:t=>e(r=>({toasts:r.toasts.filter(o=>o.id!==t)})),clearToasts:()=>e({toasts:[]})})),j={success:e=>Zt.getState().addToast("success",e),error:e=>Zt.getState().addToast("error",e),warning:e=>Zt.getState().addToast("warning",e),info:e=>Zt.getState().addToast("info",e)};create()(persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var vt=create(e=>({sidebarOpen:true,toggleSidebar:()=>e(t=>({sidebarOpen:!t.sidebarOpen})),setSidebarOpen:t=>e({sidebarOpen:t}),modal:{open:false,config:null},confirm:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default"}}}),alert:t=>e({modal:{open:true,config:{...t,variant:t.variant||"default",confirmLabel:t.confirmLabel||"OK",onConfirm:()=>e(r=>({modal:{...r.modal,open:false}}))}}}),closeModal:()=>e(t=>({modal:{...t.modal,open:false},activeModal:null})),activeModal:null,openModal:t=>e({activeModal:t})}));create(e=>({editor:null,setEditor:t=>e({editor:t}),blockDrawerOpen:false,openBlockDrawer:t=>e({blockDrawerOpen:true,pendingInsert:{pos:null,column:t?.targetColumn??null}}),closeBlockDrawer:()=>e({blockDrawerOpen:false,pendingInsert:{pos:null,column:null}}),toggleBlockDrawer:()=>e(t=>({blockDrawerOpen:!t.blockDrawerOpen})),selectedBlock:null,setSelectedBlock:t=>e({selectedBlock:t}),pendingInsert:{pos:null,column:null},setPendingInsert:(t,r)=>e({pendingInsert:{pos:t,column:r??null}}),clearPendingInsert:()=>e({pendingInsert:{pos:null,column:null}})}));create((e,t)=>({cache:{},setCache:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:o,loading:false,error:null,lastFetch:Date.now()}}})),setLoading:(r,o)=>e(a=>({cache:{...a.cache,[r]:{...a.cache[r],loading:o,error:null}}})),setError:(r,o)=>e(a=>({cache:{...a.cache,[r]:{data:null,loading:false,error:o,lastFetch:null}}})),getCache:r=>t().cache[r]||null,invalidateCache:r=>e(o=>{if(r){let{[r]:a,...n}=o.cache;return {cache:n}}return {cache:{}}})}));var am="/api/auth/refresh";async function Ll(){try{return (await fetch(Ye(am),{method:"POST",credentials:"include"})).ok}catch{return false}}async function ct(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),r["x-kyro-admin"]="true",Object.assign(r,t.headers);let o=await fetch(Ye(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Ll()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(Ye(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Me(e,t){let{autoToast:r=true,...o}=t||{},a=await ct(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&j.error(n),new Error(n)}return a.json()}async function ut(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let i=`POST Failed: ${n.status}`;try{let s=await n.json();s.error&&(i=s.error);}catch{}throw o&&j.error(i),new Error(i)}return n.json()}async function er(e,t,r){let{autoToast:o=true,...a}=r||{},n=await ct(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let i=`Update Failed: ${n.status}`;try{let s=await n.json();s.error&&(i=s.error);}catch{}throw o&&j.error(i),new Error(i)}return n.json()}async function Dt(e,t){let{autoToast:r=true,...o}={},a=await ct(e,{method:"DELETE",...o});if(!a.ok){let i=`Delete Failed: ${a.status}`;try{let s=await a.json();s.error&&(i=s.error);}catch{}throw r&&j.error(i),new Error(i)}let n=await a.text();return n?JSON.parse(n):{}}function to(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function Tn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function Dn(e,t,r){if(!r){let o=await ct(e,{method:"POST",body:t});if(!o.ok)throw new Error(`Upload Error: ${o.status}`);return o.json()}return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("POST",Ye(e)),n.withCredentials=true,n.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),n.addEventListener("load",()=>{if(n.status>=200&&n.status<300)try{o(JSON.parse(n.responseText));}catch{a(new Error("Invalid JSON response"));}else n.status===401?Ll().then(i=>{if(!i){a(new Error(`Upload Error: ${n.status}`));return}let s=new XMLHttpRequest;s.open("POST",Ye(e)),s.withCredentials=true,s.upload.addEventListener("progress",l=>{l.lengthComputable&&r(Math.round(l.loaded/l.total*100));}),s.addEventListener("load",()=>{if(s.status>=200&&s.status<300)try{o(JSON.parse(s.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${s.status}`));}),s.addEventListener("error",()=>a(new Error("Network error"))),s.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function lr({size:e="md",className:t=""}){return jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}var Lt=(e,t)=>{typeof window>"u"||import('astro:transitions/client').then(r=>{r&&r.navigate?r.navigate(e,t):window.location.href=e;}).catch(()=>{window.location.href=e;});};function Wt({variant:e,count:t=1,className:r=""}){let o={text:"h-3 rounded-md",circle:"size-10 rounded-full",rect:"h-10 rounded-xl",card:"h-32 rounded-2xl","table-row":"h-14 rounded-xl","media-card":"aspect-square rounded-2xl","stat-card":"h-24 rounded-2xl"};return jsx(Fragment,{children:Array.from({length:t}).map((a,n)=>jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function vd({back:e}){return e.href?jsx("a",{href:e.href,onClick:t=>{e.onClick&&(t.preventDefault(),e.onClick());},className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsx("button",{type:"button",onClick:e.onClick,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function sm({breadcrumbs:e}){return e?.map((t,r)=>jsxs(na.Fragment,{children:[r>0&&jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsx("a",{href:t.href,onClick:o=>{t.onClick&&(o.preventDefault(),t.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:t.label}):jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function bd({actions:e}){return Array.isArray(e)?jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>{let o=`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all ${t.variant==="outline"?"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":t.variant==="ghost"?"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] shadow-none":"kyro-btn-primary hover:opacity-90"} ${t.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${t.className||""}`;return t.href&&!t.disabled?jsxs("a",{href:t.href,className:o,children:[t.icon&&jsx(t.icon,{className:"w-4 h-4"}),t.label]},r):jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:o,children:[t.icon&&jsx(t.icon,{className:"w-4 h-4"}),t.label]},r)})}):jsx(Fragment,{children:e})}function hd({action:e}){let t=`kyro-btn kyro-btn-primary flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`;return e.href&&!e.disabled?jsxs("a",{href:e.href,className:t,children:[e.icon&&jsx(e.icon,{className:"w-4 h-4"}),e.label]}):jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:t,children:[e.icon&&jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function jt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:i,actions:s,children:l}){let d=o?.[o.length-1];return jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxs("div",{className:"flex items-center gap-2",children:[n&&jsx(vd,{back:n}),jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsx("svg",{className:"w-3 h-3 text-[var(--kyro-text-secondary)] opacity-40 group-open:rotate-180 transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsx("div",{className:"flex items-center gap-2",children:o.map((c,u)=>jsxs(na.Fragment,{children:[u>0&&jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsx("a",{href:c.href,onClick:p=>{c.onClick&&(p.preventDefault(),c.onClick());},className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] transition-all",children:c.label}):jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},u))}),a&&jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,u)=>jsx(na.Fragment,{children:c},u))}),l]})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[r&&jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxs(na.Fragment,{children:[u===0&&jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))})]})]}),jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsx(vd,{back:n}),o&&jsx(sm,{breadcrumbs:o})]}),jsxs("div",{className:"flex items-center gap-3",children:[r&&jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsx("div",{className:"flex items-center gap-2",children:a.map((c,u)=>jsxs(na.Fragment,{children:[u===0&&(t||u>0)&&jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},u))}),l]})]}),jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[s&&jsx(bd,{actions:s}),i&&jsx(hd,{action:i})]})]}),(s||i)&&jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[i&&jsx(hd,{action:i}),s&&jsx(bd,{actions:s})]})]})}var lm={draft:{class:"bg-gray-100 text-gray-600",label:"Draft"},published:{class:"bg-green-100 text-green-700",label:"Published"},scheduled:{class:"bg-blue-100 text-blue-700",label:"Scheduled"},archived:{class:"bg-yellow-100 text-yellow-700",label:"Archived"},active:{class:"bg-green-100 text-green-700",label:"Active"},inactive:{class:"bg-gray-100 text-gray-600",label:"Inactive"},pending:{class:"bg-yellow-100 text-yellow-700",label:"Pending"},completed:{class:"bg-green-100 text-green-700",label:"Completed"},cancelled:{class:"bg-red-100 text-red-700",label:"Cancelled"}};function Et({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",i=lm[n],s=i?i.class:`kyro-badge-${n}`;return jsxs("span",{className:`kyro-badge ${s} ${r}`,children:[a&&jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||i?.label||n]})}function pi({count:e,max:t=99}){return e===0?null:jsx("span",{className:"inline-flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium bg-gray-200 text-gray-700 rounded-full",children:e>t?`${t}+`:e})}function mi({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...i}){let s="kyro-btn",l=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxs("button",{type:"button",className:`${s} ${l} ${d} ${a}`,disabled:n||r,...i,children:[r?jsx("span",{className:"kyro-btn-loading",children:jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function kd({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxs("div",{className:"surface-tile flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-[var(--kyro-border)]",children:[r!==void 0&&o?jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Showing ",(e-1)*o+1," to ",Math.min(e*o,r)," of ",r]}):jsx("span",{}),jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxs("select",{value:o,onChange:i=>n(Number(i.target.value)),className:"text-xs border border-[var(--kyro-border)] rounded-lg px-2 py-1 bg-[var(--kyro-bg)] text-[var(--kyro-text-secondary)]",children:[jsx("option",{value:10,children:"10/page"}),jsx("option",{value:25,children:"25/page"}),jsx("option",{value:50,children:"50/page"}),jsx("option",{value:100,children:"100/page"})]}),jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxs("div",{className:"flex gap-1",children:[jsx(mi,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsx(mi,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var be=e=>typeof e=="string",Ga=()=>{let e,t,r=new Promise((o,a)=>{e=o,t=a;});return r.resolve=e,r.reject=t,r},wd=e=>e==null?"":String(e),um=(e,t,r)=>{e.forEach(o=>{t[o]&&(r[o]=t[o]);});},pm=/###/g,Nd=e=>e&&e.includes("###")?e.replace(pm,"."):e,Cd=e=>!e||be(e),Wa=(e,t,r)=>{let o=be(t)?t.split("."):t,a=0;for(;a<o.length-1;){if(Cd(e))return {};let n=Nd(o[a]);!e[n]&&r&&(e[n]=new r),Object.prototype.hasOwnProperty.call(e,n)?e=e[n]:e={},++a;}return Cd(e)?{}:{obj:e,k:Nd(o[a])}},Sd=(e,t,r)=>{let{obj:o,k:a}=Wa(e,t,Object);if(o!==void 0||t.length===1){o[a]=r;return}let n=t[t.length-1],i=t.slice(0,t.length-1),s=Wa(e,i,Object);for(;s.obj===void 0&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),s=Wa(e,i,Object),s?.obj&&typeof s.obj[`${s.k}.${n}`]<"u"&&(s.obj=void 0);s.obj[`${s.k}.${n}`]=r;},mm=(e,t,r,o)=>{let{obj:a,k:n}=Wa(e,t,Object);a[n]=a[n]||[],a[n].push(r);},Qn=(e,t)=>{let{obj:r,k:o}=Wa(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},fm=(e,t,r)=>{let o=Qn(e,r);return o!==void 0?o:Qn(t,r)},Fd=(e,t,r)=>{for(let o in t)o!=="__proto__"&&o!=="constructor"&&(Object.prototype.hasOwnProperty.call(e,o)?be(e[o])||e[o]instanceof String||be(t[o])||t[o]instanceof String?r&&(e[o]=t[o]):Fd(e[o],t[o],r):e[o]=t[o]);return e},Hr=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),gm={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},ym=e=>be(e)?e.replace(/[&<>"'\/]/g,t=>gm[t]):e,yi=class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[];}getRegExp(t){let r=this.regExpMap.get(t);if(r!==void 0)return r;let o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}},vm=[" ",",","?","!",";"],bm=new yi(20),hm=(e,t,r)=>{t=t||"",r=r||"";let o=vm.filter(i=>!t.includes(i)&&!r.includes(i));if(o.length===0)return true;let a=bm.getRegExp(`(${o.map(i=>i==="?"?"\\?":i).join("|")})`),n=!a.test(e);if(!n){let i=e.indexOf(r);i>0&&!a.test(e.substring(0,i))&&(n=true);}return n},vi=(e,t,r=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let o=t.split(r),a=e;for(let n=0;n<o.length;){if(!a||typeof a!="object")return;let i,s="";for(let l=n;l<o.length;++l)if(l!==n&&(s+=r),s+=o[l],i=a[s],i!==void 0){if(["string","number","boolean"].includes(typeof i)&&l<o.length-1)continue;n+=l-n+1;break}a=i;}return a},qa=e=>e?.replace(/_/g,"-"),xm={type:"logger",log(e){this.output("log",e);},warn(e){this.output("warn",e);},error(e){this.output("error",e);},output(e,t){console?.[e]?.apply?.(console,t);}},bi=class e{constructor(t,r={}){this.init(t,r);}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||xm,this.options=r,this.debug=r.debug;}log(...t){return this.forward(t,"log","",true)}warn(...t){return this.forward(t,"warn","",true)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",true)}forward(t,r,o,a){return a&&!this.debug?null:(t=t.map(n=>be(n)?n.replace(/[\r\n\x00-\x1F\x7F]/g," "):n),be(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[r](t))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},Rr=new bi,oa=class{constructor(){this.observers={};}on(t,r){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);let a=this.observers[o].get(r)||0;this.observers[o].set(r,a+1);}),this}off(t,r){if(this.observers[t]){if(!r){delete this.observers[t];return}this.observers[t].delete(r);}}once(t,r){let o=(...a)=>{r(...a),this.off(t,o);};return this.on(t,o),this}emit(t,...r){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([a,n])=>{for(let i=0;i<n;i++)a(...r);}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([a,n])=>{for(let i=0;i<n;i++)a(t,...r);});}},Zn=class extends oa{constructor(t,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=true);}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t);}removeNamespaces(t){let r=this.options.ns.indexOf(t);r>-1&&this.options.ns.splice(r,1);}getResource(t,r,o,a={}){let n=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,i=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,s;t.includes(".")?s=t.split("."):(s=[t,r],o&&(Array.isArray(o)?s.push(...o):be(o)&&n?s.push(...o.split(n)):s.push(o)));let l=Qn(this.data,s);return !l&&!r&&!o&&t.includes(".")&&(t=s[0],r=s[1],o=s.slice(2).join(".")),l||!i||!be(o)?l:vi(this.data?.[t]?.[r],o,n)}addResource(t,r,o,a,n={silent:false}){let i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,s=[t,r];o&&(s=s.concat(i?o.split(i):o)),t.includes(".")&&(s=t.split("."),a=r,r=s[1]),this.addNamespaces(r),Sd(this.data,s,a),n.silent||this.emit("added",t,r,o,a);}addResources(t,r,o,a={silent:false}){for(let n in o)(be(o[n])||Array.isArray(o[n]))&&this.addResource(t,r,n,o[n],{silent:true});a.silent||this.emit("added",t,r,o);}addResourceBundle(t,r,o,a,n,i={silent:false,skipCopy:false}){let s=[t,r];t.includes(".")&&(s=t.split("."),a=o,o=r,r=s[1]),this.addNamespaces(r);let l=Qn(this.data,s)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),a?Fd(l,o,n):l={...l,...o},Sd(this.data,s,l),i.silent||this.emit("added",t,r,o);}removeResourceBundle(t,r){this.hasResourceBundle(t,r)&&delete this.data[t][r],this.removeNamespaces(r),this.emit("removed",t,r);}hasResourceBundle(t,r){return this.getResource(t,r)!==void 0}getResourceBundle(t,r){return r||(r=this.options.defaultNS),this.getResource(t,r)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){let r=this.getDataByLanguage(t);return !!(r&&Object.keys(r)||[]).find(a=>r[a]&&Object.keys(r[a]).length>0)}toJSON(){return this.data}},Id={processors:{},addPostProcessor(e){this.processors[e.name]=e;},handle(e,t,r,o,a){return e.forEach(n=>{t=this.processors[n]?.process(t,r,o,a)??t;}),t}},Ld=Symbol("i18next/PATH_KEY");function km(){let e=[],t=Object.create(null),r;return t.get=(o,a)=>(r?.revoke?.(),a===Ld?e:(e.push(a),r=Proxy.revocable(o,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Fo(e,t){let{[Ld]:r}=e(km()),o=t?.keySeparator??".",a=t?.nsSeparator??":",n=t?.enableSelector==="strict";if(r.length>1&&a){let i=t?.ns,s=n?Array.isArray(i)?i:i?[i]:null:Array.isArray(i)?i:null;if(s&&(n?s:s.length>1?s.slice(1):[]).includes(r[0]))return `${r[0]}${a}${r.slice(1).join(o)}`}return r.join(o)}var fi=e=>!be(e)&&typeof e!="boolean"&&typeof e!="number",es=class e extends oa{constructor(t,r={}){super(),um(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Rr.create("translator"),this.checkedLoadedFor={};}changeLanguage(t){t&&(this.language=t);}exists(t,r={interpolation:{}}){let o={...r};if(t==null)return false;let a=this.resolve(t,o);if(a?.res===void 0)return false;let n=fi(a.res);return !(o.returnObjects===false&&n)}extractFromKey(t,r){let o=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");let a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,n=r.ns||this.options.defaultNS||[],i=o&&t.includes(o),s=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!hm(t,o,a);if(i&&!s){let l=t.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return {key:t,namespaces:be(n)?[n]:n};let d=t.split(o);(o!==a||o===a&&this.options.ns.includes(d[0]))&&(n=d.shift()),t=d.join(a);}return {key:t,namespaces:be(n)?[n]:n}}translate(t,r,o){let a=typeof r=="object"?{...r}:r;if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),t==null)return "";typeof t=="function"&&(t=Fo(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(E=>typeof E=="function"?Fo(E,{...this.options,...a}):String(E));let n=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:s,namespaces:l}=this.extractFromKey(t[t.length-1],a),d=l[l.length-1],c=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;c===void 0&&(c=":");let u=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?n?{res:`${d}${c}${s}`,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:`${d}${c}${s}`:n?{res:s,usedKey:s,exactUsedKey:s,usedLng:u,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:s;let f=this.resolve(t,a),m=f?.res,y=f?.usedKey||s,v=f?.exactUsedKey||s,x=["[object Number]","[object Function]","[object RegExp]"],h=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,N=a.count!==void 0&&!be(a.count),V=e.hasDefaultValue(a),P=N?this.pluralResolver.getSuffix(u,a.count,a):"",k=a.ordinal&&N?this.pluralResolver.getSuffix(u,a.count,{ordinal:false}):"",g=N&&!a.ordinal&&a.count===0,b=g&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${P}`]||a[`defaultValue${k}`]||a.defaultValue,w=m;S&&!m&&V&&(w=b);let D=fi(w),F=Object.prototype.toString.apply(w);if(S&&w&&D&&!x.includes(F)&&!(be(h)&&Array.isArray(w))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,w,{...a,ns:l}):`key '${s} (${this.language})' returned an object instead of string.`;return n?(f.res=E,f.usedParams=this.getUsedParamsDetails(a),f):E}if(i){let E=Array.isArray(w),R=E?[]:{},M=E?v:y;for(let z in w)if(Object.prototype.hasOwnProperty.call(w,z)){let I=`${M}${i}${z}`;V&&!m?R[z]=this.translate(I,{...a,defaultValue:fi(b)?b[z]:void 0,joinArrays:false,ns:l}):R[z]=this.translate(I,{...a,joinArrays:false,ns:l}),R[z]===I&&(R[z]=w[z]);}m=R;}}else if(S&&be(h)&&Array.isArray(m))m=m.join(h),m&&(m=this.extendTranslation(m,t,a,o));else {let E=false,R=false;!this.isValidLookup(m)&&V&&(E=true,m=b),this.isValidLookup(m)||(R=true,m=s);let z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:m,I=V&&b!==m&&this.options.updateMissing;if(R||E||I){if(this.logger.log(I?"updateKey":"missingKey",u,d,N&&!I?`${s}${this.pluralResolver.getSuffix(u,a.count,a)}`:s,I?b:m),i){let Y=this.resolve(s,{...a,keySeparator:false});Y&&Y.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");}let J=[],Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let Y=0;Y<Z.length;Y++)J.push(Z[Y]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(a.lng||this.language):J.push(a.lng||this.language);let te=(Y,ae,ue)=>{let he=V&&ue!==m?ue:z;this.options.missingKeyHandler?this.options.missingKeyHandler(Y,d,ae,he,I,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(Y,d,ae,he,I,a),this.emit("missingKey",Y,d,ae,m);};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?J.forEach(Y=>{let ae=this.pluralResolver.getSuffixes(Y,a);g&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!ae.includes(`${this.options.pluralSeparator}zero`)&&ae.push(`${this.options.pluralSeparator}zero`),ae.forEach(ue=>{te([Y],s+ue,a[`defaultValue${ue}`]||b);});}):te(J,s,b));}m=this.extendTranslation(m,t,a,f,o),R&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${d}${c}${s}`),(R||E)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${c}${s}`:s,E?m:void 0,a));}return n?(f.res=m,f.usedParams=this.getUsedParamsDetails(a),f):m}extendTranslation(t,r,o,a,n){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});let l=be(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables),d;if(l){let u=t.match(this.interpolator.nestingRegexp);d=u&&u.length;}let c=o.replace&&!be(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,o.lng||this.language||a.usedLng,o),l){let u=t.match(this.interpolator.nestingRegexp),p=u&&u.length;d<p&&(o.nest=false);}!o.lng&&a&&a.res&&(o.lng=this.language||a.usedLng),o.nest!==false&&(t=this.interpolator.nest(t,(...u)=>n?.[0]===u[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${u[0]} in key: ${r[0]}`),null):this.translate(...u,r),o)),o.interpolation&&this.interpolator.reset();}let i=o.postProcess||this.options.postProcess,s=be(i)?[i]:i;return t!=null&&s?.length&&o.applyPostProcessor!==false&&(t=Id.handle(s,t,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,r={}){let o,a,n,i,s;return be(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(l=>typeof l=="function"?Fo(l,{...this.options,...r}):l)),t.forEach(l=>{if(this.isValidLookup(o))return;let d=this.extractFromKey(l,r),c=d.key;a=c;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let p=r.count!==void 0&&!be(r.count),f=p&&!r.ordinal&&r.count===0,m=r.context!==void 0&&(be(r.context)||typeof r.context=="number")&&r.context!=="",y=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach(v=>{this.isValidLookup(o)||(s=v,!this.checkedLoadedFor[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${y[0]}-${v}`]=true,this.logger.warn(`key "${a}" for languages "${y.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(x=>{if(this.isValidLookup(o))return;i=x;let h=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(h,c,x,v,r);else {let N;p&&(N=this.pluralResolver.getSuffix(x,r.count,r));let V=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&N.startsWith(P)&&h.push(c+N.replace(P,this.options.pluralSeparator)),h.push(c+N),f&&h.push(c+V)),m){let k=`${c}${this.options.contextSeparator||"_"}${r.context}`;h.push(k),p&&(r.ordinal&&N.startsWith(P)&&h.push(k+N.replace(P,this.options.pluralSeparator)),h.push(k+N),f&&h.push(k+V));}}let S;for(;S=h.pop();)this.isValidLookup(o)||(n=S,o=this.getResource(x,v,S,r));}));});}),{res:o,usedKey:a,exactUsedKey:n,usedLng:i,usedNS:s}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,r,o,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,r,o,a):this.resourceStore.getResource(t,r,o,a)}getUsedParamsDetails(t={}){let r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!be(t.replace),a=o?t.replace:t;if(o&&typeof t.count<"u"&&(a={...a,count:t.count}),this.options.interpolation.defaultVariables&&(a={...this.options.interpolation.defaultVariables,...a}),!o){a={...a};for(let n of r)delete a[n];}return a}static hasDefaultValue(t){let r="defaultValue";for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&o.startsWith(r)&&t[o]!==void 0)return true;return false}},ts=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||false,this.logger=Rr.create("languageUtils");}getScriptPartFromCode(t){if(t=qa(t),!t||!t.includes("-"))return null;let r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(t){if(t=qa(t),!t||!t.includes("-"))return t;let r=t.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(t){if(be(t)&&t.includes("-")){let r;try{r=Intl.getCanonicalLocales(t)[0];}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return (this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let r;return t.forEach(o=>{if(r)return;let a=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(a))&&(r=a);}),!r&&this.options.supportedLngs&&t.forEach(o=>{if(r)return;let a=this.getScriptPartFromCode(o);if(this.isSupportedCode(a))return r=a;let n=this.getLanguagePartFromCode(o);if(this.isSupportedCode(n))return r=n;r=this.options.supportedLngs.find(i=>i===n?true:!i.includes("-")&&!n.includes("-")?false:!!(i.includes("-")&&!n.includes("-")&&i.slice(0,i.indexOf("-"))===n||i.startsWith(n)&&n.length>1));}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(t,r){if(!t)return [];if(typeof t=="function"&&(t=t(r)),be(t)&&(t=[t]),Array.isArray(t))return t;if(!r)return t.default||[];let o=t[r];return o||(o=t[this.getScriptPartFromCode(r)]),o||(o=t[this.formatLanguageCode(r)]),o||(o=t[this.getLanguagePartFromCode(r)]),o||(o=t.default),o||[]}toResolveHierarchy(t,r){let o=this.getFallbackCodes((r===false?[]:r)||this.options.fallbackLng||[],t),a=[],n=i=>{i&&(this.isSupportedCode(i)?a.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`));};return be(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(t))):be(t)&&n(this.formatLanguageCode(t)),o.forEach(i=>{a.includes(i)||n(this.formatLanguageCode(i));}),a}},Ad={zero:0,one:1,two:2,few:3,many:4,other:5},Td={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},hi=class{constructor(t,r={}){this.languageUtils=t,this.options=r,this.logger=Rr.create("pluralResolver"),this.pluralRulesCache={};}clearCache(){this.pluralRulesCache={};}getRule(t,r={}){let o=qa(t==="dev"?"en":t),a=r.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:o,type:a});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let i;try{i=new Intl.PluralRules(o,{type:a});}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Td;if(!t.match(/-|_/))return Td;let l=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(l,r);}return this.pluralRulesCache[n]=i,i}needsPlural(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,r,o={}){return this.getSuffixes(t,o).map(a=>`${r}${a}`)}getSuffixes(t,r={}){let o=this.getRule(t,r);return o||(o=this.getRule("dev",r)),o?o.resolvedOptions().pluralCategories.sort((a,n)=>Ad[a]-Ad[n]).map(a=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${a}`):[]}getSuffix(t,r,o={}){let a=this.getRule(t,o);return a?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${a.select(r)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",r,o))}},Dd=(e,t,r,o=".",a=true)=>{let n=fm(e,t,r);return !n&&a&&be(r)&&(n=vi(e,r,o),n===void 0&&(n=vi(t,r,o))),n},wm=e=>e.replace(/\$/g,"$$$$"),rs=class{constructor(t={}){this.logger=Rr.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(r=>r),this.init(t);}init(t={}){t.interpolation||(t.interpolation={escapeValue:true});let{escape:r,escapeValue:o,useRawValueToEscape:a,prefix:n,prefixEscaped:i,suffix:s,suffixEscaped:l,formatSeparator:d,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:f,nestingSuffix:m,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:h}=t.interpolation;this.escape=r!==void 0?r:ym,this.escapeValue=o!==void 0?o:true,this.useRawValueToEscape=a!==void 0?a:false,this.prefix=n?Hr(n):i||"{{",this.suffix=s?Hr(s):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=c?"":u?Hr(u):"-",this.unescapeSuffix=this.unescapePrefix?"":c?Hr(c):"",this.nestingPrefix=p?Hr(p):f||Hr("$t("),this.nestingSuffix=m?Hr(m):y||Hr(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=h!==void 0?h:false,this.resetRegExp();}reset(){this.options&&this.init(this.options);}resetRegExp(){let t=(r,o)=>r?.source===o?(r.lastIndex=0,r):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);}interpolate(t,r,o,a){let n,i,s,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=f=>{if(!f.includes(this.formatSeparator)){let x=Dd(r,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,o,{...a,...r,interpolationkey:f}):x}let m=f.split(this.formatSeparator),y=m.shift().trim(),v=m.join(this.formatSeparator).trim();return this.format(Dd(r,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,o,{...a,...r,interpolationkey:y})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false \u2014 if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return [{regex:this.regexpUnescape,safeValue:f=>f},{regex:this.regexp,safeValue:f=>this.escapeValue?this.escape(f):f}].forEach(f=>{for(s=0;n=f.regex.exec(t);){let m=n[1].trim();if(i=d(m),i===void 0)if(typeof c=="function"){let v=c(t,n,a);i=be(v)?v:"";}else if(a&&Object.prototype.hasOwnProperty.call(a,m))i="";else if(u){i=n[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${t}`),i="";else !be(i)&&!this.useRawValueToEscape&&(i=wd(i));let y=f.safeValue(i);if(t=t.replace(n[0],wm(y)),u?(f.regex.lastIndex+=y.length,f.regex.lastIndex-=n[0].length):f.regex.lastIndex=0,s++,s>=this.maxReplaces)break}}),t}nest(t,r,o={}){let a,n,i,s=(l,d)=>{let c=this.nestingOptionsSeparator;if(!l.includes(c))return l;let u=l.split(new RegExp(`${Hr(c)}[ ]*{`)),p=`{${u[1]}`;l=u[0],p=this.interpolate(p,i);let f=p.match(/'/g),m=p.match(/"/g);((f?.length??0)%2===0&&!m||(m?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),d&&(i={...d,...i});}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${c}${p}`}return i.defaultValue&&i.defaultValue.includes(this.prefix)&&delete i.defaultValue,l};for(;a=this.nestingRegexp.exec(t);){let l=[];i={...o},i=i.replace&&!be(i.replace)?i.replace:i,i.applyPostProcessor=false,delete i.defaultValue;let d=/{.*}/s.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(d!==-1&&(l=a[1].slice(d).split(this.formatSeparator).map(c=>c.trim()).filter(Boolean),a[1]=a[1].slice(0,d)),n=r(s.call(this,a[1].trim(),i),i),n&&a[0]===t&&!be(n))return n;be(n)||(n=wd(n)),n||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${t}`),n=""),l.length&&(n=l.reduce((c,u)=>this.format(c,u,o.lng,{...o,interpolationkey:a[1].trim()}),n.trim())),t=t.replace(a[0],n),this.regexp.lastIndex=0;}return t}},Nm=e=>{let t=e.toLowerCase().trim(),r={};if(e.includes("(")){let o=e.split("(");t=o[0].toLowerCase().trim();let a=o[1].slice(0,-1);t==="currency"&&!a.includes(":")?r.currency||(r.currency=a.trim()):t==="relativetime"&&!a.includes(":")?r.range||(r.range=a.trim()):a.split(";").forEach(i=>{if(i){let[s,...l]=i.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),c=s.trim();r[c]||(r[c]=d),d==="false"&&(r[c]=false),d==="true"&&(r[c]=true),isNaN(d)||(r[c]=parseInt(d,10));}});}return {formatName:t,formatOptions:r}},Pd=e=>{let t={};return (r,o,a)=>{let n=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(n={...n,[a.interpolationkey]:void 0});let i=o+JSON.stringify(n),s=t[i];return s||(s=e(qa(o),a),t[i]=s),s(r)}},Cm=e=>(t,r,o)=>e(qa(r),o)(t),xi=class{constructor(t={}){this.logger=Rr.create("formatter"),this.options=t,this.init(t);}init(t,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";let o=r.cacheInBuiltFormats?Pd:Cm;this.formats={number:o((a,n)=>{let i=new Intl.NumberFormat(a,{...n});return s=>i.format(s)}),currency:o((a,n)=>{let i=new Intl.NumberFormat(a,{...n,style:"currency"});return s=>i.format(s)}),datetime:o((a,n)=>{let i=new Intl.DateTimeFormat(a,{...n});return s=>i.format(s)}),relativetime:o((a,n)=>{let i=new Intl.RelativeTimeFormat(a,{...n});return s=>i.format(s,n.range||"day")}),list:o((a,n)=>{let i=new Intl.ListFormat(a,{...n});return s=>i.format(s)})};}add(t,r){this.formats[t.toLowerCase().trim()]=r;}addCached(t,r){this.formats[t.toLowerCase().trim()]=Pd(r);}format(t,r,o,a={}){if(!r||t==null)return t;let n=r.split(this.formatSeparator),i=[];for(let l=0;l<n.length;l++){let d=n[l];for(;d.indexOf("(")>-1&&!d.includes(")")&&l+1<n.length;)d=`${d}${this.formatSeparator}${n[++l]}`;i.push(d);}return i.reduce((l,d)=>{let{formatName:c,formatOptions:u}=Nm(d);if(this.formats[c]){let p=l;try{let f=a?.formatParams?.[a.interpolationkey]||{},m=f.locale||f.lng||a.locale||a.lng||o;p=this.formats[c](l,m,{...u,...a,...f});}catch(f){this.logger.warn(f);}return p}else this.logger.warn(`there was no format function for ${c}`);return l},t)}},Sm=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--);},ki=class extends oa{constructor(t,r,o,a={}){super(),this.backend=t,this.store=r,this.services=o,this.languageUtils=o.languageUtils,this.options=a,this.logger=Rr.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,a.backend,a);}queueLoad(t,r,o,a){let n={},i={},s={},l={};return t.forEach(d=>{let c=true;r.forEach(u=>{let p=`${d}|${u}`;!o.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?i[p]===void 0&&(i[p]=true):(this.state[p]=1,c=false,i[p]===void 0&&(i[p]=true),n[p]===void 0&&(n[p]=true),l[u]===void 0&&(l[u]=true)));}),c||(s[d]=true);}),(Object.keys(n).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(n),pending:Object.keys(i),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}loaded(t,r,o){let a=t.split("|"),n=a[0],i=a[1];r&&this.emit("failedLoading",n,i,r),!r&&o&&this.store.addResourceBundle(n,i,o,void 0,void 0,{skipCopy:true}),this.state[t]=r?-1:2,r&&o&&(this.state[t]=0);let s={};this.queue.forEach(l=>{mm(l.loaded,[n],i),Sm(l,t),r&&l.errors.push(r),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{s[d]||(s[d]={});let c=l.loaded[d];c.length&&c.forEach(u=>{s[d][u]===void 0&&(s[d][u]=true);});}),l.done=true,l.errors.length?l.callback(l.errors):l.callback());}),this.emit("loaded",s),this.queue=this.queue.filter(l=>!l.done);}read(t,r,o,a=0,n=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:r,fcName:o,tried:a,wait:n,callback:i});return}this.readingCalls++;let s=(d,c)=>{if(this.readingCalls--,this.waitingReads.length>0){let u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback);}if(d&&c&&a<this.maxRetries){setTimeout(()=>{this.read(t,r,o,a+1,n*2,i);},n);return}i(d,c);},l=this.backend[o].bind(this.backend);if(l.length===2){try{let d=l(t,r);d&&typeof d.then=="function"?d.then(c=>s(null,c)).catch(s):s(null,d);}catch(d){s(d);}return}return l(t,r,s)}prepareLoading(t,r,o={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();be(t)&&(t=this.languageUtils.toResolveHierarchy(t)),be(r)&&(r=[r]);let n=this.queueLoad(t,r,o,a);if(!n.toLoad.length)return n.pending.length||a(),null;n.toLoad.forEach(i=>{this.loadOne(i);});}load(t,r,o){this.prepareLoading(t,r,{},o);}reload(t,r,o){this.prepareLoading(t,r,{reload:true},o);}loadOne(t,r=""){let o=t.split("|"),a=o[0],n=o[1];this.read(a,n,"read",void 0,void 0,(i,s)=>{i&&this.logger.warn(`${r}loading namespace ${n} for language ${a} failed`,i),!i&&s&&this.logger.log(`${r}loaded namespace ${n} for language ${a}`,s),this.loaded(t,i,s);});}saveMissing(t,r,o,a,n,i={},s=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${o}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){let l={...i,isUpdate:n},d=this.backend.create.bind(this.backend);if(d.length<6)try{let c;d.length===5?c=d(t,r,o,a,l):c=d(t,r,o,a),c&&typeof c.then=="function"?c.then(u=>s(null,u)).catch(s):s(null,c);}catch(c){s(c);}else d(t,r,o,a,s,l);}!t||!t[0]||this.store.addResource(t[0],r,o,a);}}},gi=()=>({debug:false,initAsync:true,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:false,supportedLngs:false,nonExplicitSupportedLngs:false,load:"all",preload:false,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:false,partialBundledLanguages:false,saveMissing:false,updateMissing:false,saveMissingTo:"fallback",saveMissingPlurals:true,missingKeyHandler:false,missingInterpolationHandler:false,postProcess:false,postProcessPassResolved:false,returnNull:false,returnEmptyString:true,returnObjects:false,joinArrays:false,returnedObjectHandler:false,parseMissingKeyHandler:false,appendNamespaceToMissingKey:false,appendNamespaceToCIMode:false,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),be(e[1])&&(t.defaultValue=e[1]),be(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){let r=e[3]||e[2];Object.keys(r).forEach(o=>{t[o]=r[o];});}return t},interpolation:{escapeValue:true,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:true},cacheInBuiltFormats:true}),Rd=e=>(be(e.ns)&&(e.ns=[e.ns]),be(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),be(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Yn=()=>{},Am=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e));});},wi=class e extends oa{constructor(t={},r){if(super(),this.options=Rd(t),this.services={},this.logger=Rr,this.modules={external:[]},Am(this),r&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,r),this;setTimeout(()=>{this.init(t,r);},0);}}init(t={},r){this.isInitializing=true,typeof t=="function"&&(r=t,t={}),t.defaultNS==null&&t.ns&&(be(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));let o=gi();this.options={...o,...this.options,...Rd(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler);let a=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Rr.init(a(this.modules.logger),this.options):Rr.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=xi;let c=new ts(this.options);this.store=new Zn(this.options.resources,this.options);let u=this.services;u.logger=Rr,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new hi(c,{prepend:this.options.pluralSeparator}),d&&(u.formatter=a(d),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new rs(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new ki(a(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.languageDetector&&(u.languageDetector=a(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=a(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new es(this.services,this.options),this.translator.on("*",(p,...f)=>{this.emit(p,...f);}),this.modules.external.forEach(p=>{p.init&&p.init(this);});}if(this.format=this.options.interpolation.format,r||(r=Yn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0]);}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...c)=>this.store[d](...c);}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...c)=>(this.store[d](...c),this);});let s=Ga(),l=()=>{let d=(c,u)=>{this.isInitializing=false,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=true,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),s.resolve(u),r(c,u);};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d);};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),s}loadResources(t,r=Yn){let o=r,a=be(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();let n=[],i=s=>{if(!s||s==="cimode")return;this.services.languageUtils.toResolveHierarchy(s).forEach(d=>{d!=="cimode"&&(n.includes(d)||n.push(d));});};a?i(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>i(l)),this.options.preload?.forEach?.(s=>i(s)),this.services.backendConnector.load(n,this.options.ns,s=>{!s&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(s);});}else o(null);}reloadResources(t,r,o){let a=Ga();return typeof t=="function"&&(o=t,t=void 0),typeof r=="function"&&(o=r,r=void 0),t||(t=this.languages),r||(r=this.options.ns),o||(o=Yn),this.services.backendConnector.reload(t,r,n=>{a.resolve(),o(n);}),a}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Id.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let r=0;r<this.languages.length;r++){let o=this.languages[r];if(!["cimode","dev"].includes(o)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t));}}changeLanguage(t,r){this.isLanguageChangingTo=t;let o=Ga();this.emit("languageChanging",t);let a=s=>{this.language=s,this.languages=this.services.languageUtils.toResolveHierarchy(s),this.resolvedLanguage=void 0,this.setResolvedLanguage(s);},n=(s,l)=>{l?this.isLanguageChangingTo===t&&(a(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),r&&r(s,(...d)=>this.t(...d));},i=s=>{!t&&!s&&this.services.languageDetector&&(s=[]);let l=be(s)?s:s&&s[0],d=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(be(s)?[s]:s);d&&(this.language||a(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,c=>{n(c,d);});};return !t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),o}getFixedT(t,r,o,a){let n=a?.scopeNs,i=(s,l,...d)=>{let c;typeof l!="object"?c=this.options.overloadTranslationOptionHandler([s,l].concat(d)):c={...l},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs;let u=c.ns!==void 0&&c.ns!==null;c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||i.keyPrefix);let p={...this.options,...c};Array.isArray(n)&&!u&&(p.ns=n),typeof c.keyPrefix=="function"&&(c.keyPrefix=Fo(c.keyPrefix,p));let f=this.options.keySeparator||".",m;return c.keyPrefix&&Array.isArray(s)?m=s.map(y=>(typeof y=="function"&&(y=Fo(y,p)),`${c.keyPrefix}${f}${y}`)):(typeof s=="function"&&(s=Fo(s,p)),m=c.keyPrefix?`${c.keyPrefix}${f}${s}`:s),this.t(m,c)};return be(t)?i.lng=t:i.lngs=t,i.ns=r,i.keyPrefix=o,i}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t;}hasLoadedNamespace(t,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),false;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),false;let o=r.lng||this.resolvedLanguage||this.languages[0],a=this.options?this.options.fallbackLng:false,n=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return true;let i=(s,l)=>{let d=this.services.backendConnector.state[`${s}|${l}`];return d===-1||d===0||d===2};if(r.precheck){let s=r.precheck(this,i);if(s!==void 0)return s}return !!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(o,t)&&(!a||i(n,t)))}loadNamespaces(t,r){let o=Ga();return this.options.ns?(be(t)&&(t=[t]),t.forEach(a=>{this.options.ns.includes(a)||this.options.ns.push(a);}),this.loadResources(a=>{o.resolve(),r&&r(a);}),o):(r&&r(),Promise.resolve())}loadLanguages(t,r){let o=Ga();be(t)&&(t=[t]);let a=this.options.preload||[],n=t.filter(i=>!a.includes(i)&&this.services.languageUtils.isSupportedCode(i));return n.length?(this.options.preload=a.concat(n),this.loadResources(i=>{o.resolve(),r&&r(i);}),o):(r&&r(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return "rtl";try{let a=new Intl.Locale(t);if(a&&a.getTextInfo){let n=a.getTextInfo();if(n&&n.direction)return n.direction}}catch{}let r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new ts(gi());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},r){let o=new e(t,r);return o.createInstance=e.createInstance,o}cloneInstance(t={},r=Yn){let o=t.forkResourceStore;o&&delete t.forkResourceStore;let a={...this.options,...t,isClone:true},n=new e(a);if((t.debug!==void 0||t.prefix!==void 0)&&(n.logger=n.logger.clone(t)),["store","services","language"].forEach(s=>{n[s]=this[s];}),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},o){let s=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},l[d]=Object.keys(l[d]).reduce((c,u)=>(c[u]={...l[d][u]},c),l[d]),l),{});n.store=new Zn(s,a),n.services.resourceStore=n.store;}if(t.interpolation){let l={...gi().interpolation,...this.options.interpolation,...t.interpolation},d={...a,interpolation:l};n.services.interpolator=new rs(d);}return n.translator=new es(n.services,a),n.translator.on("*",(s,...l)=>{n.emit(s,...l);}),n.init(a,r),n.translator.options=a,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return {options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Bt=wi.createInstance();Bt.createInstance;Bt.dir;Bt.init;Bt.loadResources;Bt.reloadResources;Bt.use;Bt.changeLanguage;Bt.getFixedT;Bt.t;Bt.exists;Bt.setDefaultNamespace;Bt.hasLoadedNamespace;Bt.loadNamespaces;Bt.loadLanguages;tm(Bd());var os=(e,t,r,o)=>{let a=[r,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(a,"warn","react-i18next::",true);vr(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...a):console?.warn&&console.warn(...a);},Md={},_r=(e,t,r,o)=>{vr(r)&&Md[r]||(vr(r)&&(Md[r]=new Date),os(e,t,r,o));},$d=(e,t)=>()=>{if(e.isInitialized)t();else {let r=()=>{setTimeout(()=>{e.off("initialized",r);},0),t();};e.on("initialized",r);}},as=(e,t,r)=>{e.loadNamespaces(t,$d(e,r));},Ni=(e,t,r,o)=>{if(vr(r)&&(r=[r]),e.options.preload&&e.options.preload.indexOf(t)>-1)return as(e,r,o);r.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a);}),e.loadLanguages(t,$d(e,o));},Od=(e,t,r={})=>!t.languages||!t.languages.length?(_r(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),true):t.hasLoadedNamespace(e,{lng:r.lng,precheck:(o,a)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!a(o.isLanguageChangingTo,e))return false}});var vr=e=>typeof e=="string",Ci=e=>typeof e=="object"&&e!==null;var Dm=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Pm={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"\xA9","&#169;":"\xA9","&reg;":"\xAE","&#174;":"\xAE","&hellip;":"\u2026","&#8230;":"\u2026","&#x2F;":"/","&#47;":"/"},Rm=e=>Pm[e],Si=e=>e.replace(Dm,Rm);var Ai={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:true,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:true,unescape:Si,transDefaultProps:void 0},ns=(e={})=>{Ai={...Ai,...e};},Ja=()=>Ai;var Vd,ss=e=>{Vd=e;},br=()=>Vd;var is={type:"3rdParty",init(e){ns(e.options.react),ss(e);}};var ao=createContext(),ls=class{constructor(){this.usedNamespaces={};}addUsedNamespaces(t){t.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=true);});}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}};var jd={"&nbsp;":"\xA0","&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&copy;":"\xA9","&reg;":"\xAE","&trade;":"\u2122","&hellip;":"\u2026","&ndash;":"\u2013","&mdash;":"\u2014","&lsquo;":"\u2018","&rsquo;":"\u2019","&sbquo;":"\u201A","&ldquo;":"\u201C","&rdquo;":"\u201D","&bdquo;":"\u201E","&dagger;":"\u2020","&Dagger;":"\u2021","&bull;":"\u2022","&prime;":"\u2032","&Prime;":"\u2033","&lsaquo;":"\u2039","&rsaquo;":"\u203A","&sect;":"\xA7","&para;":"\xB6","&middot;":"\xB7","&ensp;":"\u2002","&emsp;":"\u2003","&thinsp;":"\u2009","&euro;":"\u20AC","&pound;":"\xA3","&yen;":"\xA5","&cent;":"\xA2","&curren;":"\xA4","&times;":"\xD7","&divide;":"\xF7","&minus;":"\u2212","&plusmn;":"\xB1","&ne;":"\u2260","&le;":"\u2264","&ge;":"\u2265","&asymp;":"\u2248","&equiv;":"\u2261","&infin;":"\u221E","&int;":"\u222B","&sum;":"\u2211","&prod;":"\u220F","&radic;":"\u221A","&part;":"\u2202","&permil;":"\u2030","&deg;":"\xB0","&micro;":"\xB5","&larr;":"\u2190","&uarr;":"\u2191","&rarr;":"\u2192","&darr;":"\u2193","&harr;":"\u2194","&crarr;":"\u21B5","&lArr;":"\u21D0","&uArr;":"\u21D1","&rArr;":"\u21D2","&dArr;":"\u21D3","&hArr;":"\u21D4","&alpha;":"\u03B1","&beta;":"\u03B2","&gamma;":"\u03B3","&delta;":"\u03B4","&epsilon;":"\u03B5","&zeta;":"\u03B6","&eta;":"\u03B7","&theta;":"\u03B8","&iota;":"\u03B9","&kappa;":"\u03BA","&lambda;":"\u03BB","&mu;":"\u03BC","&nu;":"\u03BD","&xi;":"\u03BE","&omicron;":"\u03BF","&pi;":"\u03C0","&rho;":"\u03C1","&sigma;":"\u03C3","&tau;":"\u03C4","&upsilon;":"\u03C5","&phi;":"\u03C6","&chi;":"\u03C7","&psi;":"\u03C8","&omega;":"\u03C9","&Alpha;":"\u0391","&Beta;":"\u0392","&Gamma;":"\u0393","&Delta;":"\u0394","&Epsilon;":"\u0395","&Zeta;":"\u0396","&Eta;":"\u0397","&Theta;":"\u0398","&Iota;":"\u0399","&Kappa;":"\u039A","&Lambda;":"\u039B","&Mu;":"\u039C","&Nu;":"\u039D","&Xi;":"\u039E","&Omicron;":"\u039F","&Pi;":"\u03A0","&Rho;":"\u03A1","&Sigma;":"\u03A3","&Tau;":"\u03A4","&Upsilon;":"\u03A5","&Phi;":"\u03A6","&Chi;":"\u03A7","&Psi;":"\u03A8","&Omega;":"\u03A9","&Agrave;":"\xC0","&Aacute;":"\xC1","&Acirc;":"\xC2","&Atilde;":"\xC3","&Auml;":"\xC4","&Aring;":"\xC5","&AElig;":"\xC6","&Ccedil;":"\xC7","&Egrave;":"\xC8","&Eacute;":"\xC9","&Ecirc;":"\xCA","&Euml;":"\xCB","&Igrave;":"\xCC","&Iacute;":"\xCD","&Icirc;":"\xCE","&Iuml;":"\xCF","&ETH;":"\xD0","&Ntilde;":"\xD1","&Ograve;":"\xD2","&Oacute;":"\xD3","&Ocirc;":"\xD4","&Otilde;":"\xD5","&Ouml;":"\xD6","&Oslash;":"\xD8","&Ugrave;":"\xD9","&Uacute;":"\xDA","&Ucirc;":"\xDB","&Uuml;":"\xDC","&Yacute;":"\xDD","&THORN;":"\xDE","&szlig;":"\xDF","&agrave;":"\xE0","&aacute;":"\xE1","&acirc;":"\xE2","&atilde;":"\xE3","&auml;":"\xE4","&aring;":"\xE5","&aelig;":"\xE6","&ccedil;":"\xE7","&egrave;":"\xE8","&eacute;":"\xE9","&ecirc;":"\xEA","&euml;":"\xEB","&igrave;":"\xEC","&iacute;":"\xED","&icirc;":"\xEE","&iuml;":"\xEF","&eth;":"\xF0","&ntilde;":"\xF1","&ograve;":"\xF2","&oacute;":"\xF3","&ocirc;":"\xF4","&otilde;":"\xF5","&ouml;":"\xF6","&oslash;":"\xF8","&ugrave;":"\xF9","&uacute;":"\xFA","&ucirc;":"\xFB","&uuml;":"\xFC","&yacute;":"\xFD","&thorn;":"\xFE","&yuml;":"\xFF","&iexcl;":"\xA1","&iquest;":"\xBF","&fnof;":"\u0192","&circ;":"\u02C6","&tilde;":"\u02DC","&OElig;":"\u0152","&oelig;":"\u0153","&Scaron;":"\u0160","&scaron;":"\u0161","&Yuml;":"\u0178","&ordf;":"\xAA","&ordm;":"\xBA","&macr;":"\xAF","&acute;":"\xB4","&cedil;":"\xB8","&sup1;":"\xB9","&sup2;":"\xB2","&sup3;":"\xB3","&frac14;":"\xBC","&frac12;":"\xBD","&frac34;":"\xBE","&spades;":"\u2660","&clubs;":"\u2663","&hearts;":"\u2665","&diams;":"\u2666","&loz;":"\u25CA","&oline;":"\u203E","&frasl;":"\u2044","&weierp;":"\u2118","&image;":"\u2111","&real;":"\u211C","&alefsym;":"\u2135"};new RegExp(Object.keys(jd).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"g");var Um=(e,t)=>{if(vr(t))return t;if(Ci(t)&&vr(t.defaultValue))return t.defaultValue;if(typeof e=="function")return "";if(Array.isArray(e)){let r=e[e.length-1];return typeof r=="function"?"":r}return e},zm={t:Um,ready:false},Hm=()=>()=>{},H=(e,t={})=>{let{i18n:r}=t,{i18n:o,defaultNS:a}=useContext(ao)||{},n=r||o||br();n&&!n.reportNamespaces&&(n.reportNamespaces=new ls),n||_r(n,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.");let i=useMemo(()=>({...Ja(),...n?.options?.react,...t}),[n,t]),{useSuspense:s,keyPrefix:l}=i,d=a||n?.options?.defaultNS,c=vr(d)?[d]:d||["translation"],u=useMemo(()=>c,c);n?.reportNamespaces?.addUsedNamespaces?.(u);let p=useRef(0),f=useCallback(b=>{if(!n)return Hm;let{bindI18n:w,bindI18nStore:D}=i,F=()=>{p.current+=1,b();};return w&&n.on(w,F),D&&n.store.on(D,F),()=>{w&&w.split(" ").forEach(E=>n.off(E,F)),D&&D.split(" ").forEach(E=>n.store.off(E,F));}},[n,i]),m=useRef(),y=useCallback(()=>{if(!n)return zm;let b=!!(n.isInitialized||n.initializedStoreOnce)&&u.every(M=>Od(M,n,i)),w=t.lng||n.language,D=p.current,F=m.current;if(F&&F.ready===b&&F.lng===w&&F.keyPrefix===l&&F.revision===D)return F;let R={t:n.getFixedT(w,i.nsMode==="fallback"?u:u[0],l,{scopeNs:u}),ready:b,lng:w,keyPrefix:l,revision:D};return m.current=R,R},[n,u,l,i,t.lng]),[v,x]=useState(0),{t:h,ready:S}=useSyncExternalStore(f,y,y);useEffect(()=>{if(n&&!S&&!s){let b=()=>x(w=>w+1);t.lng?Ni(n,t.lng,u,b):as(n,u,b);}},[n,t.lng,u,S,s,v]);let N=n||{},V=useRef(null),P=useRef(),k=b=>{let w=Object.getOwnPropertyDescriptors(b);w.__original&&delete w.__original;let D=Object.create(Object.getPrototypeOf(b),w);if(!Object.prototype.hasOwnProperty.call(D,"__original"))try{Object.defineProperty(D,"__original",{value:b,writable:!1,enumerable:!1,configurable:!1});}catch{}return D},g=useMemo(()=>{let b=N,w=b?.language,D=b;b&&(V.current&&V.current.__original===b?P.current!==w?(D=k(b),V.current=D,P.current=w):D=V.current:(D=k(b),V.current=D,P.current=w));let F=!S&&!s?(...R)=>(_r(n,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),h(...R)):h,E=[F,D,S];return E.t=F,E.i18n=D,E.ready=S,E},[h,N,S,N.resolvedLanguage,N.language,N.languages]);if(n&&s&&!S){let b=false;try{b=process.env.NODE_ENV!=="production";}catch{}throw b&&_r(n,"SUSPENDED_WHILE_LOADING","useTranslation: suspended while translations are loading (useSuspense is true by default). Add a <Suspense> boundary above this component, or set react.useSuspense: false in the i18next init options. https://react.i18next.com/latest/usetranslation-hook"),new Promise(w=>{let D=()=>w();t.lng?Ni(n,t.lng,u,D):as(n,u,D);})}return g};var{slice:Wm,forEach:qm}=[];function Jm(e){return qm.call(Wm.call(arguments,1),t=>{if(t)for(let r in t)e[r]===void 0&&(e[r]=t[r]);}),e}function Xm(e){return typeof e!="string"?false:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(e))}var Gd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ym=function(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},a=encodeURIComponent(t),n=`${e}=${a}`;if(o.maxAge>0){let i=o.maxAge-0;if(Number.isNaN(i))throw new Error("maxAge should be a Number");n+=`; Max-Age=${Math.floor(i)}`;}if(o.domain){if(!Gd.test(o.domain))throw new TypeError("option domain is invalid");n+=`; Domain=${o.domain}`;}if(o.path){if(!Gd.test(o.path))throw new TypeError("option path is invalid");n+=`; Path=${o.path}`;}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");n+=`; Expires=${o.expires.toUTCString()}`;}if(o.httpOnly&&(n+="; HttpOnly"),o.secure&&(n+="; Secure"),o.sameSite)switch(typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite){case true:n+="; SameSite=Strict";break;case "lax":n+="; SameSite=Lax";break;case "strict":n+="; SameSite=Strict";break;case "none":n+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o.partitioned&&(n+="; Partitioned"),n},Wd={create(e,t,r,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(a.expires=new Date,a.expires.setTime(a.expires.getTime()+r*60*1e3)),o&&(a.domain=o),document.cookie=Ym(e,t,a);},read(e){let t=`${e}=`,r=document.cookie.split(";");for(let o=0;o<r.length;o++){let a=r[o];for(;a.charAt(0)===" ";)a=a.substring(1,a.length);if(a.indexOf(t)===0)return a.substring(t.length,a.length)}return null},remove(e,t){this.create(e,"",-1,t);}},Qm={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<"u")return Wd.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:r,cookieMinutes:o,cookieDomain:a,cookieOptions:n}=t;r&&typeof document<"u"&&Wd.create(r,e,o,a,n);}},Zm={name:"querystring",lookup(e){let{lookupQuerystring:t}=e,r;if(typeof window<"u"){let{search:o}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(o=window.location.hash.substring(window.location.hash.indexOf("?")));let n=o.substring(1).split("&");for(let i=0;i<n.length;i++){let s=n[i].indexOf("=");s>0&&n[i].substring(0,s)===t&&(r=n[i].substring(s+1));}}return r}},ef={name:"hash",lookup(e){let{lookupHash:t,lookupFromHashIndex:r}=e,o;if(typeof window<"u"){let{hash:a}=window.location;if(a&&a.length>2){let n=a.substring(1);if(t){let i=n.split("&");for(let s=0;s<i.length;s++){let l=i[s].indexOf("=");l>0&&i[s].substring(0,l)===t&&(o=i[s].substring(l+1));}}if(o)return o;if(!o&&r>-1){let i=a.match(/\/([a-zA-Z-]*)/g);return Array.isArray(i)?i[typeof r=="number"?r:0]?.replace("/",""):void 0}}}return o}},sa=null,qd=()=>{if(sa!==null)return sa;try{if(sa=typeof window<"u"&&window.localStorage!==null,!sa)return !1;let e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e);}catch{sa=false;}return sa},tf={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&qd())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:r}=t;r&&qd()&&window.localStorage.setItem(r,e);}},ia=null,Jd=()=>{if(ia!==null)return ia;try{if(ia=typeof window<"u"&&window.sessionStorage!==null,!ia)return !1;let e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e);}catch{ia=false;}return ia},rf={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&Jd())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:r}=t;r&&Jd()&&window.sessionStorage.setItem(r,e);}},of={name:"navigator",lookup(e){let t=[];if(typeof navigator<"u"){let{languages:r,userLanguage:o,language:a}=navigator;if(r)for(let n=0;n<r.length;n++)t.push(r[n]);o&&t.push(o),a&&t.push(a);}return t.length>0?t:void 0}},af={name:"htmlTag",lookup(e){let{htmlTag:t}=e,r,o=t||(typeof document<"u"?document.documentElement:null);return o&&typeof o.getAttribute=="function"&&(r=o.getAttribute("lang")),r}},nf={name:"path",lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>"u")return;let r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?r[typeof t=="number"?t:0]?.replace("/",""):void 0}},sf={name:"subdomain",lookup(e){let{lookupFromSubdomainIndex:t}=e,r=typeof t=="number"?t+1:1,o=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(o)return o[r]}},Xd=false;try{document.cookie,Xd=!0;}catch{}var Yd=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Xd||Yd.splice(1,1);var lf=()=>({order:Yd,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),Xa=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,r);}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Jm(r,this.options||{},lf()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=a=>a.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(Qm),this.addDetector(Zm),this.addDetector(tf),this.addDetector(rf),this.addDetector(of),this.addDetector(af),this.addDetector(nf),this.addDetector(sf),this.addDetector(ef);}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return t.forEach(o=>{if(this.detectors[o]){let a=this.detectors[o].lookup(this.options);a&&typeof a=="string"&&(a=[a]),a&&(r=r.concat(a));}}),r=r.filter(o=>o!=null&&!Xm(o)).map(o=>this.options.convertDetectedLanguage(o)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(o=>{this.detectors[o]&&this.detectors[o].cacheUserLanguage(t,this.options);}));}};Xa.type="languageDetector";var Qd={actions:{cancel:"Cancel",create:"Create {{item}}",delete:"Delete",deleteDocument:"Delete Document",deleteEntry:"Delete Entry",deleting:"Deleting...",duplicateDocument:"Duplicate Document",duplicating:"Duplicating...",edit:"Edit",new:"New",newDocument:"New Document",signOut:"Sign Out",view:"View"},common:{na:"N/A",no:"No",yes:"Yes"},dashboard:{activeUsers:"Active Users",authService:"Auth Service",cloudApi:"Cloud API",contentGrowth:"Content Growth",contentGrowthDesc:"Snapshot of document velocity over the last 7 days",dbNode:"Database Node",description:"Everything looks great in your command center today.",mediaAssets:"Media Assets",mediaCdn:"Media CDN",mediaLibrary:"Media Library",mediaLibraryDesc:"Manage high-fidelity assets with our liquid masonry gallery.",newAction:"New {{item}}",noCollections:"No collections available for creation.",openAssets:"Open Assets",quickLinks:"Quick Links",recentActivity:"Recent Activity",statusActive:"Active",statusHealthy:"Healthy",statusOptimal:"Optimal",statusSecure:"Secure",systemHealth:"System Health",systemStatus:"System Status",totalContent:"Total Content",viewAuditLogs:"View Audit Logs",welcome:"Welcome back, {{name}}"},days:{fri:"Fri",mon:"Mon",sat:"Sat",sun:"Sun",thu:"Thu",tue:"Tue",wed:"Wed"},detailView:{collections:"Collections",coreConfiguration:"Core Configuration",dateCreated:"Date Created",deleteMessage:"This action cannot be undone.",deleteTitle:"Delete {{label}}?",dynamicStatus:"Dynamic Status",generatingPreview:"Generating preview URL...",globals:"Globals",justNow:"Just now",lastModified:"Last Modified",metadata:"Metadata",newDocument:"New {{label}}",openPreview:"Open Preview in New Tab",publicAt:"Public At",quickLinks:"Quick Links"},listView:{actionsCol:"Actions",addFilter:"Add Filter",advancedFilters:"Advanced Filters",clearAll:"Clear All",columns:"Columns",createdCol:"Created",deleteBulkMessage_one:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkMessage_other:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",deleteBulkTitle:"Delete Documents",deleteMessage:"Are you sure you want to delete this document? This cannot be undone.",deleteSelected:"Delete Selected",deleteTitle:"Delete Document",filters:"Filters",getStartedCreate:"Get started by creating your first {{item}}.",lastModifiedCol:"Last Modified",noDocuments:"No documents found",noFilters:'No filters applied. Click "Add Filter" to create one.',searchPlaceholder:"Search...",selectedCount_one:"{{count}} selected",selectedCount_other:"{{count}} selected",toggleColumns:"Toggle Columns",tryAdjustingFilters:"Try adjusting your filters or search query."},login:{confirmPassword:"Confirm Password",createAccount:"Create Account",createAccountDesc:"Create an account to access the admin",createAdminAccount:"Create Admin Account",creatingAccount:"Creating account...",email:"Email",enterCredentials:"Enter your credentials to access the admin",hasAccount:"Already have an account?",noAccount:"Don't have an account?",password:"Password",setupAdmin:"Set up your admin account to get started",signIn:"Sign In",signInAction:"Sign in",signingIn:"Signing in...",signUp:"Sign up"},nav:{dashboard:"Dashboard",media:"Media",users:"Users",plugins:"Plugins",settings:"Settings",content:"Content",developer:"Developer",resources:"Resources"},sidebar:{darkMode:"Dark Mode",lightMode:"Light Mode"},toast:{accountCreated:"Account created!",connectionFailed:"Connection failed",copyError:"Failed to copy document data",dataCopied:"Document data copied to clipboard",dataPasted:"Document data pasted",draftSaved:"Draft saved",duplicated:"Document duplicated",duplicateError:"Failed to duplicate document",pasteError:"Clipboard does not contain valid document JSON",published:"Published successfully",publishError:"Failed to publish",saveError:"Failed to save changes",unpublished:"Document unpublished",unpublishError:"Failed to unpublish",updated:"Updated",welcomeBack:"Welcome back!"},userMenu:{account:"Account",apiExplorer:"API Explorer",apiKeys:"API Keys",auditLogs:"Audit Logs",developer:"Developer",documentation:"Documentation",getSupport:"Get Support",graphqlPlayground:"GraphQL Playground",permissions:"Permissions",profileSettings:"Profile Settings",resources:"Resources",sessions:"Sessions",webHooks:"Web Hooks"}};var Zd={actions:{cancel:"Annuler",create:"Cr\xE9er {{item}}",delete:"Supprimer",deleteDocument:"Supprimer le document",deleteEntry:"Supprimer l'entr\xE9e",deleting:"Suppression...",duplicateDocument:"Dupliquer le document",duplicating:"Duplication...",edit:"Modifier",new:"Nouveau",newDocument:"Nouveau Document",signOut:"D\xE9connexion",view:"Voir"},common:{na:"N/D",no:"Non",yes:"Oui"},dashboard:{activeUsers:"Utilisateurs Actifs",authService:"Service d'Authentification",cloudApi:"API Cloud",contentGrowth:"Croissance du Contenu",contentGrowthDesc:"Aper\xE7u de la vitesse des documents sur les 7 derniers jours",dbNode:"N\u0153ud de Base de Donn\xE9es",description:"Tout semble parfait dans votre centre de contr\xF4le aujourd'hui.",mediaAssets:"Ressources Multim\xE9dias",mediaCdn:"CDN Multim\xE9dia",mediaLibrary:"M\xE9diath\xE8que",mediaLibraryDesc:"G\xE9rez des ressources haute fid\xE9lit\xE9 avec notre galerie fluide.",newAction:"Nouveau {{item}}",noCollections:"Aucune collection disponible \xE0 cr\xE9er.",openAssets:"Ouvrir les Ressources",quickLinks:"Liens Rapides",recentActivity:"Activit\xE9 R\xE9cente",statusActive:"Actif",statusHealthy:"Sain",statusOptimal:"Optimal",statusSecure:"S\xE9curis\xE9",systemHealth:"Sant\xE9 du Syst\xE8me",systemStatus:"\xC9tat du Syst\xE8me",totalContent:"Contenu Total",viewAuditLogs:"Voir les Journaux d'Audit",welcome:"Bon retour, {{name}}"},days:{fri:"Ven",mon:"Lun",sat:"Sam",sun:"Dim",thu:"Jeu",tue:"Mar",wed:"Mer"},detailView:{collections:"Collections",coreConfiguration:"Configuration Principale",dateCreated:"Date de Cr\xE9ation",deleteMessage:"Cette action est irr\xE9versible.",deleteTitle:"Supprimer {{label}} ?",dynamicStatus:"Statut Dynamique",generatingPreview:"G\xE9n\xE9ration de l'URL d'aper\xE7u...",globals:"Variables Globales",justNow:"\xC0 l'instant",lastModified:"Derni\xE8re Modification",metadata:"M\xE9tadonn\xE9es",newDocument:"Nouveau {{label}}",openPreview:"Ouvrir l'Aper\xE7u",publicAt:"Public \xE0",quickLinks:"Liens Rapides"},listView:{actionsCol:"Actions",addFilter:"Ajouter un Filtre",advancedFilters:"Filtres Avanc\xE9s",clearAll:"Tout Effacer",columns:"Colonnes",createdCol:"Cr\xE9\xE9",deleteBulkMessage_one:"Voulez-vous vraiment supprimer {{count}} document ? C'est irr\xE9versible.",deleteBulkMessage_other:"Voulez-vous vraiment supprimer {{count}} documents ? C'est irr\xE9versible.",deleteBulkTitle:"Supprimer des Documents",deleteMessage:"Voulez-vous vraiment supprimer ce document ? C'est irr\xE9versible.",deleteSelected:"Supprimer la S\xE9lection",deleteTitle:"Supprimer le Document",filters:"Filtres",getStartedCreate:"Commencez par cr\xE9er votre premier {{item}}.",lastModifiedCol:"Derni\xE8re Modification",noDocuments:"Aucun document trouv\xE9",noFilters:'Aucun filtre appliqu\xE9. Cliquez sur "Ajouter un Filtre" pour en cr\xE9er un.',searchPlaceholder:"Rechercher...",selectedCount_one:"{{count}} s\xE9lectionn\xE9",selectedCount_other:"{{count}} s\xE9lectionn\xE9s",toggleColumns:"Afficher/Masquer les Colonnes",tryAdjustingFilters:"Essayez de modifier vos filtres ou votre requ\xEAte de recherche."},login:{confirmPassword:"Confirmer le Mot de Passe",createAccount:"Cr\xE9er un Compte",createAccountDesc:"Cr\xE9ez un compte pour acc\xE9der \xE0 l'administration",createAdminAccount:"Cr\xE9er un Compte Administrateur",creatingAccount:"Cr\xE9ation du compte...",email:"Email",enterCredentials:"Entrez vos identifiants pour acc\xE9der \xE0 l'administration",hasAccount:"Vous avez d\xE9j\xE0 un compte ?",noAccount:"Vous n'avez pas de compte ?",password:"Mot de Passe",setupAdmin:"Configurez votre compte administrateur pour commencer",signIn:"Se Connecter",signInAction:"Se connecter",signingIn:"Connexion...",signUp:"S'inscrire"},nav:{content:"Contenu",dashboard:"Tableau de Bord",developer:"D\xE9veloppeur",media:"M\xE9dias",plugins:"Extensions",resources:"Ressources",settings:"Param\xE8tres",users:"Utilisateurs"},sidebar:{darkMode:"Mode Sombre",lightMode:"Mode Clair"},toast:{accountCreated:"Compte cr\xE9\xE9 !",connectionFailed:"\xC9chec de la connexion",copyError:"\xC9chec de la copie des donn\xE9es",dataCopied:"Donn\xE9es copi\xE9es dans le presse-papiers",dataPasted:"Donn\xE9es coll\xE9es",draftSaved:"Brouillon enregistr\xE9",duplicated:"Document dupliqu\xE9",duplicateError:"\xC9chec de la duplication du document",pasteError:"Le presse-papiers ne contient pas de JSON valide",published:"Publi\xE9 avec succ\xE8s",publishError:"\xC9chec de la publication",saveError:"\xC9chec de l'enregistrement",unpublished:"Document d\xE9publi\xE9",unpublishError:"\xC9chec de la d\xE9publication",updated:"Mise \xE0 jour r\xE9ussie",welcomeBack:"Bon retour !"},userMenu:{account:"Compte",apiExplorer:"Explorateur d'API",apiKeys:"Cl\xE9s d'API",auditLogs:"Journaux d'Audit",developer:"D\xE9veloppeur",documentation:"Documentation",getSupport:"Obtenir de l'Aide",graphqlPlayground:"Playground GraphQL",permissions:"Permissions",profileSettings:"Param\xE8tres du Profil",resources:"Ressources",sessions:"Sessions",webHooks:"Webhooks"}};var ec={actions:{cancel:"Cancelar",create:"Crear {{item}}",delete:"Eliminar",deleteDocument:"Eliminar Documento",deleteEntry:"Eliminar Entrada",deleting:"Eliminando...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Nuevo",newDocument:"Nuevo Documento",signOut:"Cerrar Sesi\xF3n",view:"Ver"},common:{na:"N/D",no:"No",yes:"S\xED"},dashboard:{activeUsers:"Usuarios Activos",authService:"Servicio de Autenticaci\xF3n",cloudApi:"API en la Nube",contentGrowth:"Crecimiento de Contenido",contentGrowthDesc:"Instant\xE1nea de la velocidad de los documentos en los \xFAltimos 7 d\xEDas",dbNode:"Nodo de Base de Datos",description:"Todo se ve genial en tu centro de comando hoy.",mediaAssets:"Recursos Multimedia",mediaCdn:"CDN Multimedia",mediaLibrary:"Biblioteca Multimedia",mediaLibraryDesc:"Administre recursos de alta fidelidad con nuestra galer\xEDa fluida.",newAction:"Nuevo {{item}}",noCollections:"No hay colecciones disponibles para crear.",openAssets:"Abrir Recursos",quickLinks:"Enlaces R\xE1pidos",recentActivity:"Actividad Reciente",statusActive:"Activo",statusHealthy:"Saludable",statusOptimal:"\xD3ptimo",statusSecure:"Seguro",systemHealth:"Salud del Sistema",systemStatus:"Estado del Sistema",totalContent:"Contenido Total",viewAuditLogs:"Ver Registros de Auditor\xEDa",welcome:"Bienvenido, {{name}}"},days:{fri:"Vie",mon:"Lun",sat:"S\xE1b",sun:"Dom",thu:"Jue",tue:"Mar",wed:"Mi\xE9"},detailView:{collections:"Colecciones",coreConfiguration:"Configuraci\xF3n Principal",dateCreated:"Fecha de Creaci\xF3n",deleteMessage:"Esta acci\xF3n no se puede deshacer.",deleteTitle:"\xBFEliminar {{label}}?",dynamicStatus:"Estado Din\xE1mico",generatingPreview:"Generando URL de vista previa...",globals:"Variables Globales",justNow:"Justo ahora",lastModified:"\xDAltima Modificaci\xF3n",metadata:"Metadatos",newDocument:"Nuevo {{label}}",openPreview:"Abrir Vista Previa",publicAt:"P\xFAblico a las",quickLinks:"Enlaces R\xE1pidos"},listView:{actionsCol:"Acciones",addFilter:"A\xF1adir Filtro",advancedFilters:"Filtros Avanzados",clearAll:"Borrar Todo",columns:"Columnas",createdCol:"Creado",deleteBulkMessage_one:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documento? Esto no se puede deshacer.",deleteBulkMessage_other:"\xBFEst\xE1s seguro de que quieres eliminar {{count}} documentos? Esto no se puede deshacer.",deleteBulkTitle:"Eliminar Documentos",deleteMessage:"\xBFEst\xE1s seguro de que quieres eliminar este documento? Esto no se puede deshacer.",deleteSelected:"Eliminar Selecci\xF3n",deleteTitle:"Eliminar Documento",filters:"Filtros",getStartedCreate:"Comienza creando tu primer {{item}}.",lastModifiedCol:"\xDAltima Modificaci\xF3n",noDocuments:"No se encontraron documentos",noFilters:'No hay filtros aplicados. Haz clic en "A\xF1adir Filtro" para crear uno.',searchPlaceholder:"Buscar...",selectedCount_one:"{{count}} seleccionado",selectedCount_other:"{{count}} seleccionados",toggleColumns:"Mostrar/Ocultar Columnas",tryAdjustingFilters:"Intenta ajustar tus filtros o consulta de b\xFAsqueda."},login:{confirmPassword:"Confirmar Contrase\xF1a",createAccount:"Crear Cuenta",createAccountDesc:"Crea una cuenta para acceder a la administraci\xF3n",createAdminAccount:"Crear Cuenta de Administrador",creatingAccount:"Creando cuenta...",email:"Correo Electr\xF3nico",enterCredentials:"Ingresa tus credenciales para acceder a la administraci\xF3n",hasAccount:"\xBFYa tienes una cuenta?",noAccount:"\xBFNo tienes una cuenta?",password:"Contrase\xF1a",setupAdmin:"Configura tu cuenta de administrador para empezar",signIn:"Iniciar Sesi\xF3n",signInAction:"Iniciar sesi\xF3n",signingIn:"Iniciando sesi\xF3n...",signUp:"Registrarse"},nav:{content:"Contenido",dashboard:"Panel de Control",developer:"Desarrollador",media:"Multimedia",plugins:"Complementos",resources:"Recursos",settings:"Ajustes",users:"Usuarios"},sidebar:{darkMode:"Modo Oscuro",lightMode:"Modo Claro"},toast:{accountCreated:"\xA1Cuenta creada!",connectionFailed:"Error de conexi\xF3n",copyError:"Error al copiar los datos del documento",dataCopied:"Datos del documento copiados al portapapeles",dataPasted:"Datos del documento pegados",draftSaved:"Borrador guardado",duplicated:"Documento duplicado",duplicateError:"Error al duplicar el documento",pasteError:"El portapapeles no contiene un JSON de documento v\xE1lido",published:"Publicado con \xE9xito",publishError:"Error al publicar",saveError:"Error al guardar los cambios",unpublished:"Documento despublicado",unpublishError:"Error al despublicar",updated:"Actualizado",welcomeBack:"\xA1Bienvenido de nuevo!"},userMenu:{account:"Cuenta",apiExplorer:"Explorador de API",apiKeys:"Claves de API",auditLogs:"Registros de Auditor\xEDa",developer:"Desarrollador",documentation:"Documentaci\xF3n",getSupport:"Obtener Soporte",graphqlPlayground:"Playground de GraphQL",permissions:"Permisos",profileSettings:"Ajustes de Perfil",resources:"Recursos",sessions:"Sesiones",webHooks:"Webhooks"}};var tc={actions:{cancel:"Abbrechen",create:"{{item}} Erstellen",delete:"L\xF6schen",deleteDocument:"Dokument L\xF6schen",deleteEntry:"Eintrag L\xF6schen",deleting:"Wird gel\xF6scht...",duplicateDocument:"Dokument Duplizieren",duplicating:"Wird dupliziert...",edit:"Bearbeiten",new:"Neu",newDocument:"Neues Dokument",signOut:"Abmelden",view:"Ansehen"},common:{na:"k.A.",no:"Nein",yes:"Ja"},dashboard:{activeUsers:"Aktive Benutzer",authService:"Authentifizierungsdienst",cloudApi:"Cloud API",contentGrowth:"Inhaltswachstum",contentGrowthDesc:"\xDCbersicht der Dokumentgeschwindigkeit in den letzten 7 Tagen",dbNode:"Datenbankknoten",description:"Alles sieht in Ihrer Kommandozentrale heute gro\xDFartig aus.",mediaAssets:"Medieninhalte",mediaCdn:"Medien CDN",mediaLibrary:"Mediathek",mediaLibraryDesc:"Verwalten Sie hochaufl\xF6sende Assets mit unserer fl\xFCssigen Galerie.",newAction:"Neues {{item}}",noCollections:"Keine Sammlungen zur Erstellung verf\xFCgbar.",openAssets:"Assets \xD6ffnen",quickLinks:"Schnellzugriff",recentActivity:"Letzte Aktivit\xE4ten",statusActive:"Aktiv",statusHealthy:"Gesund",statusOptimal:"Optimal",statusSecure:"Sicher",systemHealth:"Systemgesundheit",systemStatus:"Systemstatus",totalContent:"Gesamter Inhalt",viewAuditLogs:"Audit-Protokolle ansehen",welcome:"Willkommen zur\xFCck, {{name}}"},days:{fri:"Fr",mon:"Mo",sat:"Sa",sun:"So",thu:"Do",tue:"Di",wed:"Mi"},detailView:{collections:"Sammlungen",coreConfiguration:"Kernkonfiguration",dateCreated:"Erstellungsdatum",deleteMessage:"Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteTitle:"{{label}} l\xF6schen?",dynamicStatus:"Dynamischer Status",generatingPreview:"Vorschau-URL wird generiert...",globals:"Globale Variablen",justNow:"Gerade eben",lastModified:"Zuletzt Ge\xE4ndert",metadata:"Metadaten",newDocument:"Neues {{label}}",openPreview:"Vorschau in neuem Tab \xF6ffnen",publicAt:"\xD6ffentlich um",quickLinks:"Schnellzugriff"},listView:{actionsCol:"Aktionen",addFilter:"Filter hinzuf\xFCgen",advancedFilters:"Erweiterte Filter",clearAll:"Alles l\xF6schen",columns:"Spalten",createdCol:"Erstellt",deleteBulkMessage_one:"Sind Sie sicher, dass Sie {{count}} Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkMessage_other:"Sind Sie sicher, dass Sie {{count}} Dokumente l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteBulkTitle:"Dokumente L\xF6schen",deleteMessage:"Sind Sie sicher, dass Sie dieses Dokument l\xF6schen m\xF6chten? Dies kann nicht r\xFCckg\xE4ngig gemacht werden.",deleteSelected:"Auswahl l\xF6schen",deleteTitle:"Dokument l\xF6schen",filters:"Filter",getStartedCreate:"Beginnen Sie mit der Erstellung Ihres ersten {{item}}.",lastModifiedCol:"Zuletzt Ge\xE4ndert",noDocuments:"Keine Dokumente gefunden",noFilters:'Keine Filter angewendet. Klicken Sie auf "Filter hinzuf\xFCgen", um einen zu erstellen.',searchPlaceholder:"Suchen...",selectedCount_one:"{{count}} ausgew\xE4hlt",selectedCount_other:"{{count}} ausgew\xE4hlt",toggleColumns:"Spalten umschalten",tryAdjustingFilters:"Versuchen Sie, Ihre Filter oder die Suchanfrage anzupassen."},login:{confirmPassword:"Passwort best\xE4tigen",createAccount:"Konto erstellen",createAccountDesc:"Erstellen Sie ein Konto, um auf die Verwaltung zuzugreifen",createAdminAccount:"Admin-Konto erstellen",creatingAccount:"Konto wird erstellt...",email:"E-Mail",enterCredentials:"Geben Sie Ihre Anmeldedaten ein, um auf die Verwaltung zuzugreifen",hasAccount:"Haben Sie bereits ein Konto?",noAccount:"Sie haben noch kein Konto?",password:"Passwort",setupAdmin:"Richten Sie Ihr Admin-Konto ein, um loszulegen",signIn:"Anmelden",signInAction:"Anmelden",signingIn:"Wird angemeldet...",signUp:"Registrieren"},nav:{content:"Inhalt",dashboard:"Dashboard",developer:"Entwickler",media:"Medien",plugins:"Plugins",resources:"Ressourcen",settings:"Einstellungen",users:"Benutzer"},sidebar:{darkMode:"Dunkler Modus",lightMode:"Heller Modus"},toast:{accountCreated:"Konto erstellt!",connectionFailed:"Verbindung fehlgeschlagen",copyError:"Fehler beim Kopieren der Dokumentdaten",dataCopied:"Dokumentdaten in die Zwischenablage kopiert",dataPasted:"Dokumentdaten eingef\xFCgt",draftSaved:"Entwurf gespeichert",duplicated:"Dokument dupliziert",duplicateError:"Fehler beim Duplizieren des Dokuments",pasteError:"Die Zwischenablage enth\xE4lt kein g\xFCltiges Dokument-JSON",published:"Erfolgreich ver\xF6ffentlicht",publishError:"Fehler beim Ver\xF6ffentlichen",saveError:"Fehler beim Speichern der \xC4nderungen",unpublished:"Ver\xF6ffentlichung r\xFCckg\xE4ngig gemacht",unpublishError:"Fehler beim R\xFCckg\xE4ngigmachen der Ver\xF6ffentlichung",updated:"Aktualisiert",welcomeBack:"Willkommen zur\xFCck!"},userMenu:{account:"Konto",apiExplorer:"API Explorer",apiKeys:"API-Schl\xFCssel",auditLogs:"Audit-Protokolle",developer:"Entwickler",documentation:"Dokumentation",getSupport:"Hilfe erhalten",graphqlPlayground:"GraphQL Playground",permissions:"Berechtigungen",profileSettings:"Profileinstellungen",resources:"Ressourcen",sessions:"Sitzungen",webHooks:"Webhooks"}};var rc={actions:{cancel:"Cancelar",create:"Criar {{item}}",delete:"Excluir",deleteDocument:"Excluir Documento",deleteEntry:"Excluir Entrada",deleting:"Excluindo...",duplicateDocument:"Duplicar Documento",duplicating:"Duplicando...",edit:"Editar",new:"Novo",newDocument:"Novo Documento",signOut:"Sair",view:"Ver"},common:{na:"N/A",no:"N\xE3o",yes:"Sim"},dashboard:{activeUsers:"Usu\xE1rios Ativos",authService:"Servi\xE7o de Autentica\xE7\xE3o",cloudApi:"API em Nuvem",contentGrowth:"Crescimento de Conte\xFAdo",contentGrowthDesc:"Vis\xE3o geral da velocidade dos documentos nos \xFAltimos 7 dias",dbNode:"N\xF3 de Banco de Dados",description:"Tudo parece \xF3timo no seu centro de comando hoje.",mediaAssets:"Ativos de M\xEDdia",mediaCdn:"CDN de M\xEDdia",mediaLibrary:"Biblioteca de M\xEDdia",mediaLibraryDesc:"Gerencie ativos de alta fidelidade com nossa galeria fluida.",newAction:"Novo {{item}}",noCollections:"Nenhuma cole\xE7\xE3o dispon\xEDvel para cria\xE7\xE3o.",openAssets:"Abrir Ativos",quickLinks:"Links R\xE1pidos",recentActivity:"Atividade Recente",statusActive:"Ativo",statusHealthy:"Saud\xE1vel",statusOptimal:"Ideal",statusSecure:"Seguro",systemHealth:"Sa\xFAde do Sistema",systemStatus:"Status do Sistema",totalContent:"Conte\xFAdo Total",viewAuditLogs:"Ver Registros de Auditoria",welcome:"Bem-vindo de volta, {{name}}"},days:{fri:"Sex",mon:"Seg",sat:"S\xE1b",sun:"Dom",thu:"Qui",tue:"Ter",wed:"Qua"},detailView:{collections:"Cole\xE7\xF5es",coreConfiguration:"Configura\xE7\xE3o Principal",dateCreated:"Data de Cria\xE7\xE3o",deleteMessage:"Esta a\xE7\xE3o n\xE3o pode ser desfeita.",deleteTitle:"Excluir {{label}}?",dynamicStatus:"Status Din\xE2mico",generatingPreview:"Gerando URL de visualiza\xE7\xE3o...",globals:"Vari\xE1veis Globais",justNow:"Agora mesmo",lastModified:"\xDAltima Modifica\xE7\xE3o",metadata:"Metadados",newDocument:"Novo {{label}}",openPreview:"Abrir Visualiza\xE7\xE3o em Nova Guia",publicAt:"P\xFAblico \xE0s",quickLinks:"Links R\xE1pidos"},listView:{actionsCol:"A\xE7\xF5es",addFilter:"Adicionar Filtro",advancedFilters:"Filtros Avan\xE7ados",clearAll:"Limpar Tudo",columns:"Colunas",createdCol:"Criado",deleteBulkMessage_one:"Tem certeza de que deseja excluir {{count}} documento? Isso n\xE3o pode ser desfeito.",deleteBulkMessage_other:"Tem certeza de que deseja excluir {{count}} documentos? Isso n\xE3o pode ser desfeito.",deleteBulkTitle:"Excluir Documentos",deleteMessage:"Tem certeza de que deseja excluir este documento? Isso n\xE3o pode ser desfeito.",deleteSelected:"Excluir Selecionados",deleteTitle:"Excluir Documento",filters:"Filtros",getStartedCreate:"Comece criando seu primeiro {{item}}.",lastModifiedCol:"\xDAltima Modifica\xE7\xE3o",noDocuments:"Nenhum documento encontrado",noFilters:'Nenhum filtro aplicado. Clique em "Adicionar Filtro" para criar um.',searchPlaceholder:"Pesquisar...",selectedCount_one:"{{count}} selecionado",selectedCount_other:"{{count}} selecionados",toggleColumns:"Alternar Colunas",tryAdjustingFilters:"Tente ajustar seus filtros ou a consulta de pesquisa."},login:{confirmPassword:"Confirmar Senha",createAccount:"Criar Conta",createAccountDesc:"Crie uma conta para acessar a administra\xE7\xE3o",createAdminAccount:"Criar Conta de Administrador",creatingAccount:"Criando conta...",email:"E-mail",enterCredentials:"Insira suas credenciais para acessar a administra\xE7\xE3o",hasAccount:"J\xE1 tem uma conta?",noAccount:"N\xE3o tem uma conta?",password:"Senha",setupAdmin:"Configure sua conta de administrador para come\xE7ar",signIn:"Entrar",signInAction:"Entrar",signingIn:"Entrando...",signUp:"Inscrever-se"},nav:{content:"Conte\xFAdo",dashboard:"Painel de Controle",developer:"Desenvolvedor",media:"M\xEDdia",plugins:"Plugins",resources:"Recursos",settings:"Configura\xE7\xF5es",users:"Usu\xE1rios"},sidebar:{darkMode:"Modo Escuro",lightMode:"Modo Claro"},toast:{accountCreated:"Conta criada!",connectionFailed:"Falha na conex\xE3o",copyError:"Falha ao copiar os dados do documento",dataCopied:"Dados do documento copiados para a \xE1rea de transfer\xEAncia",dataPasted:"Dados do documento colados",draftSaved:"Rascunho salvo",duplicated:"Documento duplicado",duplicateError:"Falha ao duplicar documento",pasteError:"A \xE1rea de transfer\xEAncia n\xE3o cont\xE9m um JSON de documento v\xE1lido",published:"Publicado com sucesso",publishError:"Falha ao publicar",saveError:"Falha ao salvar as altera\xE7\xF5es",unpublished:"Documento despublicado",unpublishError:"Falha ao despublicar",updated:"Atualizado",welcomeBack:"Bem-vindo de volta!"},userMenu:{account:"Conta",apiExplorer:"Explorador de API",apiKeys:"Chaves de API",auditLogs:"Registros de Auditoria",developer:"Desenvolvedor",documentation:"Documenta\xE7\xE3o",getSupport:"Obter Suporte",graphqlPlayground:"Playground GraphQL",permissions:"Permiss\xF5es",profileSettings:"Configura\xE7\xF5es de Perfil",resources:"Recursos",sessions:"Sess\xF5es",webHooks:"Webhooks"}};var ff={en:{translation:Qd},fr:{translation:Zd},es:{translation:ec},de:{translation:tc},pt:{translation:rc}},oc=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";Bt.use(Xa).use(is).init({resources:ff,fallbackLng:oc,lng:oc,interpolation:{escapeValue:false}});function Io(e,t,r){return r in t?t[r]:Di(e,t,r)}function Di(e,t,r){for(let o of e)if(o.name){if(o.type==="tabs"&&"tabs"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.tabs?.flatMap(i=>i.fields||[])||[],a,r);if(n!==void 0)return n}}if((o.type==="group"||o.type==="collapsible")&&"fields"in o){let a=t[o.name];if(a&&typeof a=="object"){if(r in a)return a[r];let n=Di(o.fields||[],a,r);if(n!==void 0)return n}}}}function Fi({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:i}){let{t:s}=H(),l=t||e.slug,{permissions:d}=eo(),c=d?.collections?.[l]?.create!==false,u=d?.collections?.[l]?.delete!==false,p=d?.collections?.[l]?.update!==false,f=()=>{if(c)if(a)a();else {let $=`${_e}/${l}/new`;Lt($);}},m=$=>{if(n)n($);else {let ne=`${_e}/${l}/${$}`;Lt(ne);}},[y,v]=useState(r),[x,h]=useState(o),[S,N]=useState(false),[V,P]=useState(1),[k,g]=useState(10),[b,w]=useState(new Set),[D,F]=useState(""),[E,R]=useState(""),[M,z]=useState([]);useEffect(()=>{let $=setTimeout(()=>{R(D),P(1);},300);return ()=>clearTimeout($)},[D]);let{confirm:I,alert:J}=vt(),Z=()=>{z([...M,{field:"",operator:"equals",value:""}]);},te=()=>{F(""),z([]),he(null);},Y=$=>{z(M.filter((ne,pe)=>pe!==$));},ae=($,ne)=>{z(M.map((pe,Ht)=>Ht===$?{...pe,...ne}:pe));},[ue,he]=useState(null),[U,K]=useState(false),[_,xe]=useState(false);function Be($){let ne=[];for(let pe of $||[])if(!(pe.hidden===true||pe.admin?.hidden||pe.name==="id"))if(pe.type==="tabs"&&pe.tabs)for(let Ht of pe.tabs)Ht.fields&&ne.push(...Be(Ht.fields));else if((pe.type==="row"||pe.type==="collapsible")&&pe.fields)ne.push(...Be(pe.fields));else {if(!pe.name)continue;ne.push(pe);}return ne}let we=useMemo(()=>Be(e.fields),[e.fields]),C=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:we.find($=>$.type!=="group"&&typeof $.name=="string")?.name,[G,Ne]=useState(()=>{let $;return e.admin?.defaultColumns?$=[...e.admin?.defaultColumns||[]]:$=we.slice(0,4).map(ne=>ne.name).filter(ne=>!!ne),C&&$.includes(C)&&($=[C,...$.filter(ne=>ne!==C)]),$.includes("updatedAt")||$.push("updatedAt"),new Set($)}),Oe=useCallback($=>{Ne(ne=>{let pe=new Set(ne);return pe.has($)?pe.delete($):pe.add($),pe});},[]);function Ve($){let ne=we.find(pe=>pe.name===$);return ne&&ne.type==="group"&&ne.fields?.[0]?.name?`${$}.${ne.fields[0].name}`:$}let Fe=useCallback($=>{let ne=Ve($);he(pe=>pe&&pe.field===ne?{field:ne,direction:pe.direction==="asc"?"desc":"asc"}:{field:ne,direction:"asc"});},[]),mt=useMemo(()=>{let $=[];for(let ne of Array.from(G))if(ne==="status")$.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let pe=we.find(Ht=>Ht.name===ne);pe&&pe.name&&$.push(pe);}return $},[we,G]);function Cr($){return !$.name||!C?false:$.name===C||$.type==="group"&&$.fields?.[0]?.name===C}function oe($,ne){return ne.name?Io(e.fields,$,ne.name)??null:null}let O=useCallback(async()=>{N(true);try{let $=new URLSearchParams({page:V.toString(),limit:k.toString(),depth:"1"});E&&$.append("search",E),ue&&$.append("sort",ue.field),ue&&$.append("order",ue.direction),M.length>0&&$.append("filters",JSON.stringify(M));let ne=await Me(to(`/api/${l}?${$}`),{autoToast:!1});v(ne.docs||[]),h(ne.totalDocs||0);}catch($){console.error("Failed to load docs:",$);}finally{N(false);}},[l,V,k,E,ue,M]);useEffect(()=>{y.length===0&&o===0&&O();},[]);let X$1=useRef(true);useEffect(()=>{if(X$1.current){X$1.current=false;return}O();},[V,k,E,ue,M]);let de=()=>{b.size===y.length?w(new Set):w(new Set(y.map($=>$.id)));},Ie=$=>{let ne=new Set(b);ne.has($)?ne.delete($):ne.add($),w(ne);},ze=()=>{I({title:s("listView.deleteBulkTitle",{defaultValue:"Delete Documents"}),message:s("listView.deleteBulkMessage",{defaultValue:"Are you sure you want to delete {{count}} document(s)? This cannot be undone.",count:b.size}),variant:"danger",onConfirm:async()=>{try{for(let $ of Array.from(b))await Dt(`/api/${l}/${$}`);w(new Set),O(),j.success("Documents deleted");}catch($){console.error("Bulk delete failed:",$),j.error("Failed to delete some documents");}}});},Tt=$=>{I({title:s("listView.deleteTitle",{defaultValue:"Delete Document"}),message:s("listView.deleteMessage",{defaultValue:"Are you sure you want to delete this document? This cannot be undone."}),variant:"danger",onConfirm:async()=>{try{await Dt(`/api/${l}/${$}`),O(),j.success("Document deleted");}catch(ne){console.error("Delete failed:",ne),j.error("Failed to delete document");}}});},gr=Math.ceil(x/k),Or=D||M.length>0||ue;return jsxs("div",{className:"space-y-6",children:[jsx(jt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:x>0?[jsxs("span",{className:"text-xs font-bold opacity-60",children:[x," documents"]},"count")]:void 0,action:c?{label:s("actions.create",{defaultValue:"Create {{item}}",item:e.singularLabel||e.label||l}),href:a?void 0:`${_e}/${l}/new`,onClick:a?f:void 0,icon:Plus}:void 0}),jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",placeholder:s("listView.searchPlaceholder",{defaultValue:"Search..."}),value:D,onChange:$=>F($.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-sm font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})]}),jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxs("button",{type:"button",onClick:()=>K(!U),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${U||M.length>0?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(Filter,{className:"w-4 h-4"}),s("listView.filters",{defaultValue:"Filters"}),M.length>0&&jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-[var(--kyro-sidebar-text-active)] text-[var(--kyro-sidebar-active)] rounded-full text-xs",children:M.length})]}),jsxs("div",{className:"relative",children:[jsxs("button",{type:"button",onClick:()=>xe(!_),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",children:[jsx(Columns3,{className:"w-4 h-4"}),s("listView.columns",{defaultValue:"Columns"})]}),_&&jsxs("div",{className:"absolute right-0 top-full mt-2 w-56 surface-tile border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 overflow-hidden",children:[jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:s("listView.toggleColumns",{defaultValue:"Toggle Columns"})})}),jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:we.map($=>$.name?jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsx("input",{type:"checkbox",checked:G.has($.name),onChange:()=>Oe($.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:$.label||$.name})]},$.name):null)})]})]}),Or&&jsx("button",{type:"button",onClick:te,className:"px-4 py-2 rounded-xl font-bold text-sm text-red-500 hover:bg-red-50 dark:hover:bg-red-500/10 transition-all",children:s("listView.clearAll",{defaultValue:"Clear All"})})]})]}),U&&jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:s("listView.advancedFilters",{defaultValue:"Advanced Filters"})}),jsxs("button",{type:"button",onClick:Z,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-bold text-[var(--kyro-sidebar-active)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all",children:[jsx(Plus,{className:"w-4 h-4"}),s("listView.addFilter",{defaultValue:"Add Filter"})]})]}),jsxs("div",{className:"space-y-3",children:[M.map(($,ne)=>jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsx("select",{value:$.field,onChange:pe=>ae(ne,{field:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:we.map(pe=>jsx("option",{value:pe.name,children:pe.label||pe.name},pe.name))}),jsxs("select",{value:$.operator,onChange:pe=>ae(ne,{operator:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsx("option",{value:"equals",children:"Equals"}),jsx("option",{value:"contains",children:"Contains"}),jsx("option",{value:"gt",children:"Greater than"}),jsx("option",{value:"lt",children:"Less than"}),jsx("option",{value:"gte",children:"Greater or equal"}),jsx("option",{value:"lte",children:"Less or equal"})]}),jsx("input",{type:"text",value:$.value,onChange:pe=>ae(ne,{value:pe.target.value}),placeholder:s("fields.value",{defaultValue:"Value..."}),className:"flex-1 min-w-[150px] px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]"}),jsx("button",{type:"button",onClick:()=>Y(ne),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsx(X,{className:"w-4 h-4"})})]},ne)),M.length===0&&jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:s("listView.noFilters",{defaultValue:'No filters applied. Click "Add Filter" to create one.'})})]})]}),b.size>0&&jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:s("listView.selectedCount",{defaultValue:"{{count}} selected",count:b.size})}),jsxs("div",{className:"flex gap-2",children:[u&&jsxs("button",{type:"button",onClick:ze,className:"flex items-center gap-2 px-4 py-2 bg-red-500 text-white rounded-lg font-bold text-sm hover:bg-red-600 transition-all",children:[jsx(Trash2,{className:"w-4 h-4"}),s("listView.deleteSelected",{defaultValue:"Delete Selected"})]}),jsx("button",{type:"button",onClick:()=>w(new Set),className:"px-4 py-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] font-bold text-sm transition-all",children:s("actions.cancel",{defaultValue:"Cancel"})})]})]}),jsx("div",{className:"surface-tile overflow-hidden",children:S?jsx("div",{className:"space-y-2 p-4",children:jsx(Wt,{variant:"table-row",count:8})}):y.length===0?jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsx(Archive,{className:"w-4 h-4"})}),jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:s("listView.noDocuments",{defaultValue:"No documents found"})}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Or?s("listView.tryAdjustingFilters",{defaultValue:"Try adjusting your filters or search query."}):s("listView.getStartedCreate",{defaultValue:"Get started by creating your first {{item}}.",item:(e.singularLabel||e.label||l).toLowerCase()})}),!Or&&c&&jsxs("button",{type:"button",onClick:f,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsx(Plus,{className:"w-4 h-4"}),s("actions.create",{defaultValue:"Create {{item}}",item:String(e.singularLabel||e.label||l)})]})]}):jsx("div",{className:"overflow-x-auto",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsx("th",{className:"px-4 py-4 w-10",children:jsx("input",{type:"checkbox",checked:b.size===y.length&&y.length>0,onChange:de,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),mt.map($=>jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Fe($.name),children:jsxs("div",{className:"flex items-center gap-2",children:[vf(mt,$.type)??($.label||$.name),ue&&ue.field===$.name&&jsx(ChevronUp,{className:"w-4 h-4"})]})},$.name)),e.timestamps?jsx("th",{className:"px-4 py-4",children:s("listView.createdCol",{defaultValue:"Created"})}):null,e.timestamps?jsx("th",{className:"px-4 py-4",children:s("listView.lastModifiedCol",{defaultValue:"Last Modified"})}):null,jsx("th",{className:"px-4 py-4 text-right",children:s("listView.actionsCol",{defaultValue:"Actions"})})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:y.map($=>jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>m($.id),children:[jsx("td",{className:"px-4 py-3",onClick:ne=>ne.stopPropagation(),children:jsx("input",{type:"checkbox",checked:b.has($.id),onChange:()=>Ie($.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),mt.map(ne=>{let pe=oe($,ne),Ht=ne.type==="select"&&pe&&Array.isArray(ne.options)?ne.options.find(Wo=>Wo.value===pe)?.label||pe:yf(pe,ne.type,s);return jsx("td",{className:`px-4 py-3 ${Cr(ne)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Ht},ne.name)}),e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.createdAt?new Date($.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:$.updatedAt?new Date($.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsx("td",{className:"px-4 py-3 text-right",onClick:ne=>ne.stopPropagation(),children:jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>m($.id),className:"flex items-center gap-2 px-3 py-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-all",title:p?s("actions.edit",{defaultValue:"Edit"}):s("actions.view",{defaultValue:"View"}),children:jsx(Pencil,{className:"w-4 h-4"})}),u&&jsx("button",{type:"button",onClick:()=>Tt($.id),className:"inline-flex items-center justify-center w-8 h-8 rounded-md text-[var(--kyro-text-muted)] hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-500/10 transition-colors",title:s("actions.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-4 h-4"})})]})})]},$.id))})]})})}),jsx(kd,{page:V,totalPages:gr,totalDocs:x,limit:k,onPageChange:P,onLimitChange:$=>{g($),P(1);}})]})}function yf(e,t,r){if(e==null)return "\u2014";if(typeof e=="boolean")return e?r?r("common.yes",{defaultValue:"Yes"}):"Yes":r?r("common.no",{defaultValue:"No"}):"No";if(t==="number"||t==="price")return String(e);if(t==="date"||t==="datetime")return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});if(Array.isArray(e))return e.map(o=>{if(o&&typeof o=="object"){let a="value"in o&&typeof o.value=="object"&&o.value!==null?o.value:o,n=a.firstName||a.lastName?`${a.firstName||""} ${a.lastName||""}`.trim():void 0;return a.fullName||n||a.title||a.name||a.label||a.email||a.filename||a.slug||a.id||JSON.stringify(a).slice(0,30)}return String(o??"").slice(0,30)}).filter(Boolean).join(", ");if(typeof e=="object"){let o="value"in e&&typeof e.value=="object"&&e.value!==null?e.value:e,a=o.firstName||o.lastName?`${o.firstName||""} ${o.lastName||""}`.trim():void 0,n=o.fullName||a||o.title||o.name||o.label||o.email||o.filename||o.slug;return n?String(n):o.id?String(o.id):JSON.stringify(o).slice(0,50)}return String(e).slice(0,60)}function vf(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}function Qa(e){return e?Array.isArray(e)?e:Object.values(e):[]}function ps(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function ms(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ya(e,t){let r=new Set(e.map(o=>o.slug));for(let o of t)r.has(o.slug)||(e.push(o),r.add(o.slug));}var hf={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function Lo(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let i of e){if(i.name===a)if(n){if(i.fields&&Array.isArray(i.fields))return Lo(i.fields,n,r);if(i.type==="tabs"&&i.tabs&&Array.isArray(i.tabs)){for(let l of i.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,n,r))return true;return false}if(i.type==="blocks"&&i.blocks&&Array.isArray(i.blocks)){let l=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of i.blocks)if(c.slug===l&&c.fields&&Array.isArray(c.fields))return Lo(c.fields,d,r);return false}return i.type==="array"&&i.fields&&Array.isArray(i.fields)?Lo(i.fields,n,r):false}else return Object.assign(i,r),true;if(!i.name||i.type==="tabs"||i.type==="row"||i.type==="collapsible"){if(i.fields&&Array.isArray(i.fields)&&Lo(i.fields,t,r))return true;if(i.type==="tabs"&&i.tabs&&Array.isArray(i.tabs)){for(let l of i.tabs)if(l.fields&&Array.isArray(l.fields)&&Lo(l.fields,t,r))return true}}}return false}function xf(e,t){for(let[r,o]of Object.entries(e)){let a=hf[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:i,...s}=n;if(o.admin={...o.admin,...s},i&&o.fields&&Array.isArray(o.fields))for(let[l,d]of Object.entries(i))Lo(o.fields,l,d);}}}function kf(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(minimalCollections)),r.push(...coreSettingsGlobals);break;case "starter":t.push(...Object.values(starterCollections)),r.push(...coreSettingsGlobals);break;case "blog":t.push(...Object.values(blogCollections)),r.push(...coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(ecommerceCollections)),r.push(...allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(minimalCollections),...Object.values(starterCollections),...Object.values(blogCollections),...Object.values(ecommerceCollections),...Object.values(kitchenSinkCollections)),r.push(...allSettingsGlobals);break}return Ya(t,Object.values(mediaCollections)),Ya(t,Object.values(authCollections)),{collections:ps(t),globals:ms(r)}}function wf(e){let t=Qa(e.collections),r=Qa(e.globals);if(t.length===0&&r.length===0)return kf("kitchen-sink");let o=[];return Ya(o,Object.values(mediaCollections)),Ya(o,Object.values(authCollections)),Ya(o,t),{collections:ps(o),globals:ms(r)}}function Nf(){return projectConfig?projectConfig:null}var mc=Nf()||{collections:[],globals:[]},fc=wf(mc);xf(fc.collections,mc.collectionOverrides||{});var gc=fc,la=gc.collections,yc=gc.globals,Li=["users","audit_logs"];Object.values(la).filter(e=>!Li.includes(e.slug)&&e.admin?.hidden!==true);function fs({icon:e,title:t,description:r,action:o}){return jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function qt(e,t=false){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>qt(r,false));if(typeof e=="object"){let r=e,o=Object.keys(r),a="id"in r&&(typeof r.id=="string"||r.id===null),n="url"in r&&("filename"in r||"mimeType"in r);if(!t&&a&&n&&o.length<=25)return r.id;if(!t&&"relationTo"in r&&"value"in r&&typeof r.value=="object"&&r.value!==null){let s=r.value;if("id"in s&&(typeof s.id=="string"||typeof s.id=="number"))return {relationTo:r.relationTo,value:s.id}}if(!t&&a&&"createdAt"in r&&"updatedAt"in r)return r.id;let i={};for(let s of o)i[s]=qt(r[s],false);return i}return e}function Eo(e,t){if(e===t)return true;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return false;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return false;for(let a=0;a<e.length;a++)if(!Eo(e[a],t[a]))return false;return true}if(Array.isArray(e)||Array.isArray(t))return false;let r=Object.keys(e).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id"),o=Object.keys(t).filter(a=>a!=="id"&&a!=="_key"&&a!=="_id");if(r.length!==o.length)return false;for(let a of r)if(!o.includes(a)||!Eo(e[a],t[a]))return false;return true}function Bi(e){if(e==null||e===""||e===false)return true;if(Array.isArray(e))return e.length===0;if(typeof e=="object"){if(Object.keys(e).length===0)return true;if(e.type==="doc"&&Array.isArray(e.content))return e.content.length===0||e.content.length===1&&e.content[0].type==="paragraph"&&!e.content[0].content}return false}var gs=null,vc=false,Mi=async()=>(gs&&vc||(gs=createStorage({driver:Pf({dbName:"kyro-autosave",storeName:"autosave"})}),vc=true),gs),Rf=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Mi()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Mi()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Mi()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ye=create()(persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,previewUrl:null,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields),i=qt(o),s=qt(a.lastSavedData[r]);Bi(i)&&Bi(s)||Eo(i,s)?n.delete(r):n.add(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),i={...a.formData},s=i;for(let l=0;l<n.length-1;l++){s[n[l]]===void 0&&(s[n[l]]={});let d=s[n[l]];s[n[l]]={...d},s=s[n[l]];}return s[n[n.length-1]]=o,{formData:i}});},setActiveTab:r=>e({activeTab:r}),setIsSlugLocked:r=>e(o=>({isSlugLocked:typeof r=="function"?r(o.isSlugLocked):r})),setView:r=>e({view:r}),setIsDropdownOpen:r=>e(o=>({isDropdownOpen:typeof r=="function"?r(o.isDropdownOpen):r})),setVersions:r=>e({versions:r}),setLoadingVersions:r=>e({loadingVersions:r}),setShowPreview:r=>e(o=>({showPreview:typeof r=="function"?r(o.showPreview):r})),setPreviewUrl:r=>e({previewUrl:r}),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[i,s]of Object.entries(a))o-new Date(s.draftUpdatedAt).getTime()<6048e5&&(n[i]=s);e({draftCache:n});},setDraftCache:(r,o)=>e(a=>({draftCache:{...a.draftCache,[r]:o}})),getDraftCache:r=>t().draftCache[r]||null,clearDraftCache:r=>e(o=>{let a={...o.draftCache};return delete a[r],{draftCache:a}})}),{name:"kyro-autoform-storage",storage:createJSONStorage(()=>Rf()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));var bc="other";function hc(){return bc}function ys(e){bc=e;}function vs(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function kc(){let e=useRef([]),t=useRef(false);return {queueTask:useCallback((o,a)=>{e.current.push(o);async function n(){if(!t.current&&!(typeof a?.beforeProcess=="function"&&a.beforeProcess()===false))for(;e.current.length>0;){let i=e.current.pop();e.current=[],t.current=true;try{i&&await i();}catch(s){console.error("Error in queued function:",s);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function wc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:i,onActionError:s}){let l=ye(),{confirm:d}=vt(),{formData:c,setFormData:u,setField:p,lastSavedData:f,setLastSavedData:m,setHasUnsavedChanges:y,isSlugLocked:v,loadDocument:x,setIsAutoSaving:h,setAutoSaveStatus:S,setVersions:N,setLoadingVersions:V,sidebarCollapsed:P,setSidebarCollapsed:k,getDraftCache:g,setDraftCache:b,clearDraftCache:w,resetForm:D}=l,F=!!e?.versions,E=o||t?.id||a||r,R=useRef(false);!o&&E&&c&&Object.keys(c).length>0&&c.id!==E&&(R.current=true),useEffect(()=>{R.current&&(R.current=false,D());},[D]);let M=useRef(null),z=useRef(null),I=useRef(null),J=useRef(typeof navigator<"u"?navigator.onLine:true),Z=useRef(0),te=useRef(false),Y=useRef(null),ae=useRef(""),ue=useRef(""),{queueTask:he}=kc(),U=useCallback(oe=>o?`global:${o}`:r&&oe?`${r}:${oe}`:null,[r,o]),K=useCallback((oe,O,X)=>{b(oe,{data:O,baseUpdatedAt:f.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:X?.lastSyncedAt??null});},[f.updatedAt,b]),_=useCallback(async()=>{let oe=o?Ye(`/api/globals/${o}/versions`):r&&c.id?Ye(`/api/${r}/${c.id}/versions`):null;if(oe){V(true);try{let X=await(await ct(oe)).json();N(X.docs||[]);}catch(O){console.error("Failed to fetch versions:",O);}finally{V(false);}}},[c.id,r,o,V,N]),xe=useCallback(()=>{let oe=ye.getState(),O=oe.formData;if(te.current||!r||!O.id||!oe.hasDirtyFields())return;let X=U(O.id);X&&K(X,O);},[r,U,K]),Be=useCallback(async oe=>{let O=ye.getState(),X=O.formData,de=O.lastSavedData;if(te.current||!o&&(!r||!X.id)||!O.hasDirtyFields())return;let Ie=U(X.id);if(Ie&&K(Ie,X),!J.current){S("offline");return}h(true),S("saving"),O.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let ze=o?Ye(`/api/globals/${o}?autosave=true`):Ye(`/api/${r}/${X.id}?autosave=true`),Tt=await ct(ze,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:oe?.keepalive,body:JSON.stringify({...qt(X,!0),baseUpdatedAt:de.updatedAt??null})});if(Tt.ok)Z.current=Date.now(),O.setRetryCount(0),O.setLastSavedAt(Date.now()),I.current&&clearTimeout(I.current),Ie&&b(Ie,{data:X,baseUpdatedAt:de.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),S("success"),setTimeout(()=>{ye.getState().autoSaveStatus==="success"&&S("idle");},2e3);else if(Tt.status===409)S("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch(ze){console.error("Auto-save failed:",ze);let Tt=ye.getState(),gr=Tt.retryCount;if(gr<5){Tt.setRetryCount(gr+1),S("retrying");let Or=Math.min(1e3*Math.pow(2,gr),6e4);I.current&&clearTimeout(I.current),I.current=setTimeout(()=>we(oe),Or);}else S("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),h(false),ye.getState().setBackgroundProcessing(false);}},[r,U,o,K,S,b,h,F]),we=useCallback(oe=>{he(()=>Be(oe),{beforeProcess:()=>true,afterProcess:()=>{}});},[Be,he]),C=useCallback(async(oe,O=true)=>{let X=ye.getState(),de=oe||X.formData,Ie=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${de.id}`),ze=await ct(Ie,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(O)},body:JSON.stringify({...qt(de,true),baseUpdatedAt:X.lastSavedData.updatedAt??null})});return ze.status===409&&S("conflict"),ze},[r,o,S]),G=useCallback(async(oe=true)=>{let O=ye.getState(),X=O.formData,de=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${X.id}`),Ie=await ct(de,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(oe)},body:JSON.stringify({...qt(X,true)})});if(Ie.ok){let Tt=(await Ie.json()).data||X;O.loadDocument(Tt,Tt),S("success"),setTimeout(()=>{ye.getState().autoSaveStatus==="success"&&S("idle");},2e3);}return Ie},[r,o,S]);useEffect(()=>{let oe=()=>{k(!P);};return window.addEventListener("toggle-sidebar",oe),()=>window.removeEventListener("toggle-sidebar",oe)},[P,k]);let Ne=useRef(null),Oe=useRef(""),Ve=useRef(false);useEffect(()=>{let oe=o||t?.id,O=JSON.stringify(t);Ve.current&&Ne.current===oe&&Oe.current===O||(x(t||{},t||{}),Ve.current=true,Ne.current=oe,Oe.current=O);},[r,c.id,o,t,x]),useEffect(()=>{if(!r||!t?.id)return;let oe=U(c.id);if(!oe||Y.current===oe)return;let O=false;return (async()=>{if(!F)return;let de=g(oe);if(de){if(JSON.stringify(de.data)===JSON.stringify(t)){w(oe);return}Y.current=oe,d({title:"Restore draft?",message:"A newer autosaved draft was found for this document. Restore it or discard it and continue with the saved version.",confirmLabel:"Restore draft",cancelLabel:"Discard draft",onConfirm:async()=>{if(O)return;let ze={...ye.getState().formData,...de.data};u(ze),i?.("Recovered autosaved draft");},onCancel:async()=>{w(oe);}});}})(),()=>{O=true;}},[w,r,d,U,g,t,i,u,F]);function Fe(oe,O){for(let X of oe){if(X.name===O&&X.admin?.autoGenerate==="title")return X;if(X.type==="tabs"&&"tabs"in X)for(let de of X.tabs){let Ie=Fe(de.fields,O);if(Ie)return Ie}if((X.type==="group"||X.type==="collapsible")&&"fields"in X){let de=Fe(X.fields,O);if(de)return de}}}useEffect(()=>{if(!e?.fields)return;let oe=e.fields;if(!Fe(oe,"metaTitle"))return;let X=Io(oe,c,"title"),de=X?String(X):"";de&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&p("metaTitle",de);},[c,e?.fields,p]),useEffect(()=>{let oe=e?.fields,O=oe?.find(Ie=>Ie.name==="slug"&&Ie.admin?.autoGenerate);if(!O?.admin?.autoGenerate)return;let X=O.admin.autoGenerate,de=Io(oe,c,X);if(v&&typeof de=="string"){let Ie=vs(de);Ie!==c.slug&&p("slug",Ie);}},[c,v,e?.fields,p]),useEffect(()=>{if(P||!o&&(!r||!c.id)||!ye.getState().hasDirtyFields()||hc()!=="keystroke")return;ys("other");let O=JSON.stringify(c);O!==ae.current&&(M.current&&clearTimeout(M.current),M.current=setTimeout(xe,1500),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{ae.current=O,we();},8e3));},[c,P,r,o,xe,we]),useEffect(()=>{if(!o&&(!r||!c.id))return;let oe=()=>{te.current||!ye.getState().hasDirtyFields()||we({keepalive:true});},O=()=>{document.hidden&&oe();},X=()=>{J.current=true,oe();},de=()=>{J.current=false;let Ie=ye.getState();Ie.hasDirtyFields()&&Ie.setAutoSaveStatus("offline");};return window.addEventListener("blur",oe),window.addEventListener("pagehide",oe),window.addEventListener("online",X),window.addEventListener("offline",de),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("blur",oe),window.removeEventListener("pagehide",oe),window.removeEventListener("online",X),window.removeEventListener("offline",de),document.removeEventListener("visibilitychange",O);}},[r,o,c.id,we]),useEffect(()=>{let oe=JSON.stringify(c);if(oe===ue.current)return;ue.current=oe;let O=document.getElementById("form-data");O&&(O.value=oe),n?.(c);},[c,n]),useEffect(()=>{(o||c.id)&&_();},[c.id,o,_]);let mt=!c.id&&!o?"draft":F&&c.status||"published",Cr=(!!c.id||!!o)&&mt==="draft";return {...l,fetchVersions:_,performAutoSave:we,saveDocument:C,forceSave:G,autoSaveSkipRef:te,lastAutoSaveTimeRef:Z,documentStatus:mt,hasUnpublishedChanges:Cr,versionsEnabled:F}}var Za=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:i=false})=>{let{t:s}=H(),[l,d]=useState(false),[c,u]=useState(""),[p,f]=useState([]),[m,y]=useState(false),[v,x]=useState([]),[h,S]=useState(true);useEffect(()=>{Me("/api/collections").then(F=>{x((F.collections||[]).map(E=>E.slug||E.name||E)),S(false);}).catch(()=>S(false));},[]);let N=(F="")=>{y(true);let E=`/api/${e}?${Tn(F,[a],20)}`;Me(E).then(R=>{f(R.docs||[]),y(false);}).catch(()=>y(false));};useEffect(()=>{l&&N(c);},[l,c,e,a]);let V=F=>F?.[a]||F?.title||F?.name||F?.label||F?.filename||F?.slug||F?.id||"Untitled",P=t?r:o?[o]:[],k=F=>{t?P.includes(F.id)?n("selectedIds",P.filter(E=>E!==F.id)):n("selectedIds",[...P,F.id]):(n("selectedId",F.id),n("selectedIds",[F.id]),d(false));},g=F=>P.includes(F),b=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",w=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",D=e&&typeof e=="string"&&e.length>0;return jsxs("div",{className:i?"space-y-2":"space-y-4",children:[jsxs("div",{className:i?"flex items-center gap-2":"space-y-3",children:[!D&&jsx(Fragment,{children:h?jsx("div",{className:w+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxs("select",{value:e,onChange:F=>n("relationTo",F.target.value),className:w,children:[jsx("option",{value:"",children:"Select collection..."}),v.map(F=>jsx("option",{value:F,children:F},F))]})}),!i&&jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:t,onChange:F=>n("hasMany",F.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxs("div",{className:"relative",children:[jsxs("div",{className:"relative",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",value:c,onChange:F=>{u(F.target.value),d(true);},onFocus:()=>d(true),onBlur:()=>setTimeout(()=>d(false),200),placeholder:`Search ${e}...`,className:`${b} pl-9`}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:m&&jsx(LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsx("div",{className:"absolute z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-48 overflow-auto",children:m?jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):p.length===0?jsx(fs,{title:s("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:p.map(F=>jsxs("button",{type:"button",onMouseDown:E=>E.preventDefault(),onClick:()=>k(F),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${g(F.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsx("span",{children:V(F)}),g(F.id)&&jsx("span",{children:"\u2713"})]},F.id))})})]}),P.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(F=>{let E=p.find(R=>R.id===F)||{id:F};return jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[V(E),jsx("button",{type:"button",onMouseDown:R=>R.preventDefault(),onClick:()=>{t?n("selectedIds",P.filter(R=>R!==F)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]},F)})})]})};var $i=(e,t)=>{let r=e?.toLowerCase()||"",o=t?.toLowerCase()||"";return r.startsWith("image/")||o.match(/\.(jpe?g|png|gif|webp|avif|svg)$/i)?"image":r.startsWith("video/")||o.match(/\.(mp4|webm|ogg|mov)$/i)?"video":r.startsWith("audio/")||o.match(/\.(mp3|wav|ogg|m4a)$/i)?"audio":r.includes("pdf")||o.endsWith(".pdf")?"pdf":o.match(/\.(doc|docx|txt|rtf|odt)$/i)?"document":o.match(/\.(xls|xlsx|csv)$/i)?"spreadsheet":o.match(/\.(zip|tar|gz|7z|rar)$/i)?"archive":"other"},Tc=({type:e,className:t})=>{switch(e){case "image":return jsx(Image,{className:t});case "video":return jsx(Film,{className:t});case "audio":return jsx(Music,{className:t});case "pdf":case "document":return jsx(FileText,{className:t});default:return jsx(File,{className:t})}};function hr({field:e,value:t,onChange:r,disabled:o}){let a=useRef(null),n=useRef(null),[i,s]=useState(false),[l,d]=useState(false),[c,u]=useState(false),[p,f]=useState([]),[m,y]=useState([]),[v,x]=useState(""),[h,S]=useState(false),[N,V]=useState(""),[P,k]=useState(false),[g,b]=useState(""),[w,D]=useState(""),[F,E]=useState([]),R=e?.label||e?.name||"File",M=e.maxCount??(e.hasMany?999:1),z=M>1,I=Array.isArray(t)?t:t?[t]:[],J=I.length<M,[Z,te]=useState({});useEffect(()=>{(async()=>{let G=I.filter(Fe=>typeof Fe=="string").map(Fe=>Fe),Ne=I.filter(Fe=>typeof Fe=="object"&&Fe!==null&&typeof Fe.id=="string"&&!Fe.url&&!Fe.filename&&!Fe.mimeType).map(Fe=>Fe.id),Ve=[...G,...Ne].filter(Fe=>!Z[Fe]);if(Ve.length!==0)try{let Fe=await Promise.all(Ve.map(mt=>Me(`/api/media/${mt}`)));te(mt=>{let Cr={...mt};return Fe.forEach(oe=>{oe&&oe.id&&(Cr[oe.id]=oe);}),Cr});}catch(Fe){console.error("Failed to fetch media details:",Fe);}})();},[t,Z]),useEffect(()=>{l&&(Y(),ae());},[l,v]);let Y=async()=>{try{let C=await Me(to("/api/media/folders"));y(C.folders||[]);}catch{y([]);}},ae=async()=>{S(true);try{let C=to("/api/media?limit=60&sortBy=createdAt&sortDir=desc");v&&(C+="&folder="+encodeURIComponent(v));let G=await Me(C);f(G.docs||[]);}catch{f([]);}finally{S(false);}},ue=async C=>{s(true);try{let G=new FormData;G.append("file",C),v&&G.append("folder",v);let Ne=await Dn("/api/media/upload",G),Oe=Ne.data||Ne.doc||Ne,Ve={...Oe,id:Oe.id,filename:Oe.filename,originalName:Oe.originalName??C.name,url:Oe.url,mimeType:Oe.mimeType||C.type};r(z?[...I,Ve]:Ve),j.success(`Asset synchronized: ${Ve.filename}`);}catch(G){console.error("Upload failed:",G),j.error(`Upload failed: ${G instanceof Error?G.message:"Unknown error"}`);}finally{s(false);}},he=async()=>{let C=g.trim();if(C){D("");try{let G=await ut("/api/media/upload",{url:C}),Ne=(()=>{try{return new URL(C).pathname.split("/").pop()||G.originalName||"url-image"}catch{return G.originalName||"url-image"}})(),Oe={id:G.id,filename:G.filename,originalName:Ne,url:G.url,mimeType:G.mimeType||"image/*"};r(z?[...I,Oe]:Oe),j.success(`URL asset established: ${Oe.filename}`),b(""),k(!1);}catch(G){let Ne=G instanceof Error?G.message:"Invalid URL";D(Ne);}}},U=C=>({id:C.id,filename:C.filename,url:C.url,mimeType:C.mimeType}),K=C=>{z?E(G=>G.find(Oe=>Oe.id===C.id)?G.filter(Oe=>Oe.id!==C.id):[...G,C]):(r(U(C)),d(false),V(""));},_=()=>{if(F.length>0){let C=[...I,...F.map(U)];r(C);}E([]),d(false),V("");},xe=C=>{let G=[...I];G.splice(C,1),r(z?G:G[0]||null);},Be=useMemo(()=>p.filter(C=>!N||C.filename?.toLowerCase().includes(N.toLowerCase())||C.title?.toLowerCase().includes(N.toLowerCase())),[p,N]);if(i)return jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let we=(C,G)=>{if(!C)return null;let Ne=typeof C=="string"?C:C.id,Oe=Z[Ne]||(typeof C=="object"?C:{}),Ve=$i(Oe.mimeType,Oe.filename||Oe.url);return jsxs("div",{className:"flex items-center gap-3 p-2.5 bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] group",children:[jsx("div",{className:"w-10 h-10 rounded-md overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex items-center justify-center flex-shrink-0",children:Ve==="image"?jsx("img",{src:Ua(Oe.url),alt:Oe.filename||"Preview",className:"w-full h-full object-cover"}):jsx(Tc,{type:Ve,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:Oe.originalName||Oe.filename||"Unnamed File"}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:R})]}),jsx("button",{type:"button",onClick:()=>G!==void 0?xe(G):r(null),disabled:o,className:"p-1.5 rounded-md text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)] transition-all opacity-0 group-hover:opacity-100",children:jsx(X,{className:"w-4 h-4"})})]},G)};return jsxs("div",{className:"space-y-2 relative",children:[jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:C=>{let G=C.target.files?.[0];G&&ue(G);},disabled:o,className:"hidden"}),I.length>0&&jsx("div",{className:z?"grid grid-cols-2 gap-2":"space-y-2",children:I.map((C,G)=>we(C,G))}),(!I.length||J)&&jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxs("button",{type:"button",onClick:()=>a.current?.click(),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:["+ Upload ",R]}),jsx("button",{type:"button",onClick:()=>{E([]),d(true);},disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"Library"}),jsx("button",{type:"button",onClick:()=>k(!P),disabled:o,className:"px-3 py-1.5 text-xs font-semibold rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] cursor-pointer hover:border-[var(--kyro-border-active)] transition-colors",children:"URL"})]}),P&&jsxs("div",{className:"flex gap-2 items-center",children:[jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:g,onChange:C=>{b(C.target.value),D("");},onKeyDown:C=>C.key==="Enter"&&he(),disabled:o,className:"flex-1 px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),jsx("button",{type:"button",onClick:he,disabled:o||!g.trim(),className:"kyro-btn kyro-btn-primary px-3 py-1.5 text-xs rounded cursor-pointer hover:opacity-90 transition-opacity disabled:opacity-50",children:"Add"}),w&&jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:w})]}),l&&(c?createPortal(jsx(Ac,{isFullscreen:true,isMultiple:z,selectedItems:F,pickerSearch:N,setPickerSearch:V,folders:m,selectedFolder:v,setSelectedFolder:x,mediaLoading:h,filteredMedia:Be,selectFromLibrary:K,onDone:_,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsx(Ac,{isFullscreen:false,isMultiple:z,selectedItems:F,pickerSearch:N,setPickerSearch:V,folders:m,selectedFolder:v,setSelectedFolder:x,mediaLoading:h,filteredMedia:Be,selectFromLibrary:K,onDone:_,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Ac({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:i,setSelectedFolder:s,mediaLoading:l,filteredMedia:d,selectFromLibrary:c,onDone:u,setIsPickerFullscreen:p,setShowPicker:f}){let{t:m}=H(),y=v=>r.some(x=>x.id===v);return jsxs("div",{className:`${e?"fixed inset-0 z-[9999]":"relative z-[9999] w-[360px] max-h-[400px] mt-1 rounded-lg shadow-lg"} overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] flex flex-col`,children:[jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsx("input",{type:"text",placeholder:m("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:v=>a(v.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsx("button",{type:"button",onClick:()=>s(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(v=>jsx("button",{type:"button",onClick:()=>s(v.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===v.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:v.name},v.path))]})]}),jsx("div",{className:"flex-1 overflow-auto p-2",children:l?jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(v=>{let x=y(v.id);return jsxs("button",{type:"button",onClick:()=>c(v),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${x?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:$i(v.mimeType,v.filename)==="image"?jsx("img",{src:Ua(v.thumbnailUrl||v.url),alt:v.filename,className:"w-full h-full object-cover"}):jsx(Tc,{type:$i(v.mimeType,v.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&x&&jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsx(Check,{className:"w-3 h-3 text-white"})})]},v.id)})})}),jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxs("button",{type:"button",onClick:u,className:"kyro-btn kyro-btn-primary px-3 py-1 text-xs font-semibold rounded cursor-pointer hover:opacity-90 transition-opacity",children:["Done",r.length>0?` (${r.length})`:""]}),jsx("button",{type:"button",onClick:()=>p(!e),className:"p-1.5 rounded text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",title:e?"Exit fullscreen":"Fullscreen",children:e?jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}):jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsx("button",{type:"button",onClick:()=>{f(false),p(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function pt({field:e,error:t,children:r,hideLabel:o=false}){return jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsx("div",{className:"flex justify-between items-end mb-1",children:jsxs("label",{className:"block text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 group-focus-within:opacity-100 group-focus-within:text-[var(--kyro-primary)] transition-all duration-300",children:[e.label,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin?.description}),t&&jsxs("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-error)] font-bold flex items-center gap-2 animate-in fade-in slide-in-from-top-1 duration-300",children:[jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function xr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:i}){let s=useRef(null),[l,d]=useState(false);useEffect(()=>{d(true);},[]),useEffect(()=>{let u=p=>{p.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow="";}},[e,t]);let c={sm:"w-full sm:w-[320px]",md:"w-full sm:w-[400px]",lg:"w-full sm:w-[550px]",xl:"w-full sm:w-[700px]"};return !e||!l?null:createPortal(jsxs(Fragment,{children:[n&&jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxs("div",{ref:s,"data-kyro-slide-panel":"true","data-kyro-slide-width":a,className:`fixed right-0 top-0 bottom-0 z-[99999] ${c[a]} bg-[var(--kyro-surface)] ${i?`border-l-2 ${i}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsx("button",{type:"button",onClick:t,className:"p-1.5 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsx("style",{children:`
2
2
  @keyframes slideIn {
3
3
  from { transform: translateX(100%); }
4
4
  to { transform: translateX(0); }
@@ -6,7 +6,7 @@ import na,{createContext,lazy,useState,useRef,useEffect,useCallback,useContext,u
6
6
  .animate-slideIn {
7
7
  animation: slideIn 300ms ease-out;
8
8
  }
9
- `})]}),document.body)}function hs({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[i,s]=useState(n),l=d=>{d.preventDefault(),i.trim()&&(r(i.trim()),s(""),t());};return e?createPortal(jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-[var(--kyro-surface)] rounded-lg shadow-2xl animate-in fade-in zoom-in-95 duration-200 border border-[var(--kyro-border)]",children:[jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsx("button",{type:"button",onClick:t,className:"p-1 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-lg hover:bg-[var(--kyro-surface-accent)] transition-colors",children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:l,children:[jsx("div",{className:"px-6 py-4",children:jsx("input",{type:"text",value:i,onChange:d=>s(d.target.value),placeholder:a,autoFocus:true,className:"w-full px-3 py-2 border border-[var(--kyro-input-border)] rounded-lg bg-[var(--kyro-input-bg)] text-[var(--kyro-text-primary)] placeholder-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})}),jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] rounded-b-lg",children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg font-medium text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsx("button",{type:"submit",disabled:!i.trim(),className:"px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Confirm"})]})]})]})]}),document.body):null}function Ir({children:e}){return jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function _r({children:e}){return jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function At({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:i="default"}){if(useEffect(()=>{let d=c=>{c.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="";}},[e,t]),!e)return null;let s={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},l=i==="lightbox";return createPortal(jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsx("div",{className:`absolute inset-0 transition-all duration-500 ${l?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxs("div",{className:`relative ${s[n]} ${l?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!l&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${l?"":"border"} ${i==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!l&&jsxs("div",{className:"flex items-center justify-between px-8 py-6 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50 backdrop-blur-md",children:[jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsx("button",{type:"button",onClick:t,className:"p-2 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-xl hover:bg-[var(--kyro-surface)] transition-all duration-200",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:`flex-1 overflow-auto ${l?"":"px-8 py-8"}`,children:o}),a&&!l&&jsx("div",{className:"flex items-center justify-end gap-3 px-8 py-6 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50",children:a})]})]}),document.body)}function Vi({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:i="Cancel",variant:s="default",loading:l=false}){return jsx(At,{open:e,onClose:t,title:o,size:"sm",footer:jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:t,disabled:l,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:i}),jsx("button",{type:"button",onClick:r,disabled:l,className:`kyro-btn kyro-btn-md ${s==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:l?"Loading...":n})]}),children:jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function Rc({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[i,s]=useState("crop"),[l,d]=useState(t?{unit:"%",...t}:void 0),[c,u]=useState(r||{x:40,y:40,width:20,height:20}),[p,f]=useState(!!r),m=useRef(null),y=useRef(null),[v,x]=useState(false),[h,S]=useState(null),N=useRef(null),V=(E,R)=>{i==="hotspot"&&(E.stopPropagation(),E.preventDefault(),R?S(R):x(true),N.current={x:E.clientX,y:E.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},P=useCallback(E=>{if(!N.current||!m.current)return;let R=m.current.getBoundingClientRect(),M=(E.clientX-N.current.x)/R.width*100,z=(E.clientY-N.current.y)/R.height*100,I=N.current;if(v){let J=I.hX+M,Z=I.hY+z;J=Math.max(0,Math.min(J,100-I.hW)),Z=Math.max(0,Math.min(Z,100-I.hH)),u(te=>({...te,x:J,y:Z}));}else if(h){let J=I.hX,Z=I.hY,te=I.hW,Y=I.hH;h.includes("e")&&(te=I.hW+M),h.includes("w")&&(J=I.hX+M,te=I.hW-M),h.includes("s")&&(Y=I.hH+z),h.includes("n")&&(Z=I.hY+z,Y=I.hH-z),te<5&&(te=5,h.includes("w")&&(J=I.hX+I.hW-5)),Y<5&&(Y=5,h.includes("n")&&(Z=I.hY+I.hH-5)),J=Math.max(0,Math.min(J,100-te)),Z=Math.max(0,Math.min(Z,100-Y)),te=Math.min(te,100-J),Y=Math.min(Y,100-Z),u({x:J,y:Z,width:te,height:Y});}},[v,h,c]),k=useCallback(()=>{x(false),S(null),N.current=null;},[]);useEffect(()=>((v||h)&&(window.addEventListener("pointermove",P),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",k);}),[v,h,P,k]);let g=E=>{},b=()=>{let E=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(E,p?c:void 0);},w=()=>{d(void 0),f(false);},D=useMemo(()=>{if(!l||!l.width||!l.height)return null;let E=new URLSearchParams({url:e});return E.set("cx",String(l.x)),E.set("cy",String(l.y)),E.set("cw",String(l.width)),E.set("ch",String(l.height)),`/api/media/resize?${E.toString()}`},[e,l]),F=l?.width&&l.height;return jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsxs("button",{onClick:()=>s("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${i==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsx(Crop,{className:"w-4 h-4"}),"Crop"]}),jsxs("button",{onClick:()=>{s("hotspot"),p||f(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${i==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsx(MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxs("button",{onClick:w,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsx(RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsx("button",{onClick:b,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:y,children:[jsx(Gf,{crop:l,onChange:(E,R)=>d(R),locked:i==="hotspot",className:i==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsx("img",{ref:m,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:g})}),p&&m.current&&jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsx("div",{className:"relative",style:{width:m.current.width,height:m.current.height},children:jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${i==="hotspot"?"border-blue-500 bg-blue-500/20 cursor-move pointer-events-auto shadow-blue-500/50":"border-blue-500/50 bg-blue-500/10 pointer-events-none"}`,style:{left:`${c.x}%`,top:`${c.y}%`,width:`${c.width}%`,height:`${c.height}%`,borderRadius:"50%"},onPointerDown:E=>V(E),children:[jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),i==="hotspot"&&jsxs(Fragment,{children:[jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:E=>V(E,"n")}),jsx("div",{className:"absolute bottom-0 left-1/2 w-4 h-4 -ml-2 -mb-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:E=>V(E,"s")}),jsx("div",{className:"absolute top-1/2 left-0 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:E=>V(E,"w")}),jsx("div",{className:"absolute top-1/2 right-0 w-4 h-4 -mr-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:E=>V(E,"e")})]})]})})})]})}),F&&jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsx(Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:D&&jsx("img",{src:D,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxs("div",{children:["x: ",l?.x?.toFixed(1),"% y: ",l?.y?.toFixed(1),"%"]}),jsxs("div",{children:["w: ",l?.width?.toFixed(1),"% h: ",l?.height?.toFixed(1),"%"]})]})]})]}),jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:i==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Kr(e){if(typeof e!="string"||!e)return "";if(typeof window>"u"||e.startsWith("http")||e.startsWith("blob:"))return e;let t=e.replace(/^\/+/,"/");return `${window.location.origin}${t}`}function ks(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Kr(e.url))return null;let s=new URLSearchParams({url:e.url});s.set("cx",String(r)),s.set("cy",String(o)),s.set("cw",String(a)),s.set("ch",String(n)),t&&s.set("w",String(t));let l=`/api/media/resize?${s.toString()}`;return typeof window>"u"?l:`${window.location.origin}${l}`}function ws(e){if(e===0)return "0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(1))+" "+r[o]}function Xf(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Yf(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.includes("zip")||e.includes("tar")||e.includes("archive")?"archive":e.includes("pdf")||e.includes("doc")||e.includes("text")?"document":"other"}function Ns({onSelect:e,multiple:t=true,pickerMode:r=false}){let{t:o}=H(),{permissions:a}=Zr(),n=a?.media?.create!==false,i=a?.media?.delete!==false,s=a?.media?.update!==false,[l,d]=useState([]),[c,u]=useState(true),[p,f]=useState(false),[m,y]=useState([]),[v,x]=useState(""),[h,S]=useState(""),[N,V]=useState("all"),[P,k]=useState("grid"),[g,b]=useState(null),[w,D]=useState(false),[F,E]=useState(false),[R,M]=useState(false),[z,I]=useState({}),[J,Z]=useState(false),[te,Y]=useState(false),[ae,ue]=useState(null),[he,U]=useState(false),[K,_]=useState(false),[xe,Be]=useState(1),[we,C]=useState(0),[G,Ne]=useState(1),Oe=40,[Ve,Fe]=useState(new Set),{confirm:mt,alert:Cr}=vt(),[oe,O]=useState(false),X$1=useRef(null),de=useCallback(async T=>{T===1?u(true):f(true);try{let ve=new URLSearchParams({page:T.toString(),limit:Oe.toString()});v&&ve.append("folder",v),h&&ve.append("search",h),N!=="all"&&ve.append("type",N);let je=await Me(eo(`/api/media?${ve}`)),nr=(je.docs||[]).map(Ot=>({...Ot,type:Yf(Ot.mimeType)}));d(Ot=>T===1?nr:[...Ot,...nr]),C(je.totalDocs||0),Ne(je.totalPages||1);}catch(ve){console.error("Failed to load media:",ve);}finally{u(false),f(false);}},[v,h,N,Oe]),Ie=useCallback(async()=>{try{let T=await Me(eo("/api/media/folders"));y(Array.isArray(T)?T:T.folders||[]);}catch(T){console.error("Failed to load folders:",T);}},[]),ze=useCallback(async()=>{try{let ve=!!(await Me("/api/globals/storage-settings"))?.data?.provider;ue(ve);}catch{ue(false);}},[]);useEffect(()=>{r||ze();},[ze,r]),useEffect(()=>{r||ae===false&&!he&&(U(true),_(true));},[r,ae,he]),useEffect(()=>{Be(1),de(1);},[v,h,N,de]);let Tt=()=>{if(p||xe>=G)return;let T=xe+1;Be(T),de(T);};useEffect(()=>{Ie();},[Ie]),useEffect(()=>{if(r)return;let T=ve=>{let je=ve.clipboardData?.files;je&&je.length>0&&gr(je);};return window.addEventListener("paste",T),()=>window.removeEventListener("paste",T)},[r,v,ae]);let gr=async T=>{if(!ae){_(true);return}M(true);let ve=0,je=0;for(let nr=0;nr<T.length;nr++){let Ot=T[nr];try{let Sr=new FormData;Sr.append("file",Ot),v&&Sr.append("folder",v),await Dn("/api/media/upload",Sr,ei=>{I(qo=>({...qo,[Ot.name]:ei}));}),ve++;}catch(Sr){console.error(`Upload failed for ${Ot.name}:`,Sr),je++;}}M(false),I({}),Be(1),de(1),Ie(),je>0&&j.error(`${je} file(s) failed to upload`),ve>0&&j.success(`${ve} file(s) uploaded successfully`);},Or=()=>{mt({title:"Delete Media",message:`Are you sure you want to delete ${Ve.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let T of Array.from(Ve))await Dt(`/api/media/${T}`);Fe(new Set),Be(1),de(1),j.success(`${Ve.size} item(s) deleted`);}catch(T){console.error("Bulk delete failed:",T),j.error("Failed to delete some items");}}});},$=(T,ve)=>{ve.stopPropagation();let je=new Set(Ve);je.has(T)?je.delete(T):(t||je.clear(),je.add(T)),Fe(je);},ne=async T=>{try{await ut("/api/media/folders",{name:T}),Ie(),Z(!1),j.success(`Folder "${T}" created`);}catch(ve){console.error("Failed to create folder:",ve),j.error("Failed to create folder");}},pe=T=>{mt({title:"Delete Folder",message:`Are you sure you want to delete the folder "${T}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await Dt(`/api/media/folders?path=${encodeURIComponent(T)}`),v===T&&x(""),Ie(),Be(1),de(1),j.success(`Folder "${T}" deleted`);}catch(ve){console.error("Failed to delete folder:",ve),j.error("Failed to delete folder");}}});},Ht=async(T,ve)=>{try{let je=await er(`/api/media/${T}`,ve);d(nr=>nr.map(Ot=>Ot.id===T?je.doc:Ot)),g?.id===T&&b(je.doc),j.success("Metadata updated");}catch(je){console.error("Failed to update metadata:",je),j.error("Failed to update metadata");}},Wo=async(T,ve)=>{if(g)try{M(!0);let je={...g.metadata,crop:T,hotspot:ve},nr=await er(`/api/media/${g.id}`,{metadata:je});d(Ot=>Ot.map(Sr=>Sr.id===g.id?nr.doc:Sr)),b(nr.doc),E(!1),j.success("Crop & hotspot saved");}catch(je){console.error("Save failed:",je),j.error("Failed to save focal metadata");}finally{M(false);}},Zs=useMemo(()=>l.reduce((T,ve)=>(T.totalSize+=ve.fileSize||0,T),{totalSize:0}),[l]);return jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${oe?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:T=>{T.preventDefault(),O(true);},onDragLeave:()=>O(false),onDrop:T=>{T.preventDefault(),O(false),T.dataTransfer.files&&gr(T.dataTransfer.files);}},children:[jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxs("div",{children:[jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[we," Items ",jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",ws(Zs.totalSize)]})]})})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsx("button",{onClick:()=>k("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${P==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsx(Grid3X3,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>k("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${P==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsx(File,{className:"w-4 h-4"})})]}),jsx("button",{onClick:()=>Y(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsx(Filter,{className:"w-4 h-4"})}),n&&jsxs("button",{onClick:()=>X$1.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsx(Maximize2,{className:"w-4 h-4 hidden md:block"}),jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsx("div",{className:"flex items-center w-full",children:jsxs("div",{className:"relative group flex-1",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",placeholder:o("fields.searchAssets",{defaultValue:"Search assets..."}),value:h,onChange:T=>S(T.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxs("div",{className:"p-6 space-y-6",children:[jsxs("div",{children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(T=>jsxs("button",{onClick:()=>V(T),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${N===T?"text-[var(--kyro-text-primary)] bg-[var(--kyro-surface-accent)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50"}`,children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N===T?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),T]},T))})]}),jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsx("button",{onClick:()=>Z(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsx(FolderPlus,{className:"w-4 h-4"})})]}),jsxs("nav",{className:"space-y-1",children:[jsxs("button",{onClick:()=>x(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>x(T),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsx(Folder,{fill:v===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),pe(T);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})}),jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsx(Wt,{variant:"media-card",count:12})}):l.length===0?jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsx(Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&n&&jsx("button",{onClick:()=>X$1.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):P==="grid"?jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-1",children:l.map((T,ve)=>jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Ve.has(T.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>b(T),onContextMenu:je=>{je.preventDefault(),$(T.id,je);},children:[T.type==="image"?jsx("img",{src:ks(T,400)||T.url,alt:T.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsx("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500",children:T.type==="video"?jsx(Film,{className:"w-8 h-8"}):T.type==="audio"?jsx(Music,{className:"w-8 h-8"}):T.type==="document"?jsx(FileText,{className:"w-8 h-8"}):T.type==="archive"?jsx(Archive,{className:"w-8 h-8"}):jsx(File,{className:"w-8 h-8"})}),jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:T.title})]}),jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4",children:jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:T.filename}),jsx("div",{className:"flex gap-1",children:jsx("button",{onClick:je=>$(T.id,je),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Ve.has(T.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsx(Check,{className:"w-4 h-4"})})})]})}),Ve.has(T.id)&&jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsx(Check,{className:"w-4 h-4"})})]},T.id))}):jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsx("th",{className:"px-6 py-4 w-12",children:jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Ve.size===l.length,onChange:T=>{T.target.checked?Fe(new Set(l.map(ve=>ve.id))):Fe(new Set);}})}),jsx("th",{className:"px-6 py-4",children:"Asset"}),jsx("th",{className:"px-6 py-4",children:"Type"}),jsx("th",{className:"px-6 py-4",children:"Size"}),jsx("th",{className:"px-6 py-4",children:"Date"}),jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(T=>jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Ve.has(T.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>b(T),children:[jsx("td",{className:"px-6 py-4",onClick:ve=>ve.stopPropagation(),children:jsx("input",{type:"checkbox",checked:Ve.has(T.id),onChange:ve=>$(T.id,ve),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsx("td",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"w-12 h-12 rounded-xl bg-[var(--kyro-bg)] overflow-hidden border border-[var(--kyro-border)] flex-shrink-0 flex items-center justify-center",children:T.type==="image"?jsx("img",{src:ks(T,96)||T.url,alt:"",className:"w-full h-full object-cover"}):jsx(File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxs("div",{className:"flex flex-col min-w-0",children:[jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:T.title||T.filename}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:T.filename})]})]})}),jsx("td",{className:"px-6 py-4",children:jsx(Et,{variant:"outline",className:"text-[9px]",children:T.mimeType})}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:ws(T.fileSize)}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Xf(T.createdAt)}),jsx("td",{className:"px-6 py-4 text-right",children:jsx("button",{onClick:ve=>{ve.stopPropagation(),$(T.id,ve);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Ve.has(T.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsx(Grid3X3,{className:"w-4 h-4"})})})]},T.id))})]})}),!c&&xe<G&&jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsx("button",{onClick:Tt,disabled:p,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:p?jsxs(Fragment,{children:[jsx(lr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&R&&jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsx(lr,{})}),jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(z).length," Total"]})]}),jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(z).map(([T,ve])=>jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:T}),jsxs("span",{className:"text-[var(--kyro-primary)]",children:[ve,"%"]})]}),jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${ve}%`}})})]},T))})]})}),Ve.size>0&&jsxs("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl",children:[jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner",children:Ve.size}),jsxs("div",{children:[jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsx("button",{onClick:()=>Fe(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxs("div",{className:"flex items-center gap-4",children:[e&&jsx("button",{onClick:()=>{let T=l.filter(ve=>Ve.has(ve.id));e(T);},className:"px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-full font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Confirm Selection"}),!r&&i&&jsx("button",{onClick:Or,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsx(Trash2,{className:"w-5 h-5"})})]})]}),te&&!r&&jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>Y(false)}),jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[var(--kyro-surface)] rounded-t-3xl shadow-2xl max-h-[70vh] overflow-y-auto animate-in slide-in-from-bottom-12 duration-300",children:[jsxs("div",{className:"sticky top-0 bg-[var(--kyro-surface)] z-10 flex items-center justify-between p-6 pb-4 border-b border-[var(--kyro-border)]",children:[jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsx("button",{onClick:()=>Y(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("div",{className:"p-6 space-y-8",children:[jsxs("div",{children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(T=>jsx("button",{onClick:()=>{V(T),Y(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${N===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] border-transparent":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] border-[var(--kyro-border)] hover:border-[var(--kyro-text-muted)]"}`,children:T},T))})]}),jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsx("button",{onClick:()=>{Z(true),Y(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsx(FolderPlus,{className:"w-4 h-4"})})]}),jsxs("nav",{className:"space-y-1",children:[jsxs("button",{onClick:()=>{x(""),Y(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>{x(T),Y(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsx(Folder,{fill:v===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),pe(T),Y(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})]})]}),jsx(xr,{open:!!g,onClose:()=>b(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:g?.filename,children:g&&jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[g.type==="image"?jsx("img",{src:ks(g)||Kr(g.url),alt:"",className:"w-full h-full object-contain p-4"}):g.type==="video"?jsx("video",{src:Kr(g.url),controls:true,className:"w-full h-full"}):jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsx(File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsx(Et,{variant:"outline",className:"text-xs font-bold",children:g.mimeType})]}),jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsx("button",{onClick:()=>D(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsx(Maximize2,{className:"w-4 h-4"})})})]}),jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:g.type==="image"?"Original Resolution":"N/A"})]}),jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:ws(g.fileSize)})]})]}),jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxs("div",{className:"flex gap-2",children:[jsx("input",{type:"text",readOnly:true,value:Kr(g.url),className:"flex-1 px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-[10px] font-bold font-mono focus:outline-none"}),jsx("button",{onClick:()=>{navigator.clipboard.writeText(Kr(g.url)),j.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsx(Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsx("textarea",{value:g.alt||"",onChange:T=>Ht(g.id,{alt:T.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.describeThisAsset",{defaultValue:"Describe this asset..."})})]}),jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsx("textarea",{value:g.caption||"",onChange:T=>Ht(g.id,{caption:T.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.addACaption",{defaultValue:"Add a caption..."})})]})]})]})]}),!r&&jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxs("button",{onClick:()=>{let T=document.createElement("a");T.href=Kr(g.url),T.download=g.filename,T.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsx(Download,{className:"w-4 h-4"}),"Download"]}),g.type==="image"&&s&&jsx("button",{onClick:()=>E(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsx(Crop,{className:"w-4 h-4"})}),i&&jsx("button",{onClick:()=>{mt({title:"Delete Asset",message:`Are you sure you want to delete ${g.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`/api/media/${g.id}`),b(null),de(1);}catch(T){console.error("Delete failed:",T),j.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsx(Trash2,{className:"w-4 h-4"})})]})]})}),w&&g&&jsxs(At,{open:w,onClose:()=>D(false),title:"",size:"full",variant:"lightbox",children:[jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:g.filename}),jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[ws(g.fileSize)," \xB7 ",g.mimeType]})]}),jsx("button",{onClick:()=>D(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsx(X,{className:"w-6 h-6"})})]}),jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:g.type==="image"?jsx("img",{src:ks(g)||Kr(g.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):g.type==="video"?jsx("video",{src:Kr(g.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxs("div",{className:"text-white text-center",children:[jsx(File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&F&&g&&jsx(At,{open:F,onClose:()=>E(false),title:"",size:"full",variant:"lightbox",children:jsx(Rc,{url:Kr(g.url),initialCrop:g.metadata?.crop,initialHotspot:g.metadata?.hotspot,onSave:Wo,onCancel:()=>E(false),isSaving:R})}),!r&&jsx(hs,{open:J,onClose:()=>Z(false),onSubmit:ne,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsx(At,{open:K,onClose:()=>_(false),title:o("tooltips.storageNotConfigured",{defaultValue:"Storage Not Configured"}),size:"md",children:jsxs("div",{className:"text-center",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsx(Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxs("div",{className:"flex gap-3",children:[jsx("a",{href:`${_e}/settings/storage-settings`,className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsx("button",{type:"button",onClick:()=>{ut("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{_(false),ue(true),window.dispatchEvent(new Event("kyro:soft-reload"));}).catch(()=>{j.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsx("input",{type:"file",ref:X$1,onChange:T=>{T.target.files&&gr(T.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}function Fc({type:e,message:t,onClose:r}){let[o,a]=na.useState(false),n=na.useRef(null),i=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},s=()=>{n.current&&clearTimeout(n.current);};na.useEffect(()=>(o?s():i(),s),[o,r]);let l={success:CircleCheck,error:ShieldAlert,warning:TriangleAlert,info:Info}[e];return jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsx("div",{className:"kyro-toast-accent"}),jsx("div",{className:"kyro-toast-icon-container",children:jsx(l,{className:"w-4 h-4"})}),jsx("div",{className:"kyro-toast-content",children:jsx("p",{className:"kyro-toast-message",children:t})}),jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsx(X,{className:"w-3.5 h-3.5"})})]})}function O2({children:e}){return jsx(Fragment,{children:e})}function Ic(){let e=Zt(o=>o.addToast),t=Zt(o=>o.removeToast);return {toasts:Zt(o=>o.toasts),addToast:e,removeToast:t}}var Rg=[{name:"Default",value:"inherit"},{name:"Red",value:"#ef4444"},{name:"Orange",value:"#f97316"},{name:"Amber",value:"#f59e0b"},{name:"Emerald",value:"#10b981"},{name:"Blue",value:"#3b82f6"},{name:"Indigo",value:"#6366f1"},{name:"Violet",value:"#8b5cf6"},{name:"Rose",value:"#f43f5e"},{name:"Slate",value:"#64748b"}],Uc=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o,isAiLoading:a,setIsAiLoading:n})=>{let{t:i}=H(),[s,l]=useState(null),[d,c]=useState(false),u=useRef(null),{addToast:p}=Ic(),f=ye(D=>D.formData),m=ye(D=>D.setField),y=projectConfig?.plugins?.some?.(D=>D.name==="ai-assistant")??false;if(useEffect(()=>{function D(F){u.current&&!u.current.contains(F.target)&&l(null);}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]),!e)return null;let v=()=>{o();},x=()=>{let D=e.getAttributes("link").href,F=window.prompt("URL",D);if(F!==null){if(F===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:F}).run();}},h=D=>{D==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(D).run(),l(null);},S=async(D,F)=>{l(null);let E=document.querySelector('input#title, input[name="title"]')?.value,R=f?.title||E||"Untitled Document",M="document";try{let Z=window.location.pathname.split("/").filter(Boolean);Z[0]==="admin"&&Z.length>=2&&(M=Z[1],M.endsWith("s")&&(M=M.slice(0,-1)));}catch{}let z=e.state.doc.textBetween(Math.max(0,e.state.selection.from-500),Math.min(e.state.doc.content.size,e.state.selection.to+500)," "),I=e.state.doc.textBetween(e.state.selection.from,e.state.selection.to," "),J="";if(D==="Generate")J=`Write a comprehensive, engaging, and professional ${M} titled "${R}".
9
+ `})]}),document.body)}function hs({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[i,s]=useState(n),l=d=>{d.preventDefault(),i.trim()&&(r(i.trim()),s(""),t());};return e?createPortal(jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-[var(--kyro-surface)] rounded-lg shadow-2xl animate-in fade-in zoom-in-95 duration-200 border border-[var(--kyro-border)]",children:[jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsx("button",{type:"button",onClick:t,className:"p-1 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-lg hover:bg-[var(--kyro-surface-accent)] transition-colors",children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("form",{onSubmit:l,children:[jsx("div",{className:"px-6 py-4",children:jsx("input",{type:"text",value:i,onChange:d=>s(d.target.value),placeholder:a,autoFocus:true,className:"w-full px-3 py-2 border border-[var(--kyro-input-border)] rounded-lg bg-[var(--kyro-input-bg)] text-[var(--kyro-text-primary)] placeholder-[var(--kyro-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent"})}),jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] rounded-b-lg",children:[jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg font-medium text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsx("button",{type:"submit",disabled:!i.trim(),className:"px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Confirm"})]})]})]})]}),document.body):null}function Ir({children:e}){return jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Kr({children:e}){return jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function At({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:i="default"}){if(useEffect(()=>{let d=c=>{c.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",d),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="";}},[e,t]),!e)return null;let s={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl",full:"w-full h-full max-w-none rounded-none border-0"},l=i==="lightbox";return createPortal(jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsx("div",{className:`absolute inset-0 transition-all duration-500 ${l?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxs("div",{className:`relative ${s[n]} ${l?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!l&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${l?"":"border"} ${i==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!l&&jsxs("div",{className:"flex items-center justify-between px-8 py-6 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50 backdrop-blur-md",children:[jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsx("button",{type:"button",onClick:t,className:"p-2 text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] rounded-xl hover:bg-[var(--kyro-surface)] transition-all duration-200",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:`flex-1 overflow-auto ${l?"":"px-8 py-8"}`,children:o}),a&&!l&&jsx("div",{className:"flex items-center justify-end gap-3 px-8 py-6 border-t border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/50",children:a})]})]}),document.body)}function Vi({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:i="Cancel",variant:s="default",loading:l=false}){return jsx(At,{open:e,onClose:t,title:o,size:"sm",footer:jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:t,disabled:l,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:i}),jsx("button",{type:"button",onClick:r,disabled:l,className:`kyro-btn kyro-btn-md ${s==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:l?"Loading...":n})]}),children:jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function Rc({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[i,s]=useState("crop"),[l,d]=useState(t?{unit:"%",...t}:void 0),[c,u]=useState(r||{x:40,y:40,width:20,height:20}),[p,f]=useState(!!r),m=useRef(null),y=useRef(null),[v,x]=useState(false),[h,S]=useState(null),N=useRef(null),V=(E,R)=>{i==="hotspot"&&(E.stopPropagation(),E.preventDefault(),R?S(R):x(true),N.current={x:E.clientX,y:E.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},P=useCallback(E=>{if(!N.current||!m.current)return;let R=m.current.getBoundingClientRect(),M=(E.clientX-N.current.x)/R.width*100,z=(E.clientY-N.current.y)/R.height*100,I=N.current;if(v){let J=I.hX+M,Z=I.hY+z;J=Math.max(0,Math.min(J,100-I.hW)),Z=Math.max(0,Math.min(Z,100-I.hH)),u(te=>({...te,x:J,y:Z}));}else if(h){let J=I.hX,Z=I.hY,te=I.hW,Y=I.hH;h.includes("e")&&(te=I.hW+M),h.includes("w")&&(J=I.hX+M,te=I.hW-M),h.includes("s")&&(Y=I.hH+z),h.includes("n")&&(Z=I.hY+z,Y=I.hH-z),te<5&&(te=5,h.includes("w")&&(J=I.hX+I.hW-5)),Y<5&&(Y=5,h.includes("n")&&(Z=I.hY+I.hH-5)),J=Math.max(0,Math.min(J,100-te)),Z=Math.max(0,Math.min(Z,100-Y)),te=Math.min(te,100-J),Y=Math.min(Y,100-Z),u({x:J,y:Z,width:te,height:Y});}},[v,h,c]),k=useCallback(()=>{x(false),S(null),N.current=null;},[]);useEffect(()=>((v||h)&&(window.addEventListener("pointermove",P),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",k);}),[v,h,P,k]);let g=E=>{},b=()=>{let E=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(E,p?c:void 0);},w=()=>{d(void 0),f(false);},D=useMemo(()=>{if(!l||!l.width||!l.height)return null;let E=new URLSearchParams({url:e});return E.set("cx",String(l.x)),E.set("cy",String(l.y)),E.set("cw",String(l.width)),E.set("ch",String(l.height)),`/api/media/resize?${E.toString()}`},[e,l]),F=l?.width&&l.height;return jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsxs("button",{onClick:()=>s("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${i==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsx(Crop,{className:"w-4 h-4"}),"Crop"]}),jsxs("button",{onClick:()=>{s("hotspot"),p||f(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${i==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsx(MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxs("button",{onClick:w,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:[jsx(RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsx("button",{onClick:a,className:"px-4 py-2 text-sm font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:"Cancel"}),jsx("button",{onClick:b,disabled:n,className:"flex items-center justify-center min-w-[120px] px-6 py-2 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] text-sm font-bold rounded-lg shadow-lg hover:opacity-90 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed",children:n?jsxs("svg",{className:"animate-spin h-4 w-4 text-current",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):"Save Edits"})]})]}),jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:y,children:[jsx(Gf,{crop:l,onChange:(E,R)=>d(R),locked:i==="hotspot",className:i==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsx("img",{ref:m,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:g})}),p&&m.current&&jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsx("div",{className:"relative",style:{width:m.current.width,height:m.current.height},children:jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${i==="hotspot"?"border-blue-500 bg-blue-500/20 cursor-move pointer-events-auto shadow-blue-500/50":"border-blue-500/50 bg-blue-500/10 pointer-events-none"}`,style:{left:`${c.x}%`,top:`${c.y}%`,width:`${c.width}%`,height:`${c.height}%`,borderRadius:"50%"},onPointerDown:E=>V(E),children:[jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),i==="hotspot"&&jsxs(Fragment,{children:[jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:E=>V(E,"n")}),jsx("div",{className:"absolute bottom-0 left-1/2 w-4 h-4 -ml-2 -mb-2 bg-blue-500 rounded-full cursor-ns-resize",onPointerDown:E=>V(E,"s")}),jsx("div",{className:"absolute top-1/2 left-0 w-4 h-4 -ml-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:E=>V(E,"w")}),jsx("div",{className:"absolute top-1/2 right-0 w-4 h-4 -mr-2 -mt-2 bg-blue-500 rounded-full cursor-ew-resize",onPointerDown:E=>V(E,"e")})]})]})})})]})}),F&&jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsx(Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:D&&jsx("img",{src:D,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxs("div",{children:["x: ",l?.x?.toFixed(1),"% y: ",l?.y?.toFixed(1),"%"]}),jsxs("div",{children:["w: ",l?.width?.toFixed(1),"% h: ",l?.height?.toFixed(1),"%"]})]})]})]}),jsx("div",{className:"p-4 text-center bg-[var(--kyro-surface-accent)] border-t border-[var(--kyro-border)] text-sm text-[var(--kyro-text-secondary)]",children:i==="crop"?"Drag to define the crop area. The preview panel shows the result in real-time.":"Drag the circle to define the focal hotspot. This area will always remain visible when the image is resized."})]})}function Gr(e){if(typeof e!="string"||!e)return "";if(typeof window>"u"||e.startsWith("http")||e.startsWith("blob:"))return e;let t=e.replace(/^\/+/,"/");return `${window.location.origin}${t}`}function ks(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Gr(e.url))return null;let s=new URLSearchParams({url:e.url});s.set("cx",String(r)),s.set("cy",String(o)),s.set("cw",String(a)),s.set("ch",String(n)),t&&s.set("w",String(t));let l=`/api/media/resize?${s.toString()}`;return typeof window>"u"?l:`${window.location.origin}${l}`}function ws(e){if(e===0)return "0 B";let t=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(1))+" "+r[o]}function Xf(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Yf(e){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.includes("zip")||e.includes("tar")||e.includes("archive")?"archive":e.includes("pdf")||e.includes("doc")||e.includes("text")?"document":"other"}function Ns({onSelect:e,multiple:t=true,pickerMode:r=false}){let{t:o}=H(),{permissions:a}=eo(),n=a?.media?.create!==false,i=a?.media?.delete!==false,s=a?.media?.update!==false,[l,d]=useState([]),[c,u]=useState(true),[p,f]=useState(false),[m,y]=useState([]),[v,x]=useState(""),[h,S]=useState(""),[N,V]=useState("all"),[P,k]=useState("grid"),[g,b]=useState(null),[w,D]=useState(false),[F,E]=useState(false),[R,M]=useState(false),[z,I]=useState({}),[J,Z]=useState(false),[te,Y]=useState(false),[ae,ue]=useState(null),[he,U]=useState(false),[K,_]=useState(false),[xe,Be]=useState(1),[we,C]=useState(0),[G,Ne]=useState(1),Oe=40,[Ve,Fe]=useState(new Set),{confirm:mt,alert:Cr}=vt(),[oe,O]=useState(false),X$1=useRef(null),de=useCallback(async T=>{T===1?u(true):f(true);try{let ve=new URLSearchParams({page:T.toString(),limit:Oe.toString()});v&&ve.append("folder",v),h&&ve.append("search",h),N!=="all"&&ve.append("type",N);let je=await Me(to(`/api/media?${ve}`)),nr=(je.docs||[]).map(Ot=>({...Ot,type:Yf(Ot.mimeType)}));d(Ot=>T===1?nr:[...Ot,...nr]),C(je.totalDocs||0),Ne(je.totalPages||1);}catch(ve){console.error("Failed to load media:",ve);}finally{u(false),f(false);}},[v,h,N,Oe]),Ie=useCallback(async()=>{try{let T=await Me(to("/api/media/folders"));y(Array.isArray(T)?T:T.folders||[]);}catch(T){console.error("Failed to load folders:",T);}},[]),ze=useCallback(async()=>{try{let ve=!!(await Me("/api/globals/storage-settings"))?.data?.provider;ue(ve);}catch{ue(false);}},[]);useEffect(()=>{r||ze();},[ze,r]),useEffect(()=>{r||ae===false&&!he&&(U(true),_(true));},[r,ae,he]),useEffect(()=>{Be(1),de(1);},[v,h,N,de]);let Tt=()=>{if(p||xe>=G)return;let T=xe+1;Be(T),de(T);};useEffect(()=>{Ie();},[Ie]),useEffect(()=>{if(r)return;let T=ve=>{let je=ve.clipboardData?.files;je&&je.length>0&&gr(je);};return window.addEventListener("paste",T),()=>window.removeEventListener("paste",T)},[r,v,ae]);let gr=async T=>{if(!ae){_(true);return}M(true);let ve=0,je=0;for(let nr=0;nr<T.length;nr++){let Ot=T[nr];try{let Sr=new FormData;Sr.append("file",Ot),v&&Sr.append("folder",v),await Dn("/api/media/upload",Sr,ei=>{I(qo=>({...qo,[Ot.name]:ei}));}),ve++;}catch(Sr){console.error(`Upload failed for ${Ot.name}:`,Sr),je++;}}M(false),I({}),Be(1),de(1),Ie(),je>0&&j.error(`${je} file(s) failed to upload`),ve>0&&j.success(`${ve} file(s) uploaded successfully`);},Or=()=>{mt({title:"Delete Media",message:`Are you sure you want to delete ${Ve.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let T of Array.from(Ve))await Dt(`/api/media/${T}`);Fe(new Set),Be(1),de(1),j.success(`${Ve.size} item(s) deleted`);}catch(T){console.error("Bulk delete failed:",T),j.error("Failed to delete some items");}}});},$=(T,ve)=>{ve.stopPropagation();let je=new Set(Ve);je.has(T)?je.delete(T):(t||je.clear(),je.add(T)),Fe(je);},ne=async T=>{try{await ut("/api/media/folders",{name:T}),Ie(),Z(!1),j.success(`Folder "${T}" created`);}catch(ve){console.error("Failed to create folder:",ve),j.error("Failed to create folder");}},pe=T=>{mt({title:"Delete Folder",message:`Are you sure you want to delete the folder "${T}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await Dt(`/api/media/folders?path=${encodeURIComponent(T)}`),v===T&&x(""),Ie(),Be(1),de(1),j.success(`Folder "${T}" deleted`);}catch(ve){console.error("Failed to delete folder:",ve),j.error("Failed to delete folder");}}});},Ht=async(T,ve)=>{try{let je=await er(`/api/media/${T}`,ve);d(nr=>nr.map(Ot=>Ot.id===T?je.doc:Ot)),g?.id===T&&b(je.doc),j.success("Metadata updated");}catch(je){console.error("Failed to update metadata:",je),j.error("Failed to update metadata");}},Wo=async(T,ve)=>{if(g)try{M(!0);let je={...g.metadata,crop:T,hotspot:ve},nr=await er(`/api/media/${g.id}`,{metadata:je});d(Ot=>Ot.map(Sr=>Sr.id===g.id?nr.doc:Sr)),b(nr.doc),E(!1),j.success("Crop & hotspot saved");}catch(je){console.error("Save failed:",je),j.error("Failed to save focal metadata");}finally{M(false);}},Zs=useMemo(()=>l.reduce((T,ve)=>(T.totalSize+=ve.fileSize||0,T),{totalSize:0}),[l]);return jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${oe?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:T=>{T.preventDefault(),O(true);},onDragLeave:()=>O(false),onDrop:T=>{T.preventDefault(),O(false),T.dataTransfer.files&&gr(T.dataTransfer.files);}},children:[jsxs("div",{className:`flex flex-col ${r?"gap-2 p-2":"gap-4 md:gap-6 p-4 md:p-6 rounded-md md:rounded-t-xl surface-tile"} border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 z-10`,children:[!r&&jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxs("div",{children:[jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[we," Items ",jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",ws(Zs.totalSize)]})]})})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsx("button",{onClick:()=>k("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${P==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsx(Grid3X3,{className:"w-4 h-4"})}),jsx("button",{onClick:()=>k("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${P==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsx(File,{className:"w-4 h-4"})})]}),jsx("button",{onClick:()=>Y(true),className:"md:hidden p-2 rounded-xl bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors",children:jsx(Filter,{className:"w-4 h-4"})}),n&&jsxs("button",{onClick:()=>X$1.current?.click(),className:"flex items-center justify-center gap-2 px-3 md:px-6 py-2 md:py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg active:scale-95 transition-all",children:[jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsx(Maximize2,{className:"w-4 h-4 hidden md:block"}),jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsx("div",{className:"flex items-center w-full",children:jsxs("div",{className:"relative group flex-1",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",placeholder:o("fields.searchAssets",{defaultValue:"Search assets..."}),value:h,onChange:T=>S(T.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]})})]}),jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxs("div",{className:"p-6 space-y-6",children:[jsxs("div",{children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(T=>jsxs("button",{onClick:()=>V(T),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${N===T?"text-[var(--kyro-text-primary)] bg-[var(--kyro-surface-accent)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50"}`,children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N===T?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),T]},T))})]}),jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsx("button",{onClick:()=>Z(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsx(FolderPlus,{className:"w-4 h-4"})})]}),jsxs("nav",{className:"space-y-1",children:[jsxs("button",{onClick:()=>x(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>x(T),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsx(Folder,{fill:v===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),pe(T);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})}),jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxs("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${r?"px-2 py-4":"py-4 px-2 md:py-8 md:px-4"}`,children:[c?jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsx(Wt,{variant:"media-card",count:12})}):l.length===0?jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsx("div",{className:"w-24 h-24 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-8 rotate-12 group-hover:rotate-0 transition-transform duration-500",children:jsx(Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-2 max-w-xs mx-auto text-sm font-medium leading-relaxed",children:"Upload your first file or create a folder to organize your media assets."}),!r&&n&&jsx("button",{onClick:()=>X$1.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):P==="grid"?jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-1",children:l.map((T,ve)=>jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Ve.has(T.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>b(T),onContextMenu:je=>{je.preventDefault(),$(T.id,je);},children:[T.type==="image"?jsx("img",{src:ks(T,400)||T.url,alt:T.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsx("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface)] shadow-inner text-[var(--kyro-text-secondary)] group-hover:scale-110 transition-transform duration-500",children:T.type==="video"?jsx(Film,{className:"w-8 h-8"}):T.type==="audio"?jsx(Music,{className:"w-8 h-8"}):T.type==="document"?jsx(FileText,{className:"w-8 h-8"}):T.type==="archive"?jsx(Archive,{className:"w-8 h-8"}):jsx(File,{className:"w-8 h-8"})}),jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:T.title})]}),jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-end p-4",children:jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:T.filename}),jsx("div",{className:"flex gap-1",children:jsx("button",{onClick:je=>$(T.id,je),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Ve.has(T.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsx(Check,{className:"w-4 h-4"})})})]})}),Ve.has(T.id)&&jsx("div",{className:"absolute top-3 left-3 w-6 h-6 rounded-lg bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center shadow-lg border-2 border-white/20 animate-in zoom-in duration-300",children:jsx(Check,{className:"w-4 h-4"})})]},T.id))}):jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsx("th",{className:"px-6 py-4 w-12",children:jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Ve.size===l.length,onChange:T=>{T.target.checked?Fe(new Set(l.map(ve=>ve.id))):Fe(new Set);}})}),jsx("th",{className:"px-6 py-4",children:"Asset"}),jsx("th",{className:"px-6 py-4",children:"Type"}),jsx("th",{className:"px-6 py-4",children:"Size"}),jsx("th",{className:"px-6 py-4",children:"Date"}),jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(T=>jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Ve.has(T.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>b(T),children:[jsx("td",{className:"px-6 py-4",onClick:ve=>ve.stopPropagation(),children:jsx("input",{type:"checkbox",checked:Ve.has(T.id),onChange:ve=>$(T.id,ve),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsx("td",{className:"px-6 py-4",children:jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"w-12 h-12 rounded-xl bg-[var(--kyro-bg)] overflow-hidden border border-[var(--kyro-border)] flex-shrink-0 flex items-center justify-center",children:T.type==="image"?jsx("img",{src:ks(T,96)||T.url,alt:"",className:"w-full h-full object-cover"}):jsx(File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxs("div",{className:"flex flex-col min-w-0",children:[jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:T.title||T.filename}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:T.filename})]})]})}),jsx("td",{className:"px-6 py-4",children:jsx(Et,{variant:"outline",className:"text-[9px]",children:T.mimeType})}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:ws(T.fileSize)}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Xf(T.createdAt)}),jsx("td",{className:"px-6 py-4 text-right",children:jsx("button",{onClick:ve=>{ve.stopPropagation(),$(T.id,ve);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Ve.has(T.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsx(Grid3X3,{className:"w-4 h-4"})})})]},T.id))})]})}),!c&&xe<G&&jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsx("button",{onClick:Tt,disabled:p,className:"px-8 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs hover:scale-105 active:scale-95 transition-all shadow-xl disabled:opacity-50 flex items-center gap-2",children:p?jsxs(Fragment,{children:[jsx(lr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&R&&jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-[2rem] shadow-2xl p-6 ring-1 ring-white/10 animate-in slide-in-from-bottom-12 duration-700",children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center animate-pulse",children:jsx(lr,{})}),jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(z).length," Total"]})]}),jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(z).map(([T,ve])=>jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:T}),jsxs("span",{className:"text-[var(--kyro-primary)]",children:[ve,"%"]})]}),jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${ve}%`}})})]},T))})]})}),Ve.size>0&&jsxs("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-full shadow-2xl px-2 py-2 flex items-center gap-12 animate-in slide-in-from-bottom-12 duration-700 ring-1 ring-white/10 backdrop-blur-xl",children:[jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] flex items-center justify-center text-lg font-bold shadow-inner",children:Ve.size}),jsxs("div",{children:[jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsx("button",{onClick:()=>Fe(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxs("div",{className:"flex items-center gap-4",children:[e&&jsx("button",{onClick:()=>{let T=l.filter(ve=>Ve.has(ve.id));e(T);},className:"px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-full font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Confirm Selection"}),!r&&i&&jsx("button",{onClick:Or,className:"p-3 bg-red-500/10 text-red-500 hover:bg-red-500 hover:text-white rounded-full transition-all active:scale-90",children:jsx(Trash2,{className:"w-5 h-5"})})]})]}),te&&!r&&jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>Y(false)}),jsxs("div",{className:"fixed bottom-0 left-0 right-0 bg-[var(--kyro-surface)] rounded-t-3xl shadow-2xl max-h-[70vh] overflow-y-auto animate-in slide-in-from-bottom-12 duration-300",children:[jsxs("div",{className:"sticky top-0 bg-[var(--kyro-surface)] z-10 flex items-center justify-between p-6 pb-4 border-b border-[var(--kyro-border)]",children:[jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsx("button",{onClick:()=>Y(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsx(X,{className:"w-4 h-4"})})]}),jsxs("div",{className:"p-6 space-y-8",children:[jsxs("div",{children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(T=>jsx("button",{onClick:()=>{V(T),Y(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${N===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] border-transparent":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] border-[var(--kyro-border)] hover:border-[var(--kyro-text-muted)]"}`,children:T},T))})]}),jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsx("button",{onClick:()=>{Z(true),Y(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsx(FolderPlus,{className:"w-4 h-4"})})]}),jsxs("nav",{className:"space-y-1",children:[jsxs("button",{onClick:()=>{x(""),Y(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx(FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),m.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>{x(T),Y(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===T?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsx(Folder,{fill:v===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),pe(T),Y(false);},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 text-red-500 opacity-0 group-hover:opacity-100 transition-all hover:bg-red-50 rounded-lg",children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]},T))]})]})]})]})]}),jsx(xr,{open:!!g,onClose:()=>b(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:g?.filename,children:g&&jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[g.type==="image"?jsx("img",{src:ks(g)||Gr(g.url),alt:"",className:"w-full h-full object-contain p-4"}):g.type==="video"?jsx("video",{src:Gr(g.url),controls:true,className:"w-full h-full"}):jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsx(File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsx(Et,{variant:"outline",className:"text-xs font-bold",children:g.mimeType})]}),jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsx("button",{onClick:()=>D(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsx(Maximize2,{className:"w-4 h-4"})})})]}),jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:g.type==="image"?"Original Resolution":"N/A"})]}),jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:ws(g.fileSize)})]})]}),jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxs("div",{className:"flex gap-2",children:[jsx("input",{type:"text",readOnly:true,value:Gr(g.url),className:"flex-1 px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-[10px] font-bold font-mono focus:outline-none"}),jsx("button",{onClick:()=>{navigator.clipboard.writeText(Gr(g.url)),j.success("URL copied to clipboard");},className:"p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] border border-[var(--kyro-border)] rounded-xl transition-all",children:jsx(Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsx("textarea",{value:g.alt||"",onChange:T=>Ht(g.id,{alt:T.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.describeThisAsset",{defaultValue:"Describe this asset..."})})]}),jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsx("textarea",{value:g.caption||"",onChange:T=>Ht(g.id,{caption:T.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-lg text-xs font-bold transition-all resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.addACaption",{defaultValue:"Add a caption..."})})]})]})]})]}),!r&&jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxs("button",{onClick:()=>{let T=document.createElement("a");T.href=Gr(g.url),T.download=g.filename,T.click();},className:"flex-1 flex items-center justify-center gap-2 px-6 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-xs shadow-lg hover:opacity-90 transition-all",children:[jsx(Download,{className:"w-4 h-4"}),"Download"]}),g.type==="image"&&s&&jsx("button",{onClick:()=>E(true),className:"p-3 border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:jsx(Crop,{className:"w-4 h-4"})}),i&&jsx("button",{onClick:()=>{mt({title:"Delete Asset",message:`Are you sure you want to delete ${g.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`/api/media/${g.id}`),b(null),de(1);}catch(T){console.error("Delete failed:",T),j.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsx(Trash2,{className:"w-4 h-4"})})]})]})}),w&&g&&jsxs(At,{open:w,onClose:()=>D(false),title:"",size:"full",variant:"lightbox",children:[jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:g.filename}),jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[ws(g.fileSize)," \xB7 ",g.mimeType]})]}),jsx("button",{onClick:()=>D(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsx(X,{className:"w-6 h-6"})})]}),jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:g.type==="image"?jsx("img",{src:ks(g)||Gr(g.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):g.type==="video"?jsx("video",{src:Gr(g.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxs("div",{className:"text-white text-center",children:[jsx(File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&F&&g&&jsx(At,{open:F,onClose:()=>E(false),title:"",size:"full",variant:"lightbox",children:jsx(Rc,{url:Gr(g.url),initialCrop:g.metadata?.crop,initialHotspot:g.metadata?.hotspot,onSave:Wo,onCancel:()=>E(false),isSaving:R})}),!r&&jsx(hs,{open:J,onClose:()=>Z(false),onSubmit:ne,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsx(At,{open:K,onClose:()=>_(false),title:o("tooltips.storageNotConfigured",{defaultValue:"Storage Not Configured"}),size:"md",children:jsxs("div",{className:"text-center",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsx(Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mb-6 text-sm",children:"Before uploading media, you need to configure your storage settings. Choose where files should be stored and how URLs are generated."}),jsxs("div",{className:"flex gap-3",children:[jsx("a",{href:`${_e}/settings/storage-settings`,className:"flex-1 px-4 py-3 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-xl font-bold text-center hover:opacity-90 transition-colors",children:"Configure Storage"}),jsx("button",{type:"button",onClick:()=>{ut("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{_(false),ue(true),window.dispatchEvent(new Event("kyro:soft-reload"));}).catch(()=>{j.error("Failed to configure storage");});},className:"flex-1 px-4 py-3 border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded-xl font-bold hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Use Defaults"})]})]})}),!r&&jsx("input",{type:"file",ref:X$1,onChange:T=>{T.target.files&&gr(T.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}function Fc({type:e,message:t,onClose:r}){let[o,a]=na.useState(false),n=na.useRef(null),i=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},s=()=>{n.current&&clearTimeout(n.current);};na.useEffect(()=>(o?s():i(),s),[o,r]);let l={success:CircleCheck,error:ShieldAlert,warning:TriangleAlert,info:Info}[e];return jsxs("div",{className:`kyro-toast kyro-toast-${e} group animate-in fade-in slide-in-from-right-4 duration-300`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),children:[jsx("div",{className:"kyro-toast-accent"}),jsx("div",{className:"kyro-toast-icon-container",children:jsx(l,{className:"w-4 h-4"})}),jsx("div",{className:"kyro-toast-content",children:jsx("p",{className:"kyro-toast-message",children:t})}),jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsx(X,{className:"w-3.5 h-3.5"})})]})}function O2({children:e}){return jsx(Fragment,{children:e})}function Ic(){let e=Zt(o=>o.addToast),t=Zt(o=>o.removeToast);return {toasts:Zt(o=>o.toasts),addToast:e,removeToast:t}}var Rg=[{name:"Default",value:"inherit"},{name:"Red",value:"#ef4444"},{name:"Orange",value:"#f97316"},{name:"Amber",value:"#f59e0b"},{name:"Emerald",value:"#10b981"},{name:"Blue",value:"#3b82f6"},{name:"Indigo",value:"#6366f1"},{name:"Violet",value:"#8b5cf6"},{name:"Rose",value:"#f43f5e"},{name:"Slate",value:"#64748b"}],Uc=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o,isAiLoading:a,setIsAiLoading:n})=>{let{t:i}=H(),[s,l]=useState(null),[d,c]=useState(false),u=useRef(null),{addToast:p}=Ic(),f=ye(D=>D.formData),m=ye(D=>D.setField),y=projectConfig?.plugins?.some?.(D=>D.name==="ai-assistant")??false;if(useEffect(()=>{function D(F){u.current&&!u.current.contains(F.target)&&l(null);}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]),!e)return null;let v=()=>{o();},x=()=>{let D=e.getAttributes("link").href,F=window.prompt("URL",D);if(F!==null){if(F===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:F}).run();}},h=D=>{D==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(D).run(),l(null);},S=async(D,F)=>{l(null);let E=document.querySelector('input#title, input[name="title"]')?.value,R=f?.title||E||"Untitled Document",M="document";try{let Z=window.location.pathname.split("/").filter(Boolean);Z[0]==="admin"&&Z.length>=2&&(M=Z[1],M.endsWith("s")&&(M=M.slice(0,-1)));}catch{}let z=e.state.doc.textBetween(Math.max(0,e.state.selection.from-500),Math.min(e.state.doc.content.size,e.state.selection.to+500)," "),I=e.state.doc.textBetween(e.state.selection.from,e.state.selection.to," "),J="";if(D==="Generate")J=`Write a comprehensive, engaging, and professional ${M} titled "${R}".
10
10
  The content MUST be full-featured and highly formatted. You MUST include:
11
11
  1. Proper Markdown formatting (headings, paragraphs, bold/italic text, blockquotes)
12
12
  2. Relevant and context-specific images. You MUST use EXACT Markdown image syntax like this: '![alt text](https://image.pollinations.ai/prompt/URL_ENCODED_KEYWORDS)' (replace URL_ENCODED_KEYWORDS with descriptive keywords for the image)
@@ -106,12 +106,12 @@ Please format your response using rich Markdown. If your response includes image
106
106
 
107
107
  \`\`\`
108
108
  code block
109
- \`\`\``})})}),!i&&jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsx("span",{children:"**bold**"}),jsx("span",{children:"*italic*"}),jsx("span",{children:"`code`"}),jsx("span",{children:"[link](url)"}),jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsx("p",{className:"kyro-form-help",children:e.admin?.description}),o&&jsx("p",{className:"kyro-form-error",children:o})]}):jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function Ps({field:e,value:t,onChange:r,error:o,disabled:a}){let n=t??"",i=n.length>8?n.slice(0,-8)+"*".repeat(8):n;return jsx(pt,{field:e,error:o,children:jsx("div",{className:"relative",children:jsx("input",{id:e.name,type:"text",value:i,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})})})}function va({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),i=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:d,setIsSlugLocked:c,formData:u}=ye(),p=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",f=t==null?"":String(t),m={id:e.name,value:f,onChange:y=>r?.(y.target.value),placeholder:e.admin?.placeholder,disabled:a||i||l&&d,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||i||l&&d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsx(pt,{field:e,error:o,children:jsxs("div",{className:"relative",children:[s?jsx("textarea",{...m,rows:e.admin?.rows||4}):jsx("input",{type:p,...m,pattern:e.pattern}),l&&jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!d&&jsx("button",{type:"button",onClick:()=>r?.(vs(u[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:n("tooltips.regenerateSlug",{defaultValue:"Regenerate slug"}),children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"})]})}),jsx("button",{type:"button",onClick:()=>c(!d),className:`p-1.5 rounded transition-colors ${d?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:d?"Unlock slug":"Lock slug",children:d?jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxs("span",{className:f.length>60?"text-red-500":f.length>=40?"text-green-500":"text-amber-600",children:[f.length," / 60 \u2014 ",f.length>60?"Too Long":f.length>=40?"Ideal":"Short"]})})]})})}function Rs({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,children:jsx("input",{type:"number",id:e.name,value:t??"",onChange:i=>r?.(parseFloat(i.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Fs({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,hideLabel:true,children:jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsx("input",{type:"checkbox",checked:t??false,onChange:s=>r?.(s.target.checked),disabled:a||n,className:`w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)] transition-all ${a||n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`}),jsxs("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)] tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:[e.label||e.name,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Is({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,children:jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:i=>r?.(i.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Ls({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,u]=useState(null),p=JSON.stringify(n||{}),f=JSON.stringify(i||{});useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let v=setTimeout(async()=>{try{let x="";if(s)x=`${Dr}/${s}/dynamic-options/${e.name}`;else if(l)x=`${Dr}/globals/${l}/dynamic-options/${e.name}`;else return;let h=await ct(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(p),siblingData:JSON.parse(f)})});if(h.ok){let S=await h.json();S.options&&u(S.options);}}catch(x){console.error("Failed to fetch dynamic options:",x);}},300);return ()=>clearTimeout(v)},[p,f,e.name,e.options,s,l]);let m=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?m=e.options({data:n||{},siblingData:i||{}}):Array.isArray(e.options)&&(m=e.options)),e.dynamicOptions==="collections"&&(m=Object.keys(la).filter(y=>y!=="media").map(y=>({label:la[y]?.label||y,value:y}))),jsx(pt,{field:e,error:o,children:jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:y=>{if(e.hasMany){let v=Array.from(y.target.selectedOptions,x=>x.value);r?.(v);}else r?.(y.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:m.find(y=>y.value===t)?.color||void 0},className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsx("option",{value:"",children:"Select..."}),m.map(y=>jsx("option",{value:y.value,style:{color:y.color||void 0,fontWeight:y.color?"bold":"normal"},children:y.label},y.value))]})})}function ol(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function iy({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:i,setNodeRef:s,transform:l,transition:d,isDragging:c}=useSortable({id:e}),u={transform:CSS.Transform.toString(l),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxs("span",{ref:s,style:u,className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)] border border-transparent ${c?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsx("div",{...n,...i,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsx(GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]})}function ly({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),[i,s]=useState(false),[l,d]=useState(""),[c,u]=useState([]),[p,f]=useState(false),[m,y]=useState([]),v=useRef(new Set),x=useRef(null),h=useRef(()=>{});h.current=r||(()=>{});let S=e.hasMany,N=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],V=N.length>1,[P,k]=useState(N[0]||""),g=useCallback(()=>t?(S?Array.isArray(t)?t:[]:t?[t]:[]).map(J=>typeof J=="object"&&J!==null?J.value||J.id||"":String(J)).filter(Boolean):[],[t,S]),b=useCallback(I=>{I.length!==0&&I.forEach(J=>{if(v.current.has(J))return;v.current.add(J);let Z=V?(()=>{if(!t)return P;let Y=(S?Array.isArray(t)?t:[]:[t]).find(ae=>typeof ae=="object"&&ae!==null?ae.value===J||ae.id===J:false);return Y&&typeof Y=="object"&&Y.relationTo||P})():P;Me(`/api/${Z}/${J}`).then(te=>{let Y=te.data||te;!Y||typeof Y!="object"||y(ae=>ae.some(ue=>ue.id===J)?ae:[...ae,{...Y,id:String(Y.id),relationTo:Z}]);}).catch(()=>{});});},[V,t,P,S]);useEffect(()=>{let I=g();b(I);},[g,b]);let w=useCallback((I="")=>{f(true);let Z=`/api/${P}?${Tn(I,["title","name","label","email"])}`;Me(Z).then(te=>{u(Y=>{let ae=new Set(Y.map(he=>he.id)),ue=(te.docs||[]).filter(he=>!ae.has(he.id)).map(he=>({...he,id:he.id}));return [...Y,...ue]}),f(false);}).catch(()=>{f(false);});},[P]);useEffect(()=>{i&&(u([]),w(l));},[i,P]),useEffect(()=>{let I=J=>{x.current&&!x.current.contains(J.target)&&s(false);};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);let D=I=>{if(typeof I=="object"&&I!==null){let J=I.value??I.id;return J!=null?D(J):""}return String(I)},F=I=>{let J=I.id;return t?S&&Array.isArray(t)?t.some(Z=>D(Z)===J):D(t)===J:false},E=I=>{let J=I.id;if(S){let Z=Array.isArray(t)?t:[];if(F(I))h.current?.(Z.filter(te=>D(te)!==J));else {let te=V?{relationTo:P,value:J}:J;h.current?.([...Z,te]);}}else if(F(I))h.current?.(null);else {let Z=V?{relationTo:P,value:J}:J;h.current?.(Z),s(false),d("");}},R=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),M=I=>{let{active:J,over:Z}=I;if(!Z||J.id===Z.id)return;let te=S?Array.isArray(t)?t:[]:[],Y=te.findIndex(ue=>D(ue)===J.id),ae=te.findIndex(ue=>D(ue)===Z.id);if(Y!==-1&&ae!==-1){let ue=[...te],[he]=ue.splice(Y,1);ue.splice(ae,0,he),h.current?.(ue);}},z=()=>{if(!t)return null;let I=S?Array.isArray(t)?t:[]:t?[t]:[],J=I.map(Z=>D(Z));return S&&I.length>1?jsx(DndContext,{sensors:R,collisionDetection:closestCenter,onDragEnd:M,children:jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsx(SortableContext,{items:J,strategy:horizontalListSortingStrategy,children:I.map(Z=>{let te=D(Z),Y=m.find(he=>he.id===te),ae=Y?ol(Y):te.slice(0,12),ue=V&&Y?Y.relationTo:null;return jsx(iy,{id:te,label:ae,relation:ue,onRemove:()=>{let he=I.filter(U=>D(U)!==te);h.current?.(he);},disabled:a},te)})})})}):jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:I.map(Z=>{let te=D(Z),Y=m.find(he=>he.id===te),ae=Y?ol(Y):te.slice(0,12),ue=V&&Y?Y.relationTo:null;return jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[ue&&jsxs("span",{className:"opacity-60 mr-0.5",children:[ue,":"]}),ae,!a&&jsx("button",{type:"button",onClick:()=>{let he=I.filter(U=>D(U)!==te);h.current?.(S?he:he[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]},te)})})};return jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxs("div",{ref:x,className:"relative",children:[V&&jsx("div",{className:"flex gap-1 mb-1.5",children:N.map(I=>jsx("button",{type:"button",onClick:()=>{k(I),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${P===I?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:I},I))}),jsxs("div",{className:"relative",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",value:l,onChange:I=>{d(I.target.value),s(true),w(I.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${P}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:p?jsx(LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsx(ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${i?"rotate-180":""}`})})]}),i&&jsx("div",{className:"relative z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-64 overflow-auto",children:p?jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsx(fs,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:c.map(I=>jsxs("button",{type:"button",onClick:()=>E(I),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${F(I)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:ol(I)}),F(I)&&jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in I&&typeof I.slug=="string"&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:I.slug})]},I.id))})}),z()]}),e.admin?.description&&!o&&jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var dn=ly;var Mo=createContext(null);function ou(e=[],t=[]){return createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=al(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let i=ha(a),{blocks:s}=o(),l=[...s];n!==void 0?l.splice(n,0,i):l.push(i),r({blocks:l});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:i}=o(),s=cn(i,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=[...l];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:l,found:false}});if(s!==i){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),i=cn(n,s=>{let l=s.filter(d=>d.id!==a);return l.length!==s.length?{newList:l,found:true}:{newList:s,found:false}});if(i!==n){r({blocks:i});let{onBlocksChange:s}=o();s&&s();}},moveBlock:(a,n)=>{let{blocks:i}=o(),s=cn(i,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<l.length){let u=[...l];return [u[d],u[c]]=[u[c],u[d]],{newList:u,found:true}}}return {newList:l,found:false}});if(s!==i){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}}}))}function al(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};r.children&&Array.isArray(r.children)&&(r.children=al(r.children));let o=r.data;return o?.columnData&&Array.isArray(o.columnData)&&(r.data={...r.data,columnData:o.columnData.map(a=>({...a,children:a.children?al(a.children):a.children}))}),r}):[]}function ha(e){let t=py(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substring(2,11),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function py(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function qe(e){let t=useContext(Mo);if(t)return useStore(t,r=>{let o=a=>{for(let n of a){if(n.id===e)return n;if(n.children&&n.children.length>0){let s=o(n.children);if(s)return s}let i=n.data;if(i?.columnData&&Array.isArray(i.columnData)){for(let s of i.columnData)if(s&&s.children&&s.children.length>0){let l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function He(){let e=useContext(Mo);if(!e)throw new Error("useBlockActions must be used within a BlocksContext.Provider");return {updateBlock:(t,r)=>e.getState().updateBlock(t,r),removeBlock:t=>e.getState().removeBlock(t),moveBlock:(t,r)=>e.getState().moveBlock(t,r)}}function cn(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(i=>{let s={...i},l=false;if(i.children&&i.children.length>0){let c=cn(i.children,t);c!==i.children&&(s.children=c,l=true);}let d=i.data;if(d?.columnData&&Array.isArray(d.columnData)){let c=d.columnData.map(u=>{if(u.children&&u.children.length>0){let p=cn(u.children,t);if(p!==u.children)return {...u,children:p}}return u});c.some((u,p)=>u!==d.columnData[p])&&(s.data={...s.data,columnData:c},l=true);}return l&&(a=true),l?s:i});return a?n:e}function pn({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=H(),[i,s]=na.useState(null),l=async()=>{try{s(null);let d=await navigator.clipboard.readText(),c=JSON.parse(d);c.__kyro_block?o&&o(c):s("Clipboard does not contain a valid Kyro block.");}catch(d){s("Failed to read block from clipboard."),console.error(d);}};return e?jsxs(xr,{open:e,onClose:t,title:n("tooltips.insertBlock",{defaultValue:"Insert Block"}),width:"md",children:[jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsx(ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),i&&jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:i})]}),a]}):null}function au({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:i}=useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxs("div",{ref:n,...a,...o,onClick:()=>t(e.type),className:`flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group ${i?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:i?.5:1},children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:r||jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var nl=({text:e="",onChange:t,compact:r=false})=>{let{t:o}=H();return jsx("div",{className:r?"":"space-y-3",children:jsx("input",{type:"text",value:e,onChange:n=>t("text",n.target.value),className:r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.enterHeadingText",{defaultValue:"Enter heading text..."})})})};var Oo=({id:e,type:t,label:r,children:o,className:a=""})=>{let{t:n}=H(),{moveBlock:i,removeBlock:s}=He();return jsxs("div",{className:`block-${t} border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group bg-[var(--kyro-surface)] transition-all hover:border-[var(--kyro-primary)]/30 ${a}`,children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:n("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx("div",{className:"block-content",children:o})]})};var iu=({block:e,index:t})=>{let r=qe(e.id),{updateBlock:o}=He(),a=r?.data??e.data??{},n=(i,s)=>{o(e.id,{data:{...a,[i]:s}});};return jsx(Oo,{id:e.id,type:"heading",label:"Heading",children:jsx(nl,{text:a.text||"",onChange:n,compact:true})})};var du=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a}=He(),n=o?.data||e.data||{},i=(s,l)=>{a(e.id,{data:{...n,[s]:l}});};return jsx(Oo,{id:e.id,type:"paragraph",label:"Paragraph",children:jsx("textarea",{value:n.text||"",onChange:s=>i("text",s.target.value),className:"w-full px-3 py-3 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm min-h-[100px] resize-none",placeholder:r("fields.enterParagraphText",{defaultValue:"Enter paragraph text..."})})})};var cu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsxs("div",{className:"space-y-3",children:[jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsx(hr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:d=>l("src",d)})]}),jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsx("input",{type:"text",value:s.alt||"",onChange:d=>l("alt",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.alternativeText",{defaultValue:"Alternative text..."})})]}),jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsx("input",{type:"text",value:s.caption||"",onChange:d=>l("caption",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.imageCaption",{defaultValue:"Image caption..."})})]})]})]})};var il=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{let {t:n}=H();e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxs("div",{className:"space-y-2",children:[jsx("input",{type:"url",value:e,onChange:s=>r("src",s.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsx("input",{type:"text",value:t,onChange:s=>r("title",s.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]}):jsxs("div",{className:"space-y-3",children:[jsx(hr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsx("input",{type:"url",value:e,onChange:s=>r("src",s.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsx("input",{type:"text",value:t,onChange:s=>r("title",s.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]})};var pu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(il,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function Sy({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:i,transition:s,isDragging:l}=useSortable({id:e}),d={transform:CSS.Transform.toString(i),transition:s,zIndex:l?10:1,opacity:l?.8:1};return jsxs("div",{ref:n,style:d,className:`flex items-center gap-2 group/item p-1.5 hover:bg-[var(--kyro-surface-accent)]/50 rounded-md transition-colors ${l?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsx("div",{...o,...a,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",onClick:c=>c.stopPropagation(),children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var mn=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=H(),[a,n]=na.useState(""),[i,s]=na.useState([]);na.useEffect(()=>{let m=i.map(y=>y.text);JSON.stringify(m)!==JSON.stringify(e)&&s(e.map((y,v)=>({id:`${y}-${v}-${Math.random().toString(36).substr(2,4)}`,text:y})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=m=>{m.key==="Enter"&&(m.preventDefault(),l());},c=m=>{t(e.filter((y,v)=>v!==m));},u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),p=m=>{let{active:y,over:v}=m;if(!v||y.id===v.id)return;let x=i.findIndex(S=>S.id===y.id),h=i.findIndex(S=>S.id===v.id);if(x!==-1&&h!==-1){let S=[...e],[N]=S.splice(x,1);S.splice(h,0,N),t(S);}},f=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsx(DndContext,{sensors:u,collisionDetection:closestCenter,onDragEnd:p,children:jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:"No items. Type below to add."}):jsx(SortableContext,{items:i.map(m=>m.id),strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-1",children:i.map((m,y)=>jsx(Sy,{id:m.id,text:m.text,onRemove:()=>c(y)},m.id))})}),jsx("input",{type:"text",value:a,onChange:m=>n(m.target.value),onKeyDown:d,className:f,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};var mu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],d=c=>{a(e.id,{data:{...s,items:c}});};return jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(mn,{items:l,onChange:d,compact:true})]})};var fu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsx(CodeXml,{className:"w-5 h-5"})}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",s.language||"javascript"]})]})]}),jsx("div",{className:"flex items-center gap-1.5 opacity-0 group-hover/block:opacity-100 transition-all translate-x-2 group-hover/block:translate-x-0",children:jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1.5 hover:bg-[var(--kyro-surface)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})})]})})]}),jsxs("div",{className:"space-y-6",children:[jsx(ln,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:d=>l("code",d)}),jsxs("div",{className:"flex items-center gap-4 bg-[var(--kyro-surface-accent)]/20 p-4 rounded-xl border border-[var(--kyro-border)]/50",children:[jsxs("div",{className:"flex-1",children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxs("div",{className:"relative",children:[jsxs("select",{value:s.language||"javascript",onChange:d=>l("language",d.target.value),className:"w-full pl-4 pr-10 py-2.5 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl text-xs font-medium text-[var(--kyro-text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)]/20 focus:border-[var(--kyro-primary)] transition-all appearance-none cursor-pointer",children:[jsx("option",{value:"plaintext",children:"Plain Text"}),jsx("option",{value:"javascript",children:"JavaScript"}),jsx("option",{value:"typescript",children:"TypeScript"}),jsx("option",{value:"python",children:"Python"}),jsx("option",{value:"json",children:"JSON"}),jsx("option",{value:"html",children:"HTML"}),jsx("option",{value:"css",children:"CSS"}),jsx("option",{value:"sql",children:"SQL"}),jsx("option",{value:"rust",children:"Rust"}),jsx("option",{value:"markdown",children:"Markdown"})]}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsx(ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var gu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(hr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:d=>l("file",d)})]})};var ml=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=useState(0),n=jsx("div",{className:"flex justify-end gap-1 mb-2"}),i=(p,f)=>{let m=[...e];m[p]={...m[p],title:f},t(m);},s=(p,f)=>{let m=[...e];m[p]={...m[p],content:f},t(m);},l=p=>{let f=e.filter((m,y)=>y!==p);t(f),o===p?a(null):o!==null&&o>p&&a(o-1);},d=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},c="w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",u="w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return r?jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsx("div",{className:"space-y-1.5",children:e.map((p,f)=>{let{t:m}=H(),y=o===f;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(y?null:f),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3.5 h-3.5"})}),y?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),y&&jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:v=>i(f,v.target.value),onClick:v=>v.stopPropagation(),className:u,placeholder:m("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:v=>s(f,v.target.value),onClick:v=>v.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:m("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsx(Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsx("div",{className:"space-y-2",children:e.map((p,f)=>{let{t:m}=H(),y=o===f;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(y?null:f),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})}),y?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),y&&jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:v=>i(f,v.target.value),className:c,placeholder:m("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:v=>s(f,v.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:m("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsx(Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var yu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],d=c=>{a(e.id,{data:{...s,items:c}});};return jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(ml,{items:l,onChange:d,compact:true})]})};var vu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data||e.data||{},l=d=>{a(e.id,{data:{...s,content:d}});};return jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(pa,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var fl=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let{t:i}=H(),s=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",l=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return n?jsxs("div",{className:"space-y-2",children:[jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${s} font-bold text-base`,placeholder:i("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:i("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.ctaText",{defaultValue:"CTA text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]}):jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${s} font-bold text-base`,placeholder:i("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:i("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.ctaText",{defaultValue:"CTA text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var wa=({block:e,blockSchema:t,onClose:r})=>{let o=qe(e.id),{updateBlock:a}=He(),n=o?.data||e.data||{},i=o?.children||e.children||[],s=(u,p)=>{a(e.id,{data:{...n,[u]:p}});},l=u=>{a(e.id,{children:u});},d=()=>t&&Array.isArray(t.fields)?jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(u=>{if(u.admin?.condition){if(typeof u.admin.condition=="function")try{let f={values:n,...n};if(!u.admin.condition(f,f))return null}catch(f){console.warn(`Condition error for field ${u.name}:`,f);}else if(typeof u.admin.condition=="object")try{let f=u.admin.condition,m=f.field,y=n[m],v=!0;if("equals"in f?v=y===f.equals:"notEquals"in f?v=y!==f.notEquals:"in"in f&&Array.isArray(f.in)&&(v=f.in.includes(y)),!v)return null}catch(f){console.warn(`Declarative condition error for field ${u.name}:`,f);}}let p=n[u.name];return jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsx(jo,{field:u,value:p,onChange:f=>s(u.name,f)})},u.name)})}):jsxs("div",{className:"text-center py-8 text-[var(--kyro-text-muted)] text-sm italic",children:['No schema defined for block type "',e.type,'"']}),c=Ue[e.type]||Ue.default;return jsxs(xr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxs("div",{className:"space-y-4",children:[d(),i.length>0&&jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",i.length,")"]}),jsx(yo,{blockId:e.id,children:i,onUpdateChildren:l})]})]}),jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsx("button",{type:"button",onClick:r,className:"w-full py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Done"})})]})};var Ty=6,yo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Ty})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,p]=useState(null),f=useContext(Mo);if(!f)throw new Error("ChildBlocksTree must be used within a BlocksContext");let m=useStore(f,g=>g.dynamicCategories),y=useStore(f,g=>g.allowedBlocks),v=o<a,x=16,h=g=>{let b=ha(g);r([...t,b]),c(b.id);},S=g=>{let b=t.filter(w=>w.id!==g);r(b);},V=(g,b)=>{let w=t.map(D=>D.id===g?{...D,children:b}:D);r(w);},P=g=>{l(b=>{let w=new Set(b);return w.has(g)?w.delete(g):w.add(g),w});},k=g=>{let b=g.children&&g.children.length>0,w=s.has(g.id);gl(g.type);let F=b,E=d===g.id,R=y.find(M=>M.slug===g.type);return jsxs("div",{className:"relative group",children:[jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${E?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*x},onClick:()=>{v&&c(E?null:g.id);},children:[F?jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),P(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:w?jsx(ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsx(ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsx("span",{className:"w-4"}),Yt[g.type]&&jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Yt[g.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[yn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),R?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:R.admin.description})]}),b&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[g.children?.length," nested"]}),u===g.id?jsxs("div",{className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{S(g.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),p(g.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsx(X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),E&&jsx(wa,{block:g,onClose:()=>c(null)}),b&&w&&jsx("div",{className:"mt-1",children:jsx(hu,{parentId:g.id,children:g.children??[],onUpdateChildren:M=>V(g.id,M),depth:o+1,maxDepth:a})})]},g.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxs("div",{style:{marginLeft:o*x},children:[jsxs("button",{type:"button",onClick:()=>i(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsx(Plus,{className:"w-3 h-3"}),"Add Block"]}),jsx(pn,{open:n,onClose:()=>i(false),onSelect:h,children:m.map(g=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:g.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:g.blocks.map(b=>jsxs("button",{type:"button",onClick:()=>{h(b.slug),i(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Yt[b.slug]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:b.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:b.admin?.description||""})]})]},b.slug))})]},g.title))})]}),t.length===0&&v&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*x},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*x},children:["Maximum nesting level (",a,") reached"]})]})},hu=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,p]=useState(null),f=useContext(Mo);if(!f)throw new Error("NestedChildBlocks must be used within a BlocksContext");let m=useStore(f,g=>g.dynamicCategories),y=useStore(f,g=>g.allowedBlocks),v=o<a,x=16,h=g=>{let b=ha(g);r([...t,b]),c(b.id);},S=g=>{let b=t.filter(w=>w.id!==g);r(b);},V=(g,b)=>{let w=t.map(D=>D.id===g?{...D,children:b}:D);r(w);},P=g=>{l(b=>{let w=new Set(b);return w.has(g)?w.delete(g):w.add(g),w});},k=g=>{let b=g.children&&g.children.length>0,w=s.has(g.id);gl(g.type);let F=b,E=d===g.id,R=y.find(M=>M.slug===g.type);return jsxs("div",{className:"relative group",children:[jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${E?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*x},onClick:()=>{v&&c(E?null:g.id);},children:[F?jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),P(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:w?jsx(ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsx(ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsx("span",{className:"w-4"}),Yt[g.type]&&jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Yt[g.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[yn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),R?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:R.admin.description})]}),b&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[g.children?.length," nested"]}),u===g.id?jsxs("div",{className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{S(g.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),p(g.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsx(X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),E&&jsx(wa,{block:g,onClose:()=>c(null)}),b&&w&&jsx("div",{className:"mt-1",children:jsx(hu,{parentId:g.id,children:g.children??[],onUpdateChildren:M=>V(g.id,M),depth:o+1,maxDepth:a})})]},g.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxs("div",{style:{marginLeft:o*x},children:[jsxs("button",{type:"button",onClick:()=>i(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsx(Plus,{className:"w-3 h-3"}),"Add Block"]}),jsx(pn,{open:n,onClose:()=>i(false),onSelect:h,children:m.map(g=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:g.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:g.blocks.map(b=>jsxs("button",{type:"button",onClick:()=>{h(b.slug),i(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Yt[b.slug]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:b.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:b.admin?.description||""})]})]},b.slug))})]},g.title))})]}),t.length===0&&v&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*x},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*x},children:["Maximum nesting level (",a,") reached"]})]})};var xu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=o?.children??e.children??[],d=(c,u)=>{a(e.id,{data:{...s,[c]:u}});};return jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("div",{className:"flex items-center gap-2",children:jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsxs("div",{className:"space-y-3",children:[jsx(fl,{heading:s.title||"",subheading:s.subtitle||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:d,compact:true}),jsx(hr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:c=>d("bgImage",c)}),jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsx(yo,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var yl=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:i=false})=>{let{t:s}=H(),l=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",d=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxs("div",{className:i?"space-y-2":"space-y-3",children:[jsx("input",{type:"text",value:e,onChange:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:s("fields.cardTitle",{defaultValue:"Card title..."})}),jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:d,placeholder:s("fields.cardDescription",{defaultValue:"Card description..."})}),jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.target.value),className:l,placeholder:s("fields.iconEmojiOrName",{defaultValue:"Icon (emoji or name)..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:a,onChange:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.linkText",{defaultValue:"Link text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var Nu=({block:e,index:t})=>{let r=qe(e.id),{updateBlock:o}=He(),a=r?.data??e.data??{},n=(i,s)=>{o(e.id,{data:{...a,[i]:s}});};return jsx(Oo,{id:e.id,type:"card",label:"Card",children:jsx(yl,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Cu=({block:e,index:t})=>{let {t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He();o?.data??e.data??{};let l=o?.children??e.children??[];return jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx("div",{className:"space-y-3",children:jsx(yo,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var Su=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",s.relationTo||"pages"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(Za,{relationTo:s.relationTo||"pages",hasMany:s.hasMany||false,selectedIds:Array.isArray(s.selectedIds)?s.selectedIds:[],selectedId:s.selectedId,labelField:s.labelField||"title",onChange:l,compact:true})]})};var Dy={heading:iu,paragraph:du,image:cu,video:pu,list:mu,code:fu,file:gu,accordion:yu,richtext:vu,hero:xu,card:Nu,array:Cu,relationship:Su},Ue={featureSplit:{text:"text-indigo-500",border:"border-indigo-500",borderLeft:"border-l-indigo-500"},featureGrid:{text:"text-blue-500",border:"border-blue-500",borderLeft:"border-l-blue-500"},ctaBanner:{text:"text-amber-500",border:"border-amber-500",borderLeft:"border-l-amber-500"},testimonials:{text:"text-emerald-500",border:"border-emerald-500",borderLeft:"border-l-emerald-500"},faq:{text:"text-orange-500",border:"border-orange-500",borderLeft:"border-l-orange-500"},stats:{text:"text-rose-500",border:"border-rose-500",borderLeft:"border-l-rose-500"},logoCloud:{text:"text-cyan-500",border:"border-cyan-500",borderLeft:"border-l-cyan-500"},pricing:{text:"text-green-500",border:"border-green-500",borderLeft:"border-l-green-500"},team:{text:"text-violet-500",border:"border-violet-500",borderLeft:"border-l-violet-500"},recentFeed:{text:"text-sky-500",border:"border-sky-500",borderLeft:"border-l-sky-500"},processSteps:{text:"text-fuchsia-500",border:"border-fuchsia-500",borderLeft:"border-l-fuchsia-500"},formEmbed:{text:"text-pink-500",border:"border-pink-500",borderLeft:"border-l-pink-500"},videoShowcase:{text:"text-red-500",border:"border-red-500",borderLeft:"border-l-red-500"},hero:{text:"text-yellow-500",border:"border-yellow-500",borderLeft:"border-l-yellow-500"},card:{text:"text-teal-500",border:"border-teal-500",borderLeft:"border-l-teal-500"},default:{text:"text-zinc-400",border:"border-zinc-400",borderLeft:"border-l-zinc-400"}},Yt={heading:jsx(Heading1,{className:`w-4 h-4 ${Ue.default.text}`}),paragraph:jsx(AlignLeft,{className:`w-4 h-4 ${Ue.default.text}`}),image:jsx(Image,{className:`w-4 h-4 ${Ue.default.text}`}),video:jsx(Video,{className:`w-4 h-4 ${Ue.default.text}`}),list:jsx(List,{className:`w-4 h-4 ${Ue.default.text}`}),code:jsx(Code,{className:`w-4 h-4 ${Ue.default.text}`}),file:jsx(File,{className:`w-4 h-4 ${Ue.default.text}`}),accordion:jsx(ChevronDown,{className:`w-4 h-4 ${Ue.default.text}`}),richtext:jsx(AlignLeft,{className:`w-4 h-4 ${Ue.default.text}`}),hero:jsx(Star,{className:`w-4 h-4 ${Ue.hero.text}`}),card:jsx(Box,{className:`w-4 h-4 ${Ue.card.text}`}),array:jsx(ListOrdered,{className:`w-4 h-4 ${Ue.default.text}`}),relationship:jsx(Link2,{className:`w-4 h-4 ${Ue.default.text}`}),featureSplit:jsx(Columns3,{className:`w-4 h-4 ${Ue.featureSplit.text}`}),featureGrid:jsx(Blocks,{className:`w-4 h-4 ${Ue.featureGrid.text}`}),ctaBanner:jsx(Sparkles,{className:`w-4 h-4 ${Ue.ctaBanner.text}`}),testimonials:jsx(Users,{className:`w-4 h-4 ${Ue.testimonials.text}`}),faq:jsx(CircleHelp,{className:`w-4 h-4 ${Ue.faq.text}`}),stats:jsx(Activity,{className:`w-4 h-4 ${Ue.stats.text}`}),logoCloud:jsx(Image,{className:`w-4 h-4 ${Ue.logoCloud.text}`}),pricing:jsx(Tag,{className:`w-4 h-4 ${Ue.pricing.text}`}),team:jsx(Users,{className:`w-4 h-4 ${Ue.team.text}`}),recentFeed:jsx(Database,{className:`w-4 h-4 ${Ue.recentFeed.text}`}),processSteps:jsx(Clock,{className:`w-4 h-4 ${Ue.processSteps.text}`}),formEmbed:jsx(Mail,{className:`w-4 h-4 ${Ue.formEmbed.text}`}),videoShowcase:jsx(Video,{className:`w-4 h-4 ${Ue.videoShowcase.text}`})};function gl(e){return Dy[e]||null}function vl(e){return {paragraph:"Paragraph",heading:"Heading",image:"Image",video:"Video",list:"List",code:"Code",file:"File",accordion:"Accordion",array:"Repeater",relationship:"Relationship",richtext:"Rich Text",hero:"Hero Section",card:"Card Block",featureSplit:"Feature Split",featureGrid:"Feature Grid",ctaBanner:"CTA Banner",testimonials:"Testimonials Stack",faq:"FAQ Section",stats:"Stats & Metrics",logoCloud:"Logo Cloud",pricing:"Pricing Grid / Plan",team:"Team Profiles Showcase",recentFeed:"Dynamic Content Feed",processSteps:"Process Timeline / Steps",formEmbed:"Lead Intake Form",videoShowcase:"Cinematic Video Showcase",headingElement:"Heading",textElement:"Text",imageElement:"Image",richtextElement:"Rich Text",buttonElement:"Button",videoElement:"Video",listElement:"List"}[e]||e}function yn(e){let t=e.name;return t&&t.trim()?t.trim():vl(e.type)}function zy(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var Hy=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:i})=>{let{t:s}=H(),{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:p,isDragging:f}=useSortable({id:e.id}),{removeBlock:m,updateBlock:y}=He(),v=o===e.id,[x,h]=useState(false),[S,N]=useState(false),[V,P]=useState(e.name||""),k=useRef(null),[g,b]=useState(false);useEffect(()=>{S&&k.current&&(k.current.focus(),k.current.select());},[S]);let w=useCallback(()=>{N(false);let z=V.trim();z!==(e.name||"").trim()&&y(e.id,{name:z||""});},[V,e.name,e.id,y]),D=useCallback(z=>{z.stopPropagation();try{let I={__kyro_block:!0,type:e.type,blockProps:{...e,id:void 0,type:void 0}};navigator.clipboard.writeText(JSON.stringify(I,null,2)),b(!0),j.success(s("notifications.blockCopied",{defaultValue:"Block copied to clipboard"})),setTimeout(()=>b(!1),2e3);}catch{j.error(s("notifications.blockCopyFailed",{defaultValue:"Failed to copy block"}));}},[e,s]),F={transform:CSS.Transform.toString(u),transition:p,zIndex:f?10:1,opacity:f?.8:1},E=yn(e),R=e.data||{},M=zy(R,r);return i?jsxs("div",{ref:c,style:F,className:"relative group w-full",children:[jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${v?`${(Ue[e.type]||Ue.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...d,onClick:z=>z.stopPropagation(),children:jsx(GripVertical,{className:"w-2.5 h-2.5"})}),Yt[e.type]&&jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Yt[e.type]}),S?jsx("input",{ref:k,value:V,onChange:z=>P(z.target.value),onBlur:w,onKeyDown:z=>{z.key==="Enter"&&w(),z.key==="Escape"&&(P(e.name||""),N(false));},onClick:z=>z.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:E}),x?jsxs("div",{className:"flex items-center gap-0.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{m(e.id),h(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsx("button",{type:"button",onClick:()=>h(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),N(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.rename",{defaultValue:"Rename"}),children:jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.duplicateInPlace",{defaultValue:"Duplicate in place"}),children:jsx(Copy,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:D,className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.copyBlock",{defaultValue:"Copy Block to Clipboard"}),children:g?jsx(Check,{className:"w-3 h-3 text-green-500"}):jsx(ClipboardCopy,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:s("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),v&&jsx(wa,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxs("div",{ref:c,style:F,className:"relative group mb-2",children:[jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${v?`${(Ue[e.type]||Ue.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsx("div",{className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 touch-none",...l,...d,onClick:z=>z.stopPropagation(),children:jsx(GripVertical,{className:"w-4 h-4"})}),Yt[e.type]&&jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Yt[e.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[S?jsx("input",{ref:k,value:V,onChange:z=>P(z.target.value),onBlur:w,onKeyDown:z=>{z.key==="Enter"&&w(),z.key==="Escape"&&(P(e.name||""),N(false));},onClick:z=>z.stopPropagation(),placeholder:vl(e.type),className:"w-full max-w-[150px] sm:max-w-[250px] md:max-w-[400px] bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"}):jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[E,M&&typeof M=="string"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",M.length>40?`${M.slice(0,40)}...`:M]})]}),!!r?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:r.admin.description})]}),!!e.children&&Array.isArray(e.children)&&e.children.length>0&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),x?jsxs("div",{className:"flex items-center gap-1.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{m(e.id),h(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsx("button",{type:"button",onClick:()=>h(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),N(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.renameBlock",{defaultValue:"Rename Block"}),children:jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.duplicateBlock",{defaultValue:"Duplicate Block"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:D,className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.copyBlock",{defaultValue:"Copy Block to Clipboard"}),children:g?jsx(Check,{className:"w-3.5 h-3.5 text-green-500"}):jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:s("tooltips.removeBlock",{defaultValue:"Remove Block"}),children:jsx(X,{className:"w-3.5 h-3.5"})})]})]}),v&&jsx(wa,{block:e,blockSchema:r,onClose:()=>a(null)})]})},_y=na.memo(Hy),hl=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:i,justSaved:s})=>{let[l,d]=useState(false),[c,u]=useState(false),p=useRef(null),f=e.admin?.pickerMode||"drawer",m=e.blocks||[],y=m.reduce((U,K)=>{let _=K.admin?.group||"Custom Blocks";return U[_]||(U[_]=[]),U[_].push(K),U},{}),v=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],x=Object.entries(y).sort(([U],[K])=>{let _=v.indexOf(U),xe=v.indexOf(K);return _!==-1&&xe!==-1?_-xe:_!==-1?-1:xe!==-1?1:U.localeCompare(K)}).map(([U,K])=>({title:U,blocks:K})),h=useRef(null);h.current||(h.current=ou(m,x));let S=h.current,N=useStore(S,U=>U.blocks),[V,P]=useState(null),[k,g]=useState(null),b=useRef(N.length),w=useRef(new Set(N.map(U=>U.id))),D=useRef(false);useEffect(()=>{if(D.current&&N.length>b.current){let U=N.find(K=>K.id&&!w.current.has(K.id));U&&g(U.id);}b.current=N.length,w.current=new Set(N.map(U=>U.id));},[N]),useEffect(()=>(o&&S.getState().setOnBlocksChange(o),()=>{S.getState().setOnBlocksChange(()=>{});}),[o,S]);let F=useRef(null);useEffect(()=>{let U=Array.isArray(t)?t:[],K=F.current||[];if(Eo(U,K))U.length===0&&!D.current&&(D.current=true,F.current=[]);else {let _=[...U];b.current=_.length,w.current=new Set(_.map(xe=>xe.id)),S.getState().setBlocks(_),F.current=_,D.current=true;}},[t,e.name,S]);let E=useRef(r);E.current=r,useEffect(()=>{if(!E.current)return;let U=F.current;U&&(Eo(N,U)||(F.current=[...N],E.current(N)));},[N]);let M=useCallback(U=>{S.getState().addBlock(U);},[S]),z=useCallback(U=>{if(!m.some(Be=>Be.slug===U.type)){alert(`The block type "${U.type}" is not allowed in this collection.`);return}let _=Math.random().toString(36).substring(2,11),xe={...U.blockProps||{},id:_,type:U.type};S.getState().setBlocks([...N,xe]),d(false);},[m,N,S]),I=useCallback(U=>{let K=document.activeElement;if(K&&(K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.getAttribute("contenteditable")==="true"))return;let _=U.clipboardData?.getData("text");if(_)try{let xe=JSON.parse(_);xe&&xe.__kyro_block&&(U.preventDefault(),U.stopPropagation(),z(xe),j.success(`Block pasted: ${xe.type}`));}catch{}},[z]),J=useCallback(U=>{let K=N.findIndex(C=>C.id===U);if(K===-1)return;let _=N[K],xe=C=>{let G=Math.random().toString(36).substr(2,9);return {...C,id:G,children:C.children?C.children.map(Ne=>xe(Ne)):C.children,data:C.data?JSON.parse(JSON.stringify(C.data)):C.data}},Be=xe(_),we=[...N];we.splice(K+1,0,Be),S.getState().setBlocks(we);},[N,S]),Z=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}}),useSensor(TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),useSensor(KeyboardSensor)),te=U=>{P(U.active);},Y=U=>{let{active:K,over:_}=U;if(P(null),!!_){if(K.id.toString().startsWith("drawer-")){let xe=K.id.toString().replace("drawer-","");if(_.id.toString().startsWith("container-")){let Be=_.id.toString().replace("container-",""),we=N.find(C=>C.id===Be);if(we){let C=ha(xe);S.getState().updateBlock(Be,{children:[...we.children||[],C]});}}else {let Be=N.findIndex(we=>we.id===_.id);Be!==-1?S.getState().addBlock(xe,Be):M(xe);}return}if(K.id!==_.id){let xe=N.findIndex(we=>we.id===K.id),Be=N.findIndex(we=>we.id===_.id);if(xe!==-1&&Be!==-1){let we=[...N],[C]=we.splice(xe,1);we.splice(Be,0,C),S.getState().setBlocks(we);}}}},ae=V?x.flatMap(U=>U.blocks).find(U=>`drawer-${U.type}`===V.id)||N.find(U=>U.id===V.id):null;ae?"label"in ae?ae.label:ae.type:"Block";return useEffect(()=>{if(!c)return;let U=K=>{p.current&&!p.current.contains(K.target)&&u(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[c]),jsx(Mo.Provider,{value:h.current,children:jsxs("div",{className:"kyro-blocks-field",onPaste:I,tabIndex:0,style:{outline:"none"},children:[jsxs(DndContext,{sensors:Z,collisionDetection:closestCenter,onDragStart:te,onDragEnd:Y,children:[jsxs("div",{className:f==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsx("label",{className:`kyro-form-label ${f==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),f==="dropdown"?jsxs("div",{ref:p,className:"relative w-full",children:[jsxs("button",{type:"button",onClick:()=>u(!c),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsx(ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:x.map(U=>jsxs("div",{children:[x.length>1&&jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:U.title}),U.blocks.map(K=>jsxs("button",{type:"button",onClick:()=>{M(K.slug),u(false);},className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50 transition-colors text-left",children:[jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Yt[K.slug]||jsx(Box,{className:"w-4 h-4"})}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:"text-xs font-semibold truncate",children:K.label}),K.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:K.admin.description})]})]},K.slug))]},U.title))})]}):jsxs("button",{type:"button",onClick:()=>d(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsx(Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsx("div",{className:"mb-4",children:jsx(pn,{open:l,onClose:()=>d(false),onSelect:M,onPasteBlock:z,children:jsx("div",{className:"space-y-4",children:x.map(U=>jsxs("div",{children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:U.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:U.blocks.map(K=>jsx(au,{block:{type:K.slug,label:K.label,description:K.admin?.description||"",icon:null},onSelect:M,children:jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Yt[K.slug]||jsx(Box,{className:"w-4 h-4"})})})},K.slug))})]},U.title))})})}),jsx(SortableContext,{items:N.map(U=>U.id),strategy:verticalListSortingStrategy,children:jsxs("div",{className:f==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[N.map((U,K)=>{let _=e.blocks?.find(xe=>xe.slug===U.type);return jsx(_y,{block:U,index:K,blockSchema:_,editingBlockId:k,setEditingBlockId:g,onDuplicate:J,compact:f==="dropdown"},U.id||K)}),N.length===0&&jsx("div",{className:f==="dropdown"?"text-xs text-[var(--kyro-text-muted)] italic py-1":"text-center py-12 text-[var(--kyro-text-muted)] border-2 border-dashed border-[var(--kyro-border)] rounded-lg",children:f==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsx(DragOverlay,{children:V&&ae&&jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:ae.label||ae.type||"Block"})})]}),a&&jsx("p",{className:"kyro-form-error",children:a})]})})};function $s({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxs("div",{className:"kyro-form-group border border-[var(--kyro-border)] rounded-[var(--kyro-radius-lg)] p-6 bg-[var(--kyro-surface-accent)]/30",children:[jsx("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name})}),jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields?.map(n=>o(n,a,r))})]})}var Zy=new Set(["text","number","checkbox","select","radio","color","email","password"]);function ev(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Zy.has(r.type))}function Ru({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:i,onChangeItem:s,onRemove:l,disabled:d,compact:c,getItemLabel:u}){let{t:p}=H(),{attributes:f,listeners:m,setNodeRef:y,transform:v,transition:x}=useSortable({id:e}),h={transform:CSS.Transform.toString(v),transition:x},S=n.fields||[];return c?jsxs("div",{ref:y,style:h,className:"flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0",children:[jsx("div",{...f,...m,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsx("div",{className:`flex-1 min-w-0 ${S.length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:S.map(N=>jsx("div",{className:"flex-1 min-w-0",children:i(N,a,s)},N.name))}),jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:p("tooltips.remove",{defaultValue:"Remove"}),children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxs("div",{ref:y,style:h,className:"border border-[var(--kyro-border)] rounded-[var(--kyro-radius-md)] bg-[var(--kyro-surface-accent)]/10 overflow-hidden",children:[jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-[var(--kyro-surface-accent)]/20 border-b border-[var(--kyro-border)]",children:[jsx("div",{...f,...m,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0",children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-muted)] min-w-[18px]",children:t+1}),jsx("div",{className:"flex-1 min-w-0",children:jsx("span",{className:"text-xs font-medium text-[var(--kyro-text-primary)] truncate block",children:u(a)||`${n.label||n.name} Item`})}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-1 rounded hover:bg-[var(--kyro-surface-accent)]",title:p("tooltips.remove",{defaultValue:"Remove"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] transition-colors",children:r?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:S.map(N=>i(N,a,s))})]})}function Os({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],i=e.fields||[],s=i[0],l=s?.name||"user",d=s?.type==="relationship",[c,u]=na.useState(0);na.useEffect(()=>{let x=false,h=n.filter(S=>typeof S!="object"||S===null?(x=true,false):true).map(S=>!S.id&&!S._key?(x=true,{...S,id:Math.random().toString(36).substr(2,9)}):S);x&&r(h);},[t,r]);function p(x){for(let S of ["label","title","name"]){let N=x[S];if(N&&typeof N=="string")return N}let h=i;for(let S of h){if(S.type==="text"||S.type==="textarea"){let N=x[S.name];if(N&&typeof N=="string")return N}if(S.type==="group"&&S.fields){for(let N of S.fields||[])if(N.type==="text"||N.type==="textarea"){let P=x[S.name]?.[N.name];if(P&&typeof P=="string")return P}}}return ""}let f=ev(e),m=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),y=x=>{let{active:h,over:S}=x;if(!S||h.id===S.id)return;let N=n.findIndex(P=>(P.id||P._key)===h.id),V=n.findIndex(P=>(P.id||P._key)===S.id);if(N!==-1&&V!==-1){let P=[...n],[k]=P.splice(N,1);P.splice(V,0,k),r(P);}},v=na.useMemo(()=>n.map(x=>x?.id||x?._key||""),[n]);return d?jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(dn,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:void 0},value:n.map(x=>x[l]).filter(Boolean),onChange:x=>{let h=(x||[]).map(S=>({[l]:S,id:Math.random().toString(36).substr(2,9)}));r(h);},disabled:a})]}):jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(DndContext,{sensors:m,collisionDetection:closestCenter,onDragEnd:y,children:f?jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsx(SortableContext,{items:v,strategy:verticalListSortingStrategy,children:n.map((x,h)=>jsx(Ru,{id:x.id||x._key||`idx-${h}`,index:h,isOpen:false,setOpenIndex:()=>{},item:x,field:e,renderField:o,onChangeItem:S=>{let N=[...n];N[h]=S,r(N);},onRemove:()=>r(n.filter((S,N)=>N!==h)),disabled:a,compact:true,getItemLabel:p},x.id||x._key||h))}),jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxs("div",{className:"kyro-form-array border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md p-3 space-y-4",children:[jsx(SortableContext,{items:v,strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-2",children:n.map((x,h)=>{let S=c===h;return jsx(Ru,{id:x.id||x._key||`idx-${h}`,index:h,isOpen:S,setOpenIndex:u,item:x,field:e,renderField:o,onChangeItem:N=>{let V=[...n];V[h]=N,r(V);},onRemove:()=>r(n.filter((N,V)=>V!==h)),disabled:a,compact:false,getItemLabel:p},x.id||x._key||h)})})}),jsx("button",{type:"button",className:"w-full py-3 border-2 border-dashed border-[var(--kyro-border)] rounded-lg text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>{let x=Math.random().toString(36).substr(2,9);r([...n,{id:x}]),u(n.length);},children:"+ Add Item"})]})})]})}var jo=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{ys("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsx(va,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "icon":return jsx(Ss,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "textarea":return jsx(va,{field:{...e,variant:"textarea"},value:t??void 0,onChange:d,error:o,disabled:a});case "password":return jsx(va,{field:{...e,variant:"password"},value:t??void 0,onChange:d,error:o,disabled:a});case "secret":return jsx(Ps,{field:e,value:t??void 0,onChange:r,error:o,disabled:a});case "number":return jsx(Rs,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "checkbox":return jsx(Fs,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsx(Ls,{field:e,value:t??void 0,onChange:d,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l});case "date":return jsx(Is,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "richtext":return jsx(pa,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsx(Xi,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "code":return jsx(ln,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "image":case "upload":return jsx(pt,{field:e,error:o,children:jsx(hr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsx(dn,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsx(pt,{field:e,error:o,children:jsx(mn,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsx(Os,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,p)=>{let f=u[c.name];return jsx(jo,{field:c,value:f,onChange:m=>{p({...u,[c.name]:m});},disabled:a,error:o},c.name)}});case "blocks":return jsx(hl,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsx($s,{field:e,value:t,onChange:r,renderField:(c,u,p)=>{let f=u[c.name];return jsx(jo,{field:c,value:f,onChange:m=>{p({...u,[c.name]:m});},disabled:a,error:o,collectionSlug:s,globalSlug:l},c.name)}});case "color":return jsx(pt,{field:e,error:o,children:jsxs("div",{className:"flex items-center gap-3",children:[jsx("input",{type:"color",value:t||"#000000",onChange:c=>r(c.target.value),disabled:a,className:"h-10 w-14 p-1 cursor-pointer bg-[var(--kyro-input-bg)] border border-[var(--kyro-input-border)] rounded-lg"}),jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-800 text-xs italic",children:['Field type "',e.type,'" is not yet supported in this renderer.']})}};var Iu=({title:e,description:t,slug:r})=>jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg p-6 max-w-2xl shadow-sm transition-colors duration-300",children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("div",{className:"w-7 h-7 bg-[var(--kyro-bg-secondary)] rounded-full flex items-center justify-center text-[10px] text-[var(--kyro-text-primary)] font-medium border border-[var(--kyro-border)]",children:"K"}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function Eu({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=useState(0),i=e.tabs||[],s=i[a]||i[0],l=e.name?t[e.name]||{}:t;return jsxs("div",{className:"space-y-8",children:[jsx("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:i.map((d,c)=>jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))})}),jsx("div",{className:"space-y-6",children:s?.fields.map(d=>o(d,l,r))}),s?.label==="SEO Settings"&&jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsx(Iu,{title:String((typeof l.metaTitle=="object"?"":l.metaTitle)||(typeof l.title=="object"?"":l.title)||"Untitled"),description:String((typeof l.metaDescription=="object"?"":l.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function Uo({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=useState(false),i=useRef(null);return useEffect(()=>{let s=l=>{i.current&&!i.current.contains(l.target)&&n(false);};return a&&document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[a]),jsxs("div",{className:"relative",ref:i,children:[jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsx("div",{className:`absolute z-[100] min-w-[200px] py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100 ${r==="right"?"right-0":"left-0"} ${o==="down"?"top-full mt-2":"bottom-full mb-2"}`,onClick:()=>n(false),children:t})]})}function Ft({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsx("div",{className:"px-1.5",children:jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsx("span",{className:"flex-1",children:e})]})})}function hn(){return jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Ho({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:i="down"}){let s=e==="published"&&!r&&t!=="saving"&&t!=="error",l=n||t==="saving"||s||t==="saved",d="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",c=()=>t==="saving"?`${d} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:s?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${d} bg-[var(--kyro-primary)] border-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] hover:bg-[var(--kyro-primary-hover)]`,u="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",p=()=>t==="saving"?`${u} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:t==="error"?`${u} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:s?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${u} bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-hover)]`,f=()=>t==="saving"?"Publishing...":t==="saved"?"Published":t==="error"?"Retry":s?"Published":"Publish Changes";return jsxs("div",{className:"inline-flex items-center",children:[jsxs("button",{type:"button",onClick:o,disabled:l,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsx(lr,{size:"sm",className:"inline mr-1.5"}),(s||t==="saved")&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),f()]}),a&&jsx(Uo,{trigger:jsx("button",{type:"button",className:p(),disabled:t==="saving",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:i,children:a})]})}function Vu({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:i,handleDuplicate:s,handleUnpublish:l,handleDelete:d,handlePublish:c,handleSaveDraft:u,handleSchedulePublish:p,handleConflictOverride:f}){let{t:m}=H(),[y,v]=useState(Date.now()),[x,h]=useState(false),S=useRef(null),{formData:N,hasUnsavedChanges:V,autoSaveStatus:P,lastSavedAt:k,retryCount:g,view:b,setView:w,showPreview:D,setShowPreview:F,setFormData:E,markSaved:R,lastSavedData:M}=ye(),z=!N.id;useEffect(()=>{let _=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(_)},[]),useEffect(()=>{let _=xe=>{S.current&&!S.current.contains(xe.target)&&h(false);};if(x)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[x]);let I=String(N.tabs?.title||(typeof N.title=="object"?"":N.title)||(typeof N.name=="object"?"":N.name)||"Untitled"),J=N.updatedAt?new Date(N.updatedAt).toLocaleString():"Just now",Z=N.createdAt?new Date(N.createdAt).toLocaleString():"Just now",te=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",Y=o?"Unpublished":r==="published"?"Published":"Draft",ae=r==="published"&&!V?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",ue=r==="published"&&!o?"bg-[var(--kyro-success)]/10 text-[var(--kyro-success)] border-[var(--kyro-success)]/20":o?"bg-[var(--kyro-warning)]/10 text-[var(--kyro-warning)] border-[var(--kyro-warning)]/20":"bg-[var(--kyro-text-muted)]/10 text-[var(--kyro-text-muted)] border-[var(--kyro-text-muted)]/20",he=(_=false)=>jsxs(Fragment,{children:[P==="saving"&&jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),_?"Saving\u2026":"Saving draft..."]}),P==="success"&&jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsx(Check,{className:"w-3.5 h-3.5 shrink-0"}),_?"Saved":k?`Saved ${Math.floor((Date.now()-k)/6e4)}m ago`:"Draft saved"]}),P==="retrying"&&jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),_?`Retry ${g}/5`:`Retrying save (${g}/5)`]}),P==="offline"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsx("path",{d:"m2 2 20 20"}),jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),_?"Offline":"Offline \u2014 cached locally"]}),P==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:_?"Failed":"Draft save failed"}),P==="conflict"&&(_?jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxs("div",{className:"flex items-center gap-3",children:[jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>f?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsx("span",{className:"opacity-30",children:"|"}),jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("kyro:soft-reload")),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),U=()=>!z&&jsxs(Uo,{trigger:jsx("button",{type:"button",className:"kyro-btn p-2 md:p-2.5 rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)] transition-all",title:m("tooltips.moreActions",{defaultValue:"More actions"}),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsx(Ft,{onClick:u,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsx(Ft,{onClick:i,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsx(Ft,{onClick:s,disabled:n,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),children:n?"Duplicating...":"Duplicate"}),jsx(Ft,{onClick:()=>h(true),icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsx(Ft,{onClick:l,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxs(Fragment,{children:[jsx(hn,{}),jsx(Ft,{onClick:d,danger:true,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),children:"Delete"})]})]}),K=()=>x&&jsx("div",{ref:S,className:"relative",children:jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsx("button",{type:"button",onClick:()=>h(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsx("button",{type:"button",onClick:()=>{let _=document.getElementById("schedule-datetime")?.value;_&&p(_);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxs(Fragment,{children:[jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsx("a",{href:`${_e}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsx(ChevronRight,{className:"w-4 h-4"})}),jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:I}),jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${ue}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ae}`}),Y]})]}),jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsx(Ho,{status:r,saveStatus:a,hasChanges:V,onPublish:c,disabled:a==="saving"}),U(),K()]})]}),jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-[var(--kyro-border)]/50 bg-[var(--kyro-bg-secondary)]/30",children:[jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)]/50",children:["edit","version","api"].map(_=>jsx("button",{type:"button",onClick:()=>w(_),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${b===_?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 active:opacity-100"}`,children:_==="edit"?"Edit":_==="version"?"History":"API"},_))}),jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[he(true),V&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsx("button",{type:"button",onClick:()=>{ye.getState().loadDocument(M,M);},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsx("button",{type:"button",onClick:()=>F(!D),className:`p-1.5 rounded-lg transition-all ${D?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsx(ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsx("a",{href:`${_e}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsx(ChevronRight,{className:"w-4 h-4"})}),jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:I}),jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${ue}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ae}`}),te]})]}),jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[he(false),V&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsxs(Fragment,{children:[jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>{ye.getState().loadDocument(M,M);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),k&&P!=="saving"&&P!=="retrying"&&P!=="success"&&jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let _=y-k,xe=Math.floor(_/6e4),Be=Math.floor(_/1e3);return xe>=1?`${xe}m ago`:Be>=5?`${Be}s ago`:"just now"})()]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",J]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",Z]})]})]}),jsxs("div",{className:"flex items-center gap-6",children:[jsx("div",{className:"flex items-center gap-1 bg-[var(--kyro-bg-secondary)] p-1 rounded-xl border border-[var(--kyro-border)]",children:["edit","version","api"].map(_=>jsx("button",{type:"button",onClick:()=>w(_),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${b===_?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:_.toUpperCase()},_))}),jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("button",{type:"button",onClick:()=>F(!D),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${D?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:m("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsx(ExternalLink,{className:"w-4 h-4"}),D&&jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),U(),K(),jsx(Ho,{status:r,saveStatus:a,hasChanges:V,onPublish:c,disabled:a==="saving"})]})]})]})]})}function ju({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=H(),{showPreview:n,sidebarCollapsed:i,formData:s,previewUrl:l}=ye();if(t==="single")return jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(u=>o(u))})});let c=e.fields.some(u=>u.admin?.position==="sidebar")&&!n;return jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${n?"grid-cols-1 lg:grid-cols-2":i||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(u=>!u.admin?.position||u.admin.position==="main").map(u=>o(u))})}),n?jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxs("div",{className:"w-full h-full rounded-3xl border border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] shadow-2xl overflow-hidden relative group",children:[jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsx("iframe",{src:l||"",className:"w-full h-full border-none",title:a("tooltips.livePreview",{defaultValue:"Live Preview"})}),jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):i?null:jsx("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:e.fields.some(u=>u.admin?.position==="sidebar")&&jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(u=>u.admin?.position==="sidebar").map(u=>o(u))]})})]})}function Uu({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:i,compareDiffs:s,setCompareDiffs:l,loadingDiffs:d,loadingVersions:c,versions:u}=ye();return jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxs("div",{className:"px-4 md:px-6 py-3 md:py-4 border-b border-[var(--kyro-border)] flex flex-col md:flex-row md:items-center justify-between gap-2",children:[jsxs("div",{children:[jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${u.length} snapshot${u.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsx("button",{type:"button",onClick:t,disabled:d,className:"kyro-btn kyro-btn-primary px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider hover:opacity-90 disabled:opacity-50",children:d?"Comparing...":"Compare"}),jsx("button",{type:"button",onClick:()=>{a(!o),i([]),l([]);},className:`px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider transition-all ${o?"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]":"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:o?"Done":"Compare"})]})]}),s.length>0&&jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[s.length," change",s.length!==1?"s":""]}),jsx("button",{type:"button",onClick:()=>l([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"max-h-[400px] overflow-y-auto",children:s.map((p,f)=>jsxs("div",{className:"flex flex-col md:grid md:grid-cols-4 gap-1 md:gap-3 px-4 md:px-6 py-2.5 text-[11px] font-mono border-t border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)]",children:[jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:p.field}),jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof p.oldValue=="object"?JSON.stringify(p.oldValue):String(p.oldValue??"null")}),jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof p.newValue=="object"?JSON.stringify(p.newValue):String(p.newValue??"null")]})]},f))})]}),c?jsx("div",{className:"flex justify-center py-16",children:jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):u.length===0?jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:u.map((p,f)=>{let m=n.includes(p.id),y=(p.changeDescription||"").toLowerCase().includes("auto");return jsxs("div",{onClick:o?()=>r(p.id):void 0,className:`transition-all ${o?m?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsx("div",{className:`w-4 h-4 rounded-full border ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:m&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-f})}),jsxs("div",{className:"col-span-4 min-w-0",children:[jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[p.changeDescription||"Snapshot",y&&jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider",children:"Auto"})]}),jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsx("div",{className:"col-span-3",children:p.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${p.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]})}),jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:p.createdBy||"system"}),jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsx("button",{type:"button",onClick:()=>e(p.id),className:"px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[11px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})})]}),jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsx("div",{className:"pt-0.5 shrink-0",children:o?jsx("div",{className:`w-4 h-4 rounded-full border ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:m&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:u.length-f})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[p.changeDescription||"Snapshot",y&&jsx("span",{className:"text-[9px] px-1 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider shrink-0",children:"Auto"})]}),jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),p.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${p.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1 h-1 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:p.createdBy||"system"})]})]}),!o&&jsx("button",{type:"button",onClick:()=>e(p.id),className:"shrink-0 px-2.5 py-1 rounded-lg border border-[var(--kyro-border)] text-[10px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})]})]},p.id)})})]})})}function zu({collectionSlug:e,globalSlug:t}){let{t:r}=H(),{formData:o}=ye();return jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(o,null,2)})})]}),jsx("div",{className:"space-y-6",children:jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsx("div",{className:"bg-[var(--kyro-bg-secondary)] px-4 py-3 rounded-md border border-[var(--kyro-border)] text-[11px] font-mono break-all selection:bg-[var(--kyro-primary)]/20 text-[var(--kyro-text-primary)]",children:t?`kyro.globals('${t}').get()`:o.id?`kyro.collection('${e}').get('${o.id}')`:"Not saved yet"})]}),!!o.id&&jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:String(o.id)}),jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(o.id));},className:"p-1.5 hover:bg-[var(--kyro-bg-secondary)] rounded-lg transition-colors text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]",title:r("tooltips.copyId",{defaultValue:"Copy ID"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:t})]})]})]})})]})})}var _s=class extends Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=ye.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{j.success("Crash details copied to clipboard");});};handleReload=()=>{window.dispatchEvent(new Event("kyro:soft-reload"));};render(){return this.state.hasError?jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsx(TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsx(Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function Hu(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>{if(r&&typeof r=="object"&&o in r)return r[o]},e)}function Nl(e,t,r){if(!e)return true;if("and"in e&&Array.isArray(e.and))return e.and.every(o=>Nl(o,t,r));if("or"in e&&Array.isArray(e.or))return e.or.some(o=>Nl(o,t,r));if("field"in e&&e.field){let o=e.field,a=Hu(t,o);return a===void 0&&(a=Hu(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e&&e.greaterThan!==void 0?typeof a=="number"&&a>e.greaterThan:!!a}return true}var _u={};function xn({config:e,data:t=_u,errors:r=_u,onChange:o,disabled:a,collectionSlug:n,globalSlug:i,documentId:s,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:p}){let f=e||(i?yc[i]:n?la[n]:null),[m,y]=useState(f);useEffect(()=>{i&&!f?Me("/api/kyro/schema").then(B=>{let ee=B;ee?.globals?.[i]&&y(ee.globals[i]);}).catch(B=>console.error("[AutoForm] Failed to fetch dynamic schema",B)):y(f);},[i,f]);let v=m||f,{confirm:x}=vt(),{formData:h,hasUnsavedChanges:N,autoSaveStatus:k,lastSavedAt:g,view:z,setView:I,setShowPreview:ue,isMenuOpen:he,setIsMenuOpen:U,loadingFields:K,setLoadingFields:_,compareSelected:we,setCompareSelected:C,setCompareDiffs:Ne,setLoadingDiffs:Ve,setField:Fe,setFormData:mt,setLastSavedData:oe,setAutoSaveStatus:O,fetchVersions:X,saveDocument:de,forceSave:Ie,autoSaveSkipRef:ze,lastAutoSaveTimeRef:Tt,documentStatus:gr,hasUnpublishedChanges:Or,versionsEnabled:$}=wc({config:v,initialData:t,collectionSlug:n,globalSlug:i,documentId:s,onChange:o,onActionSuccess:c,onActionError:u}),ne=useRef(null),pe=useRef(null),[Ht,Wo]=useState(false),[Zs,T]=useState("idle"),[ve,je]=useState(false),[nr,Ot]=useState(Date.now()),Sr=a,[ei,qo]=useState(false),[Lp,ti]=useState(false),[Ep,Bp]=useState(0),Rl=useRef(new Map),Mp=3e4;useEffect(()=>{let B=i?`global:${i}`:`${n}:${s}`;if(!(i||n&&s&&s!=="new")||t&&Object.keys(t).length>0)return;let Ae=Rl.current.get(B),Ge=Ae&&Date.now()-Ae.ts<Mp,Ct=Ae&&!Ge;if(Ge){ye.getState().loadDocument(Ae.data,Ae.data);return}Ct&&ye.getState().loadDocument(Ae.data,Ae.data);let St=new AbortController;ti(false),Ae||qo(true);let Vr=i?`/api/globals/${i}`:`/api/${n}/${s}`;return Me(Vr,{autoToast:false,signal:St.signal}).then(bt=>{let Ao=bt.data||{};Rl.current.set(B,{data:Ao,ts:Date.now()}),ye.getState().loadDocument(Ao,Ao),qo(false);}).catch(bt=>{bt.name!=="AbortError"&&(qo(false),Ae||ti(true));}),()=>St.abort()},[n,s,i,t,Ep]),useEffect(()=>{let B=setInterval(()=>Ot(Date.now()),1e4);return ()=>clearInterval(B)},[]);let Fl=(B,ee)=>{if(typeof B=="function")try{return B(h,ee)}catch(Ae){return console.warn("Error evaluating admin runtime flag:",Ae),false}return !!B},$p=B=>{x({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let ee=i?Ye(`/api/globals/${i}/versions/${B}/restore`):Ye(`/api/${n}/${h.id}/versions/${B}/restore`),Ae=await ct(ee,{method:"POST"});!Ae.ok&&n&&(Ae=await ct(Ye(`/api/${n}/${h.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:B,action:"restore"})}));let Ge=await Ae.json();if(Ge.data){let{updatedAt:Ct,createdAt:St,...Vr}=Ge.data,bt={...h,...Vr};mt(bt),ye.getState().loadDocument(bt,bt),c?.("Version restored successfully"),X(),I("edit");}else j.error(Ge.error||"Failed to restore version");}catch(ee){console.error("Failed to restore version:",ee),j.error("Failed to restore version");}}});},Op=async()=>{if(we.length===2){Ve(true);try{let ee=await(await ct(Ye(`/api/${n}/${h.id}/versions?compareA=${we[0]}&compareB=${we[1]}`))).json();Ne(ee.diffs||[]);}catch(B){console.error("Compare failed:",B),Ne([]);}finally{Ve(false);}}},Vp=B=>{C(ee=>ee.includes(B)?ee.filter(Ae=>Ae!==B):ee.length>=2?[ee[1],B]:[...ee,B]);};useEffect(()=>{let B=ee=>{(ee.metaKey||ee.ctrlKey)&&ee.key==="s"&&(ee.preventDefault(),wn()),(ee.metaKey||ee.ctrlKey)&&ee.shiftKey&&(ee.key==="P"||ee.key==="p")&&(ee.preventDefault(),document.getElementById("btn-publish")?.click()),(ee.metaKey||ee.ctrlKey)&&!ee.shiftKey&&ee.key==="p"&&(ee.preventDefault(),ue(Ae=>!Ae)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(ee.key==="1"&&I("edit"),ee.key==="2"&&I("version"),ee.key==="3"&&I("api"));};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]),useEffect(()=>{let B=()=>I("version");return window.addEventListener("kyro:show-version-history",B),()=>window.removeEventListener("kyro:show-version-history",B)},[]),useEffect(()=>{let B=ee=>{ne.current&&!ne.current.contains(ee.target)&&U(false);};if(he)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[he]),useEffect(()=>{let B=ee=>{pe.current&&!pe.current.contains(ee.target)&&Wo(false);};if(Ht)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[Ht]);let jp=()=>{N?x({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await wn(),await new Promise(B=>setTimeout(B,1e3)),Lt(`${_e}/${n}/new`);}}):Lt(`${_e}/${n}/new`);},Up=()=>{if(!h.id){j.error("Please save the document before duplicating.");return}let B=async()=>{try{je(!0);let ee=await ct(`/api/${n}/${h.id}/duplicate`,{method:"POST"});if(ee.ok){let Ae=await ee.json();c?.("Document duplicated successfully"),Ae.data?.id?Lt(`${_e}/${n}/${Ae.data.id}`):Lt(`${_e}/${n}`);}else {let Ae=await ee.json();j.error(Ae.error||"Failed to duplicate");}}catch{j.error("Failed to duplicate document");}finally{je(false);}};if(N){x({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await wn(),await B();}});return}x({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await B();}});},zp=()=>{x({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{ze.current=true;try{await Dt(`/api/${n}/${h.id}`),Lt(`${_e}/${n}`);}catch(B){j.error(B.message||"Failed to delete document");}finally{ze.current=false;}}});},Hp=()=>{x({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{ze.current=true;try{let B=await de({...h,status:"draft"},!1);if(B?.ok)c?.("Document unpublished successfully"),ye.getState().loadDocument({...h,status:"draft"},{...h,status:"draft"});else {let ee=await B?.json().catch(()=>({}));j.error(ee?.error||"Failed to unpublish");}}catch{j.error("Failed to unpublish");}finally{ze.current=false;}}});},wn=async()=>{let B=!h.id;ze.current=true,T("saving");try{let ee=qt({...h},!0),Ae=B&&!i,Ge=Ae?await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}):await de(ee);if(Ge.ok){let Ct=await Ge.json(),St=Ct.data||ee;ye.getState().loadDocument(St,St),Tt.current=Date.now(),O("success"),T("saved"),$&&X(),setTimeout(()=>{O("idle"),T("idle");},2e3),c?.(Ae?"Document created successfully":"Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload")),Ae&&setTimeout(()=>{Lt(`${_e}/${n}/${Ct.data.id}`);},800);}else {let Ct=await Ge.json();Ge.status===409&&O("conflict"),T("error"),j.error(Ct.error||"Failed to save"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),j.error("Failed to save document"),setTimeout(()=>T("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),ze.current=false;}},_p=async()=>{let B=!h.id;ze.current=true,T("saving");try{let ee={...h};if(B&&!i){let Ct=qt({...h},!0),St=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ct)});if(!St.ok){let Ao=await St.json().catch(()=>({}));St.status===409&&O("conflict"),T("error"),j.error(Ao.error||"Failed to create document"),setTimeout(()=>T("idle"),3e3);return}let bt=(await St.json()).data||Ct;ye.getState().loadDocument(bt,bt),ee=bt;}let Ae=qt(ee,!0),Ge=await de(Ae,!1);if(Ge?.ok){let St=(await Ge.json().catch(()=>({}))).data||Ae;ye.getState().loadDocument(St,St),T("saved"),c?.("Published successfully"),setTimeout(()=>{T("idle");},2e3),B&&!i&&ee.id&&setTimeout(()=>{Lt(`${_e}/${n}/${ee.id}`);},800);}else {if(B&&!i&&ee.id){let St=await Ge?.json().catch(()=>({}));j.warning("Document saved as draft. Publishing failed: "+(St?.error||"Unknown error")),setTimeout(()=>{Lt(`${_e}/${n}/${ee.id}`);},1200);return}let Ct=await Ge?.json().catch(()=>({}));Ge?.status===409&&O("conflict"),T("error"),j.error(Ct?.error||"Failed to publish"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),j.error("Failed to publish"),setTimeout(()=>T("idle"),3e3);}finally{ze.current=false;}},Kp=async B=>{let ee=!h.id;ze.current=true;try{let Ae={...qt({...h},!0),_schedulePublishAt:B};if(ee&&!i){let Ge=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ae)});if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));j.error(Ct.error||"Failed to schedule publish");return}}else {let Ge=await de(Ae);if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));j.error(Ct.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(B).toLocaleString()}`),Wo(!1);}catch{j.error("Failed to schedule publish");}finally{ze.current=false;}},Gp=(B,ee)=>{Fe(B,ee);},Oa=(B,ee,Ae)=>{let Ge=ee!==void 0?ee:h;if(Fl(B.hidden!==void 0?B.hidden:B.admin?.hidden,Ge))return null;let St=Fl(B.readOnly!==void 0?B.readOnly:B.admin?.readOnly,Ge),Vr=!!(Sr||St);if(B.admin?.condition){if(typeof B.admin.condition=="function")try{let dt={values:h||{},...h||{}};if(!B.admin.condition(dt,Ge))return null}catch(dt){console.warn(`Condition error for field ${B.name}:`,dt);}else if(typeof B.admin.condition=="object")try{if(!Nl(B.admin.condition,Ge,h))return null}catch(dt){console.warn(`Declarative condition error for field ${B.name}:`,dt);}}let bt=Ge[B.name],Ao=r[B.name],Nn=dt=>{Ae?Ae({...Ge,[B.name]:dt}):Gp(B.name,dt);};if(B.type==="row"&&"fields"in B){let dt=B.fields;return jsx("div",{className:"kyro-form-row flex flex-col md:flex-row gap-4 md:gap-6 items-start md:items-end w-full",children:dt?.map(nt=>{let jr=nt.admin||{},Cn=jr?.action;if((nt.type==="button"||nt.type==="action")&&Cn){let Ar=dt?.find(Va=>Va.type==="email");return jsx("div",{className:"flex-shrink-0",children:jsx("button",{type:"button",onClick:async()=>{let Va=B.name,Sn=Ar?.name,An=Sn?h[Sn]:void 0;if(!An&&Va&&typeof Va=="string"&&Sn&&(An=h[Va]?.[Sn]),!!An){_(Tr=>({...Tr,[nt.name]:true}));try{let Tr=await ct(Ye(Cn),{method:jr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:An})}),ja={};try{ja=await Tr.json();}catch{ja={};}if(Tr.ok&&ja.success)c?.(ja.message||"Action completed successfully");else {let Wp=ja.error||`Request failed (${Tr.status})`;u?.(Wp);}}catch(Tr){u?.(Tr instanceof Error?Tr.message:"Error connecting to server");}finally{_(Tr=>({...Tr,[nt.name]:false}));}}},disabled:K[nt.name]||Vr,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:K[nt.name]?"Sending...":nt.label||"Click"})},nt.name)}return jsx("div",{className:nt.type==="button"||nt.type==="action"?"flex-shrink-0":"flex-1",style:jr?.width?{width:jr.width,flex:"none"}:{},children:Oa(nt,ee,Ae)},nt.name)})},B.name||`row-${Math.random()}`)}switch(B.type){case "tabs":return jsx(Eu,{field:B,formData:h,onTabDataChange:dt=>{Fe(B.name,dt);},renderField:(dt,nt,jr)=>Oa(dt,nt,jr)},B.name||`tabs-${Math.random()}`);case "group":return jsx($s,{field:B,value:bt,onChange:Nn,renderField:Oa},B.name);case "array":return jsx(Os,{field:B,value:bt,onChange:Nn,renderField:Oa,disabled:Vr},B.name);case "button":case "action":{let dt=B.name,nt=K[dt];return jsx("div",{className:"kyro-form-field",children:jsxs("button",{type:"button",disabled:nt||Vr,onClick:async()=>{let jr=B.admin?.action||B.action,Cn=B.admin?.method||B.method||"POST";if(jr){_(Ar=>({...Ar,[dt]:true}));try{let Ar=await ct(jr,{method:Cn,headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});await Ar.json(),Ar.ok;}catch(Ar){console.error("Error executing action:",Ar);}finally{_(Ar=>({...Ar,[dt]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${nt?"opacity-70 cursor-not-allowed":""}`,children:[nt&&jsxs("svg",{className:"animate-spin h-3 w-3 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),nt?"Processing...":B.label||"Click"]})},dt)}case "relationship-block":return jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[B.label||B.name,B.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx(Za,{relationTo:B.relationTo,hasMany:B.hasMany,selectedIds:Array.isArray(bt)?bt:bt?[bt]:[],onChange:(dt,nt)=>{Nn(nt);},compact:true}),B.admin?.description?jsx("p",{className:"kyro-form-help",children:String(B.admin?.description)}):null]},B.name);default:return jsx(jo,{field:B,value:bt,onChange:Nn,error:Ao,disabled:Vr,formData:h,siblingData:Ge,collectionSlug:n,globalSlug:i},B.name||Math.random().toString())}};return ei||!v?jsxs("div",{className:"space-y-6 p-4",children:[jsxs("div",{className:"space-y-2",children:[jsx(Wt,{variant:"text",className:"w-1/3"}),jsx(Wt,{variant:"text",className:"w-2/3"})]}),jsx("div",{className:"space-y-4",children:jsx(Wt,{variant:"rect",count:4})})]}):Lp?jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsx(TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsx("button",{type:"button",onClick:()=>{ti(false),qo(true),Bp(B=>B+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsx(Vu,{collectionSlug:n,globalSlug:i,documentStatus:gr||"draft",hasUnpublishedChanges:Or,localSaveStatus:Zs,isDuplicating:ve,handleCreateNew:jp,handleDuplicate:Up,handleUnpublish:Hp,handleDelete:zp,handlePublish:_p,handleSaveDraft:wn,handleSchedulePublish:Kp,handleConflictOverride:()=>Ie()}),d==="single"&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsx(Check,{className:"w-4 h-4"}),g?`Saved ${Math.floor((Date.now()-g)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),N&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!N&&k!=="success"&&k!=="saving"&&k!=="error"&&jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:h.updatedAt?`Modified ${new Date(h.updatedAt).toLocaleString()}`:""})]}),jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{ze.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let B=await de(h);if(B.ok){let Ae=(await B.json()).data||h;mt({...h,...Ae}),oe({...h,...Ae}),c?.("Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(B){console.error("Save error exception:",B),u?.("Save failed: "+B.message);}finally{ze.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxs(_s,{children:[z==="edit"&&jsx(ju,{config:v,layout:d,collectionSlug:n,renderField:Oa}),z==="version"&&jsx(Uu,{handleRestoreVersion:$p,handleCompareVersions:Op,toggleCompareSelection:Vp}),z==="api"&&jsx(zu,{collectionSlug:n,globalSlug:i})]})})]})}var Ku={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Cl({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:i,onViewHistory:s,onPreview:l,onDelete:d,onBack:c,onToggleSidebar:u,publishedAt:p,updatedAt:f,onCopyData:m,onPasteData:y}){let{t:v}=H(),x=ye(w=>w.view)||"edit",h=ye(w=>w.setView),[S,N]=useState(false),V=useRef(null);useEffect(()=>{let w=D=>{V.current&&!V.current.contains(D.target)&&N(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);let P=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,k=["edit","version","api"],g=P(),b="p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] transition-all shrink-0";return jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-[var(--kyro-surface)] border-b border-[var(--kyro-border)] w-full overflow-x-auto",children:[c&&jsx("button",{type:"button",onClick:c,className:"p-1 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all shrink-0",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Ku[e]||"bg-[var(--kyro-text-muted)]"}`}),g&&jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsx(lr,{size:"sm",className:"inline mr-0.5"}),g]}),jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)] shrink-0 max-md:hidden",children:k.map(w=>jsx("button",{type:"button",onClick:()=>h(w),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${x===w?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:w==="edit"?"Edit":w==="version"?"Ver":"API"},w))}),jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsx("button",{type:"button",onClick:l,className:`${b} max-md:hidden`,title:v("tooltips.preview",{defaultValue:"Preview"}),children:jsx(Eye,{className:"w-3.5 h-3.5"})}),s&&jsx("button",{type:"button",onClick:s,className:`${b} max-md:hidden`,title:v("tooltips.viewHistory",{defaultValue:"View History"}),children:jsx(Clock,{className:"w-3.5 h-3.5"})}),i&&jsx("button",{type:"button",onClick:i,className:`${b} max-md:hidden`,title:v("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),m&&jsx("button",{type:"button",onClick:m,className:`${b} max-md:hidden`,title:v("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),y&&jsx("button",{type:"button",onClick:y,className:`${b} max-md:hidden`,title:v("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsx("button",{type:"button",onClick:d,className:`${b} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:v("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})}),u&&jsx("button",{type:"button",onClick:u,className:`${b} max-md:hidden`,title:v("tooltips.toggleSidebar",{defaultValue:"Toggle Sidebar"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxs("div",{ref:V,className:"relative md:hidden",children:[jsx("button",{type:"button",onClick:()=>N(!S),className:b,title:v("tooltips.more",{defaultValue:"More"}),children:jsx(EllipsisVertical,{className:"w-3.5 h-3.5"})}),S&&jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-1 max-h-[70vh] overflow-y-auto",children:[g&&jsxs("div",{className:"px-3 py-2 text-[10px] text-[var(--kyro-text-muted)] border-b border-[var(--kyro-border)] flex items-center gap-1.5",children:[jsx("div",{className:`w-1.5 h-1.5 rounded-full ${Ku[e]}`}),jsx("span",{className:"capitalize",children:e}),jsx("span",{children:"\xB7"}),t==="saving"&&jsx(lr,{size:"sm",className:"inline"}),jsx("span",{children:g})]}),jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:k.map(w=>jsx("button",{type:"button",onClick:()=>{h(w),N(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${x===w?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:w==="edit"?"Edit":w==="version"?"Ver":"API"},w))}),s&&jsxs("button",{type:"button",onClick:()=>{s(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Clock,{className:"w-3.5 h-3.5"})," View History"]}),i&&jsxs("button",{type:"button",onClick:()=>{i(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),m&&jsxs("button",{type:"button",onClick:()=>{m(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),y&&jsxs("button",{type:"button",onClick:()=>{y(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),l&&jsxs("button",{type:"button",onClick:()=>{l(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxs("button",{type:"button",onClick:()=>{d(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsx(Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsx(Send,{className:"w-3.5 h-3.5"}),jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsx(Undo,{className:"w-3.5 h-3.5"}),jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxs(Ho,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[i&&jsx(Ft,{icon:jsx(Copy,{className:"w-4 h-4"}),onClick:i,children:"Duplicate"}),m&&jsx(Ft,{icon:jsx(ClipboardCopy,{className:"w-4 h-4"}),onClick:m,children:"Copy Data"}),y&&jsx(Ft,{icon:jsx(ClipboardPaste,{className:"w-4 h-4"}),onClick:y,children:"Paste Data"}),s&&jsx(Ft,{icon:jsx(Clock,{className:"w-4 h-4"}),onClick:s,children:"View History"}),l&&jsx(Ft,{icon:jsx(Eye,{className:"w-4 h-4"}),onClick:l,children:"Preview"}),(i||m||y||s||l)&&jsx(hn,{}),d&&jsx(Ft,{onClick:d,danger:true,icon:jsx(Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Sl({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:i,onError:s,mode:l="collection"}){let{t:d}=H(),{confirm:c,alert:u}=vt(),[p,f]=useState({}),[m,y]=useState({}),[v,x]=useState(true),[h,S]=useState(false),[N,V]=useState(false),[P,k]=useState(false),[g,b]=useState("idle"),[w,D]=useState("draft"),[F,E]=useState(null),[R,M]=useState(null),[z,I]=useState(null),[J,Z]=useState(false),te=ye(O=>O.showPreview),Y=ye(O=>O.setShowPreview),ae=ye(O=>O.previewUrl),ue=ye(O=>O.setPreviewUrl),he=r?.fields||t?.fields||[],U=r?.label||t?.label||"Document",K=r?.slug||t?.slug||"",_=JSON.stringify(p)!==JSON.stringify(m);useEffect(()=>{_&&w==="published"&&D("draft");},[_,w]),useEffect(()=>{_&&g==="saved"&&b("idle");},[_,g]),useEffect(()=>{l==="global"?Be():o&&xe();},[o,l,K]);let xe=async()=>{try{x(!0);let O=await Me(`/api/${K}/${o}`,{autoToast:!1}),X=O.data||{};f(X),y(X),D(X?.status||O.status||"draft"),E(O.createdAt||X.createdAt||null),M(O.updatedAt||X.updatedAt||null),I(O.publishedAt||X.publishedAt||null);}catch{s("Failed to load document");}finally{x(false);}},Be=async()=>{try{x(!0);let O=await Me(`/api/globals/${K}`,{autoToast:!1}),X=O.data||{};f(X),y(X),E(O.createdAt||null),M(O.updatedAt||null);}catch{s("Failed to load global");}finally{x(false);}},we=useCallback(async(O=false)=>{try{b("saving");let X=l==="global"?`/api/globals/${K}`:`/api/${K}/${o}`,de=w==="draft"||p?.status==="draft",Ie=await er(X,p,{autoToast:!1,headers:{"X-Draft":String(de)}}),ze=Ie&&(Ie.data||Ie)||p;O||(y(ze),n()),f(ze),D(ze?.status||w),b("saved"),M(new Date().toISOString()),Z(!0),setTimeout(()=>Z(!1),3e3),O||(w==="draft"||ze?.status==="draft"?j.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):j.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{b("idle");},2e3),te&&mt(ze);}catch{b("error"),O||(s(d("toast.saveError",{defaultValue:"Failed to save changes"})),j.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{S(false);}},[p,l,K,o,w,n,s]),C=async()=>{try{S(!0),await er(`/api/${K}/${o}`,p,{autoToast:!1,headers:{"X-Draft":"false"}}),D("published"),I(new Date().toISOString()),j.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{s(d("toast.publishError",{defaultValue:"Failed to publish"})),j.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{S(false);}},G=async()=>{try{S(!0),await er(`/api/${K}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),D("draft"),j.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{s(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),j.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{S(false);}},Ne=async()=>{try{V(!0);let O=await ut(`/api/${K}/${o}/duplicate`,void 0,{autoToast:!1});j.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),O?.data?.id?Lt(`${_e}/${K}/${O.data.id}`):Lt(`${_e}/${K}`);}catch(O){j.error(O.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{V(false);}},Oe=async()=>{try{let O={...p};delete O.id,delete O.createdAt,delete O.updatedAt,delete O.status,await navigator.clipboard.writeText(JSON.stringify(O)),j.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{j.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},Ve=async()=>{try{let O=await navigator.clipboard.readText(),X=JSON.parse(O);if(typeof X!="object"||X===null)throw new Error("Invalid format");f(de=>({...de,...X,id:de.id,createdAt:de.createdAt,updatedAt:de.updatedAt,status:de.status})),j.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{j.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Fe=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:U}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{k(!0),await Dt(`/api/${K}/${o}`),Lt(`${_e}/${K}`);}catch{k(false);}}});},mt=async(O=p)=>{try{let X=l==="global"?`/api/globals/${K}/preview-url`:`/api/${K}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",X,"with data keys:",Object.keys(O||{}),"documentId:",o);let de=await ut(X,{...O,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(de)),de&&de.url?(console.log("[Kyro Preview] Setting previewUrl:",de.url),ue(de.url)):console.warn("[Kyro Preview] No url in response:",de);}catch(X){console.error("[Kyro Preview] Error:",X.message,X),j.error(X.message||"Failed to generate preview URL");}};useEffect(()=>{te&&mt(p);},[te]);let Cr=()=>{let O=!te;Y(O),O&&mt(p);};if(v)return jsx("div",{className:"kyro-detail",children:jsxs("div",{className:"space-y-6 p-4",children:[jsxs("div",{className:"space-y-2",children:[jsx(Wt,{variant:"text",className:"w-1/3"}),jsx(Wt,{variant:"text",className:"w-2/3"})]}),jsx("div",{className:"space-y-4",children:jsx(Wt,{variant:"rect",count:4})})]})});let oe=l==="global"||t?.admin?.layout==="single";return jsxs("div",{className:"kyro-detail",children:[jsx(jt,{back:{onClick:a},breadcrumbs:[{label:l==="global"?d("detailView.globals",{defaultValue:"Globals"}):d("detailView.collections",{defaultValue:"Collections"})},{label:U,href:l==="collection"?`${_e}/${K}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?U:Io(t?.fields,p,t?.admin?.useAsTitle||"title")||p.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||U}),metadata:[jsx(Et,{variant:w==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${w}`,{defaultValue:w})},"status")]}),jsx(Cl,{status:w,saveStatus:g,hasChanges:_,onSave:()=>we(false),onPublish:C,onUnpublish:w==="published"?G:void 0,onDuplicate:Ne,onCopyData:Oe,onPasteData:Ve,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:Cr,onDelete:Fe,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:z,updatedAt:R}),jsxs("div",{className:te?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":oe?"w-full pt-4 md:pt-8":"w-full mx-auto grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-4 md:gap-8 pt-4 md:pt-0",children:[jsx("div",{className:`space-y-4 md:space-y-8 min-w-0 ${te?"overflow-y-auto pr-2 pb-20":""}`,children:jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:d("detailView.coreConfiguration",{defaultValue:"Core Configuration"})}),jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsx(xn,{config:t?{...t,fields:he}:{slug:"unknown",fields:he},data:p,onChange:f,layout:oe?"single":"split",globalSlug:l==="global"?K:void 0,collectionSlug:l==="collection"?K:void 0,onActionSuccess:O=>j.success(O),onActionError:O=>j.error(O),documentStatus:w,justSaved:J}),oe&&jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[l==="collection"&&o&&jsx("button",{type:"button",onClick:Fe,disabled:P||h,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:P?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsx(Ho,{status:w,saveStatus:h?"saving":"idle",hasChanges:_,onPublish:()=>we(false),disabled:h})]})]})}),te&&jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:ae||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsx("div",{className:"w-16"})]}),jsx("div",{className:"flex-1 bg-white relative",children:ae?jsx("iframe",{src:ae,className:"w-full h-full border-0 bg-white",title:d("tooltips.preview",{defaultValue:"Preview"}),sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsx(lr,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!oe&&!te&&jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:d("detailView.metadata",{defaultValue:"Metadata"})}),jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dynamicStatus",{defaultValue:"Dynamic Status"})}),jsx("div",{children:jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${w==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:w||"draft"})})]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dateCreated",{defaultValue:"Date Created"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:F?new Date(F).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("common.na",{defaultValue:"N/A"})})]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.lastModified",{defaultValue:"Last Modified"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:R?new Date(R).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("detailView.justNow",{defaultValue:"Just now"})})]}),z&&jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.publicAt",{defaultValue:"Public At"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(z).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:d("detailView.quickLinks",{defaultValue:"Quick Links"})}),jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsx("button",{type:"button",onClick:Ne,disabled:N||h,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:N?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),ae&&jsx("button",{type:"button",onClick:()=>window.open(ae,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:d("detailView.openPreview",{defaultValue:"Open Preview in New Tab"})}),jsx("button",{type:"button",onClick:Fe,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:d("actions.deleteEntry",{defaultValue:"Delete Entry"})})]})]})]})]})]})}function Al({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,i]=useState({}),[s,l]=useState(false),d=t.fields||[],c=t.label||t.slug,u=async p=>{try{l(!0),await ut(`/api/${t.slug}`,n),j.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(f){a(f instanceof Error?f.message:"Failed to create");}finally{l(false);}};return jsxs("div",{className:"kyro-detail",children:[jsx(jt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${_e}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:s?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>u(),disabled:s}}),jsx("div",{className:"kyro-detail-body",children:jsx("div",{className:"kyro-card",children:jsx("div",{className:"kyro-card-content",children:jsx("form",{children:jsx(xn,{config:{...t,fields:d},data:n,onChange:i})})})})})]})}function Gs(){let e=Zt(r=>r.toasts),t=Zt(r=>r.removeToast);return jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsx("div",{style:{pointerEvents:"auto"},children:jsx(Fc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Dl({onAuth:e,theme:t="light"}){let{t:r}=H(),[o,a]=useState("login"),[n,i]=useState(""),[s,l]=useState(""),[d,c]=useState(""),[u,p]=useState(false),[f,m]=useState(false),y=Zt(h=>h.addToast);useEffect(()=>{v();},[]);let v=async()=>{try{await Me("/api/users");}catch{m(true),a("register");}},x=async h=>{h.preventDefault(),p(true);try{let S=o==="login"?"/api/auth/login":"/api/auth/register",N={email:n,password:s};o==="register"&&(N.confirmPassword=d);let V=await ut(S,N);V.isFirstUser&&m(!0),localStorage.setItem("kyro_user",JSON.stringify(V.user)),y("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e(V.token,V.user);}catch{y("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{p(false);}};return jsx(Lr,{defaultMode:t,children:jsxs("div",{className:"kyro-login-page",children:[jsxs("div",{className:"kyro-login-container",children:[jsxs("div",{className:"kyro-login-header",children:[jsx("h1",{className:"kyro-login-title",children:f?r("login.createAdminAccount",{defaultValue:"Create Admin Account"}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})}),jsx("p",{className:"kyro-login-subtitle",children:f?r("login.setupAdmin",{defaultValue:"Set up your admin account to get started"}):o==="login"?r("login.enterCredentials",{defaultValue:"Enter your credentials to access the admin"}):r("login.createAccountDesc",{defaultValue:"Create an account to access the admin"})})]}),jsxs("form",{onSubmit:x,className:"kyro-login-form",children:[jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"email",children:r("login.email",{defaultValue:"Email"})}),jsx("input",{id:"email",type:"email",value:n,onChange:h=>i(h.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"password",children:r("login.password",{defaultValue:"Password"})}),jsx("input",{id:"password",type:"password",value:s,onChange:h=>l(h.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:o==="login"?"current-password":"new-password"})]}),o==="register"&&jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"confirmPassword",children:r("login.confirmPassword",{defaultValue:"Confirm Password"})}),jsx("input",{id:"confirmPassword",type:"password",value:d,onChange:h=>c(h.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:u,children:u?o==="login"?r("login.signingIn",{defaultValue:"Signing in..."}):r("login.creatingAccount",{defaultValue:"Creating account..."}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})})]}),!f&&jsx("div",{className:"kyro-login-footer",children:jsx("p",{children:o==="login"?jsxs(Fragment,{children:[r("login.noAccount",{defaultValue:"Don't have an account?"})," ",jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("register"),children:r("login.signUp",{defaultValue:"Sign up"})})]}):jsxs(Fragment,{children:[r("login.hasAccount",{defaultValue:"Already have an account?"})," ",jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("login"),children:r("login.signInAction",{defaultValue:"Sign in"})})]})})})]}),jsx(Gs,{})]})})}function Ju({collections:e,onNavigate:t,user:r}){let{t:o}=H(),{permissions:a}=Zr(),[n,i]=useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=useState(true);useEffect(()=>{let c=setTimeout(()=>{i({totalDocs:124,totalMedia:856,totalUsers:12,recentActivity:[{id:1,type:"edit",user:"Daniel Dozie",doc:"Getting Started with Kyro",collection:"posts",time:"2m ago"},{id:2,type:"create",user:"Jane Smith",doc:"New Product Launch",collection:"products",time:"15m ago"},{id:3,type:"upload",user:"Daniel Dozie",doc:"hero-banner.jpg",collection:"media",time:"1h ago"},{id:4,type:"publish",user:"System",doc:"Weekly Update",collection:"posts",time:"3h ago"}]}),l(false);},800);return ()=>clearTimeout(c)},[]);let d=Object.entries(e).filter(([c])=>!Li.includes(c)&&a?.collections?.[c]?.read!==false);return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsx(jt,{title:o("dashboard.welcome",{defaultValue:"Welcome back, {{name}}",name:r?.email?.split("@")[0]||"Admin"}),description:o("dashboard.description",{defaultValue:"Everything looks great in your command center today."}),action:d.length>0&&a?.collections?.[d[0]?.[0]]?.create!==false?{label:o("actions.newDocument",{defaultValue:"New Document"}),onClick:()=>t("create",d[0]?.[0]),icon:Plus}:void 0}),jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:o("dashboard.totalContent",{defaultValue:"Total Content"}),value:n.totalDocs,icon:FileText,color:"text-blue-500"},{label:o("dashboard.mediaAssets",{defaultValue:"Media Assets"}),value:n.totalMedia,icon:Image,color:"text-purple-500"},{label:o("dashboard.activeUsers",{defaultValue:"Active Users"}),value:n.totalUsers,icon:Users,color:"text-green-500"},{label:o("dashboard.systemHealth",{defaultValue:"System Health"}),value:"100%",icon:Activity,color:"text-amber-500"}].map((c,u)=>jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxs("div",{children:[jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsx(Wt,{variant:"text",className:"w-16"}):c.value})]}),jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsx(c.icon,{className:"w-6 h-6"})})]},u))}),jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxs("div",{className:"space-y-8 min-w-0",children:[jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsx(LayoutDashboard,{className:"w-5 h-5 opacity-40"}),o("dashboard.contentGrowth",{defaultValue:"Content Growth"})]}),jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:o("dashboard.contentGrowthDesc",{defaultValue:"Snapshot of document velocity over the last 7 days"})}),jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsx("defs",{children:jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60 L1000,200 L0,200 Z",fill:"url(#chartGradient)",className:"animate-pulse duration-[4s]"}),jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60",fill:"none",stroke:"var(--kyro-primary)",strokeWidth:"4",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:"filter drop-shadow-[0_0_8px_var(--kyro-primary)]"})]}),jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsx("span",{children:o("days.mon",{defaultValue:"Mon"})}),jsx("span",{children:o("days.tue",{defaultValue:"Tue"})}),jsx("span",{children:o("days.wed",{defaultValue:"Wed"})}),jsx("span",{children:o("days.thu",{defaultValue:"Thu"})}),jsx("span",{children:o("days.fri",{defaultValue:"Fri"})}),jsx("span",{children:o("days.sat",{defaultValue:"Sat"})}),jsx("span",{children:o("days.sun",{defaultValue:"Sun"})})]})]}),jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:d.map(([c,u])=>jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:u.label||c}),jsx(ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:u.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsx("div",{className:"flex items-center justify-between mb-4",children:jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsx(Plus,{className:"w-5 h-5"}),o("dashboard.quickLinks",{defaultValue:"Quick Links"})]})}),jsxs("div",{className:"space-y-3",children:[d.filter(([c])=>a?.collections?.[c]?.create!==false).map(([c])=>jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:o("dashboard.newAction",{defaultValue:"New {{item}}",item:e[c]?.singularLabel||e[c]?.label||c})}),jsx(Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),d.every(([c])=>a?.collections?.[c]?.create===false)&&jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:o("dashboard.noCollections",{defaultValue:"No collections available for creation."})})]})]}),jsxs("div",{className:"surface-tile p-8 bg-[#0f172a] text-white border-none shadow-2xl shadow-blue-500/10 overflow-hidden relative group cursor-pointer",children:[jsxs("div",{className:"relative z-10",children:[jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:o("dashboard.mediaLibrary",{defaultValue:"Media Library"})}),jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:o("dashboard.mediaLibraryDesc",{defaultValue:"Manage high-fidelity assets with our liquid masonry gallery."})}),jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:[o("dashboard.openAssets",{defaultValue:"Open Assets"})," ",jsx(ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsx(Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxs("div",{className:"space-y-6",children:[jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsx(Clock,{className:"w-5 h-5 opacity-40"}),o("dashboard.recentActivity",{defaultValue:"Recent Activity"})]}),jsx("div",{className:"space-y-6",children:n.recentActivity.map(c=>jsxs("div",{className:"flex gap-4 group",children:[jsx("div",{className:"mt-1",children:jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsx("span",{className:"opacity-60",children:c.collection})]}),jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:o("dashboard.viewAuditLogs",{defaultValue:"View Audit Logs"})})]}),jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsx(Activity,{className:"w-5 h-5 opacity-40"}),o("dashboard.systemStatus",{defaultValue:"System Status"})]}),jsx("div",{className:"space-y-4",children:[{label:o("dashboard.cloudApi",{defaultValue:"Cloud API"}),status:o("dashboard.statusOptimal",{defaultValue:"Optimal"}),pulse:"bg-green-500"},{label:o("dashboard.dbNode",{defaultValue:"Database Node"}),status:o("dashboard.statusHealthy",{defaultValue:"Healthy"}),pulse:"bg-green-500"},{label:o("dashboard.mediaCdn",{defaultValue:"Media CDN"}),status:o("dashboard.statusActive",{defaultValue:"Active"}),pulse:"bg-blue-500"},{label:o("dashboard.authService",{defaultValue:"Auth Service"}),status:o("dashboard.statusSecure",{defaultValue:"Secure"}),pulse:"bg-green-500"}].map((c,u)=>jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},u))})]})]})]})]})}function Yu(){let{t:e}=H(),[t,r]=useState([]),[o,a]=useState(true),[n,i]=useState(""),[s,l]=useState(false),[d,c]=useState({name:"",email:"",password:"",role:"customer"}),[u,p]=useState(""),[f,m]=useState(false),{confirm:y,alert:v}=vt();useEffect(()=>{x();},[]);let x=async()=>{try{a(!0);let k=await Me("/api/users");r(k.docs||[]);}catch(k){console.error("Failed to load users:",k);}finally{a(false);}},h=k=>{let g=!k.locked;y({title:g?"Lock User Account?":"Unlock User Account?",message:g?`Are you sure you want to lock ${k.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${k.email}?`,variant:g?"danger":"success",onConfirm:async()=>{try{await er(`/api/users/${k.id}`,{locked:g}),r(b=>b.map(w=>w.id===k.id?{...w,locked:g}:w)),j.success(g?`Account locked: ${k.email}`:`Account restored: ${k.email}`);}catch(b){console.error("Failed to toggle user lock:",b),j.error("Failed to update account status");}}});},S=k=>{y({title:"Destroy User Account",message:`You are about to permanently delete ${k.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Dt(`/api/users/${k.id}`),r(g=>g.filter(b=>b.id!==k.id)),j.success(`Identity purged: ${k.email}`);}catch(g){console.error("Failed to delete user:",g),j.error("Failed to delete user");}}});},N=async()=>{if(!d.email.trim()||!d.password.trim()){p("Email and password are required");return}m(true),p("");try{await ut("/api/users",{name:d.name.trim()||void 0,email:d.email.trim(),password:d.password,role:d.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),j.success("User created successfully"),x();}catch(k){let g=k instanceof Error?k.message:"Failed to create user";p(g),j.error(g);}finally{m(false);}},V=["super_admin","admin","editor","author","customer","guest"],P=t.filter(k=>k.email.toLowerCase().includes(n.toLowerCase())||k.name?.toLowerCase().includes(n.toLowerCase()));return jsxs("div",{className:"w-full space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700 px-4 md:px-8 pb-12",children:[jsx(jt,{title:e("tooltips.identityAccess",{defaultValue:"Identity & Access"}),description:"Manage the core administrative team and security permissions.",icon:Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),p(""),l(true);},icon:UserPlus}}),jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxs("div",{className:"relative flex-1 group",children:[jsx(Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsx("input",{type:"text",placeholder:e("fields.searchByIdentityOr",{defaultValue:"Search by identity or email..."}),value:n,onChange:k=>i(k.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]}),jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest bg-[var(--kyro-surface)] shadow-sm rounded-lg border border-[var(--kyro-border)]",children:"ALL"}),jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsx("div",{className:"surface-tile overflow-x-auto",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[9px] tracking-[0.2em] uppercase border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:o?Array.from({length:6}).map((k,g)=>jsx("tr",{className:"animate-pulse",children:jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},g)):P.length===0?jsx("tr",{children:jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):P.map(k=>jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${k.locked?"opacity-50 grayscale":""}`,children:[jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-3",children:[jsx(gv,{user:k}),jsxs("div",{className:"min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:k.name||k.email.split("@")[0]}),k.tenantId&&jsx(Et,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:k.tenantId})]}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:k.email})]})]})}),jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:k.role})]})}),jsx("td",{className:"px-6 py-3.5",children:jsx(Et,{variant:k.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:k.locked?"Restricted":"Authorized"})}),jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsx(Clock,{className:"w-3 h-3"}),k.lastLogin?new Date(k.lastLogin).toLocaleDateString():"Never"]})}),jsx("td",{className:"px-6 py-3.5 text-right",children:jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsx("button",{onClick:()=>h(k),className:`p-1.5 rounded-lg border transition-all ${k.locked?"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"}`,title:k.locked?"Restore Access":"Restrict Access",children:k.locked?jsx(LockOpen,{className:"w-3.5 h-3.5"}):jsx(Lock,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>S(k),className:"p-1.5 rounded-lg border border-red-500/20 bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all",title:e("tooltips.deleteUser",{defaultValue:"Delete User"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]})})]},k.id))})]})}),jsxs(At,{open:s,onClose:()=>l(false),title:e("tooltips.createUser",{defaultValue:"Create User"}),size:"lg",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsx("input",{type:"text",value:d.name,onChange:k=>c({...d,name:k.target.value}),placeholder:e("fields.johnDoe",{defaultValue:"John Doe"}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsx("input",{type:"email",value:d.email,onChange:k=>c({...d,email:k.target.value}),placeholder:"user@example.com",required:true,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsx("input",{type:"password",value:d.password,onChange:k=>c({...d,password:k.target.value}),placeholder:e("fields.minimum12Characters",{defaultValue:"Minimum 12 characters"}),required:true,minLength:12,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsx("select",{value:d.role,onChange:k=>c({...d,role:k.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]",children:V.map(k=>jsx("option",{value:k,children:k},k))})]}),u&&jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsx(TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxs(_r,{children:[jsx("button",{type:"button",onClick:()=>l(false),className:"px-6 py-2.5 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Cancel"}),jsx("button",{type:"button",onClick:N,disabled:f,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:f?"Creating...":"Create User"})]})]})]})}function gv({user:e}){let[t,r]=useState(null);return useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Me(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] flex items-center justify-center text-xs font-bold text-[var(--kyro-primary)] flex-shrink-0",children:e.name?e.name[0]:e.email[0].toUpperCase()})}function Qu(){let{t:e}=H(),[t,r]=useState("Kyro CMS"),[o,a]=useState("Command Center"),[n,i]=useState("#6366f1"),[s,l]=useState("Welcome back to your Command Center."),[d,c]=useState(false),[u,p]=useState(false);useEffect(()=>{(async()=>{try{let v=await Me("/api/globals/site-settings"),x=v.data||v;x&&Object.keys(x).length>0&&(x.siteName&&r(x.siteName),x.adminTitle&&a(x.adminTitle),x.primaryColor&&i(x.primaryColor),x.dashboardGreeting&&l(x.dashboardGreeting));}catch(v){console.error("Failed to load branding:",v);}})();},[]);let f=async()=>{c(true);try{await er("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:s}),p(!0),j.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.dispatchEvent(new Event("kyro:soft-reload")),800);}catch(y){j.error("Failed to save branding"),console.error(y);}finally{c(false);}},m=[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}];return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxs("div",{children:[jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsx("div",{className:"flex items-center gap-3",children:jsxs("button",{type:"button",onClick:f,disabled:d,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${u?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[d?jsx(RefreshCcw,{className:"w-4 h-4 animate-spin"}):u?jsx(Check,{className:"w-4 h-4"}):jsx(Save,{className:"w-4 h-4"}),d?"Saving...":u?"Identity Updated":"Publish Branding"]})})]}),jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsx(Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsx("input",{type:"text",value:t,onChange:y=>r(y.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Acme Corp CMS"})]}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsx("input",{type:"text",value:o,onChange:y=>a(y.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Command Center"})]}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsx("textarea",{value:s,onChange:y=>l(y.target.value),rows:3,className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all resize-none",placeholder:e("fields.greetingTextForThe",{defaultValue:"Greeting text for the dashboard..."})})]})]})]}),jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsx(Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxs("div",{className:"space-y-8",children:[jsxs("div",{className:"space-y-4",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsx("div",{className:"grid grid-cols-6 gap-3",children:m.map(y=>jsx("button",{type:"button",onClick:()=>i(y.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===y.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:y.hex},title:y.name},y.name))})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxs("div",{className:"flex items-center gap-6",children:[jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsx(Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsx(Sparkles,{className:"w-4 h-4"}),jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[o," Online"]})]}),jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",t,"."]}),jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsx("style",{dangerouslySetInnerHTML:{__html:`
109
+ \`\`\``})})}),!i&&jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsx("span",{children:"**bold**"}),jsx("span",{children:"*italic*"}),jsx("span",{children:"`code`"}),jsx("span",{children:"[link](url)"}),jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsx("p",{className:"kyro-form-help",children:e.admin?.description}),o&&jsx("p",{className:"kyro-form-error",children:o})]}):jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function Ps({field:e,value:t,onChange:r,error:o,disabled:a}){let n=t??"",i=n.length>8?n.slice(0,-8)+"*".repeat(8):n;return jsx(pt,{field:e,error:o,children:jsx("div",{className:"relative",children:jsx("input",{id:e.name,type:"text",value:i,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})})})}function va({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),i=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:d,setIsSlugLocked:c,formData:u}=ye(),p=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",f=t==null?"":String(t),m={id:e.name,value:f,onChange:y=>r?.(y.target.value),placeholder:e.admin?.placeholder,disabled:a||i||l&&d,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||i||l&&d?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsx(pt,{field:e,error:o,children:jsxs("div",{className:"relative",children:[s?jsx("textarea",{...m,rows:e.admin?.rows||4}):jsx("input",{type:p,...m,pattern:e.pattern}),l&&jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!d&&jsx("button",{type:"button",onClick:()=>r?.(vs(u[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:n("tooltips.regenerateSlug",{defaultValue:"Regenerate slug"}),children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"})]})}),jsx("button",{type:"button",onClick:()=>c(!d),className:`p-1.5 rounded transition-colors ${d?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:d?"Unlock slug":"Lock slug",children:d?jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxs("span",{className:f.length>60?"text-red-500":f.length>=40?"text-green-500":"text-amber-600",children:[f.length," / 60 \u2014 ",f.length>60?"Too Long":f.length>=40?"Ideal":"Short"]})})]})})}function Rs({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,children:jsx("input",{type:"number",id:e.name,value:t??"",onChange:i=>r?.(parseFloat(i.target.value)||0),placeholder:e.admin?.placeholder,disabled:a||n,min:e.min,max:e.max,step:e.step||(e.integer?1:"any"),required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Fs({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,hideLabel:true,children:jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsx("input",{type:"checkbox",checked:t??false,onChange:s=>r?.(s.target.checked),disabled:a||n,className:`w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)] transition-all ${a||n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`}),jsxs("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)] tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:[e.label||e.name,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Is({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsx(pt,{field:e,error:o,children:jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:i=>r?.(i.target.value),disabled:a||n,min:e.minDate,max:e.maxDate,required:e.required,className:`kyro-form-input ${a||n?"opacity-50 cursor-not-allowed":""}`})})}function Ls({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,u]=useState(null),p=JSON.stringify(n||{}),f=JSON.stringify(i||{});useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let v=setTimeout(async()=>{try{let x="";if(s)x=`${Dr}/${s}/dynamic-options/${e.name}`;else if(l)x=`${Dr}/globals/${l}/dynamic-options/${e.name}`;else return;let h=await ct(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(p),siblingData:JSON.parse(f)})});if(h.ok){let S=await h.json();S.options&&u(S.options);}}catch(x){console.error("Failed to fetch dynamic options:",x);}},300);return ()=>clearTimeout(v)},[p,f,e.name,e.options,s,l]);let m=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?m=e.options({data:n||{},siblingData:i||{}}):Array.isArray(e.options)&&(m=e.options)),e.dynamicOptions==="collections"&&(m=Object.keys(la).filter(y=>y!=="media").map(y=>({label:la[y]?.label||y,value:y}))),jsx(pt,{field:e,error:o,children:jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:y=>{if(e.hasMany){let v=Array.from(y.target.selectedOptions,x=>x.value);r?.(v);}else r?.(y.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:m.find(y=>y.value===t)?.color||void 0},className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsx("option",{value:"",children:"Select..."}),m.map(y=>jsx("option",{value:y.value,style:{color:y.color||void 0,fontWeight:y.color?"bold":"normal"},children:y.label},y.value))]})})}function ol(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function iy({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:i,setNodeRef:s,transform:l,transition:d,isDragging:c}=useSortable({id:e}),u={transform:CSS.Transform.toString(l),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxs("span",{ref:s,style:u,className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)] border border-transparent ${c?"border-[var(--kyro-primary)] shadow-sm bg-[var(--kyro-sidebar-active)]/20":""}`,children:[!a&&jsx("div",{...n,...i,className:"cursor-grab active:cursor-grabbing hover:bg-[var(--kyro-sidebar-active)]/20 rounded p-0.5 text-[var(--kyro-sidebar-active)] opacity-70 flex items-center justify-center",children:jsx(GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]})}function ly({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),[i,s]=useState(false),[l,d]=useState(""),[c,u]=useState([]),[p,f]=useState(false),[m,y]=useState([]),v=useRef(new Set),x=useRef(null),h=useRef(()=>{});h.current=r||(()=>{});let S=e.hasMany,N=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],V=N.length>1,[P,k]=useState(N[0]||""),g=useCallback(()=>t?(S?Array.isArray(t)?t:[]:t?[t]:[]).map(J=>typeof J=="object"&&J!==null?J.value||J.id||"":String(J)).filter(Boolean):[],[t,S]),b=useCallback(I=>{I.length!==0&&I.forEach(J=>{if(v.current.has(J))return;v.current.add(J);let Z=V?(()=>{if(!t)return P;let Y=(S?Array.isArray(t)?t:[]:[t]).find(ae=>typeof ae=="object"&&ae!==null?ae.value===J||ae.id===J:false);return Y&&typeof Y=="object"&&Y.relationTo||P})():P;Me(`/api/${Z}/${J}`).then(te=>{let Y=te.data||te;!Y||typeof Y!="object"||y(ae=>ae.some(ue=>ue.id===J)?ae:[...ae,{...Y,id:String(Y.id),relationTo:Z}]);}).catch(()=>{});});},[V,t,P,S]);useEffect(()=>{let I=g();b(I);},[g,b]);let w=useCallback((I="")=>{f(true);let Z=`/api/${P}?${Tn(I,["title","name","label","email"])}`;Me(Z).then(te=>{u(Y=>{let ae=new Set(Y.map(he=>he.id)),ue=(te.docs||[]).filter(he=>!ae.has(he.id)).map(he=>({...he,id:he.id}));return [...Y,...ue]}),f(false);}).catch(()=>{f(false);});},[P]);useEffect(()=>{i&&(u([]),w(l));},[i,P]),useEffect(()=>{let I=J=>{x.current&&!x.current.contains(J.target)&&s(false);};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);let D=I=>{if(typeof I=="object"&&I!==null){let J=I.value??I.id;return J!=null?D(J):""}return String(I)},F=I=>{let J=I.id;return t?S&&Array.isArray(t)?t.some(Z=>D(Z)===J):D(t)===J:false},E=I=>{let J=I.id;if(S){let Z=Array.isArray(t)?t:[];if(F(I))h.current?.(Z.filter(te=>D(te)!==J));else {let te=V?{relationTo:P,value:J}:J;h.current?.([...Z,te]);}}else if(F(I))h.current?.(null);else {let Z=V?{relationTo:P,value:J}:J;h.current?.(Z),s(false),d("");}},R=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),M=I=>{let{active:J,over:Z}=I;if(!Z||J.id===Z.id)return;let te=S?Array.isArray(t)?t:[]:[],Y=te.findIndex(ue=>D(ue)===J.id),ae=te.findIndex(ue=>D(ue)===Z.id);if(Y!==-1&&ae!==-1){let ue=[...te],[he]=ue.splice(Y,1);ue.splice(ae,0,he),h.current?.(ue);}},z=()=>{if(!t)return null;let I=S?Array.isArray(t)?t:[]:t?[t]:[],J=I.map(Z=>D(Z));return S&&I.length>1?jsx(DndContext,{sensors:R,collisionDetection:closestCenter,onDragEnd:M,children:jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsx(SortableContext,{items:J,strategy:horizontalListSortingStrategy,children:I.map(Z=>{let te=D(Z),Y=m.find(he=>he.id===te),ae=Y?ol(Y):te.slice(0,12),ue=V&&Y?Y.relationTo:null;return jsx(iy,{id:te,label:ae,relation:ue,onRemove:()=>{let he=I.filter(U=>D(U)!==te);h.current?.(he);},disabled:a},te)})})})}):jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:I.map(Z=>{let te=D(Z),Y=m.find(he=>he.id===te),ae=Y?ol(Y):te.slice(0,12),ue=V&&Y?Y.relationTo:null;return jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]",children:[ue&&jsxs("span",{className:"opacity-60 mr-0.5",children:[ue,":"]}),ae,!a&&jsx("button",{type:"button",onClick:()=>{let he=I.filter(U=>D(U)!==te);h.current?.(S?he:he[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]},te)})})};return jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxs("div",{ref:x,className:"relative",children:[V&&jsx("div",{className:"flex gap-1 mb-1.5",children:N.map(I=>jsx("button",{type:"button",onClick:()=>{k(I),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${P===I?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:I},I))}),jsxs("div",{className:"relative",children:[jsx(Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsx("input",{type:"text",value:l,onChange:I=>{d(I.target.value),s(true),w(I.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${P}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:p?jsx(LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsx(ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${i?"rotate-180":""}`})})]}),i&&jsx("div",{className:"relative z-20 w-full mt-1 border border-[var(--kyro-border)] rounded-lg shadow-lg bg-[var(--kyro-surface)] max-h-64 overflow-auto",children:p?jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsx(fs,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:c.map(I=>jsxs("button",{type:"button",onClick:()=>E(I),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${F(I)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:ol(I)}),F(I)&&jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in I&&typeof I.slug=="string"&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:I.slug})]},I.id))})}),z()]}),e.admin?.description&&!o&&jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var dn=ly;var Mo=createContext(null);function ou(e=[],t=[]){return createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=al(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let i=ha(a),{blocks:s}=o(),l=[...s];n!==void 0?l.splice(n,0,i):l.push(i),r({blocks:l});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:i}=o(),s=cn(i,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=[...l];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:l,found:false}});if(s!==i){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),i=cn(n,s=>{let l=s.filter(d=>d.id!==a);return l.length!==s.length?{newList:l,found:true}:{newList:s,found:false}});if(i!==n){r({blocks:i});let{onBlocksChange:s}=o();s&&s();}},moveBlock:(a,n)=>{let{blocks:i}=o(),s=cn(i,l=>{let d=l.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<l.length){let u=[...l];return [u[d],u[c]]=[u[c],u[d]],{newList:u,found:true}}}return {newList:l,found:false}});if(s!==i){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}}}))}function al(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};r.children&&Array.isArray(r.children)&&(r.children=al(r.children));let o=r.data;return o?.columnData&&Array.isArray(o.columnData)&&(r.data={...r.data,columnData:o.columnData.map(a=>({...a,children:a.children?al(a.children):a.children}))}),r}):[]}function ha(e){let t=py(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substring(2,11),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function py(e){return {heading:{level:1,text:""},"heading-subheading":{title:"",subtitle:""},hero:{isMultiScreen:false},card:{title:"",description:"",icon:"",link:"",linkText:"",isMultiCard:false},paragraph:{text:""},divider:{},callout:{text:"",variant:"info"},image:{src:"",alt:"",caption:""},video:{src:"",title:""},list:{type:"unordered",items:""},code:{language:"plaintext",code:""},link:{url:"",text:""},table:{rows:3,columns:3,content:""},quote:{text:"",author:""},file:{filename:"",url:""},columns:{columns:2,direction:"horizontal"},vstack:{direction:"vertical",gap:"md"},container:{options:{backgroundColor:"transparent",padding:"md",width:"full",margin:"none",minHeight:"none",borderRadius:"none"},children:[]},button:{text:"Button",url:"",variant:"primary",size:"md"},accordion:{title:"Accordion Item",content:""},gallery:{images:[]},tabs:{tabs:[{label:"Tab 1",content:""}]}}[e]||{}}function qe(e){let t=useContext(Mo);if(t)return useStore(t,r=>{let o=a=>{for(let n of a){if(n.id===e)return n;if(n.children&&n.children.length>0){let s=o(n.children);if(s)return s}let i=n.data;if(i?.columnData&&Array.isArray(i.columnData)){for(let s of i.columnData)if(s&&s.children&&s.children.length>0){let l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function He(){let e=useContext(Mo);if(!e)throw new Error("useBlockActions must be used within a BlocksContext.Provider");return {updateBlock:(t,r)=>e.getState().updateBlock(t,r),removeBlock:t=>e.getState().removeBlock(t),moveBlock:(t,r)=>e.getState().moveBlock(t,r)}}function cn(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(i=>{let s={...i},l=false;if(i.children&&i.children.length>0){let c=cn(i.children,t);c!==i.children&&(s.children=c,l=true);}let d=i.data;if(d?.columnData&&Array.isArray(d.columnData)){let c=d.columnData.map(u=>{if(u.children&&u.children.length>0){let p=cn(u.children,t);if(p!==u.children)return {...u,children:p}}return u});c.some((u,p)=>u!==d.columnData[p])&&(s.data={...s.data,columnData:c},l=true);}return l&&(a=true),l?s:i});return a?n:e}function pn({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=H(),[i,s]=na.useState(null),l=async()=>{try{s(null);let d=await navigator.clipboard.readText(),c=JSON.parse(d);c.__kyro_block?o&&o(c):s("Clipboard does not contain a valid Kyro block.");}catch(d){s("Failed to read block from clipboard."),console.error(d);}};return e?jsxs(xr,{open:e,onClose:t,title:n("tooltips.insertBlock",{defaultValue:"Insert Block"}),width:"md",children:[jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 py-2 px-4 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] text-sm font-semibold transition-all hover:bg-[var(--kyro-primary)]/5",children:[jsx(ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),i&&jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:i})]}),a]}):null}function au({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:i}=useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxs("div",{ref:n,...a,...o,onClick:()=>t(e.type),className:`flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group ${i?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:i?.5:1},children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:r||jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var nl=({text:e="",onChange:t,compact:r=false})=>{let{t:o}=H();return jsx("div",{className:r?"":"space-y-3",children:jsx("input",{type:"text",value:e,onChange:n=>t("text",n.target.value),className:r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:o("fields.enterHeadingText",{defaultValue:"Enter heading text..."})})})};var Oo=({id:e,type:t,label:r,children:o,className:a=""})=>{let{t:n}=H(),{moveBlock:i,removeBlock:s}=He();return jsxs("div",{className:`block-${t} border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group bg-[var(--kyro-surface)] transition-all hover:border-[var(--kyro-primary)]/30 ${a}`,children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:n("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:n("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx("div",{className:"block-content",children:o})]})};var iu=({block:e,index:t})=>{let r=qe(e.id),{updateBlock:o}=He(),a=r?.data??e.data??{},n=(i,s)=>{o(e.id,{data:{...a,[i]:s}});};return jsx(Oo,{id:e.id,type:"heading",label:"Heading",children:jsx(nl,{text:a.text||"",onChange:n,compact:true})})};var du=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a}=He(),n=o?.data||e.data||{},i=(s,l)=>{a(e.id,{data:{...n,[s]:l}});};return jsx(Oo,{id:e.id,type:"paragraph",label:"Paragraph",children:jsx("textarea",{value:n.text||"",onChange:s=>i("text",s.target.value),className:"w-full px-3 py-3 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm min-h-[100px] resize-none",placeholder:r("fields.enterParagraphText",{defaultValue:"Enter paragraph text..."})})})};var cu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsxs("div",{className:"space-y-3",children:[jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsx(hr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:d=>l("src",d)})]}),jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsx("input",{type:"text",value:s.alt||"",onChange:d=>l("alt",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.alternativeText",{defaultValue:"Alternative text..."})})]}),jsxs("div",{children:[jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsx("input",{type:"text",value:s.caption||"",onChange:d=>l("caption",d.target.value),className:"w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)] text-sm",placeholder:r("fields.imageCaption",{defaultValue:"Image caption..."})})]})]})]})};var il=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{let {t:n}=H();e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxs("div",{className:"space-y-2",children:[jsx("input",{type:"url",value:e,onChange:s=>r("src",s.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsx("input",{type:"text",value:t,onChange:s=>r("title",s.target.value),className:"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]}):jsxs("div",{className:"space-y-3",children:[jsx(hr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsx("input",{type:"url",value:e,onChange:s=>r("src",s.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:n("fields.mp4UrlYoutubeOr",{defaultValue:"MP4 URL, YouTube, or Vimeo link..."})}),jsx("input",{type:"text",value:t,onChange:s=>r("title",s.target.value),className:"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:n("fields.videoTitleOptional",{defaultValue:"Video title (optional)..."})})]})};var pu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(il,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function Sy({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:i,transition:s,isDragging:l}=useSortable({id:e}),d={transform:CSS.Transform.toString(i),transition:s,zIndex:l?10:1,opacity:l?.8:1};return jsxs("div",{ref:n,style:d,className:`flex items-center gap-2 group/item p-1.5 hover:bg-[var(--kyro-surface-accent)]/50 rounded-md transition-colors ${l?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsx("div",{...o,...a,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",onClick:c=>c.stopPropagation(),children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsx("button",{type:"button",onClick:r,className:"opacity-0 group-hover/item:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",children:"\xD7"})]})}var mn=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=H(),[a,n]=na.useState(""),[i,s]=na.useState([]);na.useEffect(()=>{let m=i.map(y=>y.text);JSON.stringify(m)!==JSON.stringify(e)&&s(e.map((y,v)=>({id:`${y}-${v}-${Math.random().toString(36).substr(2,4)}`,text:y})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=m=>{m.key==="Enter"&&(m.preventDefault(),l());},c=m=>{t(e.filter((y,v)=>v!==m));},u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),p=m=>{let{active:y,over:v}=m;if(!v||y.id===v.id)return;let x=i.findIndex(S=>S.id===y.id),h=i.findIndex(S=>S.id===v.id);if(x!==-1&&h!==-1){let S=[...e],[N]=S.splice(x,1);S.splice(h,0,N),t(S);}},f=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsx(DndContext,{sensors:u,collisionDetection:closestCenter,onDragEnd:p,children:jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:"No items. Type below to add."}):jsx(SortableContext,{items:i.map(m=>m.id),strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-1",children:i.map((m,y)=>jsx(Sy,{id:m.id,text:m.text,onRemove:()=>c(y)},m.id))})}),jsx("input",{type:"text",value:a,onChange:m=>n(m.target.value),onKeyDown:d,className:f,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};var mu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],d=c=>{a(e.id,{data:{...s,items:c}});};return jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(mn,{items:l,onChange:d,compact:true})]})};var fu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"group/block relative border border-[var(--kyro-border)] rounded-2xl p-6 mb-6 transition-all duration-300 bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/20",children:[jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-9 h-9 rounded-xl bg-[var(--kyro-primary)]/10 flex items-center justify-center text-[var(--kyro-primary)] transition-transform group-hover/block:scale-110",children:jsx(CodeXml,{className:"w-5 h-5"})}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",s.language||"javascript"]})]})]}),jsx("div",{className:"flex items-center gap-1.5 opacity-0 group-hover/block:opacity-100 transition-all translate-x-2 group-hover/block:translate-x-0",children:jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1.5 hover:bg-[var(--kyro-surface)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded-lg transition-all text-[var(--kyro-text-muted)] hover:text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})})]})})]}),jsxs("div",{className:"space-y-6",children:[jsx(ln,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:d=>l("code",d)}),jsxs("div",{className:"flex items-center gap-4 bg-[var(--kyro-surface-accent)]/20 p-4 rounded-xl border border-[var(--kyro-border)]/50",children:[jsxs("div",{className:"flex-1",children:[jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxs("div",{className:"relative",children:[jsxs("select",{value:s.language||"javascript",onChange:d=>l("language",d.target.value),className:"w-full pl-4 pr-10 py-2.5 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl text-xs font-medium text-[var(--kyro-text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)]/20 focus:border-[var(--kyro-primary)] transition-all appearance-none cursor-pointer",children:[jsx("option",{value:"plaintext",children:"Plain Text"}),jsx("option",{value:"javascript",children:"JavaScript"}),jsx("option",{value:"typescript",children:"TypeScript"}),jsx("option",{value:"python",children:"Python"}),jsx("option",{value:"json",children:"JSON"}),jsx("option",{value:"html",children:"HTML"}),jsx("option",{value:"css",children:"CSS"}),jsx("option",{value:"sql",children:"SQL"}),jsx("option",{value:"rust",children:"Rust"}),jsx("option",{value:"markdown",children:"Markdown"})]}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsx(ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var gu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(hr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:d=>l("file",d)})]})};var ml=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=useState(0),n=jsx("div",{className:"flex justify-end gap-1 mb-2"}),i=(p,f)=>{let m=[...e];m[p]={...m[p],title:f},t(m);},s=(p,f)=>{let m=[...e];m[p]={...m[p],content:f},t(m);},l=p=>{let f=e.filter((m,y)=>y!==p);t(f),o===p?a(null):o!==null&&o>p&&a(o-1);},d=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},c="w-full px-3 py-2 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",u="w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return r?jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsx("div",{className:"space-y-1.5",children:e.map((p,f)=>{let{t:m}=H(),y=o===f;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(y?null:f),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3.5 h-3.5"})}),y?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),y&&jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:v=>i(f,v.target.value),onClick:v=>v.stopPropagation(),className:u,placeholder:m("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:v=>s(f,v.target.value),onClick:v=>v.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:m("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsx(Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxs("div",{className:"space-y-2",children:[n,e.length===0?jsx("div",{className:"text-center py-4 text-[var(--kyro-text-muted)] text-sm border border-dashed border-[var(--kyro-border)] rounded-md",children:'No items. Click "Add Item" to create one.'}):jsx("div",{className:"space-y-2",children:e.map((p,f)=>{let{t:m}=H(),y=o===f;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(y?null:f),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${f+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:m("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})}),y?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),y&&jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:v=>i(f,v.target.value),className:c,placeholder:m("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:v=>s(f,v.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:m("fields.itemContent",{defaultValue:"Item content..."})})]})]},f)})}),jsxs("button",{type:"button",onClick:d,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 text-xs font-medium rounded-lg border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-sidebar-active)] hover:text-[var(--kyro-text-primary)] transition-colors",children:[jsx(Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var yu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],d=c=>{a(e.id,{data:{...s,items:c}});};return jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(ml,{items:l,onChange:d,compact:true})]})};var vu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data||e.data||{},l=d=>{a(e.id,{data:{...s,content:d}});};return jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(pa,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var fl=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let{t:i}=H(),s=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",l=n?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return n?jsxs("div",{className:"space-y-2",children:[jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${s} font-bold text-base`,placeholder:i("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:i("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.ctaText",{defaultValue:"CTA text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]}):jsxs("div",{className:"space-y-3",children:[jsx("input",{type:"text",value:e,onChange:d=>a("title",d.target.value),className:`${s} font-bold text-base`,placeholder:i("fields.heroHeading",{defaultValue:"Hero heading..."})}),jsx("textarea",{value:t,onChange:d=>a("subtitle",d.target.value),className:l,placeholder:i("fields.heroSubheading",{defaultValue:"Hero subheading..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:r,onChange:d=>a("ctaText",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:i("fields.ctaText",{defaultValue:"CTA text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:d=>a("ctaUrl",d.target.value),className:"flex-1 px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var wa=({block:e,blockSchema:t,onClose:r})=>{let o=qe(e.id),{updateBlock:a}=He(),n=o?.data||e.data||{},i=o?.children||e.children||[],s=(u,p)=>{a(e.id,{data:{...n,[u]:p}});},l=u=>{a(e.id,{children:u});},d=()=>t&&Array.isArray(t.fields)?jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(u=>{if(u.admin?.condition){if(typeof u.admin.condition=="function")try{let f={values:n,...n};if(!u.admin.condition(f,f))return null}catch(f){console.warn(`Condition error for field ${u.name}:`,f);}else if(typeof u.admin.condition=="object")try{let f=u.admin.condition,m=f.field,y=n[m],v=!0;if("equals"in f?v=y===f.equals:"notEquals"in f?v=y!==f.notEquals:"in"in f&&Array.isArray(f.in)&&(v=f.in.includes(y)),!v)return null}catch(f){console.warn(`Declarative condition error for field ${u.name}:`,f);}}let p=n[u.name];return jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsx(jo,{field:u,value:p,onChange:f=>s(u.name,f)})},u.name)})}):jsxs("div",{className:"text-center py-8 text-[var(--kyro-text-muted)] text-sm italic",children:['No schema defined for block type "',e.type,'"']}),c=Ue[e.type]||Ue.default;return jsxs(xr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxs("div",{className:"space-y-4",children:[d(),i.length>0&&jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",i.length,")"]}),jsx(yo,{blockId:e.id,children:i,onUpdateChildren:l})]})]}),jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsx("button",{type:"button",onClick:r,className:"w-full py-2.5 bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Done"})})]})};var Ty=6,yo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Ty})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,p]=useState(null),f=useContext(Mo);if(!f)throw new Error("ChildBlocksTree must be used within a BlocksContext");let m=useStore(f,g=>g.dynamicCategories),y=useStore(f,g=>g.allowedBlocks),v=o<a,x=16,h=g=>{let b=ha(g);r([...t,b]),c(b.id);},S=g=>{let b=t.filter(w=>w.id!==g);r(b);},V=(g,b)=>{let w=t.map(D=>D.id===g?{...D,children:b}:D);r(w);},P=g=>{l(b=>{let w=new Set(b);return w.has(g)?w.delete(g):w.add(g),w});},k=g=>{let b=g.children&&g.children.length>0,w=s.has(g.id);gl(g.type);let F=b,E=d===g.id,R=y.find(M=>M.slug===g.type);return jsxs("div",{className:"relative group",children:[jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${E?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*x},onClick:()=>{v&&c(E?null:g.id);},children:[F?jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),P(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:w?jsx(ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsx(ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsx("span",{className:"w-4"}),Yt[g.type]&&jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Yt[g.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[yn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),R?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:R.admin.description})]}),b&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[g.children?.length," nested"]}),u===g.id?jsxs("div",{className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{S(g.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),p(g.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsx(X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),E&&jsx(wa,{block:g,onClose:()=>c(null)}),b&&w&&jsx("div",{className:"mt-1",children:jsx(hu,{parentId:g.id,children:g.children??[],onUpdateChildren:M=>V(g.id,M),depth:o+1,maxDepth:a})})]},g.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxs("div",{style:{marginLeft:o*x},children:[jsxs("button",{type:"button",onClick:()=>i(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsx(Plus,{className:"w-3 h-3"}),"Add Block"]}),jsx(pn,{open:n,onClose:()=>i(false),onSelect:h,children:m.map(g=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:g.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:g.blocks.map(b=>jsxs("button",{type:"button",onClick:()=>{h(b.slug),i(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Yt[b.slug]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:b.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:b.admin?.description||""})]})]},b.slug))})]},g.title))})]}),t.length===0&&v&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*x},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*x},children:["Maximum nesting level (",a,") reached"]})]})},hu=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,p]=useState(null),f=useContext(Mo);if(!f)throw new Error("NestedChildBlocks must be used within a BlocksContext");let m=useStore(f,g=>g.dynamicCategories),y=useStore(f,g=>g.allowedBlocks),v=o<a,x=16,h=g=>{let b=ha(g);r([...t,b]),c(b.id);},S=g=>{let b=t.filter(w=>w.id!==g);r(b);},V=(g,b)=>{let w=t.map(D=>D.id===g?{...D,children:b}:D);r(w);},P=g=>{l(b=>{let w=new Set(b);return w.has(g)?w.delete(g):w.add(g),w});},k=g=>{let b=g.children&&g.children.length>0,w=s.has(g.id);gl(g.type);let F=b,E=d===g.id,R=y.find(M=>M.slug===g.type);return jsxs("div",{className:"relative group",children:[jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${E?"bg-[var(--kyro-primary)]/10 border-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"} ${v?"cursor-pointer":""}`,style:{marginLeft:o*x},onClick:()=>{v&&c(E?null:g.id);},children:[F?jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),P(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:w?jsx(ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsx(ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsx("span",{className:"w-4"}),Yt[g.type]&&jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Yt[g.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[yn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),R?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:R.admin.description})]}),b&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[g.children?.length," nested"]}),u===g.id?jsxs("div",{className:"flex items-center gap-1",onClick:M=>M.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{S(g.id),p(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>p(null),className:"px-2 py-1 text-xs bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] rounded hover:bg-[var(--kyro-border)]",children:"Cancel"})]}):jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),p(g.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsx(X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),E&&jsx(wa,{block:g,onClose:()=>c(null)}),b&&w&&jsx("div",{className:"mt-1",children:jsx(hu,{parentId:g.id,children:g.children??[],onUpdateChildren:M=>V(g.id,M),depth:o+1,maxDepth:a})})]},g.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(k)}),v&&jsxs("div",{style:{marginLeft:o*x},children:[jsxs("button",{type:"button",onClick:()=>i(true),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)] rounded transition-colors",children:[jsx(Plus,{className:"w-3 h-3"}),"Add Block"]}),jsx(pn,{open:n,onClose:()=>i(false),onSelect:h,children:m.map(g=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:g.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:g.blocks.map(b=>jsxs("button",{type:"button",onClick:()=>{h(b.slug),i(false);},className:"flex flex-col items-center text-center gap-1 p-2 rounded-md border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/60 hover:bg-[var(--kyro-surface-accent)]/30 transition-all cursor-pointer group",children:[jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all",children:Yt[b.slug]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:b.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:b.admin?.description||""})]})]},b.slug))})]},g.title))})]}),t.length===0&&v&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*x},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*x},children:["Maximum nesting level (",a,") reached"]})]})};var xu=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=o?.children??e.children??[],d=(c,u)=>{a(e.id,{data:{...s,[c]:u}});};return jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("div",{className:"flex items-center gap-2",children:jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsxs("div",{className:"space-y-3",children:[jsx(fl,{heading:s.title||"",subheading:s.subtitle||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:d,compact:true}),jsx(hr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:c=>d("bgImage",c)}),jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsx(yo,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var yl=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:i=false})=>{let{t:s}=H(),l=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",d=i?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[50px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] min-h-[80px] resize-none focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxs("div",{className:i?"space-y-2":"space-y-3",children:[jsx("input",{type:"text",value:e,onChange:c=>n("title",c.target.value),className:`${l} font-bold text-base`,placeholder:s("fields.cardTitle",{defaultValue:"Card title..."})}),jsx("textarea",{value:t,onChange:c=>n("description",c.target.value),className:d,placeholder:s("fields.cardDescription",{defaultValue:"Card description..."})}),jsx("input",{type:"text",value:r,onChange:c=>n("icon",c.target.value),className:l,placeholder:s("fields.iconEmojiOrName",{defaultValue:"Icon (emoji or name)..."})}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("input",{type:"text",value:a,onChange:c=>n("linkText",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent",placeholder:s("fields.linkText",{defaultValue:"Link text..."})}),jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsx("input",{type:"url",value:o,onChange:c=>n("link",c.target.value),className:"flex-1 px-2.5 py-1.5 border border-[var(--kyro-border)] rounded bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent font-mono text-xs",placeholder:"https://..."})]})]})};var Nu=({block:e,index:t})=>{let r=qe(e.id),{updateBlock:o}=He(),a=r?.data??e.data??{},n=(i,s)=>{o(e.id,{data:{...a,[i]:s}});};return jsx(Oo,{id:e.id,type:"card",label:"Card",children:jsx(yl,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Cu=({block:e,index:t})=>{let {t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He();o?.data??e.data??{};let l=o?.children??e.children??[];return jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx("div",{className:"space-y-3",children:jsx(yo,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var Su=({block:e,index:t})=>{let{t:r}=H(),o=qe(e.id),{updateBlock:a,removeBlock:n,moveBlock:i}=He(),s=o?.data??e.data??{},l=(d,c)=>{a(e.id,{data:{...s,[d]:c}});};return jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",s.relationTo||"pages"]})]}),jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>i(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveUp",{defaultValue:"Move up"}),children:jsx(ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsx("button",{type:"button",onClick:()=>i(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:r("tooltips.moveDown",{defaultValue:"Move down"}),children:jsx(ChevronRight,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:()=>n(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:r("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),jsx(Za,{relationTo:s.relationTo||"pages",hasMany:s.hasMany||false,selectedIds:Array.isArray(s.selectedIds)?s.selectedIds:[],selectedId:s.selectedId,labelField:s.labelField||"title",onChange:l,compact:true})]})};var Dy={heading:iu,paragraph:du,image:cu,video:pu,list:mu,code:fu,file:gu,accordion:yu,richtext:vu,hero:xu,card:Nu,array:Cu,relationship:Su},Ue={featureSplit:{text:"text-indigo-500",border:"border-indigo-500",borderLeft:"border-l-indigo-500"},featureGrid:{text:"text-blue-500",border:"border-blue-500",borderLeft:"border-l-blue-500"},ctaBanner:{text:"text-amber-500",border:"border-amber-500",borderLeft:"border-l-amber-500"},testimonials:{text:"text-emerald-500",border:"border-emerald-500",borderLeft:"border-l-emerald-500"},faq:{text:"text-orange-500",border:"border-orange-500",borderLeft:"border-l-orange-500"},stats:{text:"text-rose-500",border:"border-rose-500",borderLeft:"border-l-rose-500"},logoCloud:{text:"text-cyan-500",border:"border-cyan-500",borderLeft:"border-l-cyan-500"},pricing:{text:"text-green-500",border:"border-green-500",borderLeft:"border-l-green-500"},team:{text:"text-violet-500",border:"border-violet-500",borderLeft:"border-l-violet-500"},recentFeed:{text:"text-sky-500",border:"border-sky-500",borderLeft:"border-l-sky-500"},processSteps:{text:"text-fuchsia-500",border:"border-fuchsia-500",borderLeft:"border-l-fuchsia-500"},formEmbed:{text:"text-pink-500",border:"border-pink-500",borderLeft:"border-l-pink-500"},videoShowcase:{text:"text-red-500",border:"border-red-500",borderLeft:"border-l-red-500"},hero:{text:"text-yellow-500",border:"border-yellow-500",borderLeft:"border-l-yellow-500"},card:{text:"text-teal-500",border:"border-teal-500",borderLeft:"border-l-teal-500"},default:{text:"text-zinc-400",border:"border-zinc-400",borderLeft:"border-l-zinc-400"}},Yt={heading:jsx(Heading1,{className:`w-4 h-4 ${Ue.default.text}`}),paragraph:jsx(AlignLeft,{className:`w-4 h-4 ${Ue.default.text}`}),image:jsx(Image,{className:`w-4 h-4 ${Ue.default.text}`}),video:jsx(Video,{className:`w-4 h-4 ${Ue.default.text}`}),list:jsx(List,{className:`w-4 h-4 ${Ue.default.text}`}),code:jsx(Code,{className:`w-4 h-4 ${Ue.default.text}`}),file:jsx(File,{className:`w-4 h-4 ${Ue.default.text}`}),accordion:jsx(ChevronDown,{className:`w-4 h-4 ${Ue.default.text}`}),richtext:jsx(AlignLeft,{className:`w-4 h-4 ${Ue.default.text}`}),hero:jsx(Star,{className:`w-4 h-4 ${Ue.hero.text}`}),card:jsx(Box,{className:`w-4 h-4 ${Ue.card.text}`}),array:jsx(ListOrdered,{className:`w-4 h-4 ${Ue.default.text}`}),relationship:jsx(Link2,{className:`w-4 h-4 ${Ue.default.text}`}),featureSplit:jsx(Columns3,{className:`w-4 h-4 ${Ue.featureSplit.text}`}),featureGrid:jsx(Blocks,{className:`w-4 h-4 ${Ue.featureGrid.text}`}),ctaBanner:jsx(Sparkles,{className:`w-4 h-4 ${Ue.ctaBanner.text}`}),testimonials:jsx(Users,{className:`w-4 h-4 ${Ue.testimonials.text}`}),faq:jsx(CircleHelp,{className:`w-4 h-4 ${Ue.faq.text}`}),stats:jsx(Activity,{className:`w-4 h-4 ${Ue.stats.text}`}),logoCloud:jsx(Image,{className:`w-4 h-4 ${Ue.logoCloud.text}`}),pricing:jsx(Tag,{className:`w-4 h-4 ${Ue.pricing.text}`}),team:jsx(Users,{className:`w-4 h-4 ${Ue.team.text}`}),recentFeed:jsx(Database,{className:`w-4 h-4 ${Ue.recentFeed.text}`}),processSteps:jsx(Clock,{className:`w-4 h-4 ${Ue.processSteps.text}`}),formEmbed:jsx(Mail,{className:`w-4 h-4 ${Ue.formEmbed.text}`}),videoShowcase:jsx(Video,{className:`w-4 h-4 ${Ue.videoShowcase.text}`})};function gl(e){return Dy[e]||null}function vl(e){return {paragraph:"Paragraph",heading:"Heading",image:"Image",video:"Video",list:"List",code:"Code",file:"File",accordion:"Accordion",array:"Repeater",relationship:"Relationship",richtext:"Rich Text",hero:"Hero Section",card:"Card Block",featureSplit:"Feature Split",featureGrid:"Feature Grid",ctaBanner:"CTA Banner",testimonials:"Testimonials Stack",faq:"FAQ Section",stats:"Stats & Metrics",logoCloud:"Logo Cloud",pricing:"Pricing Grid / Plan",team:"Team Profiles Showcase",recentFeed:"Dynamic Content Feed",processSteps:"Process Timeline / Steps",formEmbed:"Lead Intake Form",videoShowcase:"Cinematic Video Showcase",headingElement:"Heading",textElement:"Text",imageElement:"Image",richtextElement:"Rich Text",buttonElement:"Button",videoElement:"Video",listElement:"List"}[e]||e}function yn(e){let t=e.name;return t&&t.trim()?t.trim():vl(e.type)}function zy(e,t){if(t?.fields){for(let r of t.fields)if(r.type==="text"||r.type==="textarea"){let o=e[r.name];if(o&&typeof o=="string")return o}}return e.title||e.text||e.name||e.label||""}var Hy=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:i})=>{let{t:s}=H(),{attributes:l,listeners:d,setNodeRef:c,transform:u,transition:p,isDragging:f}=useSortable({id:e.id}),{removeBlock:m,updateBlock:y}=He(),v=o===e.id,[x,h]=useState(false),[S,N]=useState(false),[V,P]=useState(e.name||""),k=useRef(null),[g,b]=useState(false);useEffect(()=>{S&&k.current&&(k.current.focus(),k.current.select());},[S]);let w=useCallback(()=>{N(false);let z=V.trim();z!==(e.name||"").trim()&&y(e.id,{name:z||""});},[V,e.name,e.id,y]),D=useCallback(z=>{z.stopPropagation();try{let I={__kyro_block:!0,type:e.type,blockProps:{...e,id:void 0,type:void 0}};navigator.clipboard.writeText(JSON.stringify(I,null,2)),b(!0),j.success(s("notifications.blockCopied",{defaultValue:"Block copied to clipboard"})),setTimeout(()=>b(!1),2e3);}catch{j.error(s("notifications.blockCopyFailed",{defaultValue:"Failed to copy block"}));}},[e,s]),F={transform:CSS.Transform.toString(u),transition:p,zIndex:f?10:1,opacity:f?.8:1},E=yn(e),R=e.data||{},M=zy(R,r);return i?jsxs("div",{ref:c,style:F,className:"relative group w-full",children:[jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${v?`${(Ue[e.type]||Ue.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsx("div",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 p-0.5 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] opacity-0 group-hover:opacity-100 transition-opacity hover:bg-[var(--kyro-surface-accent)] rounded touch-none",...l,...d,onClick:z=>z.stopPropagation(),children:jsx(GripVertical,{className:"w-2.5 h-2.5"})}),Yt[e.type]&&jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Yt[e.type]}),S?jsx("input",{ref:k,value:V,onChange:z=>P(z.target.value),onBlur:w,onKeyDown:z=>{z.key==="Enter"&&w(),z.key==="Escape"&&(P(e.name||""),N(false));},onClick:z=>z.stopPropagation(),className:"flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"}):jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:E}),x?jsxs("div",{className:"flex items-center gap-0.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{m(e.id),h(false);},className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsx("button",{type:"button",onClick:()=>h(false),className:"px-1.5 py-0.5 text-[9px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxs("div",{className:"flex items-center gap-0.5",children:[jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),N(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.rename",{defaultValue:"Rename"}),children:jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.duplicateInPlace",{defaultValue:"Duplicate in place"}),children:jsx(Copy,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:D,className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.copyBlock",{defaultValue:"Copy Block to Clipboard"}),children:g?jsx(Check,{className:"w-3 h-3 text-green-500"}):jsx(ClipboardCopy,{className:"w-3 h-3"})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(true);},className:"p-0.5 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:s("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3 h-3"})})]})]}),v&&jsx(wa,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxs("div",{ref:c,style:F,className:"relative group mb-2",children:[jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${v?`${(Ue[e.type]||Ue.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsx("div",{className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 touch-none",...l,...d,onClick:z=>z.stopPropagation(),children:jsx(GripVertical,{className:"w-4 h-4"})}),Yt[e.type]&&jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Yt[e.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[S?jsx("input",{ref:k,value:V,onChange:z=>P(z.target.value),onBlur:w,onKeyDown:z=>{z.key==="Enter"&&w(),z.key==="Escape"&&(P(e.name||""),N(false));},onClick:z=>z.stopPropagation(),placeholder:vl(e.type),className:"w-full max-w-[150px] sm:max-w-[250px] md:max-w-[400px] bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"}):jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[E,M&&typeof M=="string"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",M.length>40?`${M.slice(0,40)}...`:M]})]}),!!r?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:r.admin.description})]}),!!e.children&&Array.isArray(e.children)&&e.children.length>0&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),x?jsxs("div",{className:"flex items-center gap-1.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{m(e.id),h(false);},className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-danger)] text-white rounded font-semibold transition-colors hover:brightness-90",children:"Remove"}),jsx("button",{type:"button",onClick:()=>h(false),className:"px-2.5 py-1 text-[10px] bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] text-[var(--kyro-text-secondary)] rounded font-semibold transition-colors",children:"Cancel"})]}):jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P(e.name||""),N(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.renameBlock",{defaultValue:"Rename Block"}),children:jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.duplicateBlock",{defaultValue:"Duplicate Block"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:D,className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:s("tooltips.copyBlock",{defaultValue:"Copy Block to Clipboard"}),children:g?jsx(Check,{className:"w-3.5 h-3.5 text-green-500"}):jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),h(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:s("tooltips.removeBlock",{defaultValue:"Remove Block"}),children:jsx(X,{className:"w-3.5 h-3.5"})})]})]}),v&&jsx(wa,{block:e,blockSchema:r,onClose:()=>a(null)})]})},_y=na.memo(Hy),hl=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:i,justSaved:s})=>{let[l,d]=useState(false),[c,u]=useState(false),p=useRef(null),f=e.admin?.pickerMode||"drawer",m=e.blocks||[],y=m.reduce((U,K)=>{let _=K.admin?.group||"Custom Blocks";return U[_]||(U[_]=[]),U[_].push(K),U},{}),v=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],x=Object.entries(y).sort(([U],[K])=>{let _=v.indexOf(U),xe=v.indexOf(K);return _!==-1&&xe!==-1?_-xe:_!==-1?-1:xe!==-1?1:U.localeCompare(K)}).map(([U,K])=>({title:U,blocks:K})),h=useRef(null);h.current||(h.current=ou(m,x));let S=h.current,N=useStore(S,U=>U.blocks),[V,P]=useState(null),[k,g]=useState(null),b=useRef(N.length),w=useRef(new Set(N.map(U=>U.id))),D=useRef(false);useEffect(()=>{if(D.current&&N.length>b.current){let U=N.find(K=>K.id&&!w.current.has(K.id));U&&g(U.id);}b.current=N.length,w.current=new Set(N.map(U=>U.id));},[N]),useEffect(()=>(o&&S.getState().setOnBlocksChange(o),()=>{S.getState().setOnBlocksChange(()=>{});}),[o,S]);let F=useRef(null);useEffect(()=>{let U=Array.isArray(t)?t:[],K=F.current||[];if(Eo(U,K))U.length===0&&!D.current&&(D.current=true,F.current=[]);else {let _=[...U];b.current=_.length,w.current=new Set(_.map(xe=>xe.id)),S.getState().setBlocks(_),F.current=_,D.current=true;}},[t,e.name,S]);let E=useRef(r);E.current=r,useEffect(()=>{if(!E.current)return;let U=F.current;U&&(Eo(N,U)||(F.current=[...N],E.current(N)));},[N]);let M=useCallback(U=>{S.getState().addBlock(U);},[S]),z=useCallback(U=>{if(!m.some(Be=>Be.slug===U.type)){alert(`The block type "${U.type}" is not allowed in this collection.`);return}let _=Math.random().toString(36).substring(2,11),xe={...U.blockProps||{},id:_,type:U.type};S.getState().setBlocks([...N,xe]),d(false);},[m,N,S]),I=useCallback(U=>{let K=document.activeElement;if(K&&(K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.getAttribute("contenteditable")==="true"))return;let _=U.clipboardData?.getData("text");if(_)try{let xe=JSON.parse(_);xe&&xe.__kyro_block&&(U.preventDefault(),U.stopPropagation(),z(xe),j.success(`Block pasted: ${xe.type}`));}catch{}},[z]),J=useCallback(U=>{let K=N.findIndex(C=>C.id===U);if(K===-1)return;let _=N[K],xe=C=>{let G=Math.random().toString(36).substr(2,9);return {...C,id:G,children:C.children?C.children.map(Ne=>xe(Ne)):C.children,data:C.data?JSON.parse(JSON.stringify(C.data)):C.data}},Be=xe(_),we=[...N];we.splice(K+1,0,Be),S.getState().setBlocks(we);},[N,S]),Z=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}}),useSensor(TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),useSensor(KeyboardSensor)),te=U=>{P(U.active);},Y=U=>{let{active:K,over:_}=U;if(P(null),!!_){if(K.id.toString().startsWith("drawer-")){let xe=K.id.toString().replace("drawer-","");if(_.id.toString().startsWith("container-")){let Be=_.id.toString().replace("container-",""),we=N.find(C=>C.id===Be);if(we){let C=ha(xe);S.getState().updateBlock(Be,{children:[...we.children||[],C]});}}else {let Be=N.findIndex(we=>we.id===_.id);Be!==-1?S.getState().addBlock(xe,Be):M(xe);}return}if(K.id!==_.id){let xe=N.findIndex(we=>we.id===K.id),Be=N.findIndex(we=>we.id===_.id);if(xe!==-1&&Be!==-1){let we=[...N],[C]=we.splice(xe,1);we.splice(Be,0,C),S.getState().setBlocks(we);}}}},ae=V?x.flatMap(U=>U.blocks).find(U=>`drawer-${U.type}`===V.id)||N.find(U=>U.id===V.id):null;ae?"label"in ae?ae.label:ae.type:"Block";return useEffect(()=>{if(!c)return;let U=K=>{p.current&&!p.current.contains(K.target)&&u(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[c]),jsx(Mo.Provider,{value:h.current,children:jsxs("div",{className:"kyro-blocks-field",onPaste:I,tabIndex:0,style:{outline:"none"},children:[jsxs(DndContext,{sensors:Z,collisionDetection:closestCenter,onDragStart:te,onDragEnd:Y,children:[jsxs("div",{className:f==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsx("label",{className:`kyro-form-label ${f==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),f==="dropdown"?jsxs("div",{ref:p,className:"relative w-full",children:[jsxs("button",{type:"button",onClick:()=>u(!c),disabled:n,className:"flex w-full items-center justify-between px-3 py-2 text-sm text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)] rounded-md transition-colors disabled:opacity-50",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsx(ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsx("div",{className:"absolute right-0 top-full mt-1 w-full bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:x.map(U=>jsxs("div",{children:[x.length>1&&jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:U.title}),U.blocks.map(K=>jsxs("button",{type:"button",onClick:()=>{M(K.slug),u(false);},className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]/50 transition-colors text-left",children:[jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Yt[K.slug]||jsx(Box,{className:"w-4 h-4"})}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:"text-xs font-semibold truncate",children:K.label}),K.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:K.admin.description})]})]},K.slug))]},U.title))})]}):jsxs("button",{type:"button",onClick:()=>d(true),disabled:n,className:"flex items-center gap-2 px-3 py-2 text-sm text-[var(--kyro-primary)] hover:bg-[var(--kyro-surface-accent)]/30 rounded-md transition-colors disabled:opacity-50 font-semibold",children:[jsx(Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsx("div",{className:"mb-4",children:jsx(pn,{open:l,onClose:()=>d(false),onSelect:M,onPasteBlock:z,children:jsx("div",{className:"space-y-4",children:x.map(U=>jsxs("div",{children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:U.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:U.blocks.map(K=>jsx(au,{block:{type:K.slug,label:K.label,description:K.admin?.description||"",icon:null},onSelect:M,children:jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded group-hover:bg-[var(--kyro-primary)]/10 group-hover:text-[var(--kyro-primary)] transition-all duration-300",children:jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Yt[K.slug]||jsx(Box,{className:"w-4 h-4"})})})},K.slug))})]},U.title))})})}),jsx(SortableContext,{items:N.map(U=>U.id),strategy:verticalListSortingStrategy,children:jsxs("div",{className:f==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[N.map((U,K)=>{let _=e.blocks?.find(xe=>xe.slug===U.type);return jsx(_y,{block:U,index:K,blockSchema:_,editingBlockId:k,setEditingBlockId:g,onDuplicate:J,compact:f==="dropdown"},U.id||K)}),N.length===0&&jsx("div",{className:f==="dropdown"?"text-xs text-[var(--kyro-text-muted)] italic py-1":"text-center py-12 text-[var(--kyro-text-muted)] border-2 border-dashed border-[var(--kyro-border)] rounded-lg",children:f==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsx(DragOverlay,{children:V&&ae&&jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:ae.label||ae.type||"Block"})})]}),a&&jsx("p",{className:"kyro-form-error",children:a})]})})};function $s({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxs("div",{className:"kyro-form-group border border-[var(--kyro-border)] rounded-[var(--kyro-radius-lg)] p-6 bg-[var(--kyro-surface-accent)]/30",children:[jsx("div",{className:"flex items-center justify-between mb-6 border-b border-[var(--kyro-border)] pb-2",children:jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)]",children:e.label||e.name})}),jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields?.map(n=>o(n,a,r))})]})}var Zy=new Set(["text","number","checkbox","select","radio","color","email","password"]);function ev(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>Zy.has(r.type))}function Ru({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:i,onChangeItem:s,onRemove:l,disabled:d,compact:c,getItemLabel:u}){let{t:p}=H(),{attributes:f,listeners:m,setNodeRef:y,transform:v,transition:x}=useSortable({id:e}),h={transform:CSS.Transform.toString(v),transition:x},S=n.fields||[];return c?jsxs("div",{ref:y,style:h,className:"flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0",children:[jsx("div",{...f,...m,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0 mt-1",children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsx("div",{className:`flex-1 min-w-0 ${S.length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:S.map(N=>jsx("div",{className:"flex-1 min-w-0",children:i(N,a,s)},N.name))}),jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:p("tooltips.remove",{defaultValue:"Remove"}),children:jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxs("div",{ref:y,style:h,className:"border border-[var(--kyro-border)] rounded-[var(--kyro-radius-md)] bg-[var(--kyro-surface-accent)]/10 overflow-hidden",children:[jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-[var(--kyro-surface-accent)]/20 border-b border-[var(--kyro-border)]",children:[jsx("div",{...f,...m,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-surface-accent)] rounded flex-shrink-0",children:jsx(GripVertical,{className:"w-3.5 h-3.5"})}),jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-muted)] min-w-[18px]",children:t+1}),jsx("div",{className:"flex-1 min-w-0",children:jsx("span",{className:"text-xs font-medium text-[var(--kyro-text-primary)] truncate block",children:u(a)||`${n.label||n.name} Item`})}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[jsx("button",{type:"button",disabled:d,onClick:l,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-1 rounded hover:bg-[var(--kyro-surface-accent)]",title:p("tooltips.remove",{defaultValue:"Remove"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] transition-colors",children:r?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:S.map(N=>i(N,a,s))})]})}function Os({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],i=e.fields||[],s=i[0],l=s?.name||"user",d=s?.type==="relationship",[c,u]=na.useState(0);na.useEffect(()=>{let x=false,h=n.filter(S=>typeof S!="object"||S===null?(x=true,false):true).map(S=>!S.id&&!S._key?(x=true,{...S,id:Math.random().toString(36).substr(2,9)}):S);x&&r(h);},[t,r]);function p(x){for(let S of ["label","title","name"]){let N=x[S];if(N&&typeof N=="string")return N}let h=i;for(let S of h){if(S.type==="text"||S.type==="textarea"){let N=x[S.name];if(N&&typeof N=="string")return N}if(S.type==="group"&&S.fields){for(let N of S.fields||[])if(N.type==="text"||N.type==="textarea"){let P=x[S.name]?.[N.name];if(P&&typeof P=="string")return P}}}return ""}let f=ev(e),m=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),y=x=>{let{active:h,over:S}=x;if(!S||h.id===S.id)return;let N=n.findIndex(P=>(P.id||P._key)===h.id),V=n.findIndex(P=>(P.id||P._key)===S.id);if(N!==-1&&V!==-1){let P=[...n],[k]=P.splice(N,1);P.splice(V,0,k),r(P);}},v=na.useMemo(()=>n.map(x=>x?.id||x?._key||""),[n]);return d?jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(dn,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:void 0},value:n.map(x=>x[l]).filter(Boolean),onChange:x=>{let h=(x||[]).map(S=>({[l]:S,id:Math.random().toString(36).substr(2,9)}));r(h);},disabled:a})]}):jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(DndContext,{sensors:m,collisionDetection:closestCenter,onDragEnd:y,children:f?jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsx(SortableContext,{items:v,strategy:verticalListSortingStrategy,children:n.map((x,h)=>jsx(Ru,{id:x.id||x._key||`idx-${h}`,index:h,isOpen:false,setOpenIndex:()=>{},item:x,field:e,renderField:o,onChangeItem:S=>{let N=[...n];N[h]=S,r(N);},onRemove:()=>r(n.filter((S,N)=>N!==h)),disabled:a,compact:true,getItemLabel:p},x.id||x._key||h))}),jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxs("div",{className:"kyro-form-array border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md p-3 space-y-4",children:[jsx(SortableContext,{items:v,strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-2",children:n.map((x,h)=>{let S=c===h;return jsx(Ru,{id:x.id||x._key||`idx-${h}`,index:h,isOpen:S,setOpenIndex:u,item:x,field:e,renderField:o,onChangeItem:N=>{let V=[...n];V[h]=N,r(V);},onRemove:()=>r(n.filter((N,V)=>V!==h)),disabled:a,compact:false,getItemLabel:p},x.id||x._key||h)})})}),jsx("button",{type:"button",className:"w-full py-3 border-2 border-dashed border-[var(--kyro-border)] rounded-lg text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>{let x=Math.random().toString(36).substr(2,9);r([...n,{id:x}]),u(n.length);},children:"+ Add Item"})]})})]})}var jo=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{ys("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsx(va,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "icon":return jsx(Ss,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "textarea":return jsx(va,{field:{...e,variant:"textarea"},value:t??void 0,onChange:d,error:o,disabled:a});case "password":return jsx(va,{field:{...e,variant:"password"},value:t??void 0,onChange:d,error:o,disabled:a});case "secret":return jsx(Ps,{field:e,value:t??void 0,onChange:r,error:o,disabled:a});case "number":return jsx(Rs,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "checkbox":return jsx(Fs,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsx(Ls,{field:e,value:t??void 0,onChange:d,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l});case "date":return jsx(Is,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "richtext":return jsx(pa,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsx(Xi,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "code":return jsx(ln,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "image":case "upload":return jsx(pt,{field:e,error:o,children:jsx(hr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsx(dn,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsx(pt,{field:e,error:o,children:jsx(mn,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsx(Os,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,p)=>{let f=u[c.name];return jsx(jo,{field:c,value:f,onChange:m=>{p({...u,[c.name]:m});},disabled:a,error:o},c.name)}});case "blocks":return jsx(hl,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsx($s,{field:e,value:t,onChange:r,renderField:(c,u,p)=>{let f=u[c.name];return jsx(jo,{field:c,value:f,onChange:m=>{p({...u,[c.name]:m});},disabled:a,error:o,collectionSlug:s,globalSlug:l},c.name)}});case "color":return jsx(pt,{field:e,error:o,children:jsxs("div",{className:"flex items-center gap-3",children:[jsx("input",{type:"color",value:t||"#000000",onChange:c=>r(c.target.value),disabled:a,className:"h-10 w-14 p-1 cursor-pointer bg-[var(--kyro-input-bg)] border border-[var(--kyro-input-border)] rounded-lg"}),jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg text-amber-800 text-xs italic",children:['Field type "',e.type,'" is not yet supported in this renderer.']})}};var Iu=({title:e,description:t,slug:r})=>jsxs("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg p-6 max-w-2xl shadow-sm transition-colors duration-300",children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsx("div",{className:"w-7 h-7 bg-[var(--kyro-bg-secondary)] rounded-full flex items-center justify-center text-[10px] text-[var(--kyro-text-primary)] font-medium border border-[var(--kyro-border)]",children:"K"}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function Eu({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=useState(0),i=e.tabs||[],s=i[a]||i[0],l=e.name?t[e.name]||{}:t;return jsxs("div",{className:"space-y-8",children:[jsx("div",{className:"flex items-center justify-between border-b border-[var(--kyro-border)] mb-6",children:jsx("div",{className:"flex items-center gap-2 overflow-x-auto hide-scrollbar",children:i.map((d,c)=>jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))})}),jsx("div",{className:"space-y-6",children:s?.fields.map(d=>o(d,l,r))}),s?.label==="SEO Settings"&&jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsx(Iu,{title:String((typeof l.metaTitle=="object"?"":l.metaTitle)||(typeof l.title=="object"?"":l.title)||"Untitled"),description:String((typeof l.metaDescription=="object"?"":l.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function Uo({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=useState(false),i=useRef(null);return useEffect(()=>{let s=l=>{i.current&&!i.current.contains(l.target)&&n(false);};return a&&document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[a]),jsxs("div",{className:"relative",ref:i,children:[jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsx("div",{className:`absolute z-[100] min-w-[200px] py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100 ${r==="right"?"right-0":"left-0"} ${o==="down"?"top-full mt-2":"bottom-full mb-2"}`,onClick:()=>n(false),children:t})]})}function Ft({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsx("div",{className:"px-1.5",children:jsxs("button",{type:"button",onClick:t,disabled:a,className:`w-full flex items-center gap-3 px-3 py-2.5 text-[11px] font-medium tracking-wide text-left transition-all rounded-xl ${o?"text-red-500 hover:bg-red-500/10":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)]"} ${a?"opacity-50 cursor-not-allowed":""} ${n}`,children:[r&&jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsx("span",{className:"flex-1",children:e})]})})}function hn(){return jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Ho({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:i="down"}){let s=e==="published"&&!r&&t!=="saving"&&t!=="error",l=n||t==="saving"||s||t==="saved",d="kyro-btn kyro-btn-sm text-[11px] font-regular tracking-widest transition-all duration-300 rounded-lg",c=()=>t==="saving"?`${d} bg-[var(--kyro-primary)]/70 border-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] cursor-wait`:t==="saved"?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:s?`${d} bg-[var(--kyro-gray-200)] border-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] cursor-not-allowed`:`${d} bg-[var(--kyro-primary)] border-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] hover:bg-[var(--kyro-primary-hover)]`,u="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",p=()=>t==="saving"?`${u} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:t==="error"?`${u} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:s?`${u} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${u} bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-hover)]`,f=()=>t==="saving"?"Publishing...":t==="saved"?"Published":t==="error"?"Retry":s?"Published":"Publish Changes";return jsxs("div",{className:"inline-flex items-center",children:[jsxs("button",{type:"button",onClick:o,disabled:l,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsx(lr,{size:"sm",className:"inline mr-1.5"}),(s||t==="saved")&&jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),f()]}),a&&jsx(Uo,{trigger:jsx("button",{type:"button",className:p(),disabled:t==="saving",children:jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:i,children:a})]})}function Vu({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:i,handleDuplicate:s,handleUnpublish:l,handleDelete:d,handlePublish:c,handleSaveDraft:u,handleSchedulePublish:p,handleConflictOverride:f}){let{t:m}=H(),[y,v]=useState(Date.now()),[x,h]=useState(false),S=useRef(null),{formData:N,hasUnsavedChanges:V,autoSaveStatus:P,lastSavedAt:k,retryCount:g,view:b,setView:w,showPreview:D,setShowPreview:F,setFormData:E,markSaved:R,lastSavedData:M}=ye(),z=!N.id;useEffect(()=>{let _=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(_)},[]),useEffect(()=>{let _=xe=>{S.current&&!S.current.contains(xe.target)&&h(false);};if(x)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[x]);let I=String(N.tabs?.title||(typeof N.title=="object"?"":N.title)||(typeof N.name=="object"?"":N.name)||"Untitled"),J=N.updatedAt?new Date(N.updatedAt).toLocaleString():"Just now",Z=N.createdAt?new Date(N.createdAt).toLocaleString():"Just now",te=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",Y=o?"Unpublished":r==="published"?"Published":"Draft",ae=r==="published"&&!V?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",ue=r==="published"&&!o?"bg-[var(--kyro-success)]/10 text-[var(--kyro-success)] border-[var(--kyro-success)]/20":o?"bg-[var(--kyro-warning)]/10 text-[var(--kyro-warning)] border-[var(--kyro-warning)]/20":"bg-[var(--kyro-text-muted)]/10 text-[var(--kyro-text-muted)] border-[var(--kyro-text-muted)]/20",he=(_=false)=>jsxs(Fragment,{children:[P==="saving"&&jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),_?"Saving\u2026":"Saving draft..."]}),P==="success"&&jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsx(Check,{className:"w-3.5 h-3.5 shrink-0"}),_?"Saved":k?`Saved ${Math.floor((Date.now()-k)/6e4)}m ago`:"Draft saved"]}),P==="retrying"&&jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),_?`Retry ${g}/5`:`Retrying save (${g}/5)`]}),P==="offline"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsx("path",{d:"m2 2 20 20"}),jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),_?"Offline":"Offline \u2014 cached locally"]}),P==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:_?"Failed":"Draft save failed"}),P==="conflict"&&(_?jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxs("div",{className:"flex items-center gap-3",children:[jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>f?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsx("span",{className:"opacity-30",children:"|"}),jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("kyro:soft-reload")),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),U=()=>!z&&jsxs(Uo,{trigger:jsx("button",{type:"button",className:"kyro-btn p-2 md:p-2.5 rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)] transition-all",title:m("tooltips.moreActions",{defaultValue:"More actions"}),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsx(Ft,{onClick:u,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsx(Ft,{onClick:i,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsx(Ft,{onClick:s,disabled:n,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),children:n?"Duplicating...":"Duplicate"}),jsx(Ft,{onClick:()=>h(true),icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsx(Ft,{onClick:l,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxs(Fragment,{children:[jsx(hn,{}),jsx(Ft,{onClick:d,danger:true,icon:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),children:"Delete"})]})]}),K=()=>x&&jsx("div",{ref:S,className:"relative",children:jsxs("div",{className:"absolute right-0 top-2 p-4 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] shadow-2xl z-50 min-w-[260px]",children:[jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsx("input",{type:"datetime-local",id:"schedule-datetime",className:"kyro-form-input text-xs mb-3 w-full",min:new Date().toISOString().slice(0,16)}),jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsx("button",{type:"button",onClick:()=>h(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsx("button",{type:"button",onClick:()=>{let _=document.getElementById("schedule-datetime")?.value;_&&p(_);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxs(Fragment,{children:[jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsx("a",{href:`${_e}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsx(ChevronRight,{className:"w-4 h-4"})}),jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:I}),jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${ue}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ae}`}),Y]})]}),jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsx(Ho,{status:r,saveStatus:a,hasChanges:V,onPublish:c,disabled:a==="saving"}),U(),K()]})]}),jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-[var(--kyro-border)]/50 bg-[var(--kyro-bg-secondary)]/30",children:[jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)]/50",children:["edit","version","api"].map(_=>jsx("button",{type:"button",onClick:()=>w(_),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${b===_?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 active:opacity-100"}`,children:_==="edit"?"Edit":_==="version"?"History":"API"},_))}),jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[he(true),V&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsx("button",{type:"button",onClick:()=>{ye.getState().loadDocument(M,M);},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsx("button",{type:"button",onClick:()=>F(!D),className:`p-1.5 rounded-lg transition-all ${D?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsx(ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxs("header",{className:"hidden md:flex surface-tile px-8 py-6 items-center justify-between sticky top-0 border-b border-[var(--kyro-border)] mb-8 bg-[var(--kyro-surface)] z-50 backdrop-blur-md",children:[jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsx("a",{href:`${_e}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsx(ChevronRight,{className:"w-4 h-4"})}),jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:I}),jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${ue}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ae}`}),te]})]}),jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[he(false),V&&P!=="saving"&&P!=="retrying"&&P!=="conflict"&&jsxs(Fragment,{children:[jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>{ye.getState().loadDocument(M,M);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),k&&P!=="saving"&&P!=="retrying"&&P!=="success"&&jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let _=y-k,xe=Math.floor(_/6e4),Be=Math.floor(_/1e3);return xe>=1?`${xe}m ago`:Be>=5?`${Be}s ago`:"just now"})()]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",J]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",Z]})]})]}),jsxs("div",{className:"flex items-center gap-6",children:[jsx("div",{className:"flex items-center gap-1 bg-[var(--kyro-bg-secondary)] p-1 rounded-xl border border-[var(--kyro-border)]",children:["edit","version","api"].map(_=>jsx("button",{type:"button",onClick:()=>w(_),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${b===_?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:_.toUpperCase()},_))}),jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("button",{type:"button",onClick:()=>F(!D),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${D?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:m("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsx(ExternalLink,{className:"w-4 h-4"}),D&&jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),U(),K(),jsx(Ho,{status:r,saveStatus:a,hasChanges:V,onPublish:c,disabled:a==="saving"})]})]})]})]})}function ju({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=H(),{showPreview:n,sidebarCollapsed:i,formData:s,previewUrl:l}=ye();if(t==="single")return jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(u=>o(u))})});let c=e.fields.some(u=>u.admin?.position==="sidebar")&&!n;return jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${n?"grid-cols-1 lg:grid-cols-2":i||!c?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsx("div",{className:"space-y-6 md:space-y-8 animate-in fade-in slide-in-from-left-4 duration-500",children:e.tabs?o({type:"tabs",tabs:e.tabs}):jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(u=>!u.admin?.position||u.admin.position==="main").map(u=>o(u))})}),n?jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxs("div",{className:"w-full h-full rounded-3xl border border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] shadow-2xl overflow-hidden relative group",children:[jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsx("iframe",{src:l||"",className:"w-full h-full border-none",title:a("tooltips.livePreview",{defaultValue:"Live Preview"})}),jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):i?null:jsx("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:e.fields.some(u=>u.admin?.position==="sidebar")&&jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(u=>u.admin?.position==="sidebar").map(u=>o(u))]})})]})}function Uu({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:i,compareDiffs:s,setCompareDiffs:l,loadingDiffs:d,loadingVersions:c,versions:u}=ye();return jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxs("div",{className:"px-4 md:px-6 py-3 md:py-4 border-b border-[var(--kyro-border)] flex flex-col md:flex-row md:items-center justify-between gap-2",children:[jsxs("div",{children:[jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${u.length} snapshot${u.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsx("button",{type:"button",onClick:t,disabled:d,className:"kyro-btn kyro-btn-primary px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider hover:opacity-90 disabled:opacity-50",children:d?"Comparing...":"Compare"}),jsx("button",{type:"button",onClick:()=>{a(!o),i([]),l([]);},className:`px-3 py-1.5 rounded-lg text-[11px] font-bold tracking-wider transition-all ${o?"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]":"border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:o?"Done":"Compare"})]})]}),s.length>0&&jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[s.length," change",s.length!==1?"s":""]}),jsx("button",{type:"button",onClick:()=>l([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsx(X,{className:"w-4 h-4"})})]}),jsx("div",{className:"max-h-[400px] overflow-y-auto",children:s.map((p,f)=>jsxs("div",{className:"flex flex-col md:grid md:grid-cols-4 gap-1 md:gap-3 px-4 md:px-6 py-2.5 text-[11px] font-mono border-t border-[var(--kyro-border)] hover:bg-[var(--kyro-bg-secondary)]",children:[jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:p.field}),jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof p.oldValue=="object"?JSON.stringify(p.oldValue):String(p.oldValue??"null")}),jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof p.newValue=="object"?JSON.stringify(p.newValue):String(p.newValue??"null")]})]},f))})]}),c?jsx("div",{className:"flex justify-center py-16",children:jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):u.length===0?jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:u.map((p,f)=>{let m=n.includes(p.id),y=(p.changeDescription||"").toLowerCase().includes("auto");return jsxs("div",{onClick:o?()=>r(p.id):void 0,className:`transition-all ${o?m?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsx("div",{className:`w-4 h-4 rounded-full border ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:m&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-f})}),jsxs("div",{className:"col-span-4 min-w-0",children:[jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[p.changeDescription||"Snapshot",y&&jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider",children:"Auto"})]}),jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsx("div",{className:"col-span-3",children:p.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${p.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]})}),jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:p.createdBy||"system"}),jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsx("button",{type:"button",onClick:()=>e(p.id),className:"px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[11px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})})]}),jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsx("div",{className:"pt-0.5 shrink-0",children:o?jsx("div",{className:`w-4 h-4 rounded-full border ${m?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:m&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:u.length-f})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[p.changeDescription||"Snapshot",y&&jsx("span",{className:"text-[9px] px-1 py-0.5 bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)] rounded font-bold tracking-wider shrink-0",children:"Auto"})]}),jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(p.createdAt||p.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),p.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${p.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1 h-1 rounded-full ${p.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),p.status]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:p.createdBy||"system"})]})]}),!o&&jsx("button",{type:"button",onClick:()=>e(p.id),className:"shrink-0 px-2.5 py-1 rounded-lg border border-[var(--kyro-border)] text-[10px] font-bold tracking-wider text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] transition-all active:scale-95",children:"Restore"})]})]},p.id)})})]})})}function zu({collectionSlug:e,globalSlug:t}){let{t:r}=H(),{formData:o}=ye();return jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(o,null,2)})})]}),jsx("div",{className:"space-y-6",children:jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsx("div",{className:"bg-[var(--kyro-bg-secondary)] px-4 py-3 rounded-md border border-[var(--kyro-border)] text-[11px] font-mono break-all selection:bg-[var(--kyro-primary)]/20 text-[var(--kyro-text-primary)]",children:t?`kyro.globals('${t}').get()`:o.id?`kyro.collection('${e}').get('${o.id}')`:"Not saved yet"})]}),!!o.id&&jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:String(o.id)}),jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(o.id));},className:"p-1.5 hover:bg-[var(--kyro-bg-secondary)] rounded-lg transition-colors text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]",title:r("tooltips.copyId",{defaultValue:"Copy ID"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxs("div",{children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsx("code",{className:"text-xs font-mono bg-[var(--kyro-bg-secondary)] px-3 py-1.5 rounded-lg border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]",children:t})]})]})]})})]})})}var _s=class extends Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,r){console.error("[ErrorBoundary] Caught:",t,r),this.setState({errorInfo:r.componentStack||null});}handleCopyToClipboard=()=>{let{error:t,errorInfo:r}=this.state,o=ye.getState().formData,a={error:t?.message,stack:t?.stack,componentStack:r,formData:o,timestamp:new Date().toISOString()};navigator.clipboard.writeText(JSON.stringify(a,null,2)).then(()=>{j.success("Crash details copied to clipboard");});};handleReload=()=>{window.dispatchEvent(new Event("kyro:soft-reload"));};render(){return this.state.hasError?jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsx(TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] text-center max-w-md",children:"The form encountered an unexpected error. Your unsaved changes may still be recoverable."}),this.state.error&&jsx("p",{className:"text-xs font-mono text-red-500/70 bg-red-500/5 px-4 py-2 rounded-lg max-w-full overflow-auto",children:this.state.error.message}),jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxs("button",{type:"button",onClick:this.handleReload,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxs("button",{type:"button",onClick:this.handleCopyToClipboard,className:"flex items-center gap-2 px-4 py-2 text-sm font-bold rounded-xl bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/20 transition-colors",children:[jsx(Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function Hu(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>{if(r&&typeof r=="object"&&o in r)return r[o]},e)}function Nl(e,t,r){if(!e)return true;if("and"in e&&Array.isArray(e.and))return e.and.every(o=>Nl(o,t,r));if("or"in e&&Array.isArray(e.or))return e.or.some(o=>Nl(o,t,r));if("field"in e&&e.field){let o=e.field,a=Hu(t,o);return a===void 0&&(a=Hu(r,o)),"equals"in e?a===e.equals:"notEquals"in e?a!==e.notEquals:"in"in e&&Array.isArray(e.in)?e.in.includes(a):"greaterThan"in e&&e.greaterThan!==void 0?typeof a=="number"&&a>e.greaterThan:!!a}return true}var _u={};function xn({config:e,data:t=_u,errors:r=_u,onChange:o,disabled:a,collectionSlug:n,globalSlug:i,documentId:s,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:p}){let f=e||(i?yc[i]:n?la[n]:null),[m,y]=useState(f);useEffect(()=>{i&&!f?Me("/api/kyro/schema").then(B=>{let ee=B;ee?.globals?.[i]&&y(ee.globals[i]);}).catch(B=>console.error("[AutoForm] Failed to fetch dynamic schema",B)):y(f);},[i,f]);let v=m||f,{confirm:x}=vt(),{formData:h,hasUnsavedChanges:N,autoSaveStatus:k,lastSavedAt:g,view:z,setView:I,setShowPreview:ue,isMenuOpen:he,setIsMenuOpen:U,loadingFields:K,setLoadingFields:_,compareSelected:we,setCompareSelected:C,setCompareDiffs:Ne,setLoadingDiffs:Ve,setField:Fe,setFormData:mt,setLastSavedData:oe,setAutoSaveStatus:O,fetchVersions:X,saveDocument:de,forceSave:Ie,autoSaveSkipRef:ze,lastAutoSaveTimeRef:Tt,documentStatus:gr,hasUnpublishedChanges:Or,versionsEnabled:$}=wc({config:v,initialData:t,collectionSlug:n,globalSlug:i,documentId:s,onChange:o,onActionSuccess:c,onActionError:u}),ne=useRef(null),pe=useRef(null),[Ht,Wo]=useState(false),[Zs,T]=useState("idle"),[ve,je]=useState(false),[nr,Ot]=useState(Date.now()),Sr=a,[ei,qo]=useState(false),[Lp,ti]=useState(false),[Ep,Bp]=useState(0),Rl=useRef(new Map),Mp=3e4;useEffect(()=>{let B=i?`global:${i}`:`${n}:${s}`;if(!(i||n&&s&&s!=="new")||t&&Object.keys(t).length>0)return;let Ae=Rl.current.get(B),Ge=Ae&&Date.now()-Ae.ts<Mp,Ct=Ae&&!Ge;if(Ge){ye.getState().loadDocument(Ae.data,Ae.data);return}Ct&&ye.getState().loadDocument(Ae.data,Ae.data);let St=new AbortController;ti(false),Ae||qo(true);let Vr=i?`/api/globals/${i}`:`/api/${n}/${s}`;return Me(Vr,{autoToast:false,signal:St.signal}).then(bt=>{let Ao=bt.data||{};Rl.current.set(B,{data:Ao,ts:Date.now()}),ye.getState().loadDocument(Ao,Ao),qo(false);}).catch(bt=>{bt.name!=="AbortError"&&(qo(false),Ae||ti(true));}),()=>St.abort()},[n,s,i,t,Ep]),useEffect(()=>{let B=setInterval(()=>Ot(Date.now()),1e4);return ()=>clearInterval(B)},[]);let Fl=(B,ee)=>{if(typeof B=="function")try{return B(h,ee)}catch(Ae){return console.warn("Error evaluating admin runtime flag:",Ae),false}return !!B},$p=B=>{x({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let ee=i?Ye(`/api/globals/${i}/versions/${B}/restore`):Ye(`/api/${n}/${h.id}/versions/${B}/restore`),Ae=await ct(ee,{method:"POST"});!Ae.ok&&n&&(Ae=await ct(Ye(`/api/${n}/${h.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:B,action:"restore"})}));let Ge=await Ae.json();if(Ge.data){let{updatedAt:Ct,createdAt:St,...Vr}=Ge.data,bt={...h,...Vr};mt(bt),ye.getState().loadDocument(bt,bt),c?.("Version restored successfully"),X(),I("edit");}else j.error(Ge.error||"Failed to restore version");}catch(ee){console.error("Failed to restore version:",ee),j.error("Failed to restore version");}}});},Op=async()=>{if(we.length===2){Ve(true);try{let ee=await(await ct(Ye(`/api/${n}/${h.id}/versions?compareA=${we[0]}&compareB=${we[1]}`))).json();Ne(ee.diffs||[]);}catch(B){console.error("Compare failed:",B),Ne([]);}finally{Ve(false);}}},Vp=B=>{C(ee=>ee.includes(B)?ee.filter(Ae=>Ae!==B):ee.length>=2?[ee[1],B]:[...ee,B]);};useEffect(()=>{let B=ee=>{(ee.metaKey||ee.ctrlKey)&&ee.key==="s"&&(ee.preventDefault(),wn()),(ee.metaKey||ee.ctrlKey)&&ee.shiftKey&&(ee.key==="P"||ee.key==="p")&&(ee.preventDefault(),document.getElementById("btn-publish")?.click()),(ee.metaKey||ee.ctrlKey)&&!ee.shiftKey&&ee.key==="p"&&(ee.preventDefault(),ue(Ae=>!Ae)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(ee.key==="1"&&I("edit"),ee.key==="2"&&I("version"),ee.key==="3"&&I("api"));};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]),useEffect(()=>{let B=()=>I("version");return window.addEventListener("kyro:show-version-history",B),()=>window.removeEventListener("kyro:show-version-history",B)},[]),useEffect(()=>{let B=ee=>{ne.current&&!ne.current.contains(ee.target)&&U(false);};if(he)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[he]),useEffect(()=>{let B=ee=>{pe.current&&!pe.current.contains(ee.target)&&Wo(false);};if(Ht)return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[Ht]);let jp=()=>{N?x({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await wn(),await new Promise(B=>setTimeout(B,1e3)),Lt(`${_e}/${n}/new`);}}):Lt(`${_e}/${n}/new`);},Up=()=>{if(!h.id){j.error("Please save the document before duplicating.");return}let B=async()=>{try{je(!0);let ee=await ct(`/api/${n}/${h.id}/duplicate`,{method:"POST"});if(ee.ok){let Ae=await ee.json();c?.("Document duplicated successfully"),Ae.data?.id?Lt(`${_e}/${n}/${Ae.data.id}`):Lt(`${_e}/${n}`);}else {let Ae=await ee.json();j.error(Ae.error||"Failed to duplicate");}}catch{j.error("Failed to duplicate document");}finally{je(false);}};if(N){x({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await wn(),await B();}});return}x({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await B();}});},zp=()=>{x({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{ze.current=true;try{await Dt(`/api/${n}/${h.id}`),Lt(`${_e}/${n}`);}catch(B){j.error(B.message||"Failed to delete document");}finally{ze.current=false;}}});},Hp=()=>{x({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{ze.current=true;try{let B=await de({...h,status:"draft"},!1);if(B?.ok)c?.("Document unpublished successfully"),ye.getState().loadDocument({...h,status:"draft"},{...h,status:"draft"});else {let ee=await B?.json().catch(()=>({}));j.error(ee?.error||"Failed to unpublish");}}catch{j.error("Failed to unpublish");}finally{ze.current=false;}}});},wn=async()=>{let B=!h.id;ze.current=true,T("saving");try{let ee=qt({...h},!0),Ae=B&&!i,Ge=Ae?await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}):await de(ee);if(Ge.ok){let Ct=await Ge.json(),St=Ct.data||ee;ye.getState().loadDocument(St,St),Tt.current=Date.now(),O("success"),T("saved"),$&&X(),setTimeout(()=>{O("idle"),T("idle");},2e3),c?.(Ae?"Document created successfully":"Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload")),Ae&&setTimeout(()=>{Lt(`${_e}/${n}/${Ct.data.id}`);},800);}else {let Ct=await Ge.json();Ge.status===409&&O("conflict"),T("error"),j.error(Ct.error||"Failed to save"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),j.error("Failed to save document"),setTimeout(()=>T("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),ze.current=false;}},_p=async()=>{let B=!h.id;ze.current=true,T("saving");try{let ee={...h};if(B&&!i){let Ct=qt({...h},!0),St=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ct)});if(!St.ok){let Ao=await St.json().catch(()=>({}));St.status===409&&O("conflict"),T("error"),j.error(Ao.error||"Failed to create document"),setTimeout(()=>T("idle"),3e3);return}let bt=(await St.json()).data||Ct;ye.getState().loadDocument(bt,bt),ee=bt;}let Ae=qt(ee,!0),Ge=await de(Ae,!1);if(Ge?.ok){let St=(await Ge.json().catch(()=>({}))).data||Ae;ye.getState().loadDocument(St,St),T("saved"),c?.("Published successfully"),setTimeout(()=>{T("idle");},2e3),B&&!i&&ee.id&&setTimeout(()=>{Lt(`${_e}/${n}/${ee.id}`);},800);}else {if(B&&!i&&ee.id){let St=await Ge?.json().catch(()=>({}));j.warning("Document saved as draft. Publishing failed: "+(St?.error||"Unknown error")),setTimeout(()=>{Lt(`${_e}/${n}/${ee.id}`);},1200);return}let Ct=await Ge?.json().catch(()=>({}));Ge?.status===409&&O("conflict"),T("error"),j.error(Ct?.error||"Failed to publish"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),j.error("Failed to publish"),setTimeout(()=>T("idle"),3e3);}finally{ze.current=false;}},Kp=async B=>{let ee=!h.id;ze.current=true;try{let Ae={...qt({...h},!0),_schedulePublishAt:B};if(ee&&!i){let Ge=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ae)});if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));j.error(Ct.error||"Failed to schedule publish");return}}else {let Ge=await de(Ae);if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));j.error(Ct.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(B).toLocaleString()}`),Wo(!1);}catch{j.error("Failed to schedule publish");}finally{ze.current=false;}},Gp=(B,ee)=>{Fe(B,ee);},Oa=(B,ee,Ae)=>{let Ge=ee!==void 0?ee:h;if(Fl(B.hidden!==void 0?B.hidden:B.admin?.hidden,Ge))return null;let St=Fl(B.readOnly!==void 0?B.readOnly:B.admin?.readOnly,Ge),Vr=!!(Sr||St);if(B.admin?.condition){if(typeof B.admin.condition=="function")try{let dt={values:h||{},...h||{}};if(!B.admin.condition(dt,Ge))return null}catch(dt){console.warn(`Condition error for field ${B.name}:`,dt);}else if(typeof B.admin.condition=="object")try{if(!Nl(B.admin.condition,Ge,h))return null}catch(dt){console.warn(`Declarative condition error for field ${B.name}:`,dt);}}let bt=Ge[B.name],Ao=r[B.name],Nn=dt=>{Ae?Ae({...Ge,[B.name]:dt}):Gp(B.name,dt);};if(B.type==="row"&&"fields"in B){let dt=B.fields;return jsx("div",{className:"kyro-form-row flex flex-col md:flex-row gap-4 md:gap-6 items-start md:items-end w-full",children:dt?.map(nt=>{let jr=nt.admin||{},Cn=jr?.action;if((nt.type==="button"||nt.type==="action")&&Cn){let Ar=dt?.find(Va=>Va.type==="email");return jsx("div",{className:"flex-shrink-0",children:jsx("button",{type:"button",onClick:async()=>{let Va=B.name,Sn=Ar?.name,An=Sn?h[Sn]:void 0;if(!An&&Va&&typeof Va=="string"&&Sn&&(An=h[Va]?.[Sn]),!!An){_(Tr=>({...Tr,[nt.name]:true}));try{let Tr=await ct(Ye(Cn),{method:jr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:An})}),ja={};try{ja=await Tr.json();}catch{ja={};}if(Tr.ok&&ja.success)c?.(ja.message||"Action completed successfully");else {let Wp=ja.error||`Request failed (${Tr.status})`;u?.(Wp);}}catch(Tr){u?.(Tr instanceof Error?Tr.message:"Error connecting to server");}finally{_(Tr=>({...Tr,[nt.name]:false}));}}},disabled:K[nt.name]||Vr,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:K[nt.name]?"Sending...":nt.label||"Click"})},nt.name)}return jsx("div",{className:nt.type==="button"||nt.type==="action"?"flex-shrink-0":"flex-1",style:jr?.width?{width:jr.width,flex:"none"}:{},children:Oa(nt,ee,Ae)},nt.name)})},B.name||`row-${Math.random()}`)}switch(B.type){case "tabs":return jsx(Eu,{field:B,formData:h,onTabDataChange:dt=>{Fe(B.name,dt);},renderField:(dt,nt,jr)=>Oa(dt,nt,jr)},B.name||`tabs-${Math.random()}`);case "group":return jsx($s,{field:B,value:bt,onChange:Nn,renderField:Oa},B.name);case "array":return jsx(Os,{field:B,value:bt,onChange:Nn,renderField:Oa,disabled:Vr},B.name);case "button":case "action":{let dt=B.name,nt=K[dt];return jsx("div",{className:"kyro-form-field",children:jsxs("button",{type:"button",disabled:nt||Vr,onClick:async()=>{let jr=B.admin?.action||B.action,Cn=B.admin?.method||B.method||"POST";if(jr){_(Ar=>({...Ar,[dt]:true}));try{let Ar=await ct(jr,{method:Cn,headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});await Ar.json(),Ar.ok;}catch(Ar){console.error("Error executing action:",Ar);}finally{_(Ar=>({...Ar,[dt]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${nt?"opacity-70 cursor-not-allowed":""}`,children:[nt&&jsxs("svg",{className:"animate-spin h-3 w-3 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),nt?"Processing...":B.label||"Click"]})},dt)}case "relationship-block":return jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[B.label||B.name,B.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx(Za,{relationTo:B.relationTo,hasMany:B.hasMany,selectedIds:Array.isArray(bt)?bt:bt?[bt]:[],onChange:(dt,nt)=>{Nn(nt);},compact:true}),B.admin?.description?jsx("p",{className:"kyro-form-help",children:String(B.admin?.description)}):null]},B.name);default:return jsx(jo,{field:B,value:bt,onChange:Nn,error:Ao,disabled:Vr,formData:h,siblingData:Ge,collectionSlug:n,globalSlug:i},B.name||Math.random().toString())}};return ei||!v?jsxs("div",{className:"space-y-6 p-4",children:[jsxs("div",{className:"space-y-2",children:[jsx(Wt,{variant:"text",className:"w-1/3"}),jsx(Wt,{variant:"text",className:"w-2/3"})]}),jsx("div",{className:"space-y-4",children:jsx(Wt,{variant:"rect",count:4})})]}):Lp?jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsx(TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsx("button",{type:"button",onClick:()=>{ti(false),qo(true),Bp(B=>B+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsx(Vu,{collectionSlug:n,globalSlug:i,documentStatus:gr||"draft",hasUnpublishedChanges:Or,localSaveStatus:Zs,isDuplicating:ve,handleCreateNew:jp,handleDuplicate:Up,handleUnpublish:Hp,handleDelete:zp,handlePublish:_p,handleSaveDraft:wn,handleSchedulePublish:Kp,handleConflictOverride:()=>Ie()}),d==="single"&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsx(Check,{className:"w-4 h-4"}),g?`Saved ${Math.floor((Date.now()-g)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),N&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!N&&k!=="success"&&k!=="saving"&&k!=="error"&&jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:h.updatedAt?`Modified ${new Date(h.updatedAt).toLocaleString()}`:""})]}),jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{ze.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let B=await de(h);if(B.ok){let Ae=(await B.json()).data||h;mt({...h,...Ae}),oe({...h,...Ae}),c?.("Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(B){console.error("Save error exception:",B),u?.("Save failed: "+B.message);}finally{ze.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxs(_s,{children:[z==="edit"&&jsx(ju,{config:v,layout:d,collectionSlug:n,renderField:Oa}),z==="version"&&jsx(Uu,{handleRestoreVersion:$p,handleCompareVersions:Op,toggleCompareSelection:Vp}),z==="api"&&jsx(zu,{collectionSlug:n,globalSlug:i})]})})]})}var Ku={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Cl({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:i,onViewHistory:s,onPreview:l,onDelete:d,onBack:c,onToggleSidebar:u,publishedAt:p,updatedAt:f,onCopyData:m,onPasteData:y}){let{t:v}=H(),x=ye(w=>w.view)||"edit",h=ye(w=>w.setView),[S,N]=useState(false),V=useRef(null);useEffect(()=>{let w=D=>{V.current&&!V.current.contains(D.target)&&N(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);let P=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,k=["edit","version","api"],g=P(),b="p-1.5 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)] transition-all shrink-0";return jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-[var(--kyro-surface)] border-b border-[var(--kyro-border)] w-full overflow-x-auto",children:[c&&jsx("button",{type:"button",onClick:c,className:"p-1 rounded-lg hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] transition-all shrink-0",children:jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Ku[e]||"bg-[var(--kyro-text-muted)]"}`}),g&&jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsx(lr,{size:"sm",className:"inline mr-0.5"}),g]}),jsx("div",{className:"flex items-center gap-0.5 bg-[var(--kyro-bg-secondary)] p-0.5 rounded-lg border border-[var(--kyro-border)] shrink-0 max-md:hidden",children:k.map(w=>jsx("button",{type:"button",onClick:()=>h(w),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${x===w?"bg-[var(--kyro-surface)] shadow-sm border border-[var(--kyro-border)] text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)]"}`,children:w==="edit"?"Edit":w==="version"?"Ver":"API"},w))}),jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsx("button",{type:"button",onClick:l,className:`${b} max-md:hidden`,title:v("tooltips.preview",{defaultValue:"Preview"}),children:jsx(Eye,{className:"w-3.5 h-3.5"})}),s&&jsx("button",{type:"button",onClick:s,className:`${b} max-md:hidden`,title:v("tooltips.viewHistory",{defaultValue:"View History"}),children:jsx(Clock,{className:"w-3.5 h-3.5"})}),i&&jsx("button",{type:"button",onClick:i,className:`${b} max-md:hidden`,title:v("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),m&&jsx("button",{type:"button",onClick:m,className:`${b} max-md:hidden`,title:v("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),y&&jsx("button",{type:"button",onClick:y,className:`${b} max-md:hidden`,title:v("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsx("button",{type:"button",onClick:d,className:`${b} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:v("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})}),u&&jsx("button",{type:"button",onClick:u,className:`${b} max-md:hidden`,title:v("tooltips.toggleSidebar",{defaultValue:"Toggle Sidebar"}),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxs("div",{ref:V,className:"relative md:hidden",children:[jsx("button",{type:"button",onClick:()=>N(!S),className:b,title:v("tooltips.more",{defaultValue:"More"}),children:jsx(EllipsisVertical,{className:"w-3.5 h-3.5"})}),S&&jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-1 max-h-[70vh] overflow-y-auto",children:[g&&jsxs("div",{className:"px-3 py-2 text-[10px] text-[var(--kyro-text-muted)] border-b border-[var(--kyro-border)] flex items-center gap-1.5",children:[jsx("div",{className:`w-1.5 h-1.5 rounded-full ${Ku[e]}`}),jsx("span",{className:"capitalize",children:e}),jsx("span",{children:"\xB7"}),t==="saving"&&jsx(lr,{size:"sm",className:"inline"}),jsx("span",{children:g})]}),jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:k.map(w=>jsx("button",{type:"button",onClick:()=>{h(w),N(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${x===w?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:w==="edit"?"Edit":w==="version"?"Ver":"API"},w))}),s&&jsxs("button",{type:"button",onClick:()=>{s(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Clock,{className:"w-3.5 h-3.5"})," View History"]}),i&&jsxs("button",{type:"button",onClick:()=>{i(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),m&&jsxs("button",{type:"button",onClick:()=>{m(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),y&&jsxs("button",{type:"button",onClick:()=>{y(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),l&&jsxs("button",{type:"button",onClick:()=>{l(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:[jsx(Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxs("button",{type:"button",onClick:()=>{d(),N(false);},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger-bg)] transition-colors",children:[jsx(Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxs("button",{type:"button",onClick:a,disabled:t==="saving",className:"kyro-btn kyro-btn-primary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsx(Send,{className:"w-3.5 h-3.5"}),jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxs("button",{type:"button",onClick:n,disabled:t==="saving",className:"kyro-btn kyro-btn-secondary kyro-btn-sm flex items-center gap-1 shrink-0",children:[jsx(Undo,{className:"w-3.5 h-3.5"}),jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxs(Ho,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[i&&jsx(Ft,{icon:jsx(Copy,{className:"w-4 h-4"}),onClick:i,children:"Duplicate"}),m&&jsx(Ft,{icon:jsx(ClipboardCopy,{className:"w-4 h-4"}),onClick:m,children:"Copy Data"}),y&&jsx(Ft,{icon:jsx(ClipboardPaste,{className:"w-4 h-4"}),onClick:y,children:"Paste Data"}),s&&jsx(Ft,{icon:jsx(Clock,{className:"w-4 h-4"}),onClick:s,children:"View History"}),l&&jsx(Ft,{icon:jsx(Eye,{className:"w-4 h-4"}),onClick:l,children:"Preview"}),(i||m||y||s||l)&&jsx(hn,{}),d&&jsx(Ft,{onClick:d,danger:true,icon:jsx(Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Sl({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:i,onError:s,mode:l="collection"}){let{t:d}=H(),{confirm:c,alert:u}=vt(),[p,f]=useState({}),[m,y]=useState({}),[v,x]=useState(true),[h,S]=useState(false),[N,V]=useState(false),[P,k]=useState(false),[g,b]=useState("idle"),[w,D]=useState("draft"),[F,E]=useState(null),[R,M]=useState(null),[z,I]=useState(null),[J,Z]=useState(false),te=ye(O=>O.showPreview),Y=ye(O=>O.setShowPreview),ae=ye(O=>O.previewUrl),ue=ye(O=>O.setPreviewUrl),he=r?.fields||t?.fields||[],U=r?.label||t?.label||"Document",K=r?.slug||t?.slug||"",_=JSON.stringify(p)!==JSON.stringify(m);useEffect(()=>{_&&w==="published"&&D("draft");},[_,w]),useEffect(()=>{_&&g==="saved"&&b("idle");},[_,g]),useEffect(()=>{l==="global"?Be():o&&xe();},[o,l,K]);let xe=async()=>{try{x(!0);let O=await Me(`/api/${K}/${o}`,{autoToast:!1}),X=O.data||{};f(X),y(X),D(X?.status||O.status||"draft"),E(O.createdAt||X.createdAt||null),M(O.updatedAt||X.updatedAt||null),I(O.publishedAt||X.publishedAt||null);}catch{s("Failed to load document");}finally{x(false);}},Be=async()=>{try{x(!0);let O=await Me(`/api/globals/${K}`,{autoToast:!1}),X=O.data||{};f(X),y(X),E(O.createdAt||null),M(O.updatedAt||null);}catch{s("Failed to load global");}finally{x(false);}},we=useCallback(async(O=false)=>{try{b("saving");let X=l==="global"?`/api/globals/${K}`:`/api/${K}/${o}`,de=w==="draft"||p?.status==="draft",Ie=await er(X,p,{autoToast:!1,headers:{"X-Draft":String(de)}}),ze=Ie&&(Ie.data||Ie)||p;O||(y(ze),n()),f(ze),D(ze?.status||w),b("saved"),M(new Date().toISOString()),Z(!0),setTimeout(()=>Z(!1),3e3),O||(w==="draft"||ze?.status==="draft"?j.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):j.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{b("idle");},2e3),te&&mt(ze);}catch{b("error"),O||(s(d("toast.saveError",{defaultValue:"Failed to save changes"})),j.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{S(false);}},[p,l,K,o,w,n,s]),C=async()=>{try{S(!0),await er(`/api/${K}/${o}`,p,{autoToast:!1,headers:{"X-Draft":"false"}}),D("published"),I(new Date().toISOString()),j.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{s(d("toast.publishError",{defaultValue:"Failed to publish"})),j.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{S(false);}},G=async()=>{try{S(!0),await er(`/api/${K}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),D("draft"),j.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{s(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),j.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{S(false);}},Ne=async()=>{try{V(!0);let O=await ut(`/api/${K}/${o}/duplicate`,void 0,{autoToast:!1});j.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),O?.data?.id?Lt(`${_e}/${K}/${O.data.id}`):Lt(`${_e}/${K}`);}catch(O){j.error(O.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{V(false);}},Oe=async()=>{try{let O={...p};delete O.id,delete O.createdAt,delete O.updatedAt,delete O.status,await navigator.clipboard.writeText(JSON.stringify(O)),j.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{j.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},Ve=async()=>{try{let O=await navigator.clipboard.readText(),X=JSON.parse(O);if(typeof X!="object"||X===null)throw new Error("Invalid format");f(de=>({...de,...X,id:de.id,createdAt:de.createdAt,updatedAt:de.updatedAt,status:de.status})),j.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{j.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Fe=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:U}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{k(!0),await Dt(`/api/${K}/${o}`),Lt(`${_e}/${K}`);}catch{k(false);}}});},mt=async(O=p)=>{try{let X=l==="global"?`/api/globals/${K}/preview-url`:`/api/${K}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",X,"with data keys:",Object.keys(O||{}),"documentId:",o);let de=await ut(X,{...O,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(de)),de&&de.url?(console.log("[Kyro Preview] Setting previewUrl:",de.url),ue(de.url)):console.warn("[Kyro Preview] No url in response:",de);}catch(X){console.error("[Kyro Preview] Error:",X.message,X),j.error(X.message||"Failed to generate preview URL");}};useEffect(()=>{te&&mt(p);},[te]);let Cr=()=>{let O=!te;Y(O),O&&mt(p);};if(v)return jsx("div",{className:"kyro-detail",children:jsxs("div",{className:"space-y-6 p-4",children:[jsxs("div",{className:"space-y-2",children:[jsx(Wt,{variant:"text",className:"w-1/3"}),jsx(Wt,{variant:"text",className:"w-2/3"})]}),jsx("div",{className:"space-y-4",children:jsx(Wt,{variant:"rect",count:4})})]})});let oe=l==="global"||t?.admin?.layout==="single";return jsxs("div",{className:"kyro-detail",children:[jsx(jt,{back:{onClick:a},breadcrumbs:[{label:l==="global"?d("detailView.globals",{defaultValue:"Globals"}):d("detailView.collections",{defaultValue:"Collections"})},{label:U,href:l==="collection"?`${_e}/${K}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?U:Io(t?.fields,p,t?.admin?.useAsTitle||"title")||p.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||U}),metadata:[jsx(Et,{variant:w==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${w}`,{defaultValue:w})},"status")]}),jsx(Cl,{status:w,saveStatus:g,hasChanges:_,onSave:()=>we(false),onPublish:C,onUnpublish:w==="published"?G:void 0,onDuplicate:Ne,onCopyData:Oe,onPasteData:Ve,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:Cr,onDelete:Fe,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:z,updatedAt:R}),jsxs("div",{className:te?"w-full mx-auto grid grid-cols-1 lg:grid-cols-2 gap-4 md:gap-8 pt-4 md:pt-0 h-[calc(100vh-140px)]":oe?"w-full pt-4 md:pt-8":"w-full mx-auto grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-4 md:gap-8 pt-4 md:pt-0",children:[jsx("div",{className:`space-y-4 md:space-y-8 min-w-0 ${te?"overflow-y-auto pr-2 pb-20":""}`,children:jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:d("detailView.coreConfiguration",{defaultValue:"Core Configuration"})}),jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsx(xn,{config:t?{...t,fields:he}:{slug:"unknown",fields:he},data:p,onChange:f,layout:oe?"single":"split",globalSlug:l==="global"?K:void 0,collectionSlug:l==="collection"?K:void 0,onActionSuccess:O=>j.success(O),onActionError:O=>j.error(O),documentStatus:w,justSaved:J}),oe&&jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[l==="collection"&&o&&jsx("button",{type:"button",onClick:Fe,disabled:P||h,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:P?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsx(Ho,{status:w,saveStatus:h?"saving":"idle",hasChanges:_,onPublish:()=>we(false),disabled:h})]})]})}),te&&jsxs("div",{className:"surface-tile flex flex-col overflow-hidden h-full border border-[var(--kyro-border)] rounded-xl animate-in fade-in slide-in-from-right-4 duration-500 shadow-xl bg-white dark:bg-black",children:[jsxs("div",{className:"bg-[var(--kyro-surface-accent)] border-b border-[var(--kyro-border)] p-2 flex items-center justify-between shrink-0",children:[jsxs("div",{className:"flex items-center gap-2 pl-2",children:[jsx("div",{className:"w-3 h-3 rounded-full bg-red-400/80"}),jsx("div",{className:"w-3 h-3 rounded-full bg-amber-400/80"}),jsx("div",{className:"w-3 h-3 rounded-full bg-green-400/80"})]}),jsx("div",{className:"text-[10px] font-mono opacity-50 truncate max-w-[60%] bg-[var(--kyro-bg)] px-3 py-1 rounded",children:ae||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsx("div",{className:"w-16"})]}),jsx("div",{className:"flex-1 bg-white relative",children:ae?jsx("iframe",{src:ae,className:"w-full h-full border-0 bg-white",title:d("tooltips.preview",{defaultValue:"Preview"}),sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"}):jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsx(lr,{className:"w-6 h-6 text-[var(--kyro-primary)]"})})})]}),!oe&&!te&&jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:d("detailView.metadata",{defaultValue:"Metadata"})}),jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dynamicStatus",{defaultValue:"Dynamic Status"})}),jsx("div",{children:jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${w==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:w||"draft"})})]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.dateCreated",{defaultValue:"Date Created"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:F?new Date(F).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("common.na",{defaultValue:"N/A"})})]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.lastModified",{defaultValue:"Last Modified"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:R?new Date(R).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):d("detailView.justNow",{defaultValue:"Just now"})})]}),z&&jsxs("div",{className:"flex flex-col gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:d("detailView.publicAt",{defaultValue:"Public At"})}),jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(z).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:d("detailView.quickLinks",{defaultValue:"Quick Links"})}),jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsx("button",{type:"button",onClick:Ne,disabled:N||h,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:N?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),ae&&jsx("button",{type:"button",onClick:()=>window.open(ae,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:d("detailView.openPreview",{defaultValue:"Open Preview in New Tab"})}),jsx("button",{type:"button",onClick:Fe,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:d("actions.deleteEntry",{defaultValue:"Delete Entry"})})]})]})]})]})]})}function Al({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,i]=useState({}),[s,l]=useState(false),d=t.fields||[],c=t.label||t.slug,u=async p=>{try{l(!0),await ut(`/api/${t.slug}`,n),j.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(f){a(f instanceof Error?f.message:"Failed to create");}finally{l(false);}};return jsxs("div",{className:"kyro-detail",children:[jsx(jt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${_e}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:s?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>u(),disabled:s}}),jsx("div",{className:"kyro-detail-body",children:jsx("div",{className:"kyro-card",children:jsx("div",{className:"kyro-card-content",children:jsx("form",{children:jsx(xn,{config:{...t,fields:d},data:n,onChange:i})})})})})]})}function Gs(){let e=Zt(r=>r.toasts),t=Zt(r=>r.removeToast);return jsx("div",{className:"kyro-toasts-container",style:{position:"fixed",bottom:"24px",right:"24px",display:"flex",flexDirection:"column",gap:"12px",zIndex:1e5,pointerEvents:"none"},children:e.map(r=>jsx("div",{style:{pointerEvents:"auto"},children:jsx(Fc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Dl({onAuth:e,theme:t="light"}){let{t:r}=H(),[o,a]=useState("login"),[n,i]=useState(""),[s,l]=useState(""),[d,c]=useState(""),[u,p]=useState(false),[f,m]=useState(false),y=Zt(h=>h.addToast);useEffect(()=>{v();},[]);let v=async()=>{try{await Me("/api/users");}catch{m(true),a("register");}},x=async h=>{h.preventDefault(),p(true);try{let S=o==="login"?"/api/auth/login":"/api/auth/register",N={email:n,password:s};o==="register"&&(N.confirmPassword=d);let V=await ut(S,N);V.isFirstUser&&m(!0),localStorage.setItem("kyro_user",JSON.stringify(V.user)),y("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e(V.token,V.user);}catch{y("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{p(false);}};return jsx(Lr,{defaultMode:t,children:jsxs("div",{className:"kyro-login-page",children:[jsxs("div",{className:"kyro-login-container",children:[jsxs("div",{className:"kyro-login-header",children:[jsx("h1",{className:"kyro-login-title",children:f?r("login.createAdminAccount",{defaultValue:"Create Admin Account"}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})}),jsx("p",{className:"kyro-login-subtitle",children:f?r("login.setupAdmin",{defaultValue:"Set up your admin account to get started"}):o==="login"?r("login.enterCredentials",{defaultValue:"Enter your credentials to access the admin"}):r("login.createAccountDesc",{defaultValue:"Create an account to access the admin"})})]}),jsxs("form",{onSubmit:x,className:"kyro-login-form",children:[jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"email",children:r("login.email",{defaultValue:"Email"})}),jsx("input",{id:"email",type:"email",value:n,onChange:h=>i(h.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"password",children:r("login.password",{defaultValue:"Password"})}),jsx("input",{id:"password",type:"password",value:s,onChange:h=>l(h.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:o==="login"?"current-password":"new-password"})]}),o==="register"&&jsxs("div",{className:"kyro-form-group",children:[jsx("label",{htmlFor:"confirmPassword",children:r("login.confirmPassword",{defaultValue:"Confirm Password"})}),jsx("input",{id:"confirmPassword",type:"password",value:d,onChange:h=>c(h.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:u,children:u?o==="login"?r("login.signingIn",{defaultValue:"Signing in..."}):r("login.creatingAccount",{defaultValue:"Creating account..."}):o==="login"?r("login.signIn",{defaultValue:"Sign In"}):r("login.createAccount",{defaultValue:"Create Account"})})]}),!f&&jsx("div",{className:"kyro-login-footer",children:jsx("p",{children:o==="login"?jsxs(Fragment,{children:[r("login.noAccount",{defaultValue:"Don't have an account?"})," ",jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("register"),children:r("login.signUp",{defaultValue:"Sign up"})})]}):jsxs(Fragment,{children:[r("login.hasAccount",{defaultValue:"Already have an account?"})," ",jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>a("login"),children:r("login.signInAction",{defaultValue:"Sign in"})})]})})})]}),jsx(Gs,{})]})})}function Ju({collections:e,onNavigate:t,user:r}){let{t:o}=H(),{permissions:a}=eo(),[n,i]=useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=useState(true);useEffect(()=>{let c=setTimeout(()=>{i({totalDocs:124,totalMedia:856,totalUsers:12,recentActivity:[{id:1,type:"edit",user:"Daniel Dozie",doc:"Getting Started with Kyro",collection:"posts",time:"2m ago"},{id:2,type:"create",user:"Jane Smith",doc:"New Product Launch",collection:"products",time:"15m ago"},{id:3,type:"upload",user:"Daniel Dozie",doc:"hero-banner.jpg",collection:"media",time:"1h ago"},{id:4,type:"publish",user:"System",doc:"Weekly Update",collection:"posts",time:"3h ago"}]}),l(false);},800);return ()=>clearTimeout(c)},[]);let d=Object.entries(e).filter(([c])=>!Li.includes(c)&&a?.collections?.[c]?.read!==false);return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsx(jt,{title:o("dashboard.welcome",{defaultValue:"Welcome back, {{name}}",name:r?.email?.split("@")[0]||"Admin"}),description:o("dashboard.description",{defaultValue:"Everything looks great in your command center today."}),action:d.length>0&&a?.collections?.[d[0]?.[0]]?.create!==false?{label:o("actions.newDocument",{defaultValue:"New Document"}),onClick:()=>t("create",d[0]?.[0]),icon:Plus}:void 0}),jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:o("dashboard.totalContent",{defaultValue:"Total Content"}),value:n.totalDocs,icon:FileText,color:"text-blue-500"},{label:o("dashboard.mediaAssets",{defaultValue:"Media Assets"}),value:n.totalMedia,icon:Image,color:"text-purple-500"},{label:o("dashboard.activeUsers",{defaultValue:"Active Users"}),value:n.totalUsers,icon:Users,color:"text-green-500"},{label:o("dashboard.systemHealth",{defaultValue:"System Health"}),value:"100%",icon:Activity,color:"text-amber-500"}].map((c,u)=>jsxs("div",{className:"surface-tile p-6 flex items-center justify-between group hover:border-[var(--kyro-primary)] transition-all duration-500 cursor-default",children:[jsxs("div",{children:[jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:c.label}),jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsx(Wt,{variant:"text",className:"w-16"}):c.value})]}),jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${c.color}`,children:jsx(c.icon,{className:"w-6 h-6"})})]},u))}),jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxs("div",{className:"space-y-8 min-w-0",children:[jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsx(LayoutDashboard,{className:"w-5 h-5 opacity-40"}),o("dashboard.contentGrowth",{defaultValue:"Content Growth"})]}),jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:o("dashboard.contentGrowthDesc",{defaultValue:"Snapshot of document velocity over the last 7 days"})}),jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsx("defs",{children:jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60 L1000,200 L0,200 Z",fill:"url(#chartGradient)",className:"animate-pulse duration-[4s]"}),jsx("path",{d:"M0,180 Q100,140 200,160 T400,100 T600,120 T800,40 T1000,60",fill:"none",stroke:"var(--kyro-primary)",strokeWidth:"4",strokeLinecap:"round",vectorEffect:"non-scaling-stroke",className:"filter drop-shadow-[0_0_8px_var(--kyro-primary)]"})]}),jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsx("span",{children:o("days.mon",{defaultValue:"Mon"})}),jsx("span",{children:o("days.tue",{defaultValue:"Tue"})}),jsx("span",{children:o("days.wed",{defaultValue:"Wed"})}),jsx("span",{children:o("days.thu",{defaultValue:"Thu"})}),jsx("span",{children:o("days.fri",{defaultValue:"Fri"})}),jsx("span",{children:o("days.sat",{defaultValue:"Sat"})}),jsx("span",{children:o("days.sun",{defaultValue:"Sun"})})]})]}),jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:d.map(([c,u])=>jsxs("div",{onClick:()=>t("list",c),className:"p-6 rounded-2xl border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-bg-secondary)] hover:bg-[var(--kyro-surface)] transition-all cursor-pointer group",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:u.label||c}),jsx(ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:u.admin?.description||`Manage ${c} content.`})]},c))})]}),jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsx("div",{className:"flex items-center justify-between mb-4",children:jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsx(Plus,{className:"w-5 h-5"}),o("dashboard.quickLinks",{defaultValue:"Quick Links"})]})}),jsxs("div",{className:"space-y-3",children:[d.filter(([c])=>a?.collections?.[c]?.create!==false).map(([c])=>jsxs("button",{type:"button",onClick:()=>t("new",c),className:"w-full flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group/btn",children:[jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:o("dashboard.newAction",{defaultValue:"New {{item}}",item:e[c]?.singularLabel||e[c]?.label||c})}),jsx(Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},c)),d.every(([c])=>a?.collections?.[c]?.create===false)&&jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:o("dashboard.noCollections",{defaultValue:"No collections available for creation."})})]})]}),jsxs("div",{className:"surface-tile p-8 bg-[#0f172a] text-white border-none shadow-2xl shadow-blue-500/10 overflow-hidden relative group cursor-pointer",children:[jsxs("div",{className:"relative z-10",children:[jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:o("dashboard.mediaLibrary",{defaultValue:"Media Library"})}),jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:o("dashboard.mediaLibraryDesc",{defaultValue:"Manage high-fidelity assets with our liquid masonry gallery."})}),jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:[o("dashboard.openAssets",{defaultValue:"Open Assets"})," ",jsx(ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsx(Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxs("div",{className:"space-y-6",children:[jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsx(Clock,{className:"w-5 h-5 opacity-40"}),o("dashboard.recentActivity",{defaultValue:"Recent Activity"})]}),jsx("div",{className:"space-y-6",children:n.recentActivity.map(c=>jsxs("div",{className:"flex gap-4 group",children:[jsx("div",{className:"mt-1",children:jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--kyro-bg-secondary)] flex items-center justify-center border border-[var(--kyro-border)] group-hover:bg-[var(--kyro-primary)] transition-colors",children:jsx("span",{className:"text-[10px] font-bold",children:c.user[0]})})}),jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsx("span",{className:"font-bold",children:c.user})," ",c.type==="create"?"created":c.type==="edit"?"edited":c.type==="publish"?"published":"uploaded"," ",jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',c.doc,'"']})," ","in ",jsx("span",{className:"opacity-60",children:c.collection})]}),jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:c.time})]})]},c.id))}),jsx("button",{type:"button",className:"w-full mt-6 py-3 text-xs font-bold tracking-widest text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] transition-colors border-t border-[var(--kyro-border)] pt-6",children:o("dashboard.viewAuditLogs",{defaultValue:"View Audit Logs"})})]}),jsxs("section",{className:"surface-tile p-8",children:[jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsx(Activity,{className:"w-5 h-5 opacity-40"}),o("dashboard.systemStatus",{defaultValue:"System Status"})]}),jsx("div",{className:"space-y-4",children:[{label:o("dashboard.cloudApi",{defaultValue:"Cloud API"}),status:o("dashboard.statusOptimal",{defaultValue:"Optimal"}),pulse:"bg-green-500"},{label:o("dashboard.dbNode",{defaultValue:"Database Node"}),status:o("dashboard.statusHealthy",{defaultValue:"Healthy"}),pulse:"bg-green-500"},{label:o("dashboard.mediaCdn",{defaultValue:"Media CDN"}),status:o("dashboard.statusActive",{defaultValue:"Active"}),pulse:"bg-blue-500"},{label:o("dashboard.authService",{defaultValue:"Auth Service"}),status:o("dashboard.statusSecure",{defaultValue:"Secure"}),pulse:"bg-green-500"}].map((c,u)=>jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:c.label}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:c.status}),jsx("div",{className:`w-2 h-2 rounded-full ${c.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},u))})]})]})]})]})}function Yu(){let{t:e}=H(),[t,r]=useState([]),[o,a]=useState(true),[n,i]=useState(""),[s,l]=useState(false),[d,c]=useState({name:"",email:"",password:"",role:"customer"}),[u,p]=useState(""),[f,m]=useState(false),{confirm:y,alert:v}=vt();useEffect(()=>{x();},[]);let x=async()=>{try{a(!0);let k=await Me("/api/users");r(k.docs||[]);}catch(k){console.error("Failed to load users:",k);}finally{a(false);}},h=k=>{let g=!k.locked;y({title:g?"Lock User Account?":"Unlock User Account?",message:g?`Are you sure you want to lock ${k.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${k.email}?`,variant:g?"danger":"success",onConfirm:async()=>{try{await er(`/api/users/${k.id}`,{locked:g}),r(b=>b.map(w=>w.id===k.id?{...w,locked:g}:w)),j.success(g?`Account locked: ${k.email}`:`Account restored: ${k.email}`);}catch(b){console.error("Failed to toggle user lock:",b),j.error("Failed to update account status");}}});},S=k=>{y({title:"Destroy User Account",message:`You are about to permanently delete ${k.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Dt(`/api/users/${k.id}`),r(g=>g.filter(b=>b.id!==k.id)),j.success(`Identity purged: ${k.email}`);}catch(g){console.error("Failed to delete user:",g),j.error("Failed to delete user");}}});},N=async()=>{if(!d.email.trim()||!d.password.trim()){p("Email and password are required");return}m(true),p("");try{await ut("/api/users",{name:d.name.trim()||void 0,email:d.email.trim(),password:d.password,role:d.role}),l(!1),c({name:"",email:"",password:"",role:"customer"}),j.success("User created successfully"),x();}catch(k){let g=k instanceof Error?k.message:"Failed to create user";p(g),j.error(g);}finally{m(false);}},V=["super_admin","admin","editor","author","customer","guest"],P=t.filter(k=>k.email.toLowerCase().includes(n.toLowerCase())||k.name?.toLowerCase().includes(n.toLowerCase()));return jsxs("div",{className:"w-full space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-700 px-4 md:px-8 pb-12",children:[jsx(jt,{title:e("tooltips.identityAccess",{defaultValue:"Identity & Access"}),description:"Manage the core administrative team and security permissions.",icon:Users,action:{label:"New User",onClick:()=>{c({name:"",email:"",password:"",role:"customer"}),p(""),l(true);},icon:UserPlus}}),jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxs("div",{className:"relative flex-1 group",children:[jsx(Search,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-secondary)] opacity-40 group-focus-within:opacity-100 transition-opacity"}),jsx("input",{type:"text",placeholder:e("fields.searchByIdentityOr",{defaultValue:"Search by identity or email..."}),value:n,onChange:k=>i(k.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-sidebar-active)] transition-all text-xs font-bold"})]}),jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest bg-[var(--kyro-surface)] shadow-sm rounded-lg border border-[var(--kyro-border)]",children:"ALL"}),jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsx("div",{className:"surface-tile overflow-x-auto",children:jsxs("table",{className:"w-full text-left",children:[jsx("thead",{children:jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[9px] tracking-[0.2em] uppercase border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:o?Array.from({length:6}).map((k,g)=>jsx("tr",{className:"animate-pulse",children:jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},g)):P.length===0?jsx("tr",{children:jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):P.map(k=>jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${k.locked?"opacity-50 grayscale":""}`,children:[jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-3",children:[jsx(gv,{user:k}),jsxs("div",{className:"min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:k.name||k.email.split("@")[0]}),k.tenantId&&jsx(Et,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:k.tenantId})]}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:k.email})]})]})}),jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:k.role})]})}),jsx("td",{className:"px-6 py-3.5",children:jsx(Et,{variant:k.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:k.locked?"Restricted":"Authorized"})}),jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsx(Clock,{className:"w-3 h-3"}),k.lastLogin?new Date(k.lastLogin).toLocaleDateString():"Never"]})}),jsx("td",{className:"px-6 py-3.5 text-right",children:jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsx("button",{onClick:()=>h(k),className:`p-1.5 rounded-lg border transition-all ${k.locked?"bg-green-500/10 text-green-500 border-green-500/20 hover:bg-green-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20"}`,title:k.locked?"Restore Access":"Restrict Access",children:k.locked?jsx(LockOpen,{className:"w-3.5 h-3.5"}):jsx(Lock,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>S(k),className:"p-1.5 rounded-lg border border-red-500/20 bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all",title:e("tooltips.deleteUser",{defaultValue:"Delete User"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})})]})})]},k.id))})]})}),jsxs(At,{open:s,onClose:()=>l(false),title:e("tooltips.createUser",{defaultValue:"Create User"}),size:"lg",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsx("input",{type:"text",value:d.name,onChange:k=>c({...d,name:k.target.value}),placeholder:e("fields.johnDoe",{defaultValue:"John Doe"}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsx("input",{type:"email",value:d.email,onChange:k=>c({...d,email:k.target.value}),placeholder:"user@example.com",required:true,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsx("input",{type:"password",value:d.password,onChange:k=>c({...d,password:k.target.value}),placeholder:e("fields.minimum12Characters",{defaultValue:"Minimum 12 characters"}),required:true,minLength:12,className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),jsxs("div",{children:[jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsx("select",{value:d.role,onChange:k=>c({...d,role:k.target.value}),className:"w-full px-4 py-3 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]",children:V.map(k=>jsx("option",{value:k,children:k},k))})]}),u&&jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-xl flex items-center gap-2 text-red-500 text-xs font-bold",children:[jsx(TriangleAlert,{className:"w-4 h-4"}),u]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>l(false),className:"px-6 py-2.5 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Cancel"}),jsx("button",{type:"button",onClick:N,disabled:f,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:f?"Creating...":"Create User"})]})]})]})}function gv({user:e}){let[t,r]=useState(null);return useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Me(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsx("div",{className:"w-8 h-8 rounded-lg bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] flex items-center justify-center text-xs font-bold text-[var(--kyro-primary)] flex-shrink-0",children:e.name?e.name[0]:e.email[0].toUpperCase()})}function Qu(){let{t:e}=H(),[t,r]=useState("Kyro CMS"),[o,a]=useState("Command Center"),[n,i]=useState("#6366f1"),[s,l]=useState("Welcome back to your Command Center."),[d,c]=useState(false),[u,p]=useState(false);useEffect(()=>{(async()=>{try{let v=await Me("/api/globals/site-settings"),x=v.data||v;x&&Object.keys(x).length>0&&(x.siteName&&r(x.siteName),x.adminTitle&&a(x.adminTitle),x.primaryColor&&i(x.primaryColor),x.dashboardGreeting&&l(x.dashboardGreeting));}catch(v){console.error("Failed to load branding:",v);}})();},[]);let f=async()=>{c(true);try{await er("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:s}),p(!0),j.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.dispatchEvent(new Event("kyro:soft-reload")),800);}catch(y){j.error("Failed to save branding"),console.error(y);}finally{c(false);}},m=[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}];return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxs("div",{children:[jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsx("div",{className:"flex items-center gap-3",children:jsxs("button",{type:"button",onClick:f,disabled:d,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${u?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[d?jsx(RefreshCcw,{className:"w-4 h-4 animate-spin"}):u?jsx(Check,{className:"w-4 h-4"}):jsx(Save,{className:"w-4 h-4"}),d?"Saving...":u?"Identity Updated":"Publish Branding"]})})]}),jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsx(Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsx("input",{type:"text",value:t,onChange:y=>r(y.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Acme Corp CMS"})]}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsx("input",{type:"text",value:o,onChange:y=>a(y.target.value),className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all",placeholder:"e.g. Command Center"})]}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsx("textarea",{value:s,onChange:y=>l(y.target.value),rows:3,className:"w-full bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)] rounded-xl py-3 px-4 text-sm font-bold focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all resize-none",placeholder:e("fields.greetingTextForThe",{defaultValue:"Greeting text for the dashboard..."})})]})]})]}),jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsx(Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxs("div",{className:"space-y-8",children:[jsxs("div",{className:"space-y-4",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsx("div",{className:"grid grid-cols-6 gap-3",children:m.map(y=>jsx("button",{type:"button",onClick:()=>i(y.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===y.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:y.hex},title:y.name},y.name))})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxs("div",{className:"flex items-center gap-6",children:[jsxs("div",{className:"w-20 h-20 rounded-2xl bg-[var(--kyro-bg-secondary)] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center text-[var(--kyro-text-secondary)] hover:border-[var(--kyro-primary)] hover:text-[var(--kyro-primary)] cursor-pointer transition-all",children:[jsx(Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxs("div",{className:"flex-1",children:[jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsx(Sparkles,{className:"w-4 h-4"}),jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxs("div",{className:"inline-flex items-center gap-3 px-4 py-2 bg-[var(--kyro-bg-secondary)] rounded-full border border-[var(--kyro-border)]",children:[jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[o," Online"]})]}),jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",t,"."]}),jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsx("style",{dangerouslySetInnerHTML:{__html:`
110
110
  :root {
111
111
  --kyro-primary-temp: ${n};
112
112
  }
113
113
  .preview-btn {
114
114
  background-color: var(--kyro-primary-temp);
115
115
  }
116
- `}})]})]})]})}var kv=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Zu({collections:e}){let{t}=H(),[r,o]=useState([]),[a,n]=useState(false),[i,s]=useState(null),[l,d]=useState(""),[c,u]=useState(null),[p,f]=useState(false),{confirm:m,alert:y}=vt(),[v,x]=useState(false),[h,S]=useState(""),N=async()=>{try{let b=await Me("/api/keys");o(b);}catch(b){console.error(b);}};useEffect(()=>{N();},[]);let V=async()=>{S(""),x(true);},P=async()=>{if(h.trim())try{await ut("/api/keys",{name:h}),N(),x(!1),S(""),j.success("API key generated");}catch(b){console.error(b),j.error("Failed to generate API key");}},k=b=>{m({title:"Revoke API Key",message:"Are you sure you want to revoke this key? Any integrations using it will stop working.",variant:"danger",onConfirm:async()=>{try{await Dt(`/api/keys/${b}`),N(),j.success("API key revoked");}catch(w){console.error(w),j.error("Failed to revoke API key");}}});},g=async()=>{if(l){f(true);try{let w=await(await fetch(Ye(`/api/${l}`))).json();u(w);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{f(false);}}};return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsx(jt,{title:t("tooltips.developerCenter",{defaultValue:"Developer Center"}),description:"Provision access keys and explore the headless API ecosystem.",icon:CodeXml,actions:[{label:"Generate Key",onClick:V,icon:Key}]}),jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsx("div",{className:"space-y-4",children:r.length===0?jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsx(Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):r.map(b=>jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsx(Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:b.name})]}),jsxs("div",{className:"flex-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl px-4 py-3 flex items-center justify-between group/key overflow-hidden",children:[jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:i===b.id?b.key:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsx("button",{type:"button",onClick:()=>s(i===b.id?null:b.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:i===b.id?jsx(EyeOff,{className:"w-4 h-4"}):jsx(Eye,{className:"w-4 h-4"})}),jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(b.key),j.success("API key copied to clipboard");},children:jsx(Copy,{className:"w-4 h-4"})})]})]}),jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Issued:"}),jsx("span",{children:new Date(b.createdAt).toLocaleDateString()})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Status:"}),jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsx("button",{type:"button",onClick:()=>k(b.id),className:"p-3.5 bg-red-500/5 text-red-500 rounded-2xl hover:bg-red-500/10 transition-all border border-transparent hover:border-red-500/30 self-start md:self-center",title:t("tooltips.revokeKey",{defaultValue:"Revoke Key"}),children:jsx(Trash2,{className:"w-5 h-5"})})]})},b.id))})]}),jsxs("section",{className:"space-y-6",children:[jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsx(Terminal,{className:"w-48 h-48 rotate-12"})}),jsxs("div",{className:"relative z-10",children:[jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsx(Terminal,{className:"w-6 h-6 text-white"})}),jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsx(ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxs("div",{className:"space-y-5",children:[jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsx(Et,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxs("div",{className:"group relative",children:[jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsx(Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsx(Et,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxs("div",{className:"group relative",children:[jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsx(Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsx(CirclePlay,{className:"w-96 h-96"})}),jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxs("div",{className:"max-w-xl",children:[jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsx(CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",kv,"/"]}),jsx("input",{type:"text",value:l,onChange:b=>d(b.target.value),placeholder:"collection-slug",className:"w-full py-4 bg-transparent focus:outline-none font-mono text-sm font-bold text-[var(--kyro-primary)]"})]}),jsxs("button",{type:"button",onClick:g,disabled:p||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[p?jsx(RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsx(ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsx(Et,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsx(bv,{value:JSON.stringify(c,null,2),height:"450px",theme:aura,extensions:[json()],editable:false,className:"text-sm"})]})]}):jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsx(CodeXml,{className:"w-10 h-10"})}),jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxs(At,{open:v,onClose:()=>x(false),title:t("tooltips.generateAccessToken",{defaultValue:"Generate Access Token"}),size:"lg",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsx("input",{type:"text",value:h,onChange:b=>S(b.target.value),placeholder:"e.g., Mobile App SDK, Production Server",className:"w-full px-6 py-4 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)] shadow-sm transition-all",onKeyDown:b=>b.key==="Enter"&&P()})]})]})}),jsxs(_r,{children:[jsx("button",{type:"button",onClick:()=>x(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsx("button",{type:"button",onClick:P,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function ep(e){let[t,r]=useState([]),[o,a]=useState(false),[n,i]=useState(null),[s,l]=useState(false),{confirm:d}=vt(),c=useCallback(async()=>{a(true),i(null);try{let m=await Me(e.endpoint),y=Array.isArray(m)?m:m.docs||[],v=e.transformLoad?e.transformLoad(y):y;r(v),e.onSuccess?.("load",v);}catch(m){let y=m instanceof Error?m.message:"Failed to load resources";i(y),e.onError?.("load",m);}finally{a(false);}},[e.endpoint,e.transformLoad]);useEffect(()=>{c();},[c]);let u=useCallback((m,y="item")=>{d({title:`Delete ${y}`,message:`Are you sure you want to delete this ${y.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`${e.endpoint}/${m}`),r(v=>v.filter(x=>x.id!==m)),e.onSuccess?.("delete",m),j.success(`${y} deleted`);}catch(v){let x=v instanceof Error?v.message:`Failed to delete ${y}`;j.error(x),e.onError?.("delete",v);}}});},[e.endpoint,d]),p=useCallback(async m=>{i(null);try{let y=await ut(e.endpoint,m);return r(v=>[y,...v]),l(!1),e.onSuccess?.("create",y),y}catch(y){let v=y instanceof Error?y.message:"Failed to create resource";throw i(v),e.onError?.("create",y),y}},[e.endpoint]),f=useCallback(async(m,y)=>{i(null);try{let v=await er(`${e.endpoint}/${m}`,y);return r(x=>x.map(h=>h.id===m?v:h)),e.onSuccess?.("update",v),v}catch(v){let x=v instanceof Error?v.message:"Failed to update resource";throw i(x),e.onError?.("update",v),v}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:p,update:f,isCreateModalOpen:s,setIsCreateModalOpen:l}}var Cv={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function tp(){let{t:e}=H(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:i,setIsCreateModalOpen:s}=ep({endpoint:"/api/webhooks"}),{confirm:l}=vt(),[d,c]=useState(false),[u,p]=useState(false),[f,m]=useState(null),[y,v]=useState(null),[x,h]=useState({}),[S,N]=useState(true),[V,P]=useState("action"),[k,g]=useState("generic"),[b,w]=useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[D,F]=useState(""),[E,R]=useState(false),[M,z]=useState(null),[I,J]=useState([]),[Z,te]=useState(false);useEffect(()=>{Y();},[]);let Y=async()=>{try{let C=await Me("/api/webhooks/actions");h(C.actions);}catch(C){console.error("Failed to load webhook actions:",C);}finally{N(false);}},ae=()=>{P("action"),g("generic"),w({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),F("");},ue=C=>{g(C),w(G=>({...G,action:C,config:{}})),P("config");},he=(C,G)=>{w(Ne=>({...Ne,config:{...Ne.config,[C]:G}}));},U=async()=>{if(!b.name.trim()){F("Name is required");return}if(k==="generic"&&!b.url.trim()){F("URL is required for custom webhooks");return}let C=x[k];if(C){for(let G of C.configFields)if(G.required&&!b.config[G.name]?.trim()){F(`${G.label} is required`);return}}try{await o(b),ae(),j.success(`Webhook created: ${b.name}`);}catch(G){let Ne=G.message||"Failed to create webhook";F(Ne),j.error(Ne);}},K=async C=>{v(C),m(null),c(true);try{let G=await ut(`/api/webhooks/${C}/test`);m({success:!0,message:G.message||"Webhook triggered successfully"}),j.success("Test delivered successfully");}catch{m({success:false,message:"Failed to trigger webhook"});}},_=async(C,G)=>{try{let Ne=G==="active"?"paused":"active";await n(C,{status:Ne}),j.success(Ne==="active"?"Webhook activated":"Webhook paused");}catch(Ne){console.error(Ne),j.error("Failed to toggle webhook status");}},xe=async C=>{z(C),R(true),te(true);try{let G=await Me(`/api/webhooks/${C}/history`);J(G.docs||[]);}catch(G){console.error("Failed to load history:",G),j.error("Failed to load delivery history");}finally{te(false);}},Be=[{label:"Create",value:"create",description:"When a new document is created"},{label:"Update",value:"update",description:"When a document is updated"},{label:"Delete",value:"delete",description:"When a document is deleted"},{label:"Auth",value:"auth",description:"User login/logout events"}],we=C=>x[C||"generic"]?.label||"Custom URL";return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsx(jt,{title:e("tooltips.webhooks",{defaultValue:"Webhooks"}),description:"Get notified when your content changes.",icon:Webhook,actions:[{label:"New webhook",onClick:()=>{ae(),s(true);},icon:Plus},{label:"Guide",onClick:()=>p(true),icon:Info,variant:"outline"}]}),jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsx(Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsx("div",{className:"flex-1 text-center md:text-left",children:jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxs("section",{className:"space-y-6",children:[jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[t.length," hook",t.length!==1&&"s"]})]}),r?jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):t.length===0?jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsx(Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxs("button",{type:"button",onClick:()=>{ae(),s(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsx(Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsx("div",{className:"grid gap-4",children:t.map(C=>jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsx(Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold",children:C.name}),jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsx("span",{className:`text-[10px] font-medium ${C.status==="active"?"text-green-500":"text-amber-500"}`,children:C.status}),jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:we(C.action)})]})]})]}),jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxs("div",{className:"space-y-1",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:C.url,children:C.url||`${we(C.action)} webhook`})]}),jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxs("div",{className:"flex flex-wrap gap-1",children:[C.events.slice(0,3).map(G=>jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:G},G)),C.events.length>3&&jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",C.events.length-3]})]})]}),jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsx(Clock,{className:"w-3 h-3"}),C.lastTriggered?`Last triggered ${new Date(C.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),C.lastError&&jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsx(XCircle,{className:"w-3 h-3"}),jsx("span",{className:"truncate max-w-[150px]",title:C.lastError,children:C.lastError})]})]})]})]}),jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxs("button",{type:"button",onClick:()=>xe(C.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.viewDeliveryHistory",{defaultValue:"View delivery history"}),children:[jsx(Activity,{className:"w-3.5 h-3.5"}),jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxs("button",{type:"button",onClick:()=>K(C.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.sendTestRequest",{defaultValue:"Send test request"}),children:[jsx(Send,{className:"w-3.5 h-3.5"}),jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsx("button",{type:"button",onClick:()=>_(C.id,C.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${C.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:C.status==="active"?"Pause":"Activate",children:C.status==="active"?jsx(Pause,{className:"w-3.5 h-3.5"}):jsx(Play,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:()=>a(C.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:e("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},C.id))})]}),jsx(At,{open:i&&V==="action",onClose:()=>s(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsx(Ir,{children:jsx("div",{className:"space-y-4",children:S?jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsx(RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(x).map(([C,G])=>jsxs("button",{type:"button",onClick:()=>ue(C),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsx("div",{className:"text-lg mb-2",children:Cv[C]||"\u{1F517}"}),jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:G.label}),jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:G.description}),G.envVars.length>0&&jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:G.envVars.map(Ne=>jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:Ne},Ne))})]},C))})})})}),jsxs(At,{open:i&&V==="config",onClose:()=>s(false),title:x[k]?.label||"Webhook",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-5",children:[jsxs("div",{className:"flex flex-col gap-5",children:[jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsx("input",{type:"text",value:b.name,onChange:C=>w({...b,name:C.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k==="generic"&&jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsx("input",{type:"url",value:b.url,onChange:C=>w({...b,url:C.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k!=="generic"&&x[k]?.configFields.map(C=>jsxs("div",{children:[jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[C.label," ",C.required&&jsx("span",{className:"text-red-500",children:"*"})]}),jsx("input",{type:"text",value:b.config[C.name]||"",onChange:G=>he(C.name,G.target.value),placeholder:C.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},C.name)),k==="generic"&&jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsx("input",{type:"text",value:b.secret,onChange:C=>w({...b,secret:C.target.value}),placeholder:e("fields.optional",{defaultValue:"Optional"}),className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),k!=="generic"&&x[k]?.envVars.length>0&&jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsx(TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsx("div",{className:"flex flex-wrap gap-1.5",children:x[k].envVars.map(C=>jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[C,"=..."]},C))})]}),jsxs("div",{className:"space-y-3",children:[jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Be.map(C=>jsxs("button",{type:"button",onClick:()=>{let G=b.events.includes(C.value)?b.events.filter(Ne=>Ne!==C.value):[...b.events,C.value];w({...b,events:G});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${b.events.includes(C.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${b.events.includes(C.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b.events.includes(C.value)&&jsx(CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxs("div",{children:[jsx("div",{className:"text-xs font-medium",children:C.label}),jsx("div",{className:"text-[10px] opacity-40",children:C.description})]})]},C.value))})]})]}),D&&jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsx(TriangleAlert,{className:"w-3.5 h-3.5"}),D]})]})}),jsxs(_r,{children:[jsx("button",{type:"button",onClick:()=>P("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsx("button",{type:"button",onClick:U,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxs(At,{open:d,onClose:()=>c(false),title:e("tooltips.testWebhook",{defaultValue:"Test webhook"}),children:[jsx(Ir,{children:jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:f?jsxs("div",{className:"space-y-4",children:[jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${f.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:f.success?jsx(CircleCheck,{className:"w-6 h-6"}):jsx(TriangleAlert,{className:"w-6 h-6"})}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-semibold mb-1",children:f.success?"Delivered":"Failed"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:f.message})]})]}):jsxs("div",{className:"space-y-4 py-4",children:[jsx(RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsx(_r,{children:jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxs(At,{open:u,onClose:()=>p(false),title:e("tooltips.howWebhooksWork",{defaultValue:"How webhooks work"}),children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsx(ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsx(Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxs("div",{className:"space-y-2",children:[jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsx("div",{children:"{"}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsx("div",{children:"}"})]})})]})]})}),jsx(_r,{children:jsx("button",{type:"button",onClick:()=>p(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxs(At,{open:E,onClose:()=>R(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsx(Ir,{children:jsx("div",{className:"space-y-4",children:Z?jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsx(RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):I.length===0?jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:I.map(C=>jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[C.status==="success"?jsx(CircleCheck,{className:"w-4 h-4 text-green-500"}):jsx(XCircle,{className:"w-4 h-4 text-red-500"}),jsx("span",{className:"font-medium",children:C.event})]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(C.createdAt).toLocaleString()})]}),jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxs("div",{children:[jsx("span",{className:"opacity-50",children:"Status: "}),jsx("span",{className:`font-medium ${C.status==="success"?"text-green-500":"text-red-500"}`,children:C.responseStatus||C.status})]}),jsxs("div",{children:[jsx("span",{className:"opacity-50",children:"Duration: "}),C.duration?`${C.duration}ms`:"-"]})]}),C.error&&jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:C.error}),C.responseBody&&jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:C.responseBody})]},C.id))})})}),jsx(_r,{children:jsx("button",{type:"button",onClick:()=>R(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function ap({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{t:n}=H(),{user:i,permissions:s}=Zr(),[l,d]=useState(""),[c,u]=useState(0),[p,f]=useState(false),[m,y]=useState([]),v=useRef(null),x=useRef(null);useEffect(()=>{e&&(d(""),u(0),y([]),f(false),setTimeout(()=>v.current?.focus(),100));},[e]);let h=useCallback(async R=>{if(!R||R.length<2){y([]);return}f(true);try{let z=await(await fetch(Ye(`/api/search?q=${encodeURIComponent(R)}&limit=15`))).json();z.results&&y(z.results);}catch(M){console.error("Search error:",M),y([]);}finally{f(false);}},[]);if(useEffect(()=>(x.current&&clearTimeout(x.current),l.length>=2?x.current=setTimeout(()=>h(l),300):y([]),()=>{x.current&&clearTimeout(x.current);}),[l,h]),!e)return null;let S=Object.entries(r).filter(([R])=>s?.collections?.[R]?.read!==false).map(([R,M])=>({id:`col-${R}`,label:M.label||R,type:"collection",slug:R,icon:FileText})),N=Object.entries(o).filter(([R])=>s?.globals?.[R]?.read!==false).map(([R,M])=>({id:`global-${R}`,label:M.label||R,type:"global",slug:R,icon:Settings})),V=typeof document<"u"&&document.documentElement.classList.contains("dark"),P=i?.role==="admin",k=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Clock,visible:P},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:File,visible:P},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Shield,visible:P},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Database,visible:P},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Hexagon,visible:P},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Network,visible:P},{id:"action-theme",label:V?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:V?Sun:Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:LogOut,visible:true}].filter(R=>R.visible),g=m.map((R,M)=>({id:`doc-${R.collection}-${R.id}`,label:R.title,type:"document",collection:R.collection,label2:R.label,docId:R.id,icon:File,doc:R.doc})),b=l.length>=2?[...k,...S,...N,...g]:[...k,...S,...N],w=l===""?b:b.filter(R=>R.label.toLowerCase().includes(l.toLowerCase())),D=R=>{if(R.key==="ArrowDown")R.preventDefault(),u(M=>(M+1)%w.length);else if(R.key==="ArrowUp")R.preventDefault(),u(M=>(M-1+w.length)%w.length);else if(R.key==="Enter"){let M=w[c];M&&F(M);}else R.key==="Escape"&&t();},F=R=>{R.type==="collection"?R.slug==="users"?a(R.slug,R.slug):a("list",R.slug):R.type==="global"?a("settings",R.slug):R.type==="document"?R.collection==="users"?a("users","users",R.docId):a("edit",R.collection,R.docId):R.type==="action"&&(R.view==="users"?a("users","users"):R.view==="media"?a("media","media"):a(R.view,R.view)),t();},E=()=>l===""?"Quick Actions & Collections":m.length>0?"Documents":p?"Searching...":"Search Results";return jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[p?jsx(LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsx(Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsx("input",{ref:v,placeholder:n("fields.searchAnything",{defaultValue:"Search anything..."}),className:"flex-1 bg-transparent border-none focus:outline-none text-lg font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)]",value:l,onChange:R=>d(R.target.value),onKeyDown:D}),jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:w.length>0?jsxs("div",{className:"space-y-1 px-4",children:[jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:E()}),w.map((R,M)=>jsxs("div",{onClick:()=>F(R),onMouseEnter:()=>u(M),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${M===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:`p-2 rounded-xl ${M===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsx(R.icon,{className:"w-4 h-4"})}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"font-bold text-sm",children:R.label}),R.type==="document"&&R.label2&&jsx("span",{className:`text-[10px] font-bold tracking-widest ${M===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:R.label2})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${M===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:R.type}),M===c&&jsx(ArrowRight,{className:"w-4 h-4 mr-2"})]})]},R.id))]}):jsx("div",{className:"py-12 text-center",children:jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!p?`No results found for "${l}"`:"Start typing to search..."})})}),jsxs("div",{className:"px-8 py-4 bg-[var(--kyro-bg-secondary)] border-t border-[var(--kyro-border)] flex items-center justify-between text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-60",children:[jsxs("div",{className:"flex gap-6",children:[jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsx("div",{children:"Kyro Universal Search"})]})]})]})}function np(){let{modal:e,closeModal:t}=vt(),[r,o]=useState(false);if(!e.open||!e.config)return null;let{config:a}=e,n=async()=>{if(a.onConfirm)try{o(!0),await a.onConfirm();}catch(s){console.error("Modal confirm action failed:",s);}finally{o(false),t();}else t();},i=()=>{a.onCancel&&a.onCancel(),t();};return jsx(Vi,{open:e.open,onClose:i,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function Dv({config:e,theme:t="light",onThemeChange:r}){let[o,a]=useState(false),[n,i]=useState(null),s=useMemo(()=>ps(Qa(e.collections)),[e.collections]),l=useMemo(()=>ms(Qa(e.globals)),[e.globals]),[d,c]=useState(null),[u,p]=useState(null),[f,m]=useState("list"),[y,v]=useState(null),[x,h]=useState(false);useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let g=await k.json();i(g),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),useEffect(()=>{if(o&&!d){let P=Object.keys(s)[0];P&&c(P);}},[o,s,d]);let S=(P,k=null,g=null)=>{m(P),k&&c(k),g&&v(g),h(false);};useEffect(()=>{let P=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),h(g=>!g));};return window.addEventListener("keydown",P),window.openCommandPalette=()=>h(true),()=>{window.removeEventListener("keydown",P),delete window.openCommandPalette;}},[]);return o?jsx(Lr,{mode:t,onChange:r,children:jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsx("div",{className:"flex h-screen overflow-hidden",children:jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsx(ap,{isOpen:x,onClose:()=>h(false),collections:s,globals:l,onNavigate:S}),(()=>{let P=d?s[d]:null;switch(f){case "create":return P?jsx(Al,{config:e,collection:P,onSuccess:()=>m("list"),onCancel:()=>m("list"),onError:k=>j.error(k)}):null;case "detail":return P&&y?jsx(Sl,{config:e,collection:P,documentId:y,onBack:()=>m("list"),onSave:()=>{},onError:k=>j.error(k)}):null;case "users":return jsx(Yu,{});case "media":return jsx(Ns,{});case "branding":return jsx(Qu,{});case "developer":return jsx(Zu,{collections:s});case "webhooks":return jsx(tp,{});default:return P?jsx(Fi,{config:e,collection:P,onCreate:()=>m("create"),onEdit:k=>S("detail",d,k)}):jsx(Ju,{onNavigate:S,collections:s,user:n})}})()]})})}),jsx(np,{}),jsx(Gs,{})]})}):jsx(Dl,{onAuth:(P,k)=>{i(k),a(true);},theme:t})}function Pv({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(pi,{count:e}),jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsx(Uo,{trigger:jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsx(Ft,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function $v({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:i,loading:s=false}){let{t:l}=H(),d=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime())){let f=Date.parse(u);return isNaN(f)?"Invalid date":new Date(f).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime()))return d(u);let m=new Date().getTime()-p.getTime();if(m<0)return "Just now";let y=Math.floor(m/6e4),v=Math.floor(m/36e5),x=Math.floor(m/864e5);return y<1?"Just now":y<60?`${y}m ago`:v<24?`${v}h ago`:x<7?`${x}d ago`:d(u)};return jsx(xr,{open:e,onClose:t,title:l("tooltips.versionHistory",{defaultValue:"Version History"}),width:"md",children:s?jsx("div",{className:"flex items-center justify-center py-12",children:jsx(lr,{})}):r.length===0?jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsx(History,{className:"w-12 h-12 mb-4 opacity-20"}),jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(u=>{let p=u.id===o;return jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${p?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]/5 shadow-sm":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30 hover:bg-[var(--kyro-surface-accent)] hover:shadow-sm bg-[var(--kyro-surface)]"}`,children:[p&&jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${u.status==="published"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-zinc-500/10 text-zinc-600 dark:text-zinc-400"}`,children:[u.status==="published"&&jsx(CheckCircle2,{className:"w-3 h-3"}),u.status==="published"?"Published":"Draft"]}),jsxs("span",{className:"text-xs font-semibold text-[var(--kyro-text)] px-2 py-0.5 rounded-md bg-[var(--kyro-surface-accent)]",children:["v",u.version]}),p&&jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsx(Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(u.createdAt)]}),u.createdBy&&jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsx(User,{className:"w-3.5 h-3.5"}),jsx("span",{children:u.createdBy.name||u.createdBy.email})]}),u.changelog&&jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',u.changelog,'"']})]}),jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-1.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>a(u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.previewThisVersion",{defaultValue:"Preview this version"}),children:jsx(Eye,{className:"w-4 h-4"})}),i&&jsx("button",{type:"button",onClick:()=>i(u,r.find(f=>f.id===o)||u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.compareWithCurrent",{defaultValue:"Compare with current"}),children:jsx(GitCompare,{className:"w-4 h-4"})}),!p&&jsx("button",{type:"button",onClick:()=>n(u),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:l("tooltips.restoreThisVersion",{defaultValue:"Restore this version"}),children:jsx(Undo2,{className:"w-4 h-4"})})]})]})]},u.id)})})})}function sB({title:e,onMenuClick:t,actions:r}){return jsxs("header",{className:"kyro-header",children:[jsxs("div",{className:"kyro-header-left",children:[jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsx("h1",{className:"kyro-header-title",children:e})]}),jsxs("div",{className:"kyro-header-right",children:[r,jsx("div",{className:"kyro-header-user",children:jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"8",r:"4"}),jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var fr={ready:[],beforeDeploy:[],afterDeploy:[]};function Qs(e){return fr.ready.push(e),()=>{fr.ready=fr.ready.filter(t=>t!==e);}}function lp(e){return fr.beforeDeploy.push(e),()=>{fr.beforeDeploy=fr.beforeDeploy.filter(t=>t!==e);}}function dp(e){return fr.afterDeploy.push(e),()=>{fr.afterDeploy=fr.afterDeploy.filter(t=>t!==e);}}async function cp(e){let t=[];for(let r of fr.ready)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function up(e){let t=[];for(let r of fr.beforeDeploy)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function pp(e,t){for(let r of fr.afterDeploy)try{await r(e,t);}catch{}}function fp(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function gp(e,t={}){let[r,o]=useState(null),[a,n]=useState(true),[i,s]=useState(null),l=useCallback(async()=>{n(true),s(null);try{let d=new URLSearchParams;t.page&&d.set("page",String(t.page)),t.limit&&d.set("limit",String(t.limit)),t.sort&&d.set("sort",t.sort),t.order&&d.set("order",t.order);let c=`${fp(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let p=await u.json();o(p.data??p);}catch(d){s(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return useEffect(()=>{l();},[l]),{data:r,loading:a,error:i,refetch:l}}function yp(e,t="POST"){let[r,o]=useState(false),[a,n]=useState(null);return {mutate:useCallback(async s=>{o(true),n(null);try{let l=fp(`/api/${e}`),d=await fetch(l,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:s?JSON.stringify(s):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(l){return n(l instanceof Error?l.message:String(l)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var Ia=new Map;function La(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");Ia.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),Ia.set(e.name,e),e.apply&&e.apply({});}function vp(e){Ia.delete(e);}function bp(e){return Ia.get(e)}function hp(){return Array.from(Ia.values())}function xp(e){return Array.from(Ia.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Vv={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};La(Vv);var jv={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};La(jv);var Ea=new Map;function Ba(e){if(!e.id||typeof e.id!="string")throw new Error("Block must have a valid id");if(!e.label)throw new Error("Block must have a label");Ea.set(e.id,e);}function kp(e){Ea.delete(e);}function wp(e){return Ea.get(e)}function Np(){return Array.from(Ea.values())}function Cp(e){return Array.from(Ea.values()).filter(t=>t.category===e)}function Sp(e){let t=Ea.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Uv=e=>{let{data:t}=e;return jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsx("strong",{children:"Sample Block"}),jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},zv={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Uv};Ba(zv);var _v=e=>{let{data:t}=e;return jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsx("strong",{children:"Sample Block 2"}),jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},Kv={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:_v};Ba(Kv);var Ma=new Map;function $a(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");Ma.set(e.id,e);}function Dp(e){Ma.delete(e);}function Pp(e){return Ma.get(e)}function Rp(){return Array.from(Ma.values())}function Fp(e){return Array.from(Ma.values()).find(t=>t.type===e)}function Ip(e,t){let r=Ma.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsx(o,{...t})}var qv=({name:e,value:t,onChange:r})=>{let{t:o}=H();return jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleText",{defaultValue:"Sample text"})})},Jv={id:"sample-text",type:"text",label:"Sample Text",editor:qv};$a(Jv);var Yv=({name:e,value:t,onChange:r})=>{let{t:o}=H();return jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleTextarea",{defaultValue:"Sample textarea"})})},Qv={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:Yv};$a(Qv);
116
+ `}})]})]})]})}var kv=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function Zu({collections:e}){let{t}=H(),[r,o]=useState([]),[a,n]=useState(false),[i,s]=useState(null),[l,d]=useState(""),[c,u]=useState(null),[p,f]=useState(false),{confirm:m,alert:y}=vt(),[v,x]=useState(false),[h,S]=useState(""),N=async()=>{try{let b=await Me("/api/keys");o(b);}catch(b){console.error(b);}};useEffect(()=>{N();},[]);let V=async()=>{S(""),x(true);},P=async()=>{if(h.trim())try{await ut("/api/keys",{name:h}),N(),x(!1),S(""),j.success("API key generated");}catch(b){console.error(b),j.error("Failed to generate API key");}},k=b=>{m({title:"Revoke API Key",message:"Are you sure you want to revoke this key? Any integrations using it will stop working.",variant:"danger",onConfirm:async()=>{try{await Dt(`/api/keys/${b}`),N(),j.success("API key revoked");}catch(w){console.error(w),j.error("Failed to revoke API key");}}});},g=async()=>{if(l){f(true);try{let w=await(await fetch(Ye(`/api/${l}`))).json();u(w);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{f(false);}}};return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsx(jt,{title:t("tooltips.developerCenter",{defaultValue:"Developer Center"}),description:"Provision access keys and explore the headless API ecosystem.",icon:CodeXml,actions:[{label:"Generate Key",onClick:V,icon:Key}]}),jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsx("div",{className:"space-y-4",children:r.length===0?jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsx(Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):r.map(b=>jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-3xl p-6 hover:border-[var(--kyro-primary)]/50 transition-all duration-300",children:jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsx(Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:b.name})]}),jsxs("div",{className:"flex-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl px-4 py-3 flex items-center justify-between group/key overflow-hidden",children:[jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:i===b.id?b.key:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsx("button",{type:"button",onClick:()=>s(i===b.id?null:b.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:i===b.id?jsx(EyeOff,{className:"w-4 h-4"}):jsx(Eye,{className:"w-4 h-4"})}),jsx("button",{type:"button",className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",onClick:()=>{navigator.clipboard.writeText(b.key),j.success("API key copied to clipboard");},children:jsx(Copy,{className:"w-4 h-4"})})]})]}),jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Issued:"}),jsx("span",{children:new Date(b.createdAt).toLocaleDateString()})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{children:"Status:"}),jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsx("button",{type:"button",onClick:()=>k(b.id),className:"p-3.5 bg-red-500/5 text-red-500 rounded-2xl hover:bg-red-500/10 transition-all border border-transparent hover:border-red-500/30 self-start md:self-center",title:t("tooltips.revokeKey",{defaultValue:"Revoke Key"}),children:jsx(Trash2,{className:"w-5 h-5"})})]})},b.id))})]}),jsxs("section",{className:"space-y-6",children:[jsxs("div",{className:"relative overflow-hidden rounded-[2.5rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/80 p-8 group shadow-2xl shadow-[var(--kyro-primary)]/20",children:[jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.1] pointer-events-none group-hover:scale-110 transition-transform duration-700",children:jsx(Terminal,{className:"w-48 h-48 rotate-12"})}),jsxs("div",{className:"relative z-10",children:[jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsx(Terminal,{className:"w-6 h-6 text-white"})}),jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsx("p",{className:"text-white/80 text-sm font-medium leading-relaxed mb-8",children:"Kyro CMS is built for high-performance content delivery. Use these endpoints to power your headless frontends."}),jsxs("button",{type:"button",className:"w-full py-4 bg-white text-[var(--kyro-primary)] rounded-[1.2rem] font-bold text-xs uppercase tracking-widest hover:shadow-xl transition-all flex items-center justify-center gap-2 active:scale-[0.98]",children:["Full API Documentation",jsx(ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxs("div",{className:"space-y-5",children:[jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsx(Et,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxs("div",{className:"group relative",children:[jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-[var(--kyro-primary)]/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsx(Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://api.kyro.io/v1")})]})]})]}),jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsx(Et,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxs("div",{className:"group relative",children:[jsx("div",{className:"absolute -inset-0.5 bg-gradient-to-r from-amber-500/30 to-transparent rounded-xl blur opacity-0 group-hover:opacity-100 transition-all"}),jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsx(Copy,{className:"w-3.5 h-3.5 opacity-0 group-hover:opacity-40 cursor-pointer transition-opacity",onClick:()=>navigator.clipboard.writeText("https://preview.kyro.io/v1")})]})]})]})]})]})]}),jsxs("section",{className:"xl:col-span-3 rounded-[3rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-10 space-y-10 overflow-hidden relative",children:[jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsx(CirclePlay,{className:"w-96 h-96"})}),jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxs("div",{className:"max-w-xl",children:[jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsx(CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsx("p",{className:"text-[var(--kyro-text-secondary)] text-sm font-medium opacity-60 leading-relaxed",children:"Test your collection endpoints and analyze live response payloads. Enter a collection slug to fetch its latest documents."})]}),jsxs("div",{className:"flex items-center gap-4 flex-1 lg:max-w-2xl bg-[var(--kyro-bg)] p-2 rounded-[2rem] border border-[var(--kyro-border)] shadow-2xl",children:[jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",kv,"/"]}),jsx("input",{type:"text",value:l,onChange:b=>d(b.target.value),placeholder:"collection-slug",className:"w-full py-4 bg-transparent focus:outline-none font-mono text-sm font-bold text-[var(--kyro-primary)]"})]}),jsxs("button",{type:"button",onClick:g,disabled:p||!l,className:"kyro-btn kyro-btn-primary px-8 py-4 rounded-[1.5rem] font-bold text-sm shadow-xl disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] transition-all flex items-center gap-3 shrink-0",children:[p?jsx(RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsx(ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),c?jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsx(Et,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsx(bv,{value:JSON.stringify(c,null,2),height:"450px",theme:aura,extensions:[json()],editable:false,className:"text-sm"})]})]}):jsxs("div",{className:"h-80 rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] flex flex-col items-center justify-center bg-[var(--kyro-surface-accent)]/20 transition-all duration-700",children:[jsx("div",{className:"w-20 h-20 bg-[var(--kyro-surface)] rounded-3xl flex items-center justify-center shadow-lg border border-[var(--kyro-border)] mb-6 opacity-20",children:jsx(CodeXml,{className:"w-10 h-10"})}),jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxs(At,{open:v,onClose:()=>x(false),title:t("tooltips.generateAccessToken",{defaultValue:"Generate Access Token"}),size:"lg",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 leading-relaxed",children:"Define a name for this API key to identify its integration context. Keys are encrypted at rest and should be treated with extreme caution."}),jsxs("div",{className:"space-y-2",children:[jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsx("input",{type:"text",value:h,onChange:b=>S(b.target.value),placeholder:"e.g., Mobile App SDK, Production Server",className:"w-full px-6 py-4 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-2xl text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)] shadow-sm transition-all",onKeyDown:b=>b.key==="Enter"&&P()})]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>x(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsx("button",{type:"button",onClick:P,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function ep(e){let[t,r]=useState([]),[o,a]=useState(false),[n,i]=useState(null),[s,l]=useState(false),{confirm:d}=vt(),c=useCallback(async()=>{a(true),i(null);try{let m=await Me(e.endpoint),y=Array.isArray(m)?m:m.docs||[],v=e.transformLoad?e.transformLoad(y):y;r(v),e.onSuccess?.("load",v);}catch(m){let y=m instanceof Error?m.message:"Failed to load resources";i(y),e.onError?.("load",m);}finally{a(false);}},[e.endpoint,e.transformLoad]);useEffect(()=>{c();},[c]);let u=useCallback((m,y="item")=>{d({title:`Delete ${y}`,message:`Are you sure you want to delete this ${y.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`${e.endpoint}/${m}`),r(v=>v.filter(x=>x.id!==m)),e.onSuccess?.("delete",m),j.success(`${y} deleted`);}catch(v){let x=v instanceof Error?v.message:`Failed to delete ${y}`;j.error(x),e.onError?.("delete",v);}}});},[e.endpoint,d]),p=useCallback(async m=>{i(null);try{let y=await ut(e.endpoint,m);return r(v=>[y,...v]),l(!1),e.onSuccess?.("create",y),y}catch(y){let v=y instanceof Error?y.message:"Failed to create resource";throw i(v),e.onError?.("create",y),y}},[e.endpoint]),f=useCallback(async(m,y)=>{i(null);try{let v=await er(`${e.endpoint}/${m}`,y);return r(x=>x.map(h=>h.id===m?v:h)),e.onSuccess?.("update",v),v}catch(v){let x=v instanceof Error?v.message:"Failed to update resource";throw i(x),e.onError?.("update",v),v}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:p,update:f,isCreateModalOpen:s,setIsCreateModalOpen:l}}var Cv={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function tp(){let{t:e}=H(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:i,setIsCreateModalOpen:s}=ep({endpoint:"/api/webhooks"}),{confirm:l}=vt(),[d,c]=useState(false),[u,p]=useState(false),[f,m]=useState(null),[y,v]=useState(null),[x,h]=useState({}),[S,N]=useState(true),[V,P]=useState("action"),[k,g]=useState("generic"),[b,w]=useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[D,F]=useState(""),[E,R]=useState(false),[M,z]=useState(null),[I,J]=useState([]),[Z,te]=useState(false);useEffect(()=>{Y();},[]);let Y=async()=>{try{let C=await Me("/api/webhooks/actions");h(C.actions);}catch(C){console.error("Failed to load webhook actions:",C);}finally{N(false);}},ae=()=>{P("action"),g("generic"),w({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),F("");},ue=C=>{g(C),w(G=>({...G,action:C,config:{}})),P("config");},he=(C,G)=>{w(Ne=>({...Ne,config:{...Ne.config,[C]:G}}));},U=async()=>{if(!b.name.trim()){F("Name is required");return}if(k==="generic"&&!b.url.trim()){F("URL is required for custom webhooks");return}let C=x[k];if(C){for(let G of C.configFields)if(G.required&&!b.config[G.name]?.trim()){F(`${G.label} is required`);return}}try{await o(b),ae(),j.success(`Webhook created: ${b.name}`);}catch(G){let Ne=G.message||"Failed to create webhook";F(Ne),j.error(Ne);}},K=async C=>{v(C),m(null),c(true);try{let G=await ut(`/api/webhooks/${C}/test`);m({success:!0,message:G.message||"Webhook triggered successfully"}),j.success("Test delivered successfully");}catch{m({success:false,message:"Failed to trigger webhook"});}},_=async(C,G)=>{try{let Ne=G==="active"?"paused":"active";await n(C,{status:Ne}),j.success(Ne==="active"?"Webhook activated":"Webhook paused");}catch(Ne){console.error(Ne),j.error("Failed to toggle webhook status");}},xe=async C=>{z(C),R(true),te(true);try{let G=await Me(`/api/webhooks/${C}/history`);J(G.docs||[]);}catch(G){console.error("Failed to load history:",G),j.error("Failed to load delivery history");}finally{te(false);}},Be=[{label:"Create",value:"create",description:"When a new document is created"},{label:"Update",value:"update",description:"When a document is updated"},{label:"Delete",value:"delete",description:"When a document is deleted"},{label:"Auth",value:"auth",description:"User login/logout events"}],we=C=>x[C||"generic"]?.label||"Custom URL";return jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsx(jt,{title:e("tooltips.webhooks",{defaultValue:"Webhooks"}),description:"Get notified when your content changes.",icon:Webhook,actions:[{label:"New webhook",onClick:()=>{ae(),s(true);},icon:Plus},{label:"Guide",onClick:()=>p(true),icon:Info,variant:"outline"}]}),jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsx(Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsx("div",{className:"flex-1 text-center md:text-left",children:jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Receive instant HTTP notifications when events happen in your CMS. Choose a platform preset or point to any custom endpoint."})})]})}),jsxs("section",{className:"space-y-6",children:[jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[t.length," hook",t.length!==1&&"s"]})]}),r?jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):t.length===0?jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsx(Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-6 max-w-sm mx-auto",children:"Create a webhook to get notified when your content changes."}),jsxs("button",{type:"button",onClick:()=>{ae(),s(true);},className:"kyro-btn kyro-btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium",children:[jsx(Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsx("div",{className:"grid gap-4",children:t.map(C=>jsx("div",{className:"group relative overflow-hidden bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-2xl p-5 hover:border-[var(--kyro-primary)]/30 transition-all duration-200",children:jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxs("div",{className:"flex-1",children:[jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsx(Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxs("div",{children:[jsx("h3",{className:"text-sm font-semibold",children:C.name}),jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${C.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsx("span",{className:`text-[10px] font-medium ${C.status==="active"?"text-green-500":"text-amber-500"}`,children:C.status}),jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:we(C.action)})]})]})]}),jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxs("div",{className:"space-y-1",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:C.url,children:C.url||`${we(C.action)} webhook`})]}),jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxs("div",{className:"flex flex-wrap gap-1",children:[C.events.slice(0,3).map(G=>jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:G},G)),C.events.length>3&&jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",C.events.length-3]})]})]}),jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-3 sm:pt-0 sm:pl-4",children:[jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsx(Clock,{className:"w-3 h-3"}),C.lastTriggered?`Last triggered ${new Date(C.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),C.lastError&&jsxs("div",{className:"text-[10px] text-red-500/80 flex items-center gap-1.5 mt-1",children:[jsx(XCircle,{className:"w-3 h-3"}),jsx("span",{className:"truncate max-w-[150px]",title:C.lastError,children:C.lastError})]})]})]})]}),jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxs("button",{type:"button",onClick:()=>xe(C.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.viewDeliveryHistory",{defaultValue:"View delivery history"}),children:[jsx(Activity,{className:"w-3.5 h-3.5"}),jsx("span",{className:"text-[11px] font-medium hidden sm:inline",children:"History"})]}),jsxs("button",{type:"button",onClick:()=>K(C.id),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors flex items-center gap-1.5",title:e("tooltips.sendTestRequest",{defaultValue:"Send test request"}),children:[jsx(Send,{className:"w-3.5 h-3.5"}),jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsx("button",{type:"button",onClick:()=>_(C.id,C.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${C.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:C.status==="active"?"Pause":"Activate",children:C.status==="active"?jsx(Pause,{className:"w-3.5 h-3.5"}):jsx(Play,{className:"w-3.5 h-3.5"})}),jsx("button",{type:"button",onClick:()=>a(C.id,"Webhook"),className:"p-2 rounded-lg border border-[var(--kyro-border)] hover:border-red-500/30 hover:bg-red-500/5 transition-colors",title:e("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},C.id))})]}),jsx(At,{open:i&&V==="action",onClose:()=>s(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsx(Ir,{children:jsx("div",{className:"space-y-4",children:S?jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsx(RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(x).map(([C,G])=>jsxs("button",{type:"button",onClick:()=>ue(C),className:"flex flex-col items-start p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsx("div",{className:"text-lg mb-2",children:Cv[C]||"\u{1F517}"}),jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:G.label}),jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:G.description}),G.envVars.length>0&&jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:G.envVars.map(Ne=>jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:Ne},Ne))})]},C))})})})}),jsxs(At,{open:i&&V==="config",onClose:()=>s(false),title:x[k]?.label||"Webhook",children:[jsx(Ir,{children:jsxs("div",{className:"space-y-5",children:[jsxs("div",{className:"flex flex-col gap-5",children:[jsxs("div",{className:"space-y-4",children:[jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsx("input",{type:"text",value:b.name,onChange:C=>w({...b,name:C.target.value}),placeholder:"e.g., Deploy on content update",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k==="generic"&&jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsx("input",{type:"url",value:b.url,onChange:C=>w({...b,url:C.target.value}),placeholder:"https://your-server.com/webhook",className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]}),k!=="generic"&&x[k]?.configFields.map(C=>jsxs("div",{children:[jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[C.label," ",C.required&&jsx("span",{className:"text-red-500",children:"*"})]}),jsx("input",{type:"text",value:b.config[C.name]||"",onChange:G=>he(C.name,G.target.value),placeholder:C.placeholder,className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]},C.name)),k==="generic"&&jsxs("div",{children:[jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsx("input",{type:"text",value:b.secret,onChange:C=>w({...b,secret:C.target.value}),placeholder:e("fields.optional",{defaultValue:"Optional"}),className:"w-full px-3 py-2.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:border-[var(--kyro-primary)]"})]})]}),k!=="generic"&&x[k]?.envVars.length>0&&jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsx(TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsx("div",{className:"flex flex-wrap gap-1.5",children:x[k].envVars.map(C=>jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[C,"=..."]},C))})]}),jsxs("div",{className:"space-y-3",children:[jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Be.map(C=>jsxs("button",{type:"button",onClick:()=>{let G=b.events.includes(C.value)?b.events.filter(Ne=>Ne!==C.value):[...b.events,C.value];w({...b,events:G});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${b.events.includes(C.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/20"}`,children:[jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${b.events.includes(C.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b.events.includes(C.value)&&jsx(CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxs("div",{children:[jsx("div",{className:"text-xs font-medium",children:C.label}),jsx("div",{className:"text-[10px] opacity-40",children:C.description})]})]},C.value))})]})]}),D&&jsxs("div",{className:"p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-red-500 text-xs",children:[jsx(TriangleAlert,{className:"w-3.5 h-3.5"}),D]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>P("action"),className:"px-4 py-2 rounded-lg text-sm font-medium border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-colors",children:"Back"}),jsx("button",{type:"button",onClick:U,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxs(At,{open:d,onClose:()=>c(false),title:e("tooltips.testWebhook",{defaultValue:"Test webhook"}),children:[jsx(Ir,{children:jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:f?jsxs("div",{className:"space-y-4",children:[jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${f.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:f.success?jsx(CircleCheck,{className:"w-6 h-6"}):jsx(TriangleAlert,{className:"w-6 h-6"})}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-semibold mb-1",children:f.success?"Delivered":"Failed"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:f.message})]})]}):jsxs("div",{className:"space-y-4 py-4",children:[jsx(RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxs("div",{children:[jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsx(Kr,{children:jsx("button",{type:"button",onClick:()=>c(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]}),jsxs(At,{open:u,onClose:()=>p(false),title:e("tooltips.howWebhooksWork",{defaultValue:"How webhooks work"}),children:[jsx(Ir,{children:jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsx(ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsx(Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsx("span",{className:"font-mono text-[10px] bg-[var(--kyro-surface-accent)] px-1 py-0.5 rounded",children:"X-Webhook-Signature"})," header with an HMAC-SHA256 signature. Verify it in production."]})]})]}),jsxs("div",{className:"space-y-2",children:[jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsx("div",{children:"{"}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxs("div",{className:"pl-3",children:[jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsx("div",{children:"}"})]})})]})]})}),jsx(Kr,{children:jsx("button",{type:"button",onClick:()=>p(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxs(At,{open:E,onClose:()=>R(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsx(Ir,{children:jsx("div",{className:"space-y-4",children:Z?jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsx(RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):I.length===0?jsx("div",{className:"text-center p-8 text-[var(--kyro-text-secondary)] opacity-60 text-sm",children:"No delivery history available for this webhook."}):jsx("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:I.map(C=>jsxs("div",{className:"p-4 rounded-md border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-sm",children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("div",{className:"flex items-center gap-2",children:[C.status==="success"?jsx(CircleCheck,{className:"w-4 h-4 text-green-500"}):jsx(XCircle,{className:"w-4 h-4 text-red-500"}),jsx("span",{className:"font-medium",children:C.event})]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(C.createdAt).toLocaleString()})]}),jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs text-[var(--kyro-text-secondary)] mb-3",children:[jsxs("div",{children:[jsx("span",{className:"opacity-50",children:"Status: "}),jsx("span",{className:`font-medium ${C.status==="success"?"text-green-500":"text-red-500"}`,children:C.responseStatus||C.status})]}),jsxs("div",{children:[jsx("span",{className:"opacity-50",children:"Duration: "}),C.duration?`${C.duration}ms`:"-"]})]}),C.error&&jsx("div",{className:"text-xs text-red-500 bg-red-500/5 p-2 rounded border border-red-500/10 font-mono break-all mb-2",children:C.error}),C.responseBody&&jsx("div",{className:"text-[10px] font-mono bg-[var(--kyro-bg)] p-2 rounded border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] opacity-70 max-h-24 overflow-y-auto break-all",children:C.responseBody})]},C.id))})})}),jsx(Kr,{children:jsx("button",{type:"button",onClick:()=>R(false),className:"w-full py-2.5 rounded-lg text-sm font-medium bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-colors",children:"Close"})})]})]})}function ap({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{t:n}=H(),{user:i,permissions:s}=eo(),[l,d]=useState(""),[c,u]=useState(0),[p,f]=useState(false),[m,y]=useState([]),v=useRef(null),x=useRef(null);useEffect(()=>{e&&(d(""),u(0),y([]),f(false),setTimeout(()=>v.current?.focus(),100));},[e]);let h=useCallback(async R=>{if(!R||R.length<2){y([]);return}f(true);try{let z=await(await fetch(Ye(`/api/search?q=${encodeURIComponent(R)}&limit=15`))).json();z.results&&y(z.results);}catch(M){console.error("Search error:",M),y([]);}finally{f(false);}},[]);if(useEffect(()=>(x.current&&clearTimeout(x.current),l.length>=2?x.current=setTimeout(()=>h(l),300):y([]),()=>{x.current&&clearTimeout(x.current);}),[l,h]),!e)return null;let S=Object.entries(r).filter(([R])=>s?.collections?.[R]?.read!==false).map(([R,M])=>({id:`col-${R}`,label:M.label||R,type:"collection",slug:R,icon:FileText})),N=Object.entries(o).filter(([R])=>s?.globals?.[R]?.read!==false).map(([R,M])=>({id:`global-${R}`,label:M.label||R,type:"global",slug:R,icon:Settings})),V=typeof document<"u"&&document.documentElement.classList.contains("dark"),P=i?.role==="admin",k=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Clock,visible:P},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:File,visible:P},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Shield,visible:P},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Database,visible:P},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Hexagon,visible:P},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Network,visible:P},{id:"action-theme",label:V?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:V?Sun:Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:LogOut,visible:true}].filter(R=>R.visible),g=m.map((R,M)=>({id:`doc-${R.collection}-${R.id}`,label:R.title,type:"document",collection:R.collection,label2:R.label,docId:R.id,icon:File,doc:R.doc})),b=l.length>=2?[...k,...S,...N,...g]:[...k,...S,...N],w=l===""?b:b.filter(R=>R.label.toLowerCase().includes(l.toLowerCase())),D=R=>{if(R.key==="ArrowDown")R.preventDefault(),u(M=>(M+1)%w.length);else if(R.key==="ArrowUp")R.preventDefault(),u(M=>(M-1+w.length)%w.length);else if(R.key==="Enter"){let M=w[c];M&&F(M);}else R.key==="Escape"&&t();},F=R=>{R.type==="collection"?R.slug==="users"?a(R.slug,R.slug):a("list",R.slug):R.type==="global"?a("settings",R.slug):R.type==="document"?R.collection==="users"?a("users","users",R.docId):a("edit",R.collection,R.docId):R.type==="action"&&(R.view==="users"?a("users","users"):R.view==="media"?a("media","media"):a(R.view,R.view)),t();},E=()=>l===""?"Quick Actions & Collections":m.length>0?"Documents":p?"Searching...":"Search Results";return jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxs("div",{className:"relative w-full max-w-2xl bg-[var(--kyro-surface)] rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 fade-in duration-300 ring-1 ring-white/10 border border-white/5",children:[jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[p?jsx(LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsx(Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsx("input",{ref:v,placeholder:n("fields.searchAnything",{defaultValue:"Search anything..."}),className:"flex-1 bg-transparent border-none focus:outline-none text-lg font-medium text-[var(--kyro-text-primary)] placeholder:text-[var(--kyro-text-muted)]",value:l,onChange:R=>d(R.target.value),onKeyDown:D}),jsx("div",{className:"flex items-center gap-2 px-2 py-1 bg-[var(--kyro-bg-secondary)] rounded-lg border border-[var(--kyro-border)]",children:jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:w.length>0?jsxs("div",{className:"space-y-1 px-4",children:[jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:E()}),w.map((R,M)=>jsxs("div",{onClick:()=>F(R),onMouseEnter:()=>u(M),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${M===c?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xl shadow-[var(--kyro-primary)]":"hover:bg-[var(--kyro-bg-secondary)] text-[var(--kyro-text-secondary)]"}`,children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:`p-2 rounded-xl ${M===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsx(R.icon,{className:"w-4 h-4"})}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"font-bold text-sm",children:R.label}),R.type==="document"&&R.label2&&jsx("span",{className:`text-[10px] font-bold tracking-widest ${M===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:R.label2})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${M===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:R.type}),M===c&&jsx(ArrowRight,{className:"w-4 h-4 mr-2"})]})]},R.id))]}):jsx("div",{className:"py-12 text-center",children:jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!p?`No results found for "${l}"`:"Start typing to search..."})})}),jsxs("div",{className:"px-8 py-4 bg-[var(--kyro-bg-secondary)] border-t border-[var(--kyro-border)] flex items-center justify-between text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-60",children:[jsxs("div",{className:"flex gap-6",children:[jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsx("div",{children:"Kyro Universal Search"})]})]})]})}function np(){let{modal:e,closeModal:t}=vt(),[r,o]=useState(false);if(!e.open||!e.config)return null;let{config:a}=e,n=async()=>{if(a.onConfirm)try{o(!0),await a.onConfirm();}catch(s){console.error("Modal confirm action failed:",s);}finally{o(false),t();}else t();},i=()=>{a.onCancel&&a.onCancel(),t();};return jsx(Vi,{open:e.open,onClose:i,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function Dv({config:e,theme:t="light",onThemeChange:r}){let[o,a]=useState(false),[n,i]=useState(null),s=useMemo(()=>ps(Qa(e.collections)),[e.collections]),l=useMemo(()=>ms(Qa(e.globals)),[e.globals]),[d,c]=useState(null),[u,p]=useState(null),[f,m]=useState("list"),[y,v]=useState(null),[x,h]=useState(false);useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let g=await k.json();i(g),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),useEffect(()=>{if(o&&!d){let P=Object.keys(s)[0];P&&c(P);}},[o,s,d]);let S=(P,k=null,g=null)=>{m(P),k&&c(k),g&&v(g),h(false);};useEffect(()=>{let P=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),h(g=>!g));};return window.addEventListener("keydown",P),window.openCommandPalette=()=>h(true),()=>{window.removeEventListener("keydown",P),delete window.openCommandPalette;}},[]);return o?jsx(Lr,{mode:t,onChange:r,children:jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsx("div",{className:"flex h-screen overflow-hidden",children:jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsx(ap,{isOpen:x,onClose:()=>h(false),collections:s,globals:l,onNavigate:S}),(()=>{let P=d?s[d]:null;switch(f){case "create":return P?jsx(Al,{config:e,collection:P,onSuccess:()=>m("list"),onCancel:()=>m("list"),onError:k=>j.error(k)}):null;case "detail":return P&&y?jsx(Sl,{config:e,collection:P,documentId:y,onBack:()=>m("list"),onSave:()=>{},onError:k=>j.error(k)}):null;case "users":return jsx(Yu,{});case "media":return jsx(Ns,{});case "branding":return jsx(Qu,{});case "developer":return jsx(Zu,{collections:s});case "webhooks":return jsx(tp,{});default:return P?jsx(Fi,{config:e,collection:P,onCreate:()=>m("create"),onEdit:k=>S("detail",d,k)}):jsx(Ju,{onNavigate:S,collections:s,user:n})}})()]})})}),jsx(np,{}),jsx(Gs,{})]})}):jsx(Dl,{onAuth:(P,k)=>{i(k),a(true);},theme:t})}function Pv({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(pi,{count:e}),jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsx(Uo,{trigger:jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsx(Ft,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function $v({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:i,loading:s=false}){let{t:l}=H(),d=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime())){let f=Date.parse(u);return isNaN(f)?"Invalid date":new Date(f).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let p=new Date(u);if(isNaN(p.getTime()))return d(u);let m=new Date().getTime()-p.getTime();if(m<0)return "Just now";let y=Math.floor(m/6e4),v=Math.floor(m/36e5),x=Math.floor(m/864e5);return y<1?"Just now":y<60?`${y}m ago`:v<24?`${v}h ago`:x<7?`${x}d ago`:d(u)};return jsx(xr,{open:e,onClose:t,title:l("tooltips.versionHistory",{defaultValue:"Version History"}),width:"md",children:s?jsx("div",{className:"flex items-center justify-center py-12",children:jsx(lr,{})}):r.length===0?jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsx(History,{className:"w-12 h-12 mb-4 opacity-20"}),jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(u=>{let p=u.id===o;return jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${p?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]/5 shadow-sm":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30 hover:bg-[var(--kyro-surface-accent)] hover:shadow-sm bg-[var(--kyro-surface)]"}`,children:[p&&jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${u.status==="published"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-zinc-500/10 text-zinc-600 dark:text-zinc-400"}`,children:[u.status==="published"&&jsx(CheckCircle2,{className:"w-3 h-3"}),u.status==="published"?"Published":"Draft"]}),jsxs("span",{className:"text-xs font-semibold text-[var(--kyro-text)] px-2 py-0.5 rounded-md bg-[var(--kyro-surface-accent)]",children:["v",u.version]}),p&&jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsx(Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),c(u.createdAt)]}),u.createdBy&&jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsx(User,{className:"w-3.5 h-3.5"}),jsx("span",{children:u.createdBy.name||u.createdBy.email})]}),u.changelog&&jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',u.changelog,'"']})]}),jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-1.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[jsx("button",{type:"button",onClick:()=>a(u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.previewThisVersion",{defaultValue:"Preview this version"}),children:jsx(Eye,{className:"w-4 h-4"})}),i&&jsx("button",{type:"button",onClick:()=>i(u,r.find(f=>f.id===o)||u),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:l("tooltips.compareWithCurrent",{defaultValue:"Compare with current"}),children:jsx(GitCompare,{className:"w-4 h-4"})}),!p&&jsx("button",{type:"button",onClick:()=>n(u),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:l("tooltips.restoreThisVersion",{defaultValue:"Restore this version"}),children:jsx(Undo2,{className:"w-4 h-4"})})]})]})]},u.id)})})})}function sB({title:e,onMenuClick:t,actions:r}){return jsxs("header",{className:"kyro-header",children:[jsxs("div",{className:"kyro-header-left",children:[jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsx("h1",{className:"kyro-header-title",children:e})]}),jsxs("div",{className:"kyro-header-right",children:[r,jsx("div",{className:"kyro-header-user",children:jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"8",r:"4"}),jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var fr={ready:[],beforeDeploy:[],afterDeploy:[]};function Qs(e){return fr.ready.push(e),()=>{fr.ready=fr.ready.filter(t=>t!==e);}}function lp(e){return fr.beforeDeploy.push(e),()=>{fr.beforeDeploy=fr.beforeDeploy.filter(t=>t!==e);}}function dp(e){return fr.afterDeploy.push(e),()=>{fr.afterDeploy=fr.afterDeploy.filter(t=>t!==e);}}async function cp(e){let t=[];for(let r of fr.ready)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function up(e){let t=[];for(let r of fr.beforeDeploy)try{let o=await r(e);o&&typeof o=="object"&&"success"in o&&t.push(o);}catch(o){t.push({success:false,error:String(o)});}return t}async function pp(e,t){for(let r of fr.afterDeploy)try{await r(e,t);}catch{}}function fp(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function gp(e,t={}){let[r,o]=useState(null),[a,n]=useState(true),[i,s]=useState(null),l=useCallback(async()=>{n(true),s(null);try{let d=new URLSearchParams;t.page&&d.set("page",String(t.page)),t.limit&&d.set("limit",String(t.limit)),t.sort&&d.set("sort",t.sort),t.order&&d.set("order",t.order);let c=`${fp(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let p=await u.json();o(p.data??p);}catch(d){s(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return useEffect(()=>{l();},[l]),{data:r,loading:a,error:i,refetch:l}}function yp(e,t="POST"){let[r,o]=useState(false),[a,n]=useState(null);return {mutate:useCallback(async s=>{o(true),n(null);try{let l=fp(`/api/${e}`),d=await fetch(l,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:s?JSON.stringify(s):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(l){return n(l instanceof Error?l.message:String(l)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var Ia=new Map;function La(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");Ia.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),Ia.set(e.name,e),e.apply&&e.apply({});}function vp(e){Ia.delete(e);}function bp(e){return Ia.get(e)}function hp(){return Array.from(Ia.values())}function xp(e){return Array.from(Ia.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Vv={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};La(Vv);var jv={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};La(jv);var Ea=new Map;function Ba(e){if(!e.id||typeof e.id!="string")throw new Error("Block must have a valid id");if(!e.label)throw new Error("Block must have a label");Ea.set(e.id,e);}function kp(e){Ea.delete(e);}function wp(e){return Ea.get(e)}function Np(){return Array.from(Ea.values())}function Cp(e){return Array.from(Ea.values()).filter(t=>t.category===e)}function Sp(e){let t=Ea.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Uv=e=>{let{data:t}=e;return jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsx("strong",{children:"Sample Block"}),jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},zv={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Uv};Ba(zv);var _v=e=>{let{data:t}=e;return jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsx("strong",{children:"Sample Block 2"}),jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},Kv={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:_v};Ba(Kv);var Ma=new Map;function $a(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");Ma.set(e.id,e);}function Dp(e){Ma.delete(e);}function Pp(e){return Ma.get(e)}function Rp(){return Array.from(Ma.values())}function Fp(e){return Array.from(Ma.values()).find(t=>t.type===e)}function Ip(e,t){let r=Ma.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsx(o,{...t})}var qv=({name:e,value:t,onChange:r})=>{let{t:o}=H();return jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleText",{defaultValue:"Sample text"})})},Jv={id:"sample-text",type:"text",label:"Sample Text",editor:qv};$a(Jv);var Yv=({name:e,value:t,onChange:r})=>{let{t:o}=H();return jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:a=>r?.(a.target.value),placeholder:o("fields.sampleTextarea",{defaultValue:"Sample textarea"})})},Qv={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:Yv};$a(Qv);
117
117
  export{Cl as ActionBar,Dv as Admin,xn as AutoForm,Et as Badge,Pv as BulkActionsBar,mi as Button,Vi as ConfirmModal,pi as CountBadge,Al as CreateView,nn as DARK_THEME,Ds as DarkThemeProvider,Sl as DetailView,Uo as Dropdown,Ft as DropdownItem,hn as DropdownSeparator,Ds as ExtDarkThemeProvider,Ts as ExtLightThemeProvider,Lr as ExtThemeProvider,sB as Header,ma as LIGHT_THEME,Ts as LightThemeProvider,Fi as ListView,Dl as LoginPage,At as Modal,jt as PageHeader,xr as SlidePanel,lr as Spinner,Lr as ThemeProvider,Fc as Toast,O2 as ToastProvider,$v as VersionHistoryPanel,_e as adminPath,dp as afterDeploy,Dr as apiPath,lp as beforeDeploy,cp as emitAdminReady,pp as emitAfterDeploy,up as emitBeforeDeploy,wp as getBlock,Np as getBlocks,Cp as getBlocksByCategory,Pp as getField,Fp as getFieldByType,Rp as getFields,bp as getPlugin,hp as getPlugins,xp as getPluginsWithHook,sn as mergeThemes,Qs as onAdminReady,rm as paths,Ba as registerBlock,$a as registerField,La as registerPlugin,ri as resolveAdmin,Ye as resolveApi,kp as unregisterBlock,Dp as unregisterField,vp as unregisterPlugin,Sp as useBlockRenderer,fa as useExtTheme,Ip as useFieldRenderer,yp as useKyroMutation,gp as useKyroQuery,fa as useTheme,Ic as useToast};