@kyro-cms/admin 0.12.20 → 0.12.21
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.cjs +24 -24
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +19 -19
- package/package.json +6 -6
- package/src/components/ApiKeysManager.tsx +177 -227
- package/src/components/AuditLogsPage.tsx +7 -7
- package/src/components/AuthorDashboard.tsx +235 -0
- package/src/components/AutoForm.tsx +14 -4
- package/src/components/CustomerDashboard.tsx +213 -0
- package/src/components/Dashboard.tsx +1 -1
- package/src/components/DashboardMetrics.tsx +74 -9
- package/src/components/DashboardQuickSections.tsx +237 -0
- package/src/components/ListView.tsx +3 -3
- package/src/components/MediaGallery.tsx +2 -2
- package/src/components/PluginsManager.tsx +1 -1
- package/src/components/SessionsManager.tsx +15 -15
- package/src/components/Sidebar.astro +564 -116
- package/src/components/UserManagement.tsx +43 -9
- package/src/components/UserMenu.tsx +123 -61
- package/src/components/autoform/AutoFormEditView.tsx +4 -4
- package/src/components/autoform/AutoFormHeader.tsx +2 -2
- package/src/components/ui/CommandPalette.tsx +1 -1
- package/src/components/ui/Dropdown.tsx +71 -16
- package/src/components/ui/PageHeader.tsx +1 -1
- package/src/components/ui/Pagination.tsx +1 -1
- package/src/components/ui/Toast.tsx +3 -2
- package/src/components/ui/Toaster.tsx +1 -1
- package/src/components/users/UserDetail.tsx +74 -29
- package/src/components/users/UserForm.tsx +1 -1
- package/src/components/users/UsersList.tsx +2 -2
- package/src/integration.ts +4 -0
- package/src/layouts/AdminLayout.astro +26 -34
- package/src/layouts/AuthLayout.astro +18 -9
- package/src/lib/auth-server.ts +99 -0
- package/src/pages/403.astro +54 -35
- package/src/pages/[collection]/[id].astro +8 -0
- package/src/pages/[collection]/index.astro +7 -0
- package/src/pages/audit/index.astro +4 -1
- package/src/pages/auth/check-email.astro +146 -0
- package/src/pages/auth/forgot-password.astro +95 -0
- package/src/pages/auth/login.astro +29 -12
- package/src/pages/auth/register.astro +38 -12
- package/src/pages/auth/reset-password.astro +125 -0
- package/src/pages/auth/verify-email.astro +87 -0
- package/src/pages/index.astro +220 -121
- package/src/pages/keys.astro +3 -1
- package/src/pages/media.astro +3 -1
- package/src/pages/preview/[collection]/[id].astro +23 -73
- package/src/pages/roles/index.astro +134 -101
- package/src/pages/settings/[slug].astro +43 -3
- package/src/pages/users/[id].astro +5 -1
- package/src/pages/users/index.astro +4 -0
- package/src/pages/users/new.astro +4 -0
- package/src/pages/webhooks.astro +3 -1
- package/src/routes.ts +16 -0
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 Kc 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 Rf from'unstorage/drivers/indexedb';import {createPortal}from'react-dom';import {useEditor,EditorContent}from'@tiptap/react';import ng from'@tiptap/starter-kit';import {marked}from'marked';import ig from'@tiptap/extension-link';import lg from'@tiptap/extension-image';import dg from'@tiptap/extension-text-align';import cg from'@tiptap/extension-underline';import ug from'@tiptap/extension-highlight';import pg from'@tiptap/extension-task-list';import mg from'@tiptap/extension-task-item';import {TextStyle}from'@tiptap/extension-text-style';import gg from'@tiptap/extension-color';import Wf 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 xv from'@uiw/react-codemirror';import {json}from'@codemirror/lang-json';import'@kyro-cms/core/client';var Jp=Object.create;var Ll=Object.defineProperty;var Xp=Object.getOwnPropertyDescriptor;var Yp=Object.getOwnPropertyNames;var Qp=Object.getPrototypeOf,Zp=Object.prototype.hasOwnProperty;var em=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var tm=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Yp(t))!Zp.call(e,a)&&a!==r&&Ll(e,a,{get:()=>t[a],enumerable:!(o=Xp(t,a))||o.enumerable});return e};var rm=(e,t,r)=>(r=e!=null?Jp(Qp(e)):{},tm(!e||!e.__esModule?Ll(r,"default",{value:e,enumerable:true}):r,e));var Md=em((u0,Bd)=>{Bd.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 ai(e){return e.startsWith("http")||e.startsWith(_e)?e:e.startsWith("/admin/")?_e+e.slice(6):e.startsWith("/")?_e+e:e}function za(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var om={admin:_e,api:Dr,resolveApi:Ye,resolveAdmin:ai,resolveMedia:za};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:[]})})),U={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 nm="/api/auth/refresh";async function El(){try{return (await fetch(Ye(nm),{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 El()){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 Le(e,t){let{autoToast:r=true,...o}=t||{},a=await ct(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&U.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&&U.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&&U.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&&U.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 Pn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function Rn(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?El().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 bd({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 im({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 hd({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 xd({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(bd,{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(bd,{back:n}),o&&jsx(im,{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(hd,{actions:s}),i&&jsx(xd,{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(xd,{action:i}),s&&jsx(hd,{actions:s})]})]})}var dm={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=dm[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 fi({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 gi({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 wd({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(gi,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsx(gi,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var be=e=>typeof e=="string",Wa=()=>{let e,t,r=new Promise((o,a)=>{e=o,t=a;});return r.resolve=e,r.reject=t,r},Nd=e=>e==null?"":String(e),pm=(e,t,r)=>{e.forEach(o=>{t[o]&&(r[o]=t[o]);});},mm=/###/g,Cd=e=>e&&e.includes("###")?e.replace(mm,"."):e,Sd=e=>!e||be(e),qa=(e,t,r)=>{let o=be(t)?t.split("."):t,a=0;for(;a<o.length-1;){if(Sd(e))return {};let n=Cd(o[a]);!e[n]&&r&&(e[n]=new r),Object.prototype.hasOwnProperty.call(e,n)?e=e[n]:e={},++a;}return Sd(e)?{}:{obj:e,k:Cd(o[a])}},Ad=(e,t,r)=>{let{obj:o,k:a}=qa(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=qa(e,i,Object);for(;s.obj===void 0&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),s=qa(e,i,Object),s?.obj&&typeof s.obj[`${s.k}.${n}`]<"u"&&(s.obj=void 0);s.obj[`${s.k}.${n}`]=r;},fm=(e,t,r,o)=>{let{obj:a,k:n}=qa(e,t,Object);a[n]=a[n]||[],a[n].push(r);},es=(e,t)=>{let{obj:r,k:o}=qa(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},gm=(e,t,r)=>{let o=es(e,r);return o!==void 0?o:es(t,r)},Id=(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]):Id(e[o],t[o],r):e[o]=t[o]);return e},Hr=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),ym={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},vm=e=>be(e)?e.replace(/[&<>"'\/]/g,t=>ym[t]):e,bi=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}},bm=[" ",",","?","!",";"],hm=new bi(20),xm=(e,t,r)=>{t=t||"",r=r||"";let o=bm.filter(i=>!t.includes(i)&&!r.includes(i));if(o.length===0)return true;let a=hm.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},hi=(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},Ja=e=>e?.replace(/_/g,"-"),km={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);}},xi=class e{constructor(t,r={}){this.init(t,r);}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||km,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 xi,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);});}},ts=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=es(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:hi(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),Ad(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=es(this.data,s)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),a?Id(l,o,n):l={...l,...o},Ad(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}},Ld={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}},Ed=Symbol("i18next/PATH_KEY");function wm(){let e=[],t=Object.create(null),r;return t.get=(o,a)=>(r?.revoke?.(),a===Ed?e:(e.push(a),r=Proxy.revocable(o,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Fo(e,t){let{[Ed]:r}=e(wm()),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 yi=e=>!be(e)&&typeof e!="boolean"&&typeof e!="number",rs=class e extends oa{constructor(t,r={}){super(),pm(["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=yi(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&&!xm(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(L=>typeof L=="function"?Fo(L,{...this.options,...a}):String(L));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 g=this.resolve(t,a),f=g?.res,v=g?.usedKey||s,b=g?.exactUsedKey||s,S=["[object Number]","[object Function]","[object RegExp]"],w=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,R=!this.i18nFormat||this.i18nFormat.handleAsObject,k=a.count!==void 0&&!be(a.count),E=e.hasDefaultValue(a),A=k?this.pluralResolver.getSuffix(u,a.count,a):"",x=a.ordinal&&k?this.pluralResolver.getSuffix(u,a.count,{ordinal:false}):"",m=k&&!a.ordinal&&a.count===0,y=m&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${A}`]||a[`defaultValue${x}`]||a.defaultValue,h=f;R&&!f&&E&&(h=y);let N=yi(h),F=Object.prototype.toString.apply(h);if(R&&h&&N&&!S.includes(F)&&!(be(w)&&Array.isArray(h))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,h,{...a,ns:l}):`key '${s} (${this.language})' returned an object instead of string.`;return n?(g.res=L,g.usedParams=this.getUsedParamsDetails(a),g):L}if(i){let L=Array.isArray(h),P=L?[]:{},$=L?b:v;for(let z in h)if(Object.prototype.hasOwnProperty.call(h,z)){let I=`${$}${i}${z}`;E&&!f?P[z]=this.translate(I,{...a,defaultValue:yi(y)?y[z]:void 0,joinArrays:false,ns:l}):P[z]=this.translate(I,{...a,joinArrays:false,ns:l}),P[z]===I&&(P[z]=h[z]);}f=P;}}else if(R&&be(w)&&Array.isArray(f))f=f.join(w),f&&(f=this.extendTranslation(f,t,a,o));else {let L=false,P=false;!this.isValidLookup(f)&&E&&(L=true,f=y),this.isValidLookup(f)||(P=true,f=s);let z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:f,I=E&&y!==f&&this.options.updateMissing;if(P||L||I){if(this.logger.log(I?"updateKey":"missingKey",u,d,k&&!I?`${s}${this.pluralResolver.getSuffix(u,a.count,a)}`:s,I?y:f),i){let q=this.resolve(s,{...a,keySeparator:false});q&&q.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 X=[],ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let q=0;q<ee.length;q++)X.push(ee[q]);else this.options.saveMissingTo==="all"?X=this.languageUtils.toResolveHierarchy(a.lng||this.language):X.push(a.lng||this.language);let ie=(q,Q,pe)=>{let Se=E&&pe!==f?pe:z;this.options.missingKeyHandler?this.options.missingKeyHandler(q,d,Q,Se,I,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(q,d,Q,Se,I,a),this.emit("missingKey",q,d,Q,f);};this.options.saveMissing&&(this.options.saveMissingPlurals&&k?X.forEach(q=>{let Q=this.pluralResolver.getSuffixes(q,a);m&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!Q.includes(`${this.options.pluralSeparator}zero`)&&Q.push(`${this.options.pluralSeparator}zero`),Q.forEach(pe=>{ie([q],s+pe,a[`defaultValue${pe}`]||y);});}):ie(X,s,y));}f=this.extendTranslation(f,t,a,g,o),P&&f===s&&this.options.appendNamespaceToMissingKey&&(f=`${d}${c}${s}`),(P||L)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${c}${s}`:s,L?f:void 0,a));}return n?(g.res=f,g.usedParams=this.getUsedParamsDetails(a),g):f}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=Ld.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),g=p&&!r.ordinal&&r.count===0,f=r.context!==void 0&&(be(r.context)||typeof r.context=="number")&&r.context!=="",v=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach(b=>{this.isValidLookup(o)||(s=b,!this.checkedLoadedFor[`${v[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${v[0]}-${b}`]=true,this.logger.warn(`key "${a}" for languages "${v.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!!!")),v.forEach(S=>{if(this.isValidLookup(o))return;i=S;let w=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,c,S,b,r);else {let k;p&&(k=this.pluralResolver.getSuffix(S,r.count,r));let E=`${this.options.pluralSeparator}zero`,A=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(r.ordinal&&k.startsWith(A)&&w.push(c+k.replace(A,this.options.pluralSeparator)),w.push(c+k),g&&w.push(c+E)),f){let x=`${c}${this.options.contextSeparator||"_"}${r.context}`;w.push(x),p&&(r.ordinal&&k.startsWith(A)&&w.push(x+k.replace(A,this.options.pluralSeparator)),w.push(x+k),g&&w.push(x+E));}}let R;for(;R=w.pop();)this.isValidLookup(o)||(n=R,o=this.getResource(S,b,R,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}},os=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||false,this.logger=Rr.create("languageUtils");}getScriptPartFromCode(t){if(t=Ja(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=Ja(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}},Td={zero:0,one:1,two:2,few:3,many:4,other:5},Dd={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},ki=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=Ja(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!"),Dd;if(!t.match(/-|_/))return Dd;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)=>Td[a]-Td[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))}},Pd=(e,t,r,o=".",a=true)=>{let n=gm(e,t,r);return !n&&a&&be(r)&&(n=hi(e,r,o),n===void 0&&(n=hi(t,r,o))),n},Nm=e=>e.replace(/\$/g,"$$$$"),as=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:g,nestingSuffix:f,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:w}=t.interpolation;this.escape=r!==void 0?r:vm,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):g||Hr("$t("),this.nestingSuffix=f?Hr(f):v||Hr(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=w!==void 0?w: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=g=>{if(!g.includes(this.formatSeparator)){let S=Pd(r,l,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(S,void 0,o,{...a,...r,interpolationkey:g}):S}let f=g.split(this.formatSeparator),v=f.shift().trim(),b=f.join(this.formatSeparator).trim();return this.format(Pd(r,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,o,{...a,...r,interpolationkey:v})};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:g=>g},{regex:this.regexp,safeValue:g=>this.escapeValue?this.escape(g):g}].forEach(g=>{for(s=0;n=g.regex.exec(t);){let f=n[1].trim();if(i=d(f),i===void 0)if(typeof c=="function"){let b=c(t,n,a);i=be(b)?b:"";}else if(a&&Object.prototype.hasOwnProperty.call(a,f))i="";else if(u){i=n[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${t}`),i="";else !be(i)&&!this.useRawValueToEscape&&(i=Nd(i));let v=g.safeValue(i);if(t=t.replace(n[0],Nm(v)),u?(g.regex.lastIndex+=v.length,g.regex.lastIndex-=n[0].length):g.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 g=p.match(/'/g),f=p.match(/"/g);((g?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),d&&(i={...d,...i});}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,v),`${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=Nd(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}},Cm=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}},Rd=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(Ja(o),a),t[i]=s),s(r)}},Sm=e=>(t,r,o)=>e(Ja(r),o)(t),wi=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?Rd:Sm;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()]=Rd(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}=Cm(d);if(this.formats[c]){let p=l;try{let g=a?.formatParams?.[a.interpolationkey]||{},f=g.locale||g.lng||a.locale||a.lng||o;p=this.formats[c](l,f,{...u,...a,...g});}catch(g){this.logger.warn(g);}return p}else this.logger.warn(`there was no format function for ${c}`);return l},t)}},Am=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--);},Ni=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=>{fm(l.loaded,[n],i),Am(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);}}},vi=()=>({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}),Fd=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),Zn=()=>{},Tm=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e));});},Ci=class e extends oa{constructor(t={},r){if(super(),this.options=Fd(t),this.services={},this.logger=Rr,this.modules={external:[]},Tm(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=vi();this.options={...o,...this.options,...Fd(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=wi;let c=new os(this.options);this.store=new ts(this.options.resources,this.options);let u=this.services;u.logger=Rr,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new ki(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 as(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new Ni(a(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(p,...g)=>{this.emit(p,...g);}),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 rs(this.services,this.options),this.translator.on("*",(p,...g)=>{this.emit(p,...g);}),this.modules.external.forEach(p=>{p.init&&p.init(this);});}if(this.format=this.options.interpolation.format,r||(r=Zn),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=Wa(),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=Zn){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=Wa();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=Zn),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"&&Ld.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=Wa();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 g=this.options.keySeparator||".",f;return c.keyPrefix&&Array.isArray(s)?f=s.map(v=>(typeof v=="function"&&(v=Fo(v,p)),`${c.keyPrefix}${g}${v}`)):(typeof s=="function"&&(s=Fo(s,p)),f=c.keyPrefix?`${c.keyPrefix}${g}${s}`:s),this.t(f,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=Wa();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=Wa();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 os(vi());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=Zn){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 ts(s,a),n.services.resourceStore=n.store;}if(t.interpolation){let l={...vi().interpolation,...this.options.interpolation,...t.interpolation},d={...a,interpolation:l};n.services.interpolator=new as(d);}return n.translator=new rs(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=Ci.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;rm(Md());var ns=(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);},$d={},_r=(e,t,r,o)=>{vr(r)&&$d[r]||(vr(r)&&($d[r]=new Date),ns(e,t,r,o));},Od=(e,t)=>()=>{if(e.isInitialized)t();else {let r=()=>{setTimeout(()=>{e.off("initialized",r);},0),t();};e.on("initialized",r);}},ss=(e,t,r)=>{e.loadNamespaces(t,Od(e,r));},Si=(e,t,r,o)=>{if(vr(r)&&(r=[r]),e.options.preload&&e.options.preload.indexOf(t)>-1)return ss(e,r,o);r.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a);}),e.loadLanguages(t,Od(e,o));},Vd=(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",Ai=e=>typeof e=="object"&&e!==null;var Pm=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Rm={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"\xA9","©":"\xA9","®":"\xAE","®":"\xAE","…":"\u2026","…":"\u2026","/":"/","/":"/"},Fm=e=>Rm[e],Ti=e=>e.replace(Pm,Fm);var Di={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:true,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:true,unescape:Ti,transDefaultProps:void 0},is=(e={})=>{Di={...Di,...e};},Xa=()=>Di;var jd,ls=e=>{jd=e;},br=()=>jd;var ds={type:"3rdParty",init(e){is(e.options.react),ls(e);}};var oo=createContext(),cs=class{constructor(){this.usedNamespaces={};}addUsedNamespaces(t){t.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=true);});}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}};var Ud={" ":"\xA0","&":"&","<":"<",">":">",""":'"',"'":"'","©":"\xA9","®":"\xAE","™":"\u2122","…":"\u2026","–":"\u2013","—":"\u2014","‘":"\u2018","’":"\u2019","‚":"\u201A","“":"\u201C","”":"\u201D","„":"\u201E","†":"\u2020","‡":"\u2021","•":"\u2022","′":"\u2032","″":"\u2033","‹":"\u2039","›":"\u203A","§":"\xA7","¶":"\xB6","·":"\xB7"," ":"\u2002"," ":"\u2003"," ":"\u2009","€":"\u20AC","£":"\xA3","¥":"\xA5","¢":"\xA2","¤":"\xA4","×":"\xD7","÷":"\xF7","−":"\u2212","±":"\xB1","≠":"\u2260","≤":"\u2264","≥":"\u2265","≈":"\u2248","≡":"\u2261","∞":"\u221E","∫":"\u222B","∑":"\u2211","∏":"\u220F","√":"\u221A","∂":"\u2202","‰":"\u2030","°":"\xB0","µ":"\xB5","←":"\u2190","↑":"\u2191","→":"\u2192","↓":"\u2193","↔":"\u2194","↵":"\u21B5","⇐":"\u21D0","⇑":"\u21D1","⇒":"\u21D2","⇓":"\u21D3","⇔":"\u21D4","α":"\u03B1","β":"\u03B2","γ":"\u03B3","δ":"\u03B4","ε":"\u03B5","ζ":"\u03B6","η":"\u03B7","θ":"\u03B8","ι":"\u03B9","κ":"\u03BA","λ":"\u03BB","μ":"\u03BC","ν":"\u03BD","ξ":"\u03BE","ο":"\u03BF","π":"\u03C0","ρ":"\u03C1","σ":"\u03C3","τ":"\u03C4","υ":"\u03C5","φ":"\u03C6","χ":"\u03C7","ψ":"\u03C8","ω":"\u03C9","Α":"\u0391","Β":"\u0392","Γ":"\u0393","Δ":"\u0394","Ε":"\u0395","Ζ":"\u0396","Η":"\u0397","Θ":"\u0398","Ι":"\u0399","Κ":"\u039A","Λ":"\u039B","Μ":"\u039C","Ν":"\u039D","Ξ":"\u039E","Ο":"\u039F","Π":"\u03A0","Ρ":"\u03A1","Σ":"\u03A3","Τ":"\u03A4","Υ":"\u03A5","Φ":"\u03A6","Χ":"\u03A7","Ψ":"\u03A8","Ω":"\u03A9","À":"\xC0","Á":"\xC1","Â":"\xC2","Ã":"\xC3","Ä":"\xC4","Å":"\xC5","Æ":"\xC6","Ç":"\xC7","È":"\xC8","É":"\xC9","Ê":"\xCA","Ë":"\xCB","Ì":"\xCC","Í":"\xCD","Î":"\xCE","Ï":"\xCF","Ð":"\xD0","Ñ":"\xD1","Ò":"\xD2","Ó":"\xD3","Ô":"\xD4","Õ":"\xD5","Ö":"\xD6","Ø":"\xD8","Ù":"\xD9","Ú":"\xDA","Û":"\xDB","Ü":"\xDC","Ý":"\xDD","Þ":"\xDE","ß":"\xDF","à":"\xE0","á":"\xE1","â":"\xE2","ã":"\xE3","ä":"\xE4","å":"\xE5","æ":"\xE6","ç":"\xE7","è":"\xE8","é":"\xE9","ê":"\xEA","ë":"\xEB","ì":"\xEC","í":"\xED","î":"\xEE","ï":"\xEF","ð":"\xF0","ñ":"\xF1","ò":"\xF2","ó":"\xF3","ô":"\xF4","õ":"\xF5","ö":"\xF6","ø":"\xF8","ù":"\xF9","ú":"\xFA","û":"\xFB","ü":"\xFC","ý":"\xFD","þ":"\xFE","ÿ":"\xFF","¡":"\xA1","¿":"\xBF","ƒ":"\u0192","ˆ":"\u02C6","˜":"\u02DC","Œ":"\u0152","œ":"\u0153","Š":"\u0160","š":"\u0161","Ÿ":"\u0178","ª":"\xAA","º":"\xBA","¯":"\xAF","´":"\xB4","¸":"\xB8","¹":"\xB9","²":"\xB2","³":"\xB3","¼":"\xBC","½":"\xBD","¾":"\xBE","♠":"\u2660","♣":"\u2663","♥":"\u2665","♦":"\u2666","◊":"\u25CA","‾":"\u203E","⁄":"\u2044","℘":"\u2118","ℑ":"\u2111","ℜ":"\u211C","ℵ":"\u2135"};new RegExp(Object.keys(Ud).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"g");var zm=(e,t)=>{if(vr(t))return t;if(Ai(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},Hm={t:zm,ready:false},_m=()=>()=>{},H=(e,t={})=>{let{i18n:r}=t,{i18n:o,defaultNS:a}=useContext(oo)||{},n=r||o||br();n&&!n.reportNamespaces&&(n.reportNamespaces=new cs),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(()=>({...Xa(),...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),g=useCallback(y=>{if(!n)return _m;let{bindI18n:h,bindI18nStore:N}=i,F=()=>{p.current+=1,y();};return h&&n.on(h,F),N&&n.store.on(N,F),()=>{h&&h.split(" ").forEach(L=>n.off(L,F)),N&&N.split(" ").forEach(L=>n.store.off(L,F));}},[n,i]),f=useRef(),v=useCallback(()=>{if(!n)return Hm;let y=!!(n.isInitialized||n.initializedStoreOnce)&&u.every($=>Vd($,n,i)),h=t.lng||n.language,N=p.current,F=f.current;if(F&&F.ready===y&&F.lng===h&&F.keyPrefix===l&&F.revision===N)return F;let P={t:n.getFixedT(h,i.nsMode==="fallback"?u:u[0],l,{scopeNs:u}),ready:y,lng:h,keyPrefix:l,revision:N};return f.current=P,P},[n,u,l,i,t.lng]),[b,S]=useState(0),{t:w,ready:R}=useSyncExternalStore(g,v,v);useEffect(()=>{if(n&&!R&&!s){let y=()=>S(h=>h+1);t.lng?Si(n,t.lng,u,y):ss(n,u,y);}},[n,t.lng,u,R,s,b]);let k=n||{},E=useRef(null),A=useRef(),x=y=>{let h=Object.getOwnPropertyDescriptors(y);h.__original&&delete h.__original;let N=Object.create(Object.getPrototypeOf(y),h);if(!Object.prototype.hasOwnProperty.call(N,"__original"))try{Object.defineProperty(N,"__original",{value:y,writable:!1,enumerable:!1,configurable:!1});}catch{}return N},m=useMemo(()=>{let y=k,h=y?.language,N=y;y&&(E.current&&E.current.__original===y?A.current!==h?(N=x(y),E.current=N,A.current=h):N=E.current:(N=x(y),E.current=N,A.current=h));let F=!R&&!s?(...P)=>(_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."),w(...P)):w,L=[F,N,R];return L.t=F,L.i18n=N,L.ready=R,L},[w,k,R,k.resolvedLanguage,k.language,k.languages]);if(n&&s&&!R){let y=false;try{y=process.env.NODE_ENV!=="production";}catch{}throw y&&_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(h=>{let N=()=>h();t.lng?Si(n,t.lng,u,N):ss(n,u,N);})}return m};var{slice:qm,forEach:Jm}=[];function Xm(e){return Jm.call(qm.call(arguments,1),t=>{if(t)for(let r in t)e[r]===void 0&&(e[r]=t[r]);}),e}function Ym(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 Wd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Qm=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(!Wd.test(o.domain))throw new TypeError("option domain is invalid");n+=`; Domain=${o.domain}`;}if(o.path){if(!Wd.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},qd={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=Qm(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);}},Zm={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<"u")return qd.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:r,cookieMinutes:o,cookieDomain:a,cookieOptions:n}=t;r&&typeof document<"u"&&qd.create(r,e,o,a,n);}},ef={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}},tf={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,Jd=()=>{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},rf={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&Jd())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:r}=t;r&&Jd()&&window.localStorage.setItem(r,e);}},ia=null,Xd=()=>{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},of={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&Xd())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:r}=t;r&&Xd()&&window.sessionStorage.setItem(r,e);}},af={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}},nf={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}},sf={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}},lf={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]}},Yd=false;try{document.cookie,Yd=!0;}catch{}var Qd=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Yd||Qd.splice(1,1);var df=()=>({order:Qd,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),Ya=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=Xm(r,this.options||{},df()),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(Zm),this.addDetector(ef),this.addDetector(rf),this.addDetector(of),this.addDetector(af),this.addDetector(nf),this.addDetector(sf),this.addDetector(lf),this.addDetector(tf);}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&&!Ym(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);}));}};Ya.type="languageDetector";var Zd={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 ec={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 tc={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 rc={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 oc={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 gf={en:{translation:Zd},fr:{translation:ec},es:{translation:tc},de:{translation:rc},pt:{translation:oc}},ac=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";Bt.use(Ya).use(ds).init({resources:gf,fallbackLng:ac,lng:ac,interpolation:{escapeValue:false}});function Io(e,t,r){return r in t?t[r]:Ri(e,t,r)}function Ri(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=Ri(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=Ri(o.fields||[],a,r);if(n!==void 0)return n}}}}function Li({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,g=()=>{if(c)if(a)a();else {let O=`${_e}/${l}/new`;Lt(O);}},f=O=>{if(n)n(O);else {let ae=`${_e}/${l}/${O}`;Lt(ae);}},[v,b]=useState(r),[S,w]=useState(o),[R,k]=useState(false),[E,A]=useState(1),[x,m]=useState(10),[y,h]=useState(new Set),[N,F]=useState(""),[L,P]=useState(""),[$,z]=useState([]);useEffect(()=>{let O=setTimeout(()=>{P(N),A(1);},300);return ()=>clearTimeout(O)},[N]);let{confirm:I,alert:X$1}=vt(),ee=()=>{z([...$,{field:"",operator:"equals",value:""}]);},ie=()=>{F(""),z([]),Se(null);},q=O=>{z($.filter((ae,ue)=>ue!==O));},Q=(O,ae)=>{z($.map((ue,Ht)=>Ht===O?{...ue,...ae}:ue));},[pe,Se]=useState(null),[j,_]=useState(false),[K,he]=useState(false);function Me(O){let ae=[];for(let ue of O||[])if(!(ue.hidden===true||ue.admin?.hidden||ue.name==="id"))if(ue.type==="tabs"&&ue.tabs)for(let Ht of ue.tabs)Ht.fields&&ae.push(...Me(Ht.fields));else if((ue.type==="row"||ue.type==="collapsible")&&ue.fields)ae.push(...Me(ue.fields));else {if(!ue.name)continue;ae.push(ue);}return ae}let ke=useMemo(()=>Me(e.fields),[e.fields]),C=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:ke.find(O=>O.type!=="group"&&typeof O.name=="string")?.name,[G,we]=useState(()=>{let O;return e.admin?.defaultColumns?O=[...e.admin?.defaultColumns||[]]:O=ke.slice(0,4).map(ae=>ae.name).filter(ae=>!!ae),C&&O.includes(C)&&(O=[C,...O.filter(ae=>ae!==C)]),O.includes("updatedAt")||O.push("updatedAt"),new Set(O)}),Ve=useCallback(O=>{we(ae=>{let ue=new Set(ae);return ue.has(O)?ue.delete(O):ue.add(O),ue});},[]);function je(O){let ae=ke.find(ue=>ue.name===O);return ae&&ae.type==="group"&&ae.fields?.[0]?.name?`${O}.${ae.fields[0].name}`:O}let Ie=useCallback(O=>{let ae=je(O);Se(ue=>ue&&ue.field===ae?{field:ae,direction:ue.direction==="asc"?"desc":"asc"}:{field:ae,direction:"asc"});},[]),mt=useMemo(()=>{let O=[];for(let ae of Array.from(G))if(ae==="status")O.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let ue=ke.find(Ht=>Ht.name===ae);ue&&ue.name&&O.push(ue);}return O},[ke,G]);function Cr(O){return !O.name||!C?false:O.name===C||O.type==="group"&&O.fields?.[0]?.name===C}function oe(O,ae){return ae.name?Io(e.fields,O,ae.name)??null:null}let V=useCallback(async()=>{k(true);try{let O=new URLSearchParams({page:E.toString(),limit:x.toString(),depth:"1"});L&&O.append("search",L),pe&&O.append("sort",pe.field),pe&&O.append("order",pe.direction),$.length>0&&O.append("filters",JSON.stringify($));let ae=await Le(eo(`/api/${l}?${O}`),{autoToast:!1});b(ae.docs||[]),w(ae.totalDocs||0);}catch(O){console.error("Failed to load docs:",O);}finally{k(false);}},[l,E,x,L,pe,$]);useEffect(()=>{v.length===0&&o===0&&V();},[]);let Y=useRef(true);useEffect(()=>{if(Y.current){Y.current=false;return}V();},[E,x,L,pe,$]);let le=()=>{y.size===v.length?h(new Set):h(new Set(v.map(O=>O.id)));},Ae=O=>{let ae=new Set(y);ae.has(O)?ae.delete(O):ae.add(O),h(ae);},$e=()=>{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:y.size}),variant:"danger",onConfirm:async()=>{try{for(let O of Array.from(y))await Dt(`/api/${l}/${O}`);h(new Set),V(),U.success("Documents deleted");}catch(O){console.error("Bulk delete failed:",O),U.error("Failed to delete some documents");}}});},Tt=O=>{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}`),V(),U.success("Document deleted");}catch(ae){console.error("Delete failed:",ae),U.error("Failed to delete document");}}});},gr=Math.ceil(S/x),Or=N||$.length>0||pe;return jsxs("div",{className:"space-y-6",children:[jsx(jt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:S>0?[jsxs("span",{className:"text-xs font-bold opacity-60",children:[S," 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?g: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:N,onChange:O=>F(O.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:()=>_(!j),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${j||$.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"}),$.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:$.length})]}),jsxs("div",{className:"relative",children:[jsxs("button",{type:"button",onClick:()=>he(!K),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"})]}),K&&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:ke.map(O=>O.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(O.name),onChange:()=>Ve(O.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:O.label||O.name})]},O.name):null)})]})]}),Or&&jsx("button",{type:"button",onClick:ie,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"})})]})]}),j&&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:ee,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:[$.map((O,ae)=>jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsx("select",{value:O.field,onChange:ue=>Q(ae,{field:ue.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:ke.map(ue=>jsx("option",{value:ue.name,children:ue.label||ue.name},ue.name))}),jsxs("select",{value:O.operator,onChange:ue=>Q(ae,{operator:ue.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:O.value,onChange:ue=>Q(ae,{value:ue.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:()=>q(ae),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsx(X,{className:"w-4 h-4"})})]},ae)),$.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.'})})]})]}),y.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:y.size})}),jsxs("div",{className:"flex gap-2",children:[u&&jsxs("button",{type:"button",onClick:$e,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:()=>h(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:R?jsx("div",{className:"space-y-2 p-4",children:jsx(Wt,{variant:"table-row",count:8})}):v.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:g,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:y.size===v.length&&v.length>0,onChange:le,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),mt.map(O=>jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Ie(O.name),children:jsxs("div",{className:"flex items-center gap-2",children:[bf(mt,O.type)??(O.label||O.name),pe&&pe.field===O.name&&jsx(ChevronUp,{className:"w-4 h-4"})]})},O.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:v.map(O=>jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>f(O.id),children:[jsx("td",{className:"px-4 py-3",onClick:ae=>ae.stopPropagation(),children:jsx("input",{type:"checkbox",checked:y.has(O.id),onChange:()=>Ae(O.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(ae=>{let ue=oe(O,ae),Ht=ae.type==="select"&&ue&&Array.isArray(ae.options)?ae.options.find(Wo=>Wo.value===ue)?.label||ue:vf(ue,ae.type,s);return jsx("td",{className:`px-4 py-3 ${Cr(ae)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Ht},ae.name)}),e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:O.createdAt?new Date(O.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:O.updatedAt?new Date(O.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsx("td",{className:"px-4 py-3 text-right",onClick:ae=>ae.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:()=>f(O.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(O.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"})})]})})]},O.id))})]})})}),jsx(wd,{page:E,totalPages:gr,totalDocs:S,limit:x,onPageChange:A,onLimitChange:O=>{m(O),A(1);}})]})}function vf(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 bf(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}function Za(e){return e?Array.isArray(e)?e:Object.values(e):[]}function fs(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function gs(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Qa(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 xf={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 s of i.tabs)if(s.fields&&Array.isArray(s.fields)&&Lo(s.fields,n,r))return true;return false}if(i.type==="blocks"&&i.blocks&&Array.isArray(i.blocks)){let s=n.split(".")[0],l=n.split(".").slice(1).join(".");if(!l)return false;for(let d of i.blocks)if(d.slug===s&&d.fields&&Array.isArray(d.fields))return Lo(d.fields,l,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;for(let i of e)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 n?false:(e.push({name:a,...r}),true)}function kf(e,t){for(let[r,o]of Object.entries(e)){let a=xf[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 wf(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 Qa(t,Object.values(mediaCollections)),Qa(t,Object.values(authCollections)),{collections:fs(t),globals:gs(r)}}function Nf(e){let t=Za(e.collections),r=Za(e.globals);if(t.length===0&&r.length===0)return wf("kitchen-sink");let o=[];return Qa(o,Object.values(mediaCollections)),Qa(o,Object.values(authCollections)),Qa(o,t),{collections:fs(o),globals:gs(r)}}function Cf(){return projectConfig?projectConfig:null}var fc=Cf()||{collections:[],globals:[]},gc=Nf(fc);kf(gc.collections,fc.collectionOverrides||{});var yc=gc,la=yc.collections,vc=yc.globals,Bi=["users","audit_logs"];Object.values(la).filter(e=>!Bi.includes(e.slug)&&e.admin?.hidden!==true);function ys({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 $i(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 vs=null,bc=false,Oi=async()=>(vs&&bc||(vs=createStorage({driver:Rf({dbName:"kyro-autosave",storeName:"autosave"})}),bc=true),vs),Ff=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Oi()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Oi()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Oi()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ge=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)=>{if(!r||r==="undefined")return;let a=t(),n=new Set(a.dirtyFields),i=qt(o),s=qt(a.lastSavedData[r]);$i(i)&&$i(s)||Eo(i,s)?n.delete(r):n.add(r);let l={...a.formData};delete l.undefined,delete l.undefined,l[r]=o,e({formData:l,dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{let o={...r};delete o.undefined,delete o.undefined,e({formData:o});},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,delete i.undefined,delete i.undefined,{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={...r};delete a.undefined,delete a.undefined;let n=o?{...o}:a;delete n.undefined,delete n.undefined;let i=t();i.formData===a&&i.lastSavedData===n&&!i.hasUnsavedChanges||e({formData:a,lastSavedData:n,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(()=>Ff()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));var hc="other";function xc(){return hc}function bs(e){hc=e;}function hs(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function wc(){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 Nc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:i,onActionError:s}){let l=ge(),{confirm:d}=vt(),{formData:c,setFormData:u,setField:p,lastSavedData:g,setLastSavedData:f,setHasUnsavedChanges:v,isSlugLocked:b,loadDocument:S,setIsAutoSaving:w,setAutoSaveStatus:R,setVersions:k,setLoadingVersions:E,sidebarCollapsed:A,setSidebarCollapsed:x,getDraftCache:m,setDraftCache:y,clearDraftCache:h,resetForm:N}=l,F=!!e?.versions,L=o||t?.id||a||r,P=useRef(false);!o&&L&&c&&Object.keys(c).length>0&&c.id!==L&&(P.current=true),useEffect(()=>{P.current&&(P.current=false,N());},[N]);let $=useRef(null),z=useRef(null),I=useRef(null),X=useRef(typeof navigator<"u"?navigator.onLine:true),ee=useRef(0),ie=useRef(false),q=useRef(null),Q=useRef(""),pe=useRef(""),{queueTask:Se}=wc(),j=useCallback(oe=>o?`global:${o}`:r&&oe?`${r}:${oe}`:null,[r,o]),_=useCallback((oe,V,Y)=>{y(oe,{data:V,baseUpdatedAt:g.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:Y?.lastSyncedAt??null});},[g.updatedAt,y]),K=useCallback(async()=>{let oe=o?Ye(`/api/globals/${o}/versions`):r&&c.id?Ye(`/api/${r}/${c.id}/versions`):null;if(oe){E(true);try{let Y=await(await ct(oe)).json();k(Y.docs||[]);}catch(V){console.error("Failed to fetch versions:",V);}finally{E(false);}}},[c.id,r,o,E,k]),he=useCallback(()=>{let oe=ge.getState(),V=oe.formData;if(ie.current||!r||!V.id||!oe.hasDirtyFields())return;let Y=j(V.id);Y&&_(Y,V);},[r,j,_]),Me=useCallback(async oe=>{let V=ge.getState(),Y=V.formData,le=V.lastSavedData;if(ie.current||!o&&(!r||!Y.id)||!V.hasDirtyFields())return;let Ae=j(Y.id);if(Ae&&_(Ae,Y),!X.current){R("offline");return}w(true),R("saving"),V.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let $e=o?Ye(`/api/globals/${o}?autosave=true`):Ye(`/api/${r}/${Y.id}?autosave=true`),Tt=await ct($e,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:oe?.keepalive,body:JSON.stringify({...qt(Y,!0),baseUpdatedAt:le.updatedAt??null})});if(Tt.ok)ee.current=Date.now(),V.setRetryCount(0),V.setLastSavedAt(Date.now()),I.current&&clearTimeout(I.current),Ae&&y(Ae,{data:Y,baseUpdatedAt:le.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),R("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&R("idle");},2e3);else if(Tt.status===409)R("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch($e){console.error("Auto-save failed:",$e);let Tt=ge.getState(),gr=Tt.retryCount;if(gr<5){Tt.setRetryCount(gr+1),R("retrying");let Or=Math.min(1e3*Math.pow(2,gr),6e4);I.current&&clearTimeout(I.current),I.current=setTimeout(()=>ke(oe),Or);}else R("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),w(false),ge.getState().setBackgroundProcessing(false);}},[r,j,o,_,R,y,w,F]),ke=useCallback(oe=>{Se(()=>Me(oe),{beforeProcess:()=>true,afterProcess:()=>{}});},[Me,Se]),C=useCallback(async(oe,V=true)=>{let Y=ge.getState(),le=oe||Y.formData,Ae=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${le.id}`),$e=await ct(Ae,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(V)},body:JSON.stringify({...qt(le,true),baseUpdatedAt:Y.lastSavedData.updatedAt??null})});return $e.status===409&&R("conflict"),$e},[r,o,R]),G=useCallback(async(oe=true)=>{let V=ge.getState(),Y=V.formData,le=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${Y.id}`),Ae=await ct(le,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(oe)},body:JSON.stringify({...qt(Y,true)})});if(Ae.ok){let Tt=(await Ae.json()).data||Y;V.loadDocument(Tt,Tt),R("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&R("idle");},2e3);}return Ae},[r,o,R]);useEffect(()=>{let oe=()=>{x(!A);};return window.addEventListener("toggle-sidebar",oe),()=>window.removeEventListener("toggle-sidebar",oe)},[A,x]);let we=useRef(null),Ve=useRef(""),je=useRef(false);useEffect(()=>{let oe=o||t?.id,V=JSON.stringify(t);je.current&&we.current===oe&&Ve.current===V||(S(t||{},t||{}),je.current=true,we.current=oe,Ve.current=V);},[r,c.id,o,t,S]),useEffect(()=>{if(!r||!t?.id)return;let oe=j(c.id);if(!oe||q.current===oe)return;let V=false;return (async()=>{if(!F)return;let le=m(oe);if(le){if(JSON.stringify(le.data)===JSON.stringify(t)){h(oe);return}q.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(V)return;let $e={...ge.getState().formData,...le.data};u($e),i?.("Recovered autosaved draft");},onCancel:async()=>{h(oe);}});}})(),()=>{V=true;}},[h,r,d,j,m,t,i,u,F]);function Ie(oe,V){for(let Y of oe){if(Y.name===V&&Y.admin?.autoGenerate==="title")return Y;if(Y.type==="tabs"&&"tabs"in Y)for(let le of Y.tabs){let Ae=Ie(le.fields,V);if(Ae)return Ae}if((Y.type==="group"||Y.type==="collapsible")&&"fields"in Y){let le=Ie(Y.fields,V);if(le)return le}}}useEffect(()=>{if(!e?.fields)return;let oe=e.fields;if(!Ie(oe,"metaTitle"))return;let Y=Io(oe,c,"title"),le=Y?String(Y):"";le&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&c.metaTitle!==le&&ge.setState(Ae=>({formData:{...Ae.formData,metaTitle:le,_lastMetaTitle:le}}));},[c.title,e?.fields]),useEffect(()=>{let oe=e?.fields,V=oe?.find(Ae=>Ae.name==="slug"&&Ae.admin?.autoGenerate);if(!V?.admin?.autoGenerate)return;let Y=V.admin.autoGenerate,le=Io(oe,c,Y);if(b&&typeof le=="string"&&le){let Ae=hs(le);Ae&&Ae!==c.slug&&ge.setState($e=>({formData:{...$e.formData,slug:Ae}}));}},[c.title,b,e?.fields]),useEffect(()=>{if(A||!o&&(!r||!c.id)||!ge.getState().hasDirtyFields()||xc()!=="keystroke")return;bs("other");let V=JSON.stringify(c);V!==Q.current&&($.current&&clearTimeout($.current),$.current=setTimeout(he,1500),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{Q.current=V,ke();},8e3));},[c,A,r,o,he,ke]),useEffect(()=>{if(!o&&(!r||!c.id))return;let oe=()=>{ie.current||!ge.getState().hasDirtyFields()||ke({keepalive:true});},V=()=>{document.hidden&&oe();},Y=()=>{X.current=true,oe();},le=()=>{X.current=false;let Ae=ge.getState();Ae.hasDirtyFields()&&Ae.setAutoSaveStatus("offline");};return window.addEventListener("blur",oe),window.addEventListener("pagehide",oe),window.addEventListener("online",Y),window.addEventListener("offline",le),document.addEventListener("visibilitychange",V),()=>{window.removeEventListener("blur",oe),window.removeEventListener("pagehide",oe),window.removeEventListener("online",Y),window.removeEventListener("offline",le),document.removeEventListener("visibilitychange",V);}},[r,o,c.id,ke]),useEffect(()=>{let oe=JSON.stringify(c);if(oe===pe.current)return;pe.current=oe;let V=document.getElementById("form-data");V&&(V.value=oe),n?.(c);},[c,n]),useEffect(()=>{(o||c.id)&&K();},[c.id,o,K]);let mt=!c.id&&!o?"draft":F&&c.status||"published",Cr=(!!c.id||!!o)&&mt==="draft";return {...l,fetchVersions:K,performAutoSave:ke,saveDocument:C,forceSave:G,autoSaveSkipRef:ie,lastAutoSaveTimeRef:ee,documentStatus:mt,hasUnpublishedChanges:Cr,versionsEnabled:F}}var en=({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,g]=useState([]),[f,v]=useState(false),[b,S]=useState([]),[w,R]=useState(true);useEffect(()=>{Le("/api/collections").then(F=>{S((F.collections||[]).map(L=>L.slug||L.name||L)),R(false);}).catch(()=>R(false));},[]);let k=(F="")=>{v(true);let L=`/api/${e}?${Pn(F,[a],20)}`;Le(L).then(P=>{g(P.docs||[]),v(false);}).catch(()=>v(false));};useEffect(()=>{l&&k(c);},[l,c,e,a]);let E=F=>F?.[a]||F?.title||F?.name||F?.label||F?.filename||F?.slug||F?.id||"Untitled",A=t?r:o?[o]:[],x=F=>{t?A.includes(F.id)?n("selectedIds",A.filter(L=>L!==F.id)):n("selectedIds",[...A,F.id]):(n("selectedId",F.id),n("selectedIds",[F.id]),d(false));},m=F=>A.includes(F),y=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",h=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",N=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:[!N&&jsx(Fragment,{children:w?jsx("div",{className:h+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxs("select",{value:e,onChange:F=>n("relationTo",F.target.value),className:h,children:[jsx("option",{value:"",children:"Select collection..."}),b.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:`${y} pl-9`}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:f&&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:f?jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):p.length===0?jsx(ys,{title:s("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:p.map(F=>jsxs("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>x(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 ${m(F.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsx("span",{children:E(F)}),m(F.id)&&jsx("span",{children:"\u2713"})]},F.id))})})]}),A.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(F=>{let L=p.find(P=>P.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:[E(L),jsx("button",{type:"button",onMouseDown:P=>P.preventDefault(),onClick:()=>{t?n("selectedIds",A.filter(P=>P!==F)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]},F)})})]})};var Vi=(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"},Dc=({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,g]=useState([]),[f,v]=useState([]),[b,S]=useState(""),[w,R]=useState(false),[k,E]=useState(""),[A,x]=useState(false),[m,y]=useState(""),[h,N]=useState(""),[F,L]=useState([]),P=e?.label||e?.name||"File",$=e.maxCount??(e.hasMany?999:1),z=$>1,I=Array.isArray(t)?t:t?[t]:[],X$1=I.length<$,[ee,ie]=useState({});useEffect(()=>{(async()=>{let G=I.filter(Ie=>typeof Ie=="string").map(Ie=>Ie),we=I.filter(Ie=>typeof Ie=="object"&&Ie!==null&&typeof Ie.id=="string"&&!Ie.url&&!Ie.filename&&!Ie.mimeType).map(Ie=>Ie.id),je=[...G,...we].filter(Ie=>!ee[Ie]);if(je.length!==0)try{let Ie=await Promise.all(je.map(mt=>Le(`/api/media/${mt}`)));ie(mt=>{let Cr={...mt};return Ie.forEach(oe=>{oe&&oe.id&&(Cr[oe.id]=oe);}),Cr});}catch(Ie){console.error("Failed to fetch media details:",Ie);}})();},[t,ee]),useEffect(()=>{l&&(q(),Q());},[l,b]);let q=async()=>{try{let C=await Le(eo("/api/media/folders"));v(C.folders||[]);}catch{v([]);}},Q=async()=>{R(true);try{let C=eo("/api/media?limit=60&sortBy=createdAt&sortDir=desc");b&&(C+="&folder="+encodeURIComponent(b));let G=await Le(C);g(G.docs||[]);}catch{g([]);}finally{R(false);}},pe=async C=>{s(true);try{let G=new FormData;G.append("file",C),b&&G.append("folder",b);let we=await Rn("/api/media/upload",G),Ve=we.data||we.doc||we,je={...Ve,id:Ve.id,filename:Ve.filename,originalName:Ve.originalName??C.name,url:Ve.url,mimeType:Ve.mimeType||C.type};r(z?[...I,je]:je),U.success(`Asset synchronized: ${je.filename}`);}catch(G){console.error("Upload failed:",G),U.error(`Upload failed: ${G instanceof Error?G.message:"Unknown error"}`);}finally{s(false);}},Se=async()=>{let C=m.trim();if(C){N("");try{let G=await ut("/api/media/upload",{url:C}),we=(()=>{try{return new URL(C).pathname.split("/").pop()||G.originalName||"url-image"}catch{return G.originalName||"url-image"}})(),Ve={id:G.id,filename:G.filename,originalName:we,url:G.url,mimeType:G.mimeType||"image/*"};r(z?[...I,Ve]:Ve),U.success(`URL asset established: ${Ve.filename}`),y(""),x(!1);}catch(G){let we=G instanceof Error?G.message:"Invalid URL";N(we);}}},j=C=>({id:C.id,filename:C.filename,url:C.url,mimeType:C.mimeType}),_=C=>{z?L(G=>G.find(Ve=>Ve.id===C.id)?G.filter(Ve=>Ve.id!==C.id):[...G,C]):(r(j(C)),d(false),E(""));},K=()=>{if(F.length>0){let C=[...I,...F.map(j)];r(C);}L([]),d(false),E("");},he=C=>{let G=[...I];G.splice(C,1),r(z?G:G[0]||null);},Me=useMemo(()=>p.filter(C=>!k||C.filename?.toLowerCase().includes(k.toLowerCase())||C.title?.toLowerCase().includes(k.toLowerCase())),[p,k]);if(i)return jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let ke=(C,G)=>{if(!C)return null;let we=typeof C=="string"?C:C.id,Ve=ee[we]||(typeof C=="object"?C:{}),je=Vi(Ve.mimeType,Ve.filename||Ve.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:je==="image"?jsx("img",{src:za(Ve.url),alt:Ve.filename||"Preview",className:"w-full h-full object-cover"}):jsx(Dc,{type:je,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:Ve.originalName||Ve.filename||"Unnamed File"}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:P})]}),jsx("button",{type:"button",onClick:()=>G!==void 0?he(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&&pe(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)=>ke(C,G))}),(!I.length||X$1)&&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 ",P]}),jsx("button",{type:"button",onClick:()=>{L([]),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:()=>x(!A),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"})]}),A&&jsxs("div",{className:"flex gap-2 items-center",children:[jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:m,onChange:C=>{y(C.target.value),N("");},onKeyDown:C=>C.key==="Enter"&&Se(),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:Se,disabled:o||!m.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"}),h&&jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:h})]}),l&&(c?createPortal(jsx(Tc,{isFullscreen:true,isMultiple:z,selectedItems:F,pickerSearch:k,setPickerSearch:E,folders:f,selectedFolder:b,setSelectedFolder:S,mediaLoading:w,filteredMedia:Me,selectFromLibrary:_,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsx(Tc,{isFullscreen:false,isMultiple:z,selectedItems:F,pickerSearch:k,setPickerSearch:E,folders:f,selectedFolder:b,setSelectedFolder:S,mediaLoading:w,filteredMedia:Me,selectFromLibrary:_,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Tc({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:g}){let{t:f}=H(),v=b=>r.some(S=>S.id===b);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:f("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:b=>a(b.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(b=>jsx("button",{type:"button",onClick:()=>s(b.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===b.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:b.name},b.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(b=>{let S=v(b.id);return jsxs("button",{type:"button",onClick:()=>c(b),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${S?"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:Vi(b.mimeType,b.filename)==="image"?jsx("img",{src:za(b.thumbnailUrl||b.url),alt:b.filename,className:"w-full h-full object-cover"}):jsx(Dc,{type:Vi(b.mimeType,b.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&S&&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"})})]},b.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:()=>{g(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 ia,{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 Gc 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 Lf from'unstorage/drivers/indexedb';import {createPortal}from'react-dom';import {useEditor,EditorContent}from'@tiptap/react';import lg from'@tiptap/starter-kit';import {marked}from'marked';import cg from'@tiptap/extension-link';import ug from'@tiptap/extension-image';import pg from'@tiptap/extension-text-align';import mg from'@tiptap/extension-underline';import fg from'@tiptap/extension-highlight';import gg from'@tiptap/extension-task-list';import yg from'@tiptap/extension-task-item';import {TextStyle}from'@tiptap/extension-text-style';import bg from'@tiptap/extension-color';import Xf 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 kv from'@uiw/react-codemirror';import {json}from'@codemirror/lang-json';import'@kyro-cms/core/client';var Qp=Object.create;var El=Object.defineProperty;var Zp=Object.getOwnPropertyDescriptor;var em=Object.getOwnPropertyNames;var tm=Object.getPrototypeOf,rm=Object.prototype.hasOwnProperty;var om=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var am=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of em(t))!rm.call(e,a)&&a!==r&&El(e,a,{get:()=>t[a],enumerable:!(o=Zp(t,a))||o.enumerable});return e};var nm=(e,t,r)=>(r=e!=null?Qp(tm(e)):{},am(!e||!e.__esModule?El(r,"default",{value:e,enumerable:true}):r,e));var $d=om((p0,Md)=>{Md.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 ai(e){return e.startsWith("http")||e.startsWith(_e)?e:e.startsWith("/admin/")?_e+e.slice(6):e.startsWith("/")?_e+e:e}function Ha(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var sm={admin:_e,api:Dr,resolveApi:Ye,resolveAdmin:ai,resolveMedia:Ha};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:[]})})),V={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 lm="/api/auth/refresh";async function Bl(){try{return (await fetch(Ye(lm),{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 Bl()){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 Ie(e,t){let{autoToast:r=true,...o}=t||{},a=await ct(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&V.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&&V.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&&V.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&&V.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 Pn(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function Rn(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?Bl().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 hd({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 cm({breadcrumbs:e}){return e?.map((t,r)=>jsxs(ia.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 xd({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 kd({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 rounded-lg",children:[jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxs("div",{className:"flex items-center gap-2",children:[n&&jsx(hd,{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(ia.Fragment,{children:[u>0&&jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsx("a",{href:c.href,onClick:m=>{c.onClick&&(m.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(ia.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(ia.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(hd,{back:n}),o&&jsx(cm,{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(ia.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(xd,{actions:s}),i&&jsx(kd,{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(kd,{action:i}),s&&jsx(xd,{actions:s})]})]})}var pm={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=pm[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 fi({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 gi({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 Nd({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)] rounded-lg",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(gi,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsx(gi,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}var be=e=>typeof e=="string",qa=()=>{let e,t,r=new Promise((o,a)=>{e=o,t=a;});return r.resolve=e,r.reject=t,r},Cd=e=>e==null?"":String(e),gm=(e,t,r)=>{e.forEach(o=>{t[o]&&(r[o]=t[o]);});},ym=/###/g,Sd=e=>e&&e.includes("###")?e.replace(ym,"."):e,Ad=e=>!e||be(e),Ja=(e,t,r)=>{let o=be(t)?t.split("."):t,a=0;for(;a<o.length-1;){if(Ad(e))return {};let n=Sd(o[a]);!e[n]&&r&&(e[n]=new r),Object.prototype.hasOwnProperty.call(e,n)?e=e[n]:e={},++a;}return Ad(e)?{}:{obj:e,k:Sd(o[a])}},Td=(e,t,r)=>{let{obj:o,k:a}=Ja(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=Ja(e,i,Object);for(;s.obj===void 0&&i.length;)n=`${i[i.length-1]}.${n}`,i=i.slice(0,i.length-1),s=Ja(e,i,Object),s?.obj&&typeof s.obj[`${s.k}.${n}`]<"u"&&(s.obj=void 0);s.obj[`${s.k}.${n}`]=r;},vm=(e,t,r,o)=>{let{obj:a,k:n}=Ja(e,t,Object);a[n]=a[n]||[],a[n].push(r);},es=(e,t)=>{let{obj:r,k:o}=Ja(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},bm=(e,t,r)=>{let o=es(e,r);return o!==void 0?o:es(t,r)},Ld=(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]):Ld(e[o],t[o],r):e[o]=t[o]);return e},Hr=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),hm={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},xm=e=>be(e)?e.replace(/[&<>"'\/]/g,t=>hm[t]):e,bi=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}},km=[" ",",","?","!",";"],wm=new bi(20),Nm=(e,t,r)=>{t=t||"",r=r||"";let o=km.filter(i=>!t.includes(i)&&!r.includes(i));if(o.length===0)return true;let a=wm.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},hi=(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},Xa=e=>e?.replace(/_/g,"-"),Cm={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);}},xi=class e{constructor(t,r={}){this.init(t,r);}init(t,r={}){this.prefix=r.prefix||"i18next:",this.logger=t||Cm,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 xi,na=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);});}},ts=class extends na{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=es(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:hi(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),Td(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=es(this.data,s)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),a?Ld(l,o,n):l={...l,...o},Td(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}},Ed={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}},Bd=Symbol("i18next/PATH_KEY");function Sm(){let e=[],t=Object.create(null),r;return t.get=(o,a)=>(r?.revoke?.(),a===Bd?e:(e.push(a),r=Proxy.revocable(o,t),r.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Fo(e,t){let{[Bd]:r}=e(Sm()),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 yi=e=>!be(e)&&typeof e!="boolean"&&typeof e!="number",rs=class e extends na{constructor(t,r={}){super(),gm(["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=yi(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&&!Nm(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(L=>typeof L=="function"?Fo(L,{...this.options,...a}):String(L));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,m=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return m?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 v=this.resolve(t,a),f=v?.res,b=v?.usedKey||s,h=v?.exactUsedKey||s,C=["[object Number]","[object Function]","[object RegExp]"],x=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,R=!this.i18nFormat||this.i18nFormat.handleAsObject,k=a.count!==void 0&&!be(a.count),E=e.hasDefaultValue(a),S=k?this.pluralResolver.getSuffix(u,a.count,a):"",D=a.ordinal&&k?this.pluralResolver.getSuffix(u,a.count,{ordinal:false}):"",g=k&&!a.ordinal&&a.count===0,p=g&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${S}`]||a[`defaultValue${D}`]||a.defaultValue,y=f;R&&!f&&E&&(y=p);let w=yi(y),F=Object.prototype.toString.apply(y);if(R&&y&&w&&!C.includes(F)&&!(be(x)&&Array.isArray(y))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,y,{...a,ns:l}):`key '${s} (${this.language})' returned an object instead of string.`;return n?(v.res=L,v.usedParams=this.getUsedParamsDetails(a),v):L}if(i){let L=Array.isArray(y),P=L?[]:{},$=L?h:b;for(let z in y)if(Object.prototype.hasOwnProperty.call(y,z)){let I=`${$}${i}${z}`;E&&!f?P[z]=this.translate(I,{...a,defaultValue:yi(p)?p[z]:void 0,joinArrays:false,ns:l}):P[z]=this.translate(I,{...a,joinArrays:false,ns:l}),P[z]===I&&(P[z]=y[z]);}f=P;}}else if(R&&be(x)&&Array.isArray(f))f=f.join(x),f&&(f=this.extendTranslation(f,t,a,o));else {let L=false,P=false;!this.isValidLookup(f)&&E&&(L=true,f=p),this.isValidLookup(f)||(P=true,f=s);let z=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:f,I=E&&p!==f&&this.options.updateMissing;if(P||L||I){if(this.logger.log(I?"updateKey":"missingKey",u,d,k&&!I?`${s}${this.pluralResolver.getSuffix(u,a.count,a)}`:s,I?p:f),i){let q=this.resolve(s,{...a,keySeparator:false});q&&q.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 X=[],ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let q=0;q<ee.length;q++)X.push(ee[q]);else this.options.saveMissingTo==="all"?X=this.languageUtils.toResolveHierarchy(a.lng||this.language):X.push(a.lng||this.language);let ie=(q,Q,pe)=>{let Ae=E&&pe!==f?pe:z;this.options.missingKeyHandler?this.options.missingKeyHandler(q,d,Q,Ae,I,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(q,d,Q,Ae,I,a),this.emit("missingKey",q,d,Q,f);};this.options.saveMissing&&(this.options.saveMissingPlurals&&k?X.forEach(q=>{let Q=this.pluralResolver.getSuffixes(q,a);g&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!Q.includes(`${this.options.pluralSeparator}zero`)&&Q.push(`${this.options.pluralSeparator}zero`),Q.forEach(pe=>{ie([q],s+pe,a[`defaultValue${pe}`]||p);});}):ie(X,s,p));}f=this.extendTranslation(f,t,a,v,o),P&&f===s&&this.options.appendNamespaceToMissingKey&&(f=`${d}${c}${s}`),(P||L)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${c}${s}`:s,L?f:void 0,a));}return n?(v.res=f,v.usedParams=this.getUsedParamsDetails(a),v):f}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),m=u&&u.length;d<m&&(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=Ed.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 m=r.count!==void 0&&!be(r.count),v=m&&!r.ordinal&&r.count===0,f=r.context!==void 0&&(be(r.context)||typeof r.context=="number")&&r.context!=="",b=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);u.forEach(h=>{this.isValidLookup(o)||(s=h,!this.checkedLoadedFor[`${b[0]}-${h}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${b[0]}-${h}`]=true,this.logger.warn(`key "${a}" for languages "${b.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!!!")),b.forEach(C=>{if(this.isValidLookup(o))return;i=C;let x=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(x,c,C,h,r);else {let k;m&&(k=this.pluralResolver.getSuffix(C,r.count,r));let E=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(r.ordinal&&k.startsWith(S)&&x.push(c+k.replace(S,this.options.pluralSeparator)),x.push(c+k),v&&x.push(c+E)),f){let D=`${c}${this.options.contextSeparator||"_"}${r.context}`;x.push(D),m&&(r.ordinal&&k.startsWith(S)&&x.push(D+k.replace(S,this.options.pluralSeparator)),x.push(D+k),v&&x.push(D+E));}}let R;for(;R=x.pop();)this.isValidLookup(o)||(n=R,o=this.getResource(C,h,R,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}},os=class{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||false,this.logger=Rr.create("languageUtils");}getScriptPartFromCode(t){if(t=Xa(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=Xa(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}},Dd={zero:0,one:1,two:2,few:3,many:4,other:5},Pd={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})},ki=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=Xa(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!"),Pd;if(!t.match(/-|_/))return Pd;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)=>Dd[a]-Dd[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))}},Rd=(e,t,r,o=".",a=true)=>{let n=bm(e,t,r);return !n&&a&&be(r)&&(n=hi(e,r,o),n===void 0&&(n=hi(t,r,o))),n},Am=e=>e.replace(/\$/g,"$$$$"),as=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:m,nestingPrefixEscaped:v,nestingSuffix:f,nestingSuffixEscaped:b,nestingOptionsSeparator:h,maxReplaces:C,alwaysFormat:x}=t.interpolation;this.escape=r!==void 0?r:xm,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=m?Hr(m):v||Hr("$t("),this.nestingSuffix=f?Hr(f):b||Hr(")"),this.nestingOptionsSeparator=h||",",this.maxReplaces=C||1e3,this.alwaysFormat=x!==void 0?x: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=v=>{if(!v.includes(this.formatSeparator)){let C=Rd(r,l,v,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,o,{...a,...r,interpolationkey:v}):C}let f=v.split(this.formatSeparator),b=f.shift().trim(),h=f.join(this.formatSeparator).trim();return this.format(Rd(r,l,b,this.options.keySeparator,this.options.ignoreJSONStructure),h,o,{...a,...r,interpolationkey:b})};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:v=>v},{regex:this.regexp,safeValue:v=>this.escapeValue?this.escape(v):v}].forEach(v=>{for(s=0;n=v.regex.exec(t);){let f=n[1].trim();if(i=d(f),i===void 0)if(typeof c=="function"){let h=c(t,n,a);i=be(h)?h:"";}else if(a&&Object.prototype.hasOwnProperty.call(a,f))i="";else if(u){i=n[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${t}`),i="";else !be(i)&&!this.useRawValueToEscape&&(i=Cd(i));let b=v.safeValue(i);if(t=t.replace(n[0],Am(b)),u?(v.regex.lastIndex+=b.length,v.regex.lastIndex-=n[0].length):v.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)}[ ]*{`)),m=`{${u[1]}`;l=u[0],m=this.interpolate(m,i);let v=m.match(/'/g),f=m.match(/"/g);((v?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{i=JSON.parse(m),d&&(i={...d,...i});}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,b),`${l}${c}${m}`}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=Cd(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}},Tm=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}},Fd=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(Xa(o),a),t[i]=s),s(r)}},Dm=e=>(t,r,o)=>e(Xa(r),o)(t),wi=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?Fd:Dm;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()]=Fd(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}=Tm(d);if(this.formats[c]){let m=l;try{let v=a?.formatParams?.[a.interpolationkey]||{},f=v.locale||v.lng||a.locale||a.lng||o;m=this.formats[c](l,f,{...u,...a,...v});}catch(v){this.logger.warn(v);}return m}else this.logger.warn(`there was no format function for ${c}`);return l},t)}},Pm=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--);},Ni=class extends na{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 m=`${d}|${u}`;!o.reload&&this.store.hasResourceBundle(d,u)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?i[m]===void 0&&(i[m]=true):(this.state[m]=1,c=false,i[m]===void 0&&(i[m]=true),n[m]===void 0&&(n[m]=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=>{vm(l.loaded,[n],i),Pm(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);}}},vi=()=>({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}),Id=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),Zn=()=>{},Rm=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(r=>{typeof e[r]=="function"&&(e[r]=e[r].bind(e));});},Ci=class e extends na{constructor(t={},r){if(super(),this.options=Id(t),this.services={},this.logger=Rr,this.modules={external:[]},Rm(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=vi();this.options={...o,...this.options,...Id(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=wi;let c=new os(this.options);this.store=new ts(this.options.resources,this.options);let u=this.services;u.logger=Rr,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new ki(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 as(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new Ni(a(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(m,...v)=>{this.emit(m,...v);}),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 rs(this.services,this.options),this.translator.on("*",(m,...v)=>{this.emit(m,...v);}),this.modules.external.forEach(m=>{m.init&&m.init(this);});}if(this.format=this.options.interpolation.format,r||(r=Zn),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=qa(),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=Zn){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=qa();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=Zn),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"&&Ed.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=qa();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 m={...this.options,...c};Array.isArray(n)&&!u&&(m.ns=n),typeof c.keyPrefix=="function"&&(c.keyPrefix=Fo(c.keyPrefix,m));let v=this.options.keySeparator||".",f;return c.keyPrefix&&Array.isArray(s)?f=s.map(b=>(typeof b=="function"&&(b=Fo(b,m)),`${c.keyPrefix}${v}${b}`)):(typeof s=="function"&&(s=Fo(s,m)),f=c.keyPrefix?`${c.keyPrefix}${v}${s}`:s),this.t(f,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=qa();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=qa();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 os(vi());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=Zn){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 ts(s,a),n.services.resourceStore=n.store;}if(t.interpolation){let l={...vi().interpolation,...this.options.interpolation,...t.interpolation},d={...a,interpolation:l};n.services.interpolator=new as(d);}return n.translator=new rs(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=Ci.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;nm($d());var ns=(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);},Od={},_r=(e,t,r,o)=>{vr(r)&&Od[r]||(vr(r)&&(Od[r]=new Date),ns(e,t,r,o));},Vd=(e,t)=>()=>{if(e.isInitialized)t();else {let r=()=>{setTimeout(()=>{e.off("initialized",r);},0),t();};e.on("initialized",r);}},ss=(e,t,r)=>{e.loadNamespaces(t,Vd(e,r));},Si=(e,t,r,o)=>{if(vr(r)&&(r=[r]),e.options.preload&&e.options.preload.indexOf(t)>-1)return ss(e,r,o);r.forEach(a=>{e.options.ns.indexOf(a)<0&&e.options.ns.push(a);}),e.loadLanguages(t,Vd(e,o));},jd=(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",Ai=e=>typeof e=="object"&&e!==null;var Im=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Lm={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"\xA9","©":"\xA9","®":"\xAE","®":"\xAE","…":"\u2026","…":"\u2026","/":"/","/":"/"},Em=e=>Lm[e],Ti=e=>e.replace(Im,Em);var Di={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:true,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:true,unescape:Ti,transDefaultProps:void 0},is=(e={})=>{Di={...Di,...e};},Ya=()=>Di;var Ud,ls=e=>{Ud=e;},br=()=>Ud;var ds={type:"3rdParty",init(e){is(e.options.react),ls(e);}};var ao=createContext(),cs=class{constructor(){this.usedNamespaces={};}addUsedNamespaces(t){t.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=true);});}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}};var zd={" ":"\xA0","&":"&","<":"<",">":">",""":'"',"'":"'","©":"\xA9","®":"\xAE","™":"\u2122","…":"\u2026","–":"\u2013","—":"\u2014","‘":"\u2018","’":"\u2019","‚":"\u201A","“":"\u201C","”":"\u201D","„":"\u201E","†":"\u2020","‡":"\u2021","•":"\u2022","′":"\u2032","″":"\u2033","‹":"\u2039","›":"\u203A","§":"\xA7","¶":"\xB6","·":"\xB7"," ":"\u2002"," ":"\u2003"," ":"\u2009","€":"\u20AC","£":"\xA3","¥":"\xA5","¢":"\xA2","¤":"\xA4","×":"\xD7","÷":"\xF7","−":"\u2212","±":"\xB1","≠":"\u2260","≤":"\u2264","≥":"\u2265","≈":"\u2248","≡":"\u2261","∞":"\u221E","∫":"\u222B","∑":"\u2211","∏":"\u220F","√":"\u221A","∂":"\u2202","‰":"\u2030","°":"\xB0","µ":"\xB5","←":"\u2190","↑":"\u2191","→":"\u2192","↓":"\u2193","↔":"\u2194","↵":"\u21B5","⇐":"\u21D0","⇑":"\u21D1","⇒":"\u21D2","⇓":"\u21D3","⇔":"\u21D4","α":"\u03B1","β":"\u03B2","γ":"\u03B3","δ":"\u03B4","ε":"\u03B5","ζ":"\u03B6","η":"\u03B7","θ":"\u03B8","ι":"\u03B9","κ":"\u03BA","λ":"\u03BB","μ":"\u03BC","ν":"\u03BD","ξ":"\u03BE","ο":"\u03BF","π":"\u03C0","ρ":"\u03C1","σ":"\u03C3","τ":"\u03C4","υ":"\u03C5","φ":"\u03C6","χ":"\u03C7","ψ":"\u03C8","ω":"\u03C9","Α":"\u0391","Β":"\u0392","Γ":"\u0393","Δ":"\u0394","Ε":"\u0395","Ζ":"\u0396","Η":"\u0397","Θ":"\u0398","Ι":"\u0399","Κ":"\u039A","Λ":"\u039B","Μ":"\u039C","Ν":"\u039D","Ξ":"\u039E","Ο":"\u039F","Π":"\u03A0","Ρ":"\u03A1","Σ":"\u03A3","Τ":"\u03A4","Υ":"\u03A5","Φ":"\u03A6","Χ":"\u03A7","Ψ":"\u03A8","Ω":"\u03A9","À":"\xC0","Á":"\xC1","Â":"\xC2","Ã":"\xC3","Ä":"\xC4","Å":"\xC5","Æ":"\xC6","Ç":"\xC7","È":"\xC8","É":"\xC9","Ê":"\xCA","Ë":"\xCB","Ì":"\xCC","Í":"\xCD","Î":"\xCE","Ï":"\xCF","Ð":"\xD0","Ñ":"\xD1","Ò":"\xD2","Ó":"\xD3","Ô":"\xD4","Õ":"\xD5","Ö":"\xD6","Ø":"\xD8","Ù":"\xD9","Ú":"\xDA","Û":"\xDB","Ü":"\xDC","Ý":"\xDD","Þ":"\xDE","ß":"\xDF","à":"\xE0","á":"\xE1","â":"\xE2","ã":"\xE3","ä":"\xE4","å":"\xE5","æ":"\xE6","ç":"\xE7","è":"\xE8","é":"\xE9","ê":"\xEA","ë":"\xEB","ì":"\xEC","í":"\xED","î":"\xEE","ï":"\xEF","ð":"\xF0","ñ":"\xF1","ò":"\xF2","ó":"\xF3","ô":"\xF4","õ":"\xF5","ö":"\xF6","ø":"\xF8","ù":"\xF9","ú":"\xFA","û":"\xFB","ü":"\xFC","ý":"\xFD","þ":"\xFE","ÿ":"\xFF","¡":"\xA1","¿":"\xBF","ƒ":"\u0192","ˆ":"\u02C6","˜":"\u02DC","Œ":"\u0152","œ":"\u0153","Š":"\u0160","š":"\u0161","Ÿ":"\u0178","ª":"\xAA","º":"\xBA","¯":"\xAF","´":"\xB4","¸":"\xB8","¹":"\xB9","²":"\xB2","³":"\xB3","¼":"\xBC","½":"\xBD","¾":"\xBE","♠":"\u2660","♣":"\u2663","♥":"\u2665","♦":"\u2666","◊":"\u25CA","‾":"\u203E","⁄":"\u2044","℘":"\u2118","ℑ":"\u2111","ℜ":"\u211C","ℵ":"\u2135"};new RegExp(Object.keys(zd).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"g");var Km=(e,t)=>{if(vr(t))return t;if(Ai(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},Gm={t:Km,ready:false},Wm=()=>()=>{},H=(e,t={})=>{let{i18n:r}=t,{i18n:o,defaultNS:a}=useContext(ao)||{},n=r||o||br();n&&!n.reportNamespaces&&(n.reportNamespaces=new cs),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(()=>({...Ya(),...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 m=useRef(0),v=useCallback(p=>{if(!n)return Wm;let{bindI18n:y,bindI18nStore:w}=i,F=()=>{m.current+=1,p();};return y&&n.on(y,F),w&&n.store.on(w,F),()=>{y&&y.split(" ").forEach(L=>n.off(L,F)),w&&w.split(" ").forEach(L=>n.store.off(L,F));}},[n,i]),f=useRef(),b=useCallback(()=>{if(!n)return Gm;let p=!!(n.isInitialized||n.initializedStoreOnce)&&u.every($=>jd($,n,i)),y=t.lng||n.language,w=m.current,F=f.current;if(F&&F.ready===p&&F.lng===y&&F.keyPrefix===l&&F.revision===w)return F;let P={t:n.getFixedT(y,i.nsMode==="fallback"?u:u[0],l,{scopeNs:u}),ready:p,lng:y,keyPrefix:l,revision:w};return f.current=P,P},[n,u,l,i,t.lng]),[h,C]=useState(0),{t:x,ready:R}=useSyncExternalStore(v,b,b);useEffect(()=>{if(n&&!R&&!s){let p=()=>C(y=>y+1);t.lng?Si(n,t.lng,u,p):ss(n,u,p);}},[n,t.lng,u,R,s,h]);let k=n||{},E=useRef(null),S=useRef(),D=p=>{let y=Object.getOwnPropertyDescriptors(p);y.__original&&delete y.__original;let w=Object.create(Object.getPrototypeOf(p),y);if(!Object.prototype.hasOwnProperty.call(w,"__original"))try{Object.defineProperty(w,"__original",{value:p,writable:!1,enumerable:!1,configurable:!1});}catch{}return w},g=useMemo(()=>{let p=k,y=p?.language,w=p;p&&(E.current&&E.current.__original===p?S.current!==y?(w=D(p),E.current=w,S.current=y):w=E.current:(w=D(p),E.current=w,S.current=y));let F=!R&&!s?(...P)=>(_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."),x(...P)):x,L=[F,w,R];return L.t=F,L.i18n=w,L.ready=R,L},[x,k,R,k.resolvedLanguage,k.language,k.languages]);if(n&&s&&!R){let p=false;try{p=process.env.NODE_ENV!=="production";}catch{}throw p&&_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(y=>{let w=()=>y();t.lng?Si(n,t.lng,u,w):ss(n,u,w);})}return g};var{slice:Ym,forEach:Qm}=[];function Zm(e){return Qm.call(Ym.call(arguments,1),t=>{if(t)for(let r in t)e[r]===void 0&&(e[r]=t[r]);}),e}function ef(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 qd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,tf=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(!qd.test(o.domain))throw new TypeError("option domain is invalid");n+=`; Domain=${o.domain}`;}if(o.path){if(!qd.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},Jd={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=tf(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);}},rf={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<"u")return Jd.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:r,cookieMinutes:o,cookieDomain:a,cookieOptions:n}=t;r&&typeof document<"u"&&Jd.create(r,e,o,a,n);}},of={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}},af={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}},la=null,Xd=()=>{if(la!==null)return la;try{if(la=typeof window<"u"&&window.localStorage!==null,!la)return !1;let e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e);}catch{la=false;}return la},nf={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&Xd())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:r}=t;r&&Xd()&&window.localStorage.setItem(r,e);}},da=null,Yd=()=>{if(da!==null)return da;try{if(da=typeof window<"u"&&window.sessionStorage!==null,!da)return !1;let e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e);}catch{da=false;}return da},sf={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&Yd())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:r}=t;r&&Yd()&&window.sessionStorage.setItem(r,e);}},lf={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}},df={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}},cf={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}},uf={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]}},Qd=false;try{document.cookie,Qd=!0;}catch{}var Zd=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Qd||Zd.splice(1,1);var pf=()=>({order:Zd,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),Qa=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=Zm(r,this.options||{},pf()),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(rf),this.addDetector(of),this.addDetector(nf),this.addDetector(sf),this.addDetector(lf),this.addDetector(df),this.addDetector(cf),this.addDetector(uf),this.addDetector(af);}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&&!ef(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);}));}};Qa.type="languageDetector";var ec={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 tc={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 rc={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 oc={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 ac={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 bf={en:{translation:ec},fr:{translation:tc},es:{translation:rc},de:{translation:oc},pt:{translation:ac}},nc=typeof window<"u"&&window.KYRO_LANG?window.KYRO_LANG:"en";Bt.use(Qa).use(ds).init({resources:bf,fallbackLng:nc,lng:nc,interpolation:{escapeValue:false}});function Io(e,t,r){return r in t?t[r]:Ri(e,t,r)}function Ri(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=Ri(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=Ri(o.fields||[],a,r);if(n!==void 0)return n}}}}function Li({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,m=d?.collections?.[l]?.update!==false,v=()=>{if(c)if(a)a();else {let O=`${_e}/${l}/new`;Lt(O);}},f=O=>{if(n)n(O);else {let ae=`${_e}/${l}/${O}`;Lt(ae);}},[b,h]=useState(r),[C,x]=useState(o),[R,k]=useState(false),[E,S]=useState(1),[D,g]=useState(10),[p,y]=useState(new Set),[w,F]=useState(""),[L,P]=useState(""),[$,z]=useState([]);useEffect(()=>{let O=setTimeout(()=>{P(w),S(1);},300);return ()=>clearTimeout(O)},[w]);let{confirm:I,alert:X$1}=vt(),ee=()=>{z([...$,{field:"",operator:"equals",value:""}]);},ie=()=>{F(""),z([]),Ae(null);},q=O=>{z($.filter((ae,ue)=>ue!==O));},Q=(O,ae)=>{z($.map((ue,Ht)=>Ht===O?{...ue,...ae}:ue));},[pe,Ae]=useState(null),[U,_]=useState(false),[K,he]=useState(false);function Me(O){let ae=[];for(let ue of O||[])if(!(ue.hidden===true||ue.admin?.hidden||ue.name==="id"))if(ue.type==="tabs"&&ue.tabs)for(let Ht of ue.tabs)Ht.fields&&ae.push(...Me(Ht.fields));else if((ue.type==="row"||ue.type==="collapsible")&&ue.fields)ae.push(...Me(ue.fields));else {if(!ue.name)continue;ae.push(ue);}return ae}let ke=useMemo(()=>Me(e.fields),[e.fields]),N=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:ke.find(O=>O.type!=="group"&&typeof O.name=="string")?.name,[G,we]=useState(()=>{let O;return e.admin?.defaultColumns?O=[...e.admin?.defaultColumns||[]]:O=ke.slice(0,4).map(ae=>ae.name).filter(ae=>!!ae),N&&O.includes(N)&&(O=[N,...O.filter(ae=>ae!==N)]),O.includes("updatedAt")||O.push("updatedAt"),new Set(O)}),Ve=useCallback(O=>{we(ae=>{let ue=new Set(ae);return ue.has(O)?ue.delete(O):ue.add(O),ue});},[]);function je(O){let ae=ke.find(ue=>ue.name===O);return ae&&ae.type==="group"&&ae.fields?.[0]?.name?`${O}.${ae.fields[0].name}`:O}let Le=useCallback(O=>{let ae=je(O);Ae(ue=>ue&&ue.field===ae?{field:ae,direction:ue.direction==="asc"?"desc":"asc"}:{field:ae,direction:"asc"});},[]),ft=useMemo(()=>{let O=[];for(let ae of Array.from(G))if(ae==="status")O.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]});else {let ue=ke.find(Ht=>Ht.name===ae);ue&&ue.name&&O.push(ue);}return O},[ke,G]);function Cr(O){return !O.name||!N?false:O.name===N||O.type==="group"&&O.fields?.[0]?.name===N}function oe(O,ae){return ae.name?Io(e.fields,O,ae.name)??null:null}let j=useCallback(async()=>{k(true);try{let O=new URLSearchParams({page:E.toString(),limit:D.toString(),depth:"1"});L&&O.append("search",L),pe&&O.append("sort",pe.field),pe&&O.append("order",pe.direction),$.length>0&&O.append("filters",JSON.stringify($));let ae=await Ie(to(`/api/${l}?${O}`),{autoToast:!1});h(ae.docs||[]),x(ae.totalDocs||0);}catch(O){console.error("Failed to load docs:",O);}finally{k(false);}},[l,E,D,L,pe,$]);useEffect(()=>{b.length===0&&o===0&&j();},[]);let Y=useRef(true);useEffect(()=>{if(Y.current){Y.current=false;return}j();},[E,D,L,pe,$]);let le=()=>{p.size===b.length?y(new Set):y(new Set(b.map(O=>O.id)));},Te=O=>{let ae=new Set(p);ae.has(O)?ae.delete(O):ae.add(O),y(ae);},$e=()=>{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:p.size}),variant:"danger",onConfirm:async()=>{try{for(let O of Array.from(p))await Dt(`/api/${l}/${O}`);y(new Set),j(),V.success("Documents deleted");}catch(O){console.error("Bulk delete failed:",O),V.error("Failed to delete some documents");}}});},Tt=O=>{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(),V.success("Document deleted");}catch(ae){console.error("Delete failed:",ae),V.error("Failed to delete document");}}});},gr=Math.ceil(C/D),Or=w||$.length>0||pe;return jsxs("div",{className:"space-y-6",children:[jsx(jt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:C>0?[jsxs("span",{className:"text-xs font-bold opacity-60",children:[C," 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?v: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 rounded-lg",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:w,onChange:O=>F(O.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:()=>_(!U),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${U||$.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"}),$.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:$.length})]}),jsxs("div",{className:"relative",children:[jsxs("button",{type:"button",onClick:()=>he(!K),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"})]}),K&&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:ke.map(O=>O.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(O.name),onChange:()=>Ve(O.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:O.label||O.name})]},O.name):null)})]})]}),Or&&jsx("button",{type:"button",onClick:ie,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)] rounded-lg",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:ee,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:[$.map((O,ae)=>jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsx("select",{value:O.field,onChange:ue=>Q(ae,{field:ue.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:ke.map(ue=>jsx("option",{value:ue.name,children:ue.label||ue.name},ue.name))}),jsxs("select",{value:O.operator,onChange:ue=>Q(ae,{operator:ue.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:O.value,onChange:ue=>Q(ae,{value:ue.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:()=>q(ae),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsx(X,{className:"w-4 h-4"})})]},ae)),$.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.'})})]})]}),p.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:p.size})}),jsxs("div",{className:"flex gap-2",children:[u&&jsxs("button",{type:"button",onClick:$e,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:()=>y(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 rounded-lg",children:R?jsx("div",{className:"space-y-2 p-4",children:jsx(Wt,{variant:"table-row",count:8})}):b.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:v,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:p.size===b.length&&b.length>0,onChange:le,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),ft.map(O=>jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Le(O.name),children:jsxs("div",{className:"flex items-center gap-2",children:[kf(ft,O.type)??(O.label||O.name),pe&&pe.field===O.name&&jsx(ChevronUp,{className:"w-4 h-4"})]})},O.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:b.map(O=>jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>f(O.id),children:[jsx("td",{className:"px-4 py-3",onClick:ae=>ae.stopPropagation(),children:jsx("input",{type:"checkbox",checked:p.has(O.id),onChange:()=>Te(O.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),ft.map(ae=>{let ue=oe(O,ae),Ht=ae.type==="select"&&ue&&Array.isArray(ae.options)?ae.options.find(Wo=>Wo.value===ue)?.label||ue:xf(ue,ae.type,s);return jsx("td",{className:`px-4 py-3 ${Cr(ae)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:Ht},ae.name)}),e.timestamps?jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:O.createdAt?new Date(O.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:O.updatedAt?new Date(O.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsx("td",{className:"px-4 py-3 text-right",onClick:ae=>ae.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:()=>f(O.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:m?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(O.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"})})]})})]},O.id))})]})})}),jsx(Nd,{page:E,totalPages:gr,totalDocs:C,limit:D,onPageChange:S,onLimitChange:O=>{g(O),S(1);}})]})}function xf(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 kf(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}function en(e){return e?Array.isArray(e)?e:Object.values(e):[]}function fs(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function gs(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Za(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 Nf={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 s of i.tabs)if(s.fields&&Array.isArray(s.fields)&&Lo(s.fields,n,r))return true;return false}if(i.type==="blocks"&&i.blocks&&Array.isArray(i.blocks)){let s=n.split(".")[0],l=n.split(".").slice(1).join(".");if(!l)return false;for(let d of i.blocks)if(d.slug===s&&d.fields&&Array.isArray(d.fields))return Lo(d.fields,l,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;for(let i of e)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 n?false:(e.push({name:a,...r}),true)}function Cf(e,t){for(let[r,o]of Object.entries(e)){let a=Nf[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 Sf(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 Za(t,Object.values(mediaCollections)),Za(t,Object.values(authCollections)),{collections:fs(t),globals:gs(r)}}function Af(e){let t=en(e.collections),r=en(e.globals);if(t.length===0&&r.length===0)return Sf("kitchen-sink");let o=[];return Za(o,Object.values(mediaCollections)),Za(o,Object.values(authCollections)),Za(o,t),{collections:fs(o),globals:gs(r)}}function Tf(){return projectConfig?projectConfig:null}var gc=Tf()||{collections:[],globals:[]},yc=Af(gc);Cf(yc.collections,gc.collectionOverrides||{});var vc=yc,ca=vc.collections,bc=vc.globals,Bi=["users","audit_logs"];Object.values(ca).filter(e=>!Bi.includes(e.slug)&&e.admin?.hidden!==true);function ys({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 $i(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 vs=null,hc=false,Oi=async()=>(vs&&hc||(vs=createStorage({driver:Lf({dbName:"kyro-autosave",storeName:"autosave"})}),hc=true),vs),Ef=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Oi()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Oi()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Oi()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},ge=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)=>{if(!r||r==="undefined")return;let a=t(),n=new Set(a.dirtyFields),i=qt(o),s=qt(a.lastSavedData[r]);$i(i)&&$i(s)||Eo(i,s)?n.delete(r):n.add(r);let l={...a.formData};delete l.undefined,delete l.undefined,l[r]=o,e({formData:l,dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{let o={...r};delete o.undefined,delete o.undefined,e({formData:o});},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,delete i.undefined,delete i.undefined,{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={...r};delete a.undefined,delete a.undefined;let n=o?{...o}:a;delete n.undefined,delete n.undefined;let i=t();i.formData===a&&i.lastSavedData===n&&!i.hasUnsavedChanges||e({formData:a,lastSavedData:n,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(()=>Ef()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));var xc="other";function kc(){return xc}function bs(e){xc=e;}function hs(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Nc(){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 Cc({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:i,onActionError:s}){let l=ge(),{confirm:d}=vt(),{formData:c,setFormData:u,setField:m,lastSavedData:v,setLastSavedData:f,setHasUnsavedChanges:b,isSlugLocked:h,loadDocument:C,setIsAutoSaving:x,setAutoSaveStatus:R,setVersions:k,setLoadingVersions:E,sidebarCollapsed:S,setSidebarCollapsed:D,getDraftCache:g,setDraftCache:p,clearDraftCache:y,resetForm:w}=l,F=!!e?.versions,L=o||t?.id||a||r,P=useRef(false);!o&&L&&c&&Object.keys(c).length>0&&c.id!==L&&(P.current=true),useEffect(()=>{P.current&&(P.current=false,w());},[w]);let $=useRef(null),z=useRef(null),I=useRef(null),X=useRef(typeof navigator<"u"?navigator.onLine:true),ee=useRef(0),ie=useRef(false),q=useRef(null),Q=useRef(""),pe=useRef(""),{queueTask:Ae}=Nc(),U=useCallback(oe=>o?`global:${o}`:r&&oe?`${r}:${oe}`:null,[r,o]),_=useCallback((oe,j,Y)=>{p(oe,{data:j,baseUpdatedAt:v.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:Y?.lastSyncedAt??null});},[v.updatedAt,p]),K=useCallback(async()=>{let oe=o?Ye(`/api/globals/${o}/versions`):r&&c.id?Ye(`/api/${r}/${c.id}/versions`):null;if(oe){E(true);try{let Y=await(await ct(oe)).json();k(Y.docs||[]);}catch(j){console.error("Failed to fetch versions:",j);}finally{E(false);}}},[c.id,r,o,E,k]),he=useCallback(()=>{let oe=ge.getState(),j=oe.formData;if(ie.current||!r||!j.id||!oe.hasDirtyFields())return;let Y=U(j.id);Y&&_(Y,j);},[r,U,_]),Me=useCallback(async oe=>{let j=ge.getState(),Y=j.formData,le=j.lastSavedData;if(ie.current||!o&&(!r||!Y.id)||!j.hasDirtyFields())return;let Te=U(Y.id);if(Te&&_(Te,Y),!X.current){R("offline");return}x(true),R("saving"),j.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let $e=o?Ye(`/api/globals/${o}?autosave=true`):Ye(`/api/${r}/${Y.id}?autosave=true`),Tt=await ct($e,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:oe?.keepalive,body:JSON.stringify({...qt(Y,!0),baseUpdatedAt:le.updatedAt??null})});if(Tt.ok)ee.current=Date.now(),j.setRetryCount(0),j.setLastSavedAt(Date.now()),I.current&&clearTimeout(I.current),Te&&p(Te,{data:Y,baseUpdatedAt:le.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),R("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&R("idle");},2e3);else if(Tt.status===409)R("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch($e){console.error("Auto-save failed:",$e);let Tt=ge.getState(),gr=Tt.retryCount;if(gr<5){Tt.setRetryCount(gr+1),R("retrying");let Or=Math.min(1e3*Math.pow(2,gr),6e4);I.current&&clearTimeout(I.current),I.current=setTimeout(()=>ke(oe),Or);}else R("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),x(false),ge.getState().setBackgroundProcessing(false);}},[r,U,o,_,R,p,x,F]),ke=useCallback(oe=>{Ae(()=>Me(oe),{beforeProcess:()=>true,afterProcess:()=>{}});},[Me,Ae]),N=useCallback(async(oe,j=true)=>{let Y=ge.getState(),le=oe||Y.formData,Te=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${le.id}`),$e=await ct(Te,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(j)},body:JSON.stringify({...qt(le,true),baseUpdatedAt:Y.lastSavedData.updatedAt??null})});return $e.status===409&&R("conflict"),$e},[r,o,R]),G=useCallback(async(oe=true)=>{let j=ge.getState(),Y=j.formData,le=o?Ye(`/api/globals/${o}`):Ye(`/api/${r}/${Y.id}`),Te=await ct(le,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(oe)},body:JSON.stringify({...qt(Y,true)})});if(Te.ok){let Tt=(await Te.json()).data||Y;j.loadDocument(Tt,Tt),R("success"),setTimeout(()=>{ge.getState().autoSaveStatus==="success"&&R("idle");},2e3);}return Te},[r,o,R]);useEffect(()=>{let oe=()=>{D(!S);};return window.addEventListener("toggle-sidebar",oe),()=>window.removeEventListener("toggle-sidebar",oe)},[S,D]);let we=useRef(null),Ve=useRef(""),je=useRef(false);useEffect(()=>{let oe=o||t?.id,j=JSON.stringify(t);je.current&&we.current===oe&&Ve.current===j||(C(t||{},t||{}),je.current=true,we.current=oe,Ve.current=j);},[r,c.id,o,t,C]),useEffect(()=>{if(!r||!t?.id)return;let oe=U(c.id);if(!oe||q.current===oe)return;let j=false;return (async()=>{if(!F)return;let le=g(oe);if(le){if(JSON.stringify(le.data)===JSON.stringify(t)){y(oe);return}q.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(j)return;let $e={...ge.getState().formData,...le.data};u($e),i?.("Recovered autosaved draft");},onCancel:async()=>{y(oe);}});}})(),()=>{j=true;}},[y,r,d,U,g,t,i,u,F]);function Le(oe,j){for(let Y of oe){if(Y.name===j&&Y.admin?.autoGenerate==="title")return Y;if(Y.type==="tabs"&&"tabs"in Y)for(let le of Y.tabs){let Te=Le(le.fields,j);if(Te)return Te}if((Y.type==="group"||Y.type==="collapsible")&&"fields"in Y){let le=Le(Y.fields,j);if(le)return le}}}useEffect(()=>{if(!e?.fields)return;let oe=e.fields;if(!Le(oe,"metaTitle"))return;let Y=Io(oe,c,"title"),le=Y?String(Y):"";le&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&c.metaTitle!==le&&ge.setState(Te=>({formData:{...Te.formData,metaTitle:le,_lastMetaTitle:le}}));},[c.title,e?.fields]),useEffect(()=>{let oe=e?.fields,j=oe?.find(Te=>Te.name==="slug"&&Te.admin?.autoGenerate);if(!j?.admin?.autoGenerate)return;let Y=j.admin.autoGenerate,le=Io(oe,c,Y);if(h&&typeof le=="string"&&le){let Te=hs(le);Te&&Te!==c.slug&&ge.setState($e=>({formData:{...$e.formData,slug:Te}}));}},[c.title,h,e?.fields]),useEffect(()=>{if(S||!o&&(!r||!c.id)||!ge.getState().hasDirtyFields()||kc()!=="keystroke")return;bs("other");let j=JSON.stringify(c);j!==Q.current&&($.current&&clearTimeout($.current),$.current=setTimeout(he,1500),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{Q.current=j,ke();},8e3));},[c,S,r,o,he,ke]),useEffect(()=>{if(!o&&(!r||!c.id))return;let oe=()=>{ie.current||!ge.getState().hasDirtyFields()||ke({keepalive:true});},j=()=>{document.hidden&&oe();},Y=()=>{X.current=true,oe();},le=()=>{X.current=false;let Te=ge.getState();Te.hasDirtyFields()&&Te.setAutoSaveStatus("offline");};return window.addEventListener("blur",oe),window.addEventListener("pagehide",oe),window.addEventListener("online",Y),window.addEventListener("offline",le),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("blur",oe),window.removeEventListener("pagehide",oe),window.removeEventListener("online",Y),window.removeEventListener("offline",le),document.removeEventListener("visibilitychange",j);}},[r,o,c.id,ke]),useEffect(()=>{let oe=JSON.stringify(c);if(oe===pe.current)return;pe.current=oe;let j=document.getElementById("form-data");j&&(j.value=oe),n?.(c);},[c,n]),useEffect(()=>{(o||c.id)&&K();},[c.id,o,K]);let ft=!c.id&&!o?"draft":F&&c.status||"published",Cr=(!!c.id||!!o)&&ft==="draft";return {...l,fetchVersions:K,performAutoSave:ke,saveDocument:N,forceSave:G,autoSaveSkipRef:ie,lastAutoSaveTimeRef:ee,documentStatus:ft,hasUnpublishedChanges:Cr,versionsEnabled:F}}var tn=({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(""),[m,v]=useState([]),[f,b]=useState(false),[h,C]=useState([]),[x,R]=useState(true);useEffect(()=>{Ie("/api/collections").then(F=>{C((F.collections||[]).map(L=>L.slug||L.name||L)),R(false);}).catch(()=>R(false));},[]);let k=(F="")=>{b(true);let L=`/api/${e}?${Pn(F,[a],20)}`;Ie(L).then(P=>{v(P.docs||[]),b(false);}).catch(()=>b(false));};useEffect(()=>{l&&k(c);},[l,c,e,a]);let E=F=>F?.[a]||F?.title||F?.name||F?.label||F?.filename||F?.slug||F?.id||"Untitled",S=t?r:o?[o]:[],D=F=>{t?S.includes(F.id)?n("selectedIds",S.filter(L=>L!==F.id)):n("selectedIds",[...S,F.id]):(n("selectedId",F.id),n("selectedIds",[F.id]),d(false));},g=F=>S.includes(F),p=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",y=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=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:[!w&&jsx(Fragment,{children:x?jsx("div",{className:y+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxs("select",{value:e,onChange:F=>n("relationTo",F.target.value),className:y,children:[jsx("option",{value:"",children:"Select collection..."}),h.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:`${p} pl-9`}),jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:f&&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:f?jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsx(ys,{title:s("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:m.map(F=>jsxs("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>D(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:E(F)}),g(F.id)&&jsx("span",{children:"\u2713"})]},F.id))})})]}),S.length>0&&jsx("div",{className:"flex flex-wrap gap-1.5",children:S.map(F=>{let L=m.find(P=>P.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:[E(L),jsx("button",{type:"button",onMouseDown:P=>P.preventDefault(),onClick:()=>{t?n("selectedIds",S.filter(P=>P!==F)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsx(X,{className:"w-3 h-3"})})]},F)})})]})};var Vi=(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"},Pc=({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),[m,v]=useState([]),[f,b]=useState([]),[h,C]=useState(""),[x,R]=useState(false),[k,E]=useState(""),[S,D]=useState(false),[g,p]=useState(""),[y,w]=useState(""),[F,L]=useState([]),P=e?.label||e?.name||"File",$=e.maxCount??(e.hasMany?999:1),z=$>1,I=Array.isArray(t)?t:t?[t]:[],X$1=I.length<$,[ee,ie]=useState({});useEffect(()=>{(async()=>{let G=I.filter(Le=>typeof Le=="string").map(Le=>Le),we=I.filter(Le=>typeof Le=="object"&&Le!==null&&typeof Le.id=="string"&&!Le.url&&!Le.filename&&!Le.mimeType).map(Le=>Le.id),je=[...G,...we].filter(Le=>!ee[Le]);if(je.length!==0)try{let Le=await Promise.all(je.map(ft=>Ie(`/api/media/${ft}`)));ie(ft=>{let Cr={...ft};return Le.forEach(oe=>{oe&&oe.id&&(Cr[oe.id]=oe);}),Cr});}catch(Le){console.error("Failed to fetch media details:",Le);}})();},[t,ee]),useEffect(()=>{l&&(q(),Q());},[l,h]);let q=async()=>{try{let N=await Ie(to("/api/media/folders"));b(N.folders||[]);}catch{b([]);}},Q=async()=>{R(true);try{let N=to("/api/media?limit=60&sortBy=createdAt&sortDir=desc");h&&(N+="&folder="+encodeURIComponent(h));let G=await Ie(N);v(G.docs||[]);}catch{v([]);}finally{R(false);}},pe=async N=>{s(true);try{let G=new FormData;G.append("file",N),h&&G.append("folder",h);let we=await Rn("/api/media/upload",G),Ve=we.data||we.doc||we,je={...Ve,id:Ve.id,filename:Ve.filename,originalName:Ve.originalName??N.name,url:Ve.url,mimeType:Ve.mimeType||N.type};r(z?[...I,je]:je),V.success(`Asset synchronized: ${je.filename}`);}catch(G){console.error("Upload failed:",G),V.error(`Upload failed: ${G instanceof Error?G.message:"Unknown error"}`);}finally{s(false);}},Ae=async()=>{let N=g.trim();if(N){w("");try{let G=await ut("/api/media/upload",{url:N}),we=(()=>{try{return new URL(N).pathname.split("/").pop()||G.originalName||"url-image"}catch{return G.originalName||"url-image"}})(),Ve={id:G.id,filename:G.filename,originalName:we,url:G.url,mimeType:G.mimeType||"image/*"};r(z?[...I,Ve]:Ve),V.success(`URL asset established: ${Ve.filename}`),p(""),D(!1);}catch(G){let we=G instanceof Error?G.message:"Invalid URL";w(we);}}},U=N=>({id:N.id,filename:N.filename,url:N.url,mimeType:N.mimeType}),_=N=>{z?L(G=>G.find(Ve=>Ve.id===N.id)?G.filter(Ve=>Ve.id!==N.id):[...G,N]):(r(U(N)),d(false),E(""));},K=()=>{if(F.length>0){let N=[...I,...F.map(U)];r(N);}L([]),d(false),E("");},he=N=>{let G=[...I];G.splice(N,1),r(z?G:G[0]||null);},Me=useMemo(()=>m.filter(N=>!k||N.filename?.toLowerCase().includes(k.toLowerCase())||N.title?.toLowerCase().includes(k.toLowerCase())),[m,k]);if(i)return jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let ke=(N,G)=>{if(!N)return null;let we=typeof N=="string"?N:N.id,Ve=ee[we]||(typeof N=="object"?N:{}),je=Vi(Ve.mimeType,Ve.filename||Ve.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:je==="image"?jsx("img",{src:Ha(Ve.url),alt:Ve.filename||"Preview",className:"w-full h-full object-cover"}):jsx(Pc,{type:je,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:Ve.originalName||Ve.filename||"Unnamed File"}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:P})]}),jsx("button",{type:"button",onClick:()=>G!==void 0?he(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:N=>{let G=N.target.files?.[0];G&&pe(G);},disabled:o,className:"hidden"}),I.length>0&&jsx("div",{className:z?"grid grid-cols-2 gap-2":"space-y-2",children:I.map((N,G)=>ke(N,G))}),(!I.length||X$1)&&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 ",P]}),jsx("button",{type:"button",onClick:()=>{L([]),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:()=>D(!S),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"})]}),S&&jsxs("div",{className:"flex gap-2 items-center",children:[jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:g,onChange:N=>{p(N.target.value),w("");},onKeyDown:N=>N.key==="Enter"&&Ae(),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:Ae,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"}),y&&jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:y})]}),l&&(c?createPortal(jsx(Dc,{isFullscreen:true,isMultiple:z,selectedItems:F,pickerSearch:k,setPickerSearch:E,folders:f,selectedFolder:h,setSelectedFolder:C,mediaLoading:x,filteredMedia:Me,selectFromLibrary:_,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}),document.body):jsx(Dc,{isFullscreen:false,isMultiple:z,selectedItems:F,pickerSearch:k,setPickerSearch:E,folders:f,selectedFolder:h,setSelectedFolder:C,mediaLoading:x,filteredMedia:Me,selectFromLibrary:_,onDone:K,setIsPickerFullscreen:u,setShowPicker:d}))]})}function Dc({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:m,setShowPicker:v}){let{t:f}=H(),b=h=>r.some(C=>C.id===h);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:f("fields.searchMedia",{defaultValue:"Search media..."}),value:o,onChange:h=>a(h.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(h=>jsx("button",{type:"button",onClick:()=>s(h.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${i===h.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:h.name},h.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(h=>{let C=b(h.id);return jsxs("button",{type:"button",onClick:()=>c(h),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${C?"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:Vi(h.mimeType,h.filename)==="image"?jsx("img",{src:Ha(h.thumbnailUrl||h.url),alt:h.filename,className:"w-full h-full object-cover"}):jsx(Pc,{type:Vi(h.mimeType,h.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&C&&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"})})]},h.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:()=>m(!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:()=>{v(false),m(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=m=>{m.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,34 +6,34 @@ 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 ks({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 Ui({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 Fc({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,g]=useState(!!r),f=useRef(null),v=useRef(null),[b,S]=useState(false),[w,R]=useState(null),k=useRef(null),E=(L,P)=>{i==="hotspot"&&(L.stopPropagation(),L.preventDefault(),P?R(P):S(true),k.current={x:L.clientX,y:L.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},A=useCallback(L=>{if(!k.current||!f.current)return;let P=f.current.getBoundingClientRect(),$=(L.clientX-k.current.x)/P.width*100,z=(L.clientY-k.current.y)/P.height*100,I=k.current;if(b){let X=I.hX+$,ee=I.hY+z;X=Math.max(0,Math.min(X,100-I.hW)),ee=Math.max(0,Math.min(ee,100-I.hH)),u(ie=>({...ie,x:X,y:ee}));}else if(w){let X=I.hX,ee=I.hY,ie=I.hW,q=I.hH;w.includes("e")&&(ie=I.hW+$),w.includes("w")&&(X=I.hX+$,ie=I.hW-$),w.includes("s")&&(q=I.hH+z),w.includes("n")&&(ee=I.hY+z,q=I.hH-z),ie<5&&(ie=5,w.includes("w")&&(X=I.hX+I.hW-5)),q<5&&(q=5,w.includes("n")&&(ee=I.hY+I.hH-5)),X=Math.max(0,Math.min(X,100-ie)),ee=Math.max(0,Math.min(ee,100-q)),ie=Math.min(ie,100-X),q=Math.min(q,100-ee),u({x:X,y:ee,width:ie,height:q});}},[b,w,c]),x=useCallback(()=>{S(false),R(null),k.current=null;},[]);useEffect(()=>((b||w)&&(window.addEventListener("pointermove",A),window.addEventListener("pointerup",x)),()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",x);}),[b,w,A,x]);let m=L=>{},y=()=>{let L=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(L,p?c:void 0);},h=()=>{d(void 0),g(false);},N=useMemo(()=>{if(!l||!l.width||!l.height)return null;let L=new URLSearchParams({url:e});return L.set("cx",String(l.x)),L.set("cy",String(l.y)),L.set("cw",String(l.width)),L.set("ch",String(l.height)),`/api/media/resize?${L.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||g(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:h,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:y,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:v,children:[jsx(Wf,{crop:l,onChange:(L,P)=>d(P),locked:i==="hotspot",className:i==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsx("img",{ref:f,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:m})}),p&&f.current&&jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsx("div",{className:"relative",style:{width:f.current.width,height:f.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:L=>E(L),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:L=>E(L,"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:L=>E(L,"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:L=>E(L,"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:L=>E(L,"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:N&&jsx("img",{src:N,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 Ns(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 Cs(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 Yf(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Qf(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 Ss({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,g]=useState(false),[f,v]=useState([]),[b,S]=useState(""),[w,R]=useState(""),[k,E]=useState("all"),[A,x]=useState("grid"),[m,y]=useState(null),[h,N]=useState(false),[F,L]=useState(false),[P,$]=useState(false),[z,I]=useState({}),[X$1,ee]=useState(false),[ie,q]=useState(false),[Q,pe]=useState(null),[Se,j]=useState(false),[_,K]=useState(false),[he,Me]=useState(1),[ke,C]=useState(0),[G,we]=useState(1),Ve=40,[je,Ie]=useState(new Set),{confirm:mt,alert:Cr}=vt(),[oe,V]=useState(false),Y=useRef(null),le=useCallback(async D=>{D===1?u(true):g(true);try{let ve=new URLSearchParams({page:D.toString(),limit:Ve.toString()});b&&ve.append("folder",b),w&&ve.append("search",w),k!=="all"&&ve.append("type",k);let Ue=await Le(eo(`/api/media?${ve}`)),nr=(Ue.docs||[]).map(Ot=>({...Ot,type:Qf(Ot.mimeType)}));d(Ot=>D===1?nr:[...Ot,...nr]),C(Ue.totalDocs||0),we(Ue.totalPages||1);}catch(ve){console.error("Failed to load media:",ve);}finally{u(false),g(false);}},[b,w,k,Ve]),Ae=useCallback(async()=>{try{let D=await Le(eo("/api/media/folders"));v(Array.isArray(D)?D:D.folders||[]);}catch(D){console.error("Failed to load folders:",D);}},[]),$e=useCallback(async()=>{try{let ve=!!(await Le("/api/globals/storage-settings"))?.data?.provider;pe(ve);}catch{pe(false);}},[]);useEffect(()=>{r||$e();},[$e,r]),useEffect(()=>{r||Q===false&&!Se&&(j(true),K(true));},[r,Q,Se]),useEffect(()=>{Me(1),le(1);},[b,w,k,le]);let Tt=()=>{if(p||he>=G)return;let D=he+1;Me(D),le(D);};useEffect(()=>{Ae();},[Ae]),useEffect(()=>{if(r)return;let D=ve=>{let Ue=ve.clipboardData?.files;Ue&&Ue.length>0&&gr(Ue);};return window.addEventListener("paste",D),()=>window.removeEventListener("paste",D)},[r,b,Q]);let gr=async D=>{if(!Q){K(true);return}$(true);let ve=0,Ue=0;for(let nr=0;nr<D.length;nr++){let Ot=D[nr];try{let Sr=new FormData;Sr.append("file",Ot),b&&Sr.append("folder",b),await Rn("/api/media/upload",Sr,ri=>{I(qo=>({...qo,[Ot.name]:ri}));}),ve++;}catch(Sr){console.error(`Upload failed for ${Ot.name}:`,Sr),Ue++;}}$(false),I({}),Me(1),le(1),Ae(),Ue>0&&U.error(`${Ue} file(s) failed to upload`),ve>0&&U.success(`${ve} file(s) uploaded successfully`);},Or=()=>{mt({title:"Delete Media",message:`Are you sure you want to delete ${je.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let D of Array.from(je))await Dt(`/api/media/${D}`);Ie(new Set),Me(1),le(1),U.success(`${je.size} item(s) deleted`);}catch(D){console.error("Bulk delete failed:",D),U.error("Failed to delete some items");}}});},O=(D,ve)=>{ve.stopPropagation();let Ue=new Set(je);Ue.has(D)?Ue.delete(D):(t||Ue.clear(),Ue.add(D)),Ie(Ue);},ae=async D=>{try{await ut("/api/media/folders",{name:D}),Ae(),ee(!1),U.success(`Folder "${D}" created`);}catch(ve){console.error("Failed to create folder:",ve),U.error("Failed to create folder");}},ue=D=>{mt({title:"Delete Folder",message:`Are you sure you want to delete the folder "${D}"? 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(D)}`),b===D&&S(""),Ae(),Me(1),le(1),U.success(`Folder "${D}" deleted`);}catch(ve){console.error("Failed to delete folder:",ve),U.error("Failed to delete folder");}}});},Ht=async(D,ve)=>{try{let Ue=await er(`/api/media/${D}`,ve);d(nr=>nr.map(Ot=>Ot.id===D?Ue.doc:Ot)),m?.id===D&&y(Ue.doc),U.success("Metadata updated");}catch(Ue){console.error("Failed to update metadata:",Ue),U.error("Failed to update metadata");}},Wo=async(D,ve)=>{if(m)try{$(!0);let Ue={...m.metadata,crop:D,hotspot:ve},nr=await er(`/api/media/${m.id}`,{metadata:Ue});d(Ot=>Ot.map(Sr=>Sr.id===m.id?nr.doc:Sr)),y(nr.doc),L(!1),U.success("Crop & hotspot saved");}catch(Ue){console.error("Save failed:",Ue),U.error("Failed to save focal metadata");}finally{$(false);}},ti=useMemo(()=>l.reduce((D,ve)=>(D.totalSize+=ve.fileSize||0,D),{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:D=>{D.preventDefault(),V(true);},onDragLeave:()=>V(false),onDrop:D=>{D.preventDefault(),V(false),D.dataTransfer.files&&gr(D.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:[ke," Items ",jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",Cs(ti.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:()=>x("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${A==="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:()=>x("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${A==="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:()=>q(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:()=>Y.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:w,onChange:D=>R(D.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(D=>jsxs("button",{onClick:()=>E(D),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${k===D?"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 ${k===D?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),D]},D))})]}),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:()=>ee(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:()=>S(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${b===""?"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"]}),f.map(D=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>S(D),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${b===D?"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:b===D?"currentColor":"none"})}),D]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),ue(D);},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"})})]},D))]})]})]})}),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:()=>Y.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"})]}):A==="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((D,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 ${je.has(D.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>y(D),onContextMenu:Ue=>{Ue.preventDefault(),O(D.id,Ue);},children:[D.type==="image"?jsx("img",{src:Ns(D,400)||D.url,alt:D.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:D.type==="video"?jsx(Film,{className:"w-8 h-8"}):D.type==="audio"?jsx(Music,{className:"w-8 h-8"}):D.type==="document"?jsx(FileText,{className:"w-8 h-8"}):D.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:D.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:D.filename}),jsx("div",{className:"flex gap-1",children:jsx("button",{onClick:Ue=>O(D.id,Ue),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${je.has(D.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsx(Check,{className:"w-4 h-4"})})})]})}),je.has(D.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"})})]},D.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:je.size===l.length,onChange:D=>{D.target.checked?Ie(new Set(l.map(ve=>ve.id))):Ie(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(D=>jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${je.has(D.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>y(D),children:[jsx("td",{className:"px-6 py-4",onClick:ve=>ve.stopPropagation(),children:jsx("input",{type:"checkbox",checked:je.has(D.id),onChange:ve=>O(D.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:D.type==="image"?jsx("img",{src:Ns(D,96)||D.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:D.title||D.filename}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:D.filename})]})]})}),jsx("td",{className:"px-6 py-4",children:jsx(Et,{variant:"outline",className:"text-[9px]",children:D.mimeType})}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Cs(D.fileSize)}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Yf(D.createdAt)}),jsx("td",{className:"px-6 py-4 text-right",children:jsx("button",{onClick:ve=>{ve.stopPropagation(),O(D.id,ve);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${je.has(D.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"})})})]},D.id))})]})}),!c&&he<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&&P&&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(([D,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:D}),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}%`}})})]},D))})]})}),je.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:je.size}),jsxs("div",{children:[jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsx("button",{onClick:()=>Ie(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 D=l.filter(ve=>je.has(ve.id));e(D);},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"})})]})]}),ie&&!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:()=>q(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:()=>q(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(D=>jsx("button",{onClick:()=>{E(D),q(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${k===D?"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:D},D))})]}),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:()=>{ee(true),q(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:()=>{S(""),q(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${b===""?"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"]}),f.map(D=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>{S(D),q(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${b===D?"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:b===D?"currentColor":"none"})}),D]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),ue(D),q(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"})})]},D))]})]})]})]})]}),jsx(xr,{open:!!m,onClose:()=>y(null),title:o("tooltips.assetDetails",{defaultValue:"Asset Details"}),subtitle:m?.filename,children:m&&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:[m.type==="image"?jsx("img",{src:Ns(m)||Gr(m.url),alt:"",className:"w-full h-full object-contain p-4"}):m.type==="video"?jsx("video",{src:Gr(m.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:m.mimeType})]}),jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsx("button",{onClick:()=>N(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:m.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:Cs(m.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(m.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(m.url)),U.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:m.alt||"",onChange:D=>Ht(m.id,{alt:D.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:m.caption||"",onChange:D=>Ht(m.id,{caption:D.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 D=document.createElement("a");D.href=Gr(m.url),D.download=m.filename,D.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"]}),m.type==="image"&&s&&jsx("button",{onClick:()=>L(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 ${m.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`/api/media/${m.id}`),y(null),le(1);}catch(D){console.error("Delete failed:",D),U.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"})})]})]})}),h&&m&&jsxs(At,{open:h,onClose:()=>N(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:m.filename}),jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[Cs(m.fileSize)," \xB7 ",m.mimeType]})]}),jsx("button",{onClick:()=>N(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:m.type==="image"?jsx("img",{src:Ns(m)||Gr(m.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):m.type==="video"?jsx("video",{src:Gr(m.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&&m&&jsx(At,{open:F,onClose:()=>L(false),title:"",size:"full",variant:"lightbox",children:jsx(Fc,{url:Gr(m.url),initialCrop:m.metadata?.crop,initialHotspot:m.metadata?.hotspot,onSave:Wo,onCancel:()=>L(false),isSaving:P})}),!r&&jsx(ks,{open:X$1,onClose:()=>ee(false),onSubmit:ae,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsx(At,{open:_,onClose:()=>K(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(()=>{K(false),pe(true),window.dispatchEvent(new Event("kyro:soft-reload"));}).catch(()=>{U.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:Y,onChange:D=>{D.target.files&&gr(D.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}function Ic({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 j2({children:e}){return jsx(Fragment,{children:e})}function Lc(){let e=Zt(o=>o.addToast),t=Zt(o=>o.removeToast);return {toasts:Zt(o=>o.toasts),addToast:e,removeToast:t}}var Fg=[{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"}],zc=({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}=Lc(),g=ge(N=>N.formData),f=ge(N=>N.setField),v=projectConfig?.plugins?.some?.(N=>N.name==="ai-assistant")??false;if(useEffect(()=>{function N(F){u.current&&!u.current.contains(F.target)&&l(null);}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),!e)return null;let b=()=>{o();},S=()=>{let N=e.getAttributes("link").href,F=window.prompt("URL",N);if(F!==null){if(F===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:F}).run();}},w=N=>{N==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(N).run(),l(null);},R=async(N,F)=>{l(null);let L=document.querySelector('input#title, input[name="title"]')?.value,P=g?.title||L||"Untitled Document",$="document";try{let ee=window.location.pathname.split("/").filter(Boolean);ee[0]==="admin"&&ee.length>=2&&($=ee[1],$.endsWith("s")&&($=$.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," "),X="";if(N==="Generate")X=`Write a comprehensive, engaging, and professional ${$} titled "${P}".
|
|
9
|
+
`})]}),document.body)}function ks({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 Ui({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 Ic({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}),[m,v]=useState(!!r),f=useRef(null),b=useRef(null),[h,C]=useState(false),[x,R]=useState(null),k=useRef(null),E=(L,P)=>{i==="hotspot"&&(L.stopPropagation(),L.preventDefault(),P?R(P):C(true),k.current={x:L.clientX,y:L.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},S=useCallback(L=>{if(!k.current||!f.current)return;let P=f.current.getBoundingClientRect(),$=(L.clientX-k.current.x)/P.width*100,z=(L.clientY-k.current.y)/P.height*100,I=k.current;if(h){let X=I.hX+$,ee=I.hY+z;X=Math.max(0,Math.min(X,100-I.hW)),ee=Math.max(0,Math.min(ee,100-I.hH)),u(ie=>({...ie,x:X,y:ee}));}else if(x){let X=I.hX,ee=I.hY,ie=I.hW,q=I.hH;x.includes("e")&&(ie=I.hW+$),x.includes("w")&&(X=I.hX+$,ie=I.hW-$),x.includes("s")&&(q=I.hH+z),x.includes("n")&&(ee=I.hY+z,q=I.hH-z),ie<5&&(ie=5,x.includes("w")&&(X=I.hX+I.hW-5)),q<5&&(q=5,x.includes("n")&&(ee=I.hY+I.hH-5)),X=Math.max(0,Math.min(X,100-ie)),ee=Math.max(0,Math.min(ee,100-q)),ie=Math.min(ie,100-X),q=Math.min(q,100-ee),u({x:X,y:ee,width:ie,height:q});}},[h,x,c]),D=useCallback(()=>{C(false),R(null),k.current=null;},[]);useEffect(()=>((h||x)&&(window.addEventListener("pointermove",S),window.addEventListener("pointerup",D)),()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",D);}),[h,x,S,D]);let g=L=>{},p=()=>{let L=l?.width&&l?.height?{x:l.x,y:l.y,width:l.width,height:l.height}:void 0;o(L,m?c:void 0);},y=()=>{d(void 0),v(false);},w=useMemo(()=>{if(!l||!l.width||!l.height)return null;let L=new URLSearchParams({url:e});return L.set("cx",String(l.x)),L.set("cy",String(l.y)),L.set("cw",String(l.width)),L.set("ch",String(l.height)),`/api/media/resize?${L.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"),m||v(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:y,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:p,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:b,children:[jsx(Xf,{crop:l,onChange:(L,P)=>d(P),locked:i==="hotspot",className:i==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsx("img",{ref:f,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:g})}),m&&f.current&&jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsx("div",{className:"relative",style:{width:f.current.width,height:f.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:L=>E(L),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:L=>E(L,"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:L=>E(L,"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:L=>E(L,"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:L=>E(L,"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:w&&jsx("img",{src:w,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 Ns(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 Cs(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 eg(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function tg(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 Ss({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),[m,v]=useState(false),[f,b]=useState([]),[h,C]=useState(""),[x,R]=useState(""),[k,E]=useState("all"),[S,D]=useState("grid"),[g,p]=useState(null),[y,w]=useState(false),[F,L]=useState(false),[P,$]=useState(false),[z,I]=useState({}),[X$1,ee]=useState(false),[ie,q]=useState(false),[Q,pe]=useState(null),[Ae,U]=useState(false),[_,K]=useState(false),[he,Me]=useState(1),[ke,N]=useState(0),[G,we]=useState(1),Ve=40,[je,Le]=useState(new Set),{confirm:ft,alert:Cr}=vt(),[oe,j]=useState(false),Y=useRef(null),le=useCallback(async T=>{T===1?u(true):v(true);try{let ve=new URLSearchParams({page:T.toString(),limit:Ve.toString()});h&&ve.append("folder",h),x&&ve.append("search",x),k!=="all"&&ve.append("type",k);let Ue=await Ie(to(`/api/media?${ve}`)),nr=(Ue.docs||[]).map(Ot=>({...Ot,type:tg(Ot.mimeType)}));d(Ot=>T===1?nr:[...Ot,...nr]),N(Ue.totalDocs||0),we(Ue.totalPages||1);}catch(ve){console.error("Failed to load media:",ve);}finally{u(false),v(false);}},[h,x,k,Ve]),Te=useCallback(async()=>{try{let T=await Ie(to("/api/media/folders"));b(Array.isArray(T)?T:T.folders||[]);}catch(T){console.error("Failed to load folders:",T);}},[]),$e=useCallback(async()=>{try{let ve=!!(await Ie("/api/globals/storage-settings"))?.data?.provider;pe(ve);}catch{pe(false);}},[]);useEffect(()=>{r||$e();},[$e,r]),useEffect(()=>{r||Q===false&&!Ae&&(U(true),K(true));},[r,Q,Ae]),useEffect(()=>{Me(1),le(1);},[h,x,k,le]);let Tt=()=>{if(m||he>=G)return;let T=he+1;Me(T),le(T);};useEffect(()=>{Te();},[Te]),useEffect(()=>{if(r)return;let T=ve=>{let Ue=ve.clipboardData?.files;Ue&&Ue.length>0&&gr(Ue);};return window.addEventListener("paste",T),()=>window.removeEventListener("paste",T)},[r,h,Q]);let gr=async T=>{if(!Q){K(true);return}$(true);let ve=0,Ue=0;for(let nr=0;nr<T.length;nr++){let Ot=T[nr];try{let Sr=new FormData;Sr.append("file",Ot),h&&Sr.append("folder",h),await Rn("/api/media/upload",Sr,ri=>{I(qo=>({...qo,[Ot.name]:ri}));}),ve++;}catch(Sr){console.error(`Upload failed for ${Ot.name}:`,Sr),Ue++;}}$(false),I({}),Me(1),le(1),Te(),Ue>0&&V.error(`${Ue} file(s) failed to upload`),ve>0&&V.success(`${ve} file(s) uploaded successfully`);},Or=()=>{ft({title:"Delete Media",message:`Are you sure you want to delete ${je.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let T of Array.from(je))await Dt(`/api/media/${T}`);Le(new Set),Me(1),le(1),V.success(`${je.size} item(s) deleted`);}catch(T){console.error("Bulk delete failed:",T),V.error("Failed to delete some items");}}});},O=(T,ve)=>{ve.stopPropagation();let Ue=new Set(je);Ue.has(T)?Ue.delete(T):(t||Ue.clear(),Ue.add(T)),Le(Ue);},ae=async T=>{try{await ut("/api/media/folders",{name:T}),Te(),ee(!1),V.success(`Folder "${T}" created`);}catch(ve){console.error("Failed to create folder:",ve),V.error("Failed to create folder");}},ue=T=>{ft({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)}`),h===T&&C(""),Te(),Me(1),le(1),V.success(`Folder "${T}" deleted`);}catch(ve){console.error("Failed to delete folder:",ve),V.error("Failed to delete folder");}}});},Ht=async(T,ve)=>{try{let Ue=await er(`/api/media/${T}`,ve);d(nr=>nr.map(Ot=>Ot.id===T?Ue.doc:Ot)),g?.id===T&&p(Ue.doc),V.success("Metadata updated");}catch(Ue){console.error("Failed to update metadata:",Ue),V.error("Failed to update metadata");}},Wo=async(T,ve)=>{if(g)try{$(!0);let Ue={...g.metadata,crop:T,hotspot:ve},nr=await er(`/api/media/${g.id}`,{metadata:Ue});d(Ot=>Ot.map(Sr=>Sr.id===g.id?nr.doc:Sr)),p(nr.doc),L(!1),V.success("Crop & hotspot saved");}catch(Ue){console.error("Save failed:",Ue),V.error("Failed to save focal metadata");}finally{$(false);}},ti=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(),j(true);},onDragLeave:()=>j(false),onDrop:T=>{T.preventDefault(),j(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:[ke," Items ",jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",Cs(ti.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:()=>D("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${S==="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:()=>D("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${S==="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:()=>q(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:()=>Y.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:x,onChange:T=>R(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:()=>E(T),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${k===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 ${k===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:()=>ee(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:()=>C(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${h===""?"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"]}),f.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>C(T),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${h===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:h===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),ue(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:()=>Y.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"})]}):S==="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 ${je.has(T.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>p(T),onContextMenu:Ue=>{Ue.preventDefault(),O(T.id,Ue);},children:[T.type==="image"?jsx("img",{src:Ns(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:Ue=>O(T.id,Ue),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${je.has(T.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsx(Check,{className:"w-4 h-4"})})})]})}),je.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 rounded-lg 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:je.size===l.length,onChange:T=>{T.target.checked?Le(new Set(l.map(ve=>ve.id))):Le(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 ${je.has(T.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>p(T),children:[jsx("td",{className:"px-6 py-4",onClick:ve=>ve.stopPropagation(),children:jsx("input",{type:"checkbox",checked:je.has(T.id),onChange:ve=>O(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:Ns(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:Cs(T.fileSize)}),jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:eg(T.createdAt)}),jsx("td",{className:"px-6 py-4 text-right",children:jsx("button",{onClick:ve=>{ve.stopPropagation(),O(T.id,ve);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${je.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&&he<G&&jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsx("button",{onClick:Tt,disabled:m,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:m?jsxs(Fragment,{children:[jsx(lr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&P&&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))})]})}),je.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:je.size}),jsxs("div",{children:[jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsx("button",{onClick:()=>Le(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=>je.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"})})]})]}),ie&&!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:()=>q(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:()=>q(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:()=>{E(T),q(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${k===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:()=>{ee(true),q(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:()=>{C(""),q(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${h===""?"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"]}),f.map(T=>jsxs("div",{className:"group relative",children:[jsxs("button",{onClick:()=>{C(T),q(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${h===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:h===T?"currentColor":"none"})}),T]}),jsx("button",{onClick:ve=>{ve.stopPropagation(),ue(T),q(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:()=>p(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:Ns(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:()=>w(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:Cs(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)),V.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:()=>L(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:()=>{ft({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}`),p(null),le(1);}catch(T){console.error("Delete failed:",T),V.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"})})]})]})}),y&&g&&jsxs(At,{open:y,onClose:()=>w(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:[Cs(g.fileSize)," \xB7 ",g.mimeType]})]}),jsx("button",{onClick:()=>w(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:Ns(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:()=>L(false),title:"",size:"full",variant:"lightbox",children:jsx(Ic,{url:Gr(g.url),initialCrop:g.metadata?.crop,initialHotspot:g.metadata?.hotspot,onSave:Wo,onCancel:()=>L(false),isSaving:P})}),!r&&jsx(ks,{open:X$1,onClose:()=>ee(false),onSubmit:ae,title:o("tooltips.createNewFolder",{defaultValue:"Create New Folder"}),placeholder:o("fields.folderName",{defaultValue:"Folder name"})}),!r&&jsx(At,{open:_,onClose:()=>K(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(()=>{K(false),pe(true),window.dispatchEvent(new Event("kyro:soft-reload"));}).catch(()=>{V.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:Y,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 Lc({type:e,message:t,duration:r=3e3,onClose:o}){let[a,n]=ia.useState(false),i=ia.useRef(null),s=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(o,r);},l=()=>{i.current&&clearTimeout(i.current);};ia.useEffect(()=>(a?l():s(),l),[a,o]);let d={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:()=>n(true),onMouseLeave:()=>n(false),children:[jsx("div",{className:"kyro-toast-accent"}),jsx("div",{className:"kyro-toast-icon-container",children:jsx(d,{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:o,children:jsx(X,{className:"w-3.5 h-3.5"})})]})}function U2({children:e}){return jsx(Fragment,{children:e})}function Ec(){let e=Zt(o=>o.addToast),t=Zt(o=>o.removeToast);return {toasts:Zt(o=>o.toasts),addToast:e,removeToast:t}}var Eg=[{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"}],Hc=({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:m}=Ec(),v=ge(w=>w.formData),f=ge(w=>w.setField),b=projectConfig?.plugins?.some?.(w=>w.name==="ai-assistant")??false;if(useEffect(()=>{function w(F){u.current&&!u.current.contains(F.target)&&l(null);}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),!e)return null;let h=()=>{o();},C=()=>{let w=e.getAttributes("link").href,F=window.prompt("URL",w);if(F!==null){if(F===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:F}).run();}},x=w=>{w==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(w).run(),l(null);},R=async(w,F)=>{l(null);let L=document.querySelector('input#title, input[name="title"]')?.value,P=v?.title||L||"Untitled Document",$="document";try{let ee=window.location.pathname.split("/").filter(Boolean);ee[0]==="admin"&&ee.length>=2&&($=ee[1],$.endsWith("s")&&($=$.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," "),X="";if(w==="Generate")X=`Write a comprehensive, engaging, and professional ${$} titled "${P}".
|
|
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: '' (replace URL_ENCODED_KEYWORDS with descriptive keywords for the image)
|
|
13
13
|
3. Hyperlinks where necessary to provide additional context or references
|
|
14
|
-
4. Well-structured sections with bullet points or numbered lists where appropriate.`;else if(
|
|
14
|
+
4. Well-structured sections with bullet points or numbered lists where appropriate.`;else if(w==="Summarize")X=`Summarize the following content from the ${$} titled "${P}" into a concise paragraph. Use clear Markdown formatting if necessary (like bolding key terms): ${I||z}`;else if(w==="Expand")X=`Expand on the following content from the ${$} titled "${P}". Add more details, context, and depth.
|
|
15
15
|
Please format the output using rich Markdown (headings, paragraphs, lists).
|
|
16
16
|
If visual context would be helpful, include relevant images using EXACT Markdown image syntax: ''.
|
|
17
|
-
Here is the content to expand: ${I||z}`;else if(
|
|
17
|
+
Here is the content to expand: ${I||z}`;else if(w==="Prompt")if(F)X=`${F}
|
|
18
18
|
|
|
19
|
-
Please format your response using rich Markdown. If your response includes images, use EXACT Markdown image syntax: ''`;else {c(true);return}n(true);try{let ee=window.__KYRO_API_PATH__||"/api",ie=await fetch(`${ee}/kyro/ai/completion`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({prompt:X,context:I||z})});if(!ie.ok)throw new Error("Failed to get AI response");let Q=(await ie.json()).text;if(Q){console.log("[AI Client] Raw Markdown Response:",Q);let pe=await marked.parse(Q);if(console.log("[AI Client] Parsed HTML Response:",pe),e.chain().focus().insertContent(pe).run(),document.querySelector('input[name="excerpt"], textarea[name="excerpt"]')||"excerpt"in
|
|
19
|
+
Please format your response using rich Markdown. If your response includes images, use EXACT Markdown image syntax: ''`;else {c(true);return}n(true);try{let ee=window.__KYRO_API_PATH__||"/api",ie=await fetch(`${ee}/kyro/ai/completion`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({prompt:X,context:I||z})});if(!ie.ok)throw new Error("Failed to get AI response");let Q=(await ie.json()).text;if(Q){console.log("[AI Client] Raw Markdown Response:",Q);let pe=await marked.parse(Q);if(console.log("[AI Client] Parsed HTML Response:",pe),e.chain().focus().insertContent(pe).run(),document.querySelector('input[name="excerpt"], textarea[name="excerpt"]')||"excerpt"in v){let U=Q.replace(/<[^>]*>?/gm,"").replace(/[#*]/g,""),_=U.match(/^.*?[.!?](?:\s|$)/),K=_?_[0].trim():U.substring(0,150)+"...";K.length>200&&(K=K.substring(0,150)+"..."),f("excerpt",K),m("success","Content generated and excerpt updated.");}else m("success","Content generated.");}}catch(ee){console.error("AI Assistant Error:",ee),m("error","AI Assistant failed to generate text.");}finally{n(false);}},k=w=>{l(s===w?null:w);},E=()=>e.isActive("heading",{level:1})?"Heading 1":e.isActive("heading",{level:2})?"Heading 2":e.isActive("heading",{level:3})?"Heading 3":e.isActive("heading",{level:4})?"Heading 4":"Normal Text",S=()=>e.isActive({textAlign:"center"})?jsx(AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsx(AlignRight,{size:12}):jsx(AlignLeft,{size:12}),D=()=>e.isActive("orderedList")?jsx(ListOrdered,{size:12}):e.isActive("taskList")?jsx(CheckSquare,{size:12}):jsx(List,{size:12}),g=()=>e.isActive("codeBlock")?jsx(Terminal,{size:12}):jsx(Quote,{size:12}),p=({onClick:w,isActive:F=false,disabled:L=false,children:P,title:$})=>jsx("button",{type:"button",onClick:w,disabled:L,title:$,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
|
|
20
20
|
${F?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
|
|
21
|
-
${L?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:P}),
|
|
22
|
-
${F?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[L,jsx(ChevronDown,{size:10,className:"opacity-60"})]});return jsxs("div",{ref:u,className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg select-none",children:[jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(
|
|
23
|
-
${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(
|
|
24
|
-
${e.isActive("heading",{level:
|
|
21
|
+
${L?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:P}),y=({onClick:w,isActive:F,children:L,title:P})=>jsxs("button",{type:"button",onClick:w,title:P,className:`px-2 py-1 rounded flex items-center gap-1 transition-all duration-150 text-xs border border-transparent hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] active:scale-98
|
|
22
|
+
${F?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[L,jsx(ChevronDown,{size:10,className:"opacity-60"})]});return jsxs("div",{ref:u,className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg select-none",children:[jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(p,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:i("tooltips.undoCtrlz",{defaultValue:"Undo (Ctrl+Z)"}),children:jsx(Undo,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:i("tooltips.redoCtrly",{defaultValue:"Redo (Ctrl+Y)"}),children:jsx(Redo,{size:12})})]}),jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(p,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:i("tooltips.boldCtrlb",{defaultValue:"Bold (Ctrl+B)"}),children:jsx(Bold,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:i("tooltips.italicCtrli",{defaultValue:"Italic (Ctrl+I)"}),children:jsx(Italic,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:i("tooltips.underlineCtrlu",{defaultValue:"Underline (Ctrl+U)"}),children:jsx(Underline,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:i("tooltips.strikethrough",{defaultValue:"Strikethrough"}),children:jsx(Strikethrough,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:i("tooltips.inlineCode",{defaultValue:"Inline Code"}),children:jsx(Code,{size:12})}),jsx(p,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:i("tooltips.highlightText",{defaultValue:"Highlight Text"}),children:jsx(Highlighter,{size:12})}),jsxs("div",{className:"relative flex items-center justify-center",children:[jsx(p,{onClick:()=>k("color"),title:i("tooltips.textColor",{defaultValue:"Text Color"}),isActive:s==="color"||e.isActive("textStyle"),children:jsx(Palette,{size:12})}),s==="color"&&jsx("div",{className:"absolute top-full left-0 mt-1.5 p-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 flex flex-wrap gap-1 w-44 animate-in fade-in slide-in-from-top-1 duration-150",children:Eg.map(w=>jsx("button",{type:"button",onClick:()=>x(w.value),title:w.name,className:"w-6 h-6 rounded-full border border-[var(--kyro-border)] transition-transform hover:scale-115 active:scale-95 cursor-pointer relative",style:{backgroundColor:w.value==="inherit"?"transparent":w.value},children:w.value==="inherit"&&jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},w.name))})]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(y,{onClick:()=>k("heading"),isActive:s==="heading",title:i("tooltips.headingHierarchy",{defaultValue:"Heading hierarchy"}),children:jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:E()})}),s==="heading"&&jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
|
|
23
|
+
${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(w=>jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:w}).run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors
|
|
24
|
+
${e.isActive("heading",{level:w})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",w]},w))]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(y,{onClick:()=>k("lists"),isActive:s==="lists",title:i("tooltips.listTypes",{defaultValue:"List Types"}),children:D()}),s==="lists"&&jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
25
25
|
${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(List,{size:12}),"Bullet List"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
26
26
|
${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(ListOrdered,{size:12}),"Ordered List"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
27
|
-
${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(
|
|
27
|
+
${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(y,{onClick:()=>k("blocks"),isActive:s==="blocks",title:i("tooltips.structuralBlocks",{defaultValue:"Structural Blocks"}),children:g()}),s==="blocks"&&jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-36 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
28
28
|
${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(Quote,{size:12}),"Blockquote"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
29
|
-
${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(Terminal,{size:12}),"Code Block"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),l(null);},className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors",children:[jsx(Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(
|
|
29
|
+
${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(Terminal,{size:12}),"Code Block"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),l(null);},className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors",children:[jsx(Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(y,{onClick:()=>k("align"),isActive:s==="align",title:i("tooltips.alignment",{defaultValue:"Alignment"}),children:S()}),s==="align"&&jsxs("div",{className:"absolute top-full left-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-32 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
30
30
|
${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(AlignLeft,{size:12}),"Align Left"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
31
31
|
${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(AlignCenter,{size:12}),"Align Center"]}),jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),l(null);},className:`px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] flex items-center gap-2 transition-colors
|
|
32
|
-
${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(AlignRight,{size:12}),"Align Right"]})]})]}),jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(
|
|
32
|
+
${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsx(AlignRight,{size:12}),"Align Right"]})]})]}),jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsx(p,{onClick:C,isActive:e.isActive("link"),title:i("tooltips.link",{defaultValue:"Link"}),children:jsx(Link,{size:12})}),jsx(p,{onClick:h,title:i("tooltips.addImage",{defaultValue:"Add Image"}),children:jsx(Image,{size:12})})]}),jsxs("div",{className:"flex items-center gap-0.5 p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs ml-auto",children:[b&&jsxs("div",{className:"relative flex items-center justify-center",children:[jsx(p,{onClick:()=>k("ai"),title:i("tooltips.aiAssistant",{defaultValue:"AI Assistant"}),isActive:s==="ai",disabled:a,children:a?jsx(Sparkles,{size:14,className:"animate-pulse text-[var(--kyro-primary)]"}):s==="ai"?jsx(Sparkles,{size:14,className:"text-[var(--kyro-primary)]"}):jsxs(Fragment,{children:[jsx("img",{src:"/logo.svg",alt:"Kyro AI",className:"w-3.5 h-3.5 object-contain opacity-80 group-hover:opacity-100 block dark:hidden"}),jsx("img",{src:"/logo-white.svg",alt:"Kyro AI",className:"w-3.5 h-3.5 object-contain opacity-80 group-hover:opacity-100 hidden dark:block"})]})}),s==="ai"&&jsxs("div",{className:"absolute top-full right-0 mt-1.5 p-1 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 min-w-32 flex flex-col gap-0.5 animate-in fade-in slide-in-from-top-1 duration-150",children:[jsxs("button",{type:"button",onClick:()=>R("Generate"),className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors flex items-center gap-2",children:[jsx(Sparkles,{size:12,className:"text-[var(--kyro-primary)]"})," Generate"]}),jsxs("button",{type:"button",onClick:()=>R("Summarize"),className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors flex items-center gap-2",children:[jsx(AlignLeft,{size:12})," Summarize"]}),jsxs("button",{type:"button",onClick:()=>R("Expand"),className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors flex items-center gap-2",children:[jsx(Maximize2,{size:12})," Expand"]}),jsxs("button",{type:"button",onClick:()=>R("Prompt"),className:"px-2.5 py-1.5 text-xs text-left rounded-md hover:bg-[var(--kyro-bg-hover)] cursor-pointer text-[var(--kyro-text)] transition-colors flex items-center gap-2 border-t border-[var(--kyro-border)] mt-0.5",children:[jsx(Terminal,{size:12})," Prompt"]})]})]}),jsx(p,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsx(Minimize2,{size:12}):jsx(Maximize2,{size:12})})]}),jsx(ks,{open:d,onClose:()=>c(false),onSubmit:w=>{c(false),R("Prompt",w);},title:"AI Assistant Prompt",placeholder:"What do you want the AI to do?",defaultValue:e.state.doc.textBetween(e.state.selection.from,e.state.selection.to," ")?"Rewrite this text to be more engaging.":"Write a paragraph about..."})]})};function fa({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,i]=useState(false);return useEffect(()=>{i(true);},[]),n?jsx(Bg,{field:e,value:t,onChange:r,error:o,disabled:a}):jsx(pt,{field:e,error:o,children:jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
33
33
|
${o?"border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]":"border-[var(--kyro-border)]"}
|
|
34
|
-
${a?"opacity-60 cursor-not-allowed":""}`,children:[jsx("div",{className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]"}),jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function
|
|
34
|
+
${a?"opacity-60 cursor-not-allowed":""}`,children:[jsx("div",{className:"flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]"}),jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function Bg({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),[i,s]=useState(false),[l,d]=useState(0),[c,u]=useState(false),[m,v]=useState(false);useEffect(()=>{if(!i){d(0);return}let b=document.querySelector('[data-kyro-slide-panel="true"]'),h=()=>{d(b?b.getBoundingClientRect().width:0);};h();let C=new MutationObserver(()=>{h();});b&&C.observe(b),window.addEventListener("resize",h);let x=setInterval(h,100);return ()=>{C&&C.disconnect(),window.removeEventListener("resize",h),clearInterval(x);}},[i]);let f=useEditor({extensions:[lg.configure({codeBlock:{},link:false,underline:false}),cg.configure({openOnClick:false}),ug,pg.configure({types:["heading","paragraph"]}),mg,fg.configure({multicolor:true}),gg,yg.configure({nested:true}),TextStyle,bg],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:b})=>{r(b.getJSON());},editorProps:{attributes:{class:"prose prose-sm dark:prose-invert focus:outline-none min-h-[160px] p-4 max-w-none kyro-richtext text-[0.875rem] leading-relaxed"}}});return useEffect(()=>{f&&t&&JSON.stringify(t)!==JSON.stringify(f.getJSON())&&f.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,f]),jsxs(pt,{field:e,error:o,children:[i?jsxs("div",{className:"border rounded-lg bg-[var(--kyro-bg-secondary)] border-[var(--kyro-border)] p-4 text-center text-xs text-[var(--kyro-text-muted)] flex items-center justify-center gap-3 h-20 transition-all duration-200 shadow-inner",children:[jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsx("button",{type:"button",onClick:()=>s(false),className:"px-2.5 py-1 bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] text-xs rounded-md shadow-sm font-medium hover:scale-102 active:scale-98 transition-transform cursor-pointer",children:"Minimize Workspace"})]}):jsxs("div",{className:`border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
35
35
|
${o?"border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]":"border-[var(--kyro-border)] focus-within:border-[var(--kyro-primary)] focus-within:ring-1 focus-within:ring-[var(--kyro-primary)]"}
|
|
36
|
-
${a?"opacity-60 cursor-not-allowed":""}`,children:[jsx(
|
|
36
|
+
${a?"opacity-60 cursor-not-allowed":""}`,children:[jsx(Hc,{editor:f,isExpanded:i,setIsExpanded:s,onOpenMediaPicker:()=>u(true),isAiLoading:m,setIsAiLoading:v}),jsxs("div",{className:`overflow-y-auto min-h-[160px] max-h-[400px] transition-all duration-300 ${m?"opacity-40 pointer-events-none":""} relative`,children:[m&&jsxs("div",{className:"absolute inset-0 flex items-center justify-center z-10 font-medium text-sm text-[var(--kyro-primary)]",children:[jsx(Sparkles,{size:16,className:"animate-pulse mr-2"})," Generating content..."]}),jsx(EditorContent,{editor:f})]})]}),i&&typeof document<"u"&&createPortal(jsxs("div",{style:{position:"fixed",top:"16px",bottom:"16px",left:"16px",right:l>0?`${l+16}px`:"16px",zIndex:9999},className:"flex flex-col bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200 transition-all duration-300",children:[jsx(Hc,{editor:f,isExpanded:i,setIsExpanded:s,onOpenMediaPicker:()=>u(true),isAiLoading:m,setIsAiLoading:v}),jsxs("div",{className:`flex-1 overflow-y-auto transition-all duration-300 ${m?"opacity-40 pointer-events-none":""} relative`,children:[m&&jsxs("div",{className:"absolute inset-0 flex items-center justify-center z-10 font-medium text-lg text-[var(--kyro-primary)]",children:[jsx(Sparkles,{size:24,className:"animate-pulse mr-3"})," Generating content..."]}),jsx(EditorContent,{editor:f,className:"h-full"})]})]}),document.body),jsx("style",{children:`
|
|
37
37
|
.kyro-richtext ul[data-type="taskList"] {
|
|
38
38
|
list-style: none !important;
|
|
39
39
|
padding: 0 !important;
|
|
@@ -89,8 +89,8 @@ Please format your response using rich Markdown. If your response includes image
|
|
|
89
89
|
font-style: italic !important;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
`}),c&&jsx(xr,{open:c,onClose:()=>u(false),title:n("tooltips.selectImage",{defaultValue:"Select Image"}),width:"xl",children:jsx(Ss,{pickerMode:true,multiple:false,onSelect:v=>{if(v&&v.length>0){let b=v[0];f.chain().focus().setImage({src:b.url,alt:b.alt||b.title||"",title:b.title||""}).run();}u(false);}})})]})}var Hc=Object.keys(Kc).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Gc({open:e,onClose:t,onSelect:r}){let{t:o}=H(),[a,n]=useState(""),i=useMemo(()=>{if(!a)return Hc;let s=a.toLowerCase();return Hc.filter(l=>l.toLowerCase().includes(s))},[a]);return jsx(At,{open:e,onClose:t,title:o("tooltips.selectAnIcon",{defaultValue:"Select an Icon"}),size:"xl",children:jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxs("div",{className:"relative mb-6",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.searchIcons",{defaultValue:"Search icons..."}),value:a,onChange:s=>n(s.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:i.map(s=>{let l=Kc[s],d=s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsx("button",{type:"button",onClick:()=>{r(d),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:s,children:jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},s)})})})]})})}function Ts({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,i]=useState(false),s=t==null?"":String(t),l=useMemo(()=>s?s.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""):"",[s]),d=Kc[l],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxs(pt,{field:e,error:o,children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"flex-1 relative",children:jsx("input",{id:e.name,type:"text",value:s,onChange:u=>r?.(u.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxs("button",{type:"button",onClick:()=>i(true),disabled:a||c,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[d?jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsx(Kc.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsx(Gc,{open:n,onClose:()=>i(false),onSelect:u=>{r?.(u);}})]})}var ma={id:"light",label:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",success:"#22c55e",error:"#ef4444",warning:"#f59e0b",info:"#06b6d4"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1)"}},sn={id:"dark",label:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",background:"#0b1222",surface:"#1e293b",text:"#f1f5f9",textMuted:"#94a3b8",border:"#334155",success:"#4ade80",error:"#f87171",warning:"#fbbf24",info:"#22d3ee"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.5)"}};function ln(e,t){return {...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows},blocks:e.blocks?{...e.blocks,...t.blocks}:t.blocks,fields:e.fields?{...e.fields,...t.fields}:t.fields}}var Xc=createContext(null);function fa(){let e=useContext(Xc);return e||{mode:"light",theme:ma,lightTheme:ma,darkTheme:sn,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function qc(e){let t=document.documentElement;t&&(e.colors&&Object.entries(e.colors).forEach(([r,o])=>{o&&(t.style.setProperty(`--kyro-${r}`,o),t.style.setProperty(`--kyro-${r}-light`,Jc(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Jc(o,.8)));}),e.typography&&(e.typography.fontFamily&&t.style.setProperty("--kyro-font-family",e.typography.fontFamily),e.typography.fontFamilyMono&&t.style.setProperty("--kyro-font-mono",e.typography.fontFamilyMono)),e.spacing&&Object.entries(e.spacing).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-spacing-${r}`,o);}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-radius-${r}`,o);}),e.shadows&&Object.entries(e.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-shadow-${r}`,o);}),e.blocks&&(e.blocks.card&&Object.entries(e.blocks.card).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-card-${r}`,o);}),e.blocks.hero?.background&&t.style.setProperty("--kyro-block-hero-bg",e.blocks.hero.background),e.blocks.code&&Object.entries(e.blocks.code).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-code-${r}`,o);})),e.fields&&(e.fields.input&&Object.entries(e.fields.input).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-field-input-${r}`,o);}),e.fields.upload&&e.fields.upload.dropzoneBackground&&t.style.setProperty("--kyro-field-upload-dropzone-bg",e.fields.upload.dropzoneBackground)));}function Jc(e,t){if(!e.startsWith("#"))return e;let r=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=i=>Math.round(i*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function Lr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=useState(t),[i,s]=useState(r||{}),[l,d]=useState(o||{}),c=ln(ma,i),u=ln(sn,l),p=useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?u:c:a==="dark"?u:c,[a,c,u]),[g,f]=useState(p());useEffect(()=>{let S=p();f(S),qc(S);},[p]),useEffect(()=>{if(a!=="system")return;let S=window.matchMedia("(prefers-color-scheme: dark)"),w=()=>{let R=p();f(R),qc(R);};return S.addEventListener("change",w),()=>S.removeEventListener("change",w)},[a,p]);let v=useCallback(S=>{s(w=>({...w,...S})),d(w=>({...w,...S}));},[]),b=useCallback(S=>`var(--kyro-${S})`,[]);return jsx(Xc.Provider,{value:{mode:a,theme:g,lightTheme:c,darkTheme:u,setMode:n,updateTheme:v,getCssVar:b},children:e})}var Ps=e=>jsx(Lr,{defaultMode:"light",...e}),Rs=e=>jsx(Lr,{defaultMode:"dark",...e});var _g=lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),Kg=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"sql",label:"SQL"},{value:"python",label:"Python"},{value:"rust",label:"Rust"},{value:"java",label:"Java"},{value:"php",label:"PHP"},{value:"markdown",label:"Markdown"}],Qc={javascript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),typescript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),js:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),jsx:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),ts:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({typescript:true})),json:()=>import('@codemirror/lang-json').then(e=>e.json()),css:()=>import('@codemirror/lang-css').then(e=>e.css()),sql:()=>import('@codemirror/lang-sql').then(e=>e.sql()),python:()=>import('@codemirror/lang-python').then(e=>e.python()),html:()=>import('@codemirror/lang-html').then(e=>e.html()),rust:()=>import('@codemirror/lang-rust').then(e=>e.rust()),java:()=>import('@codemirror/lang-java').then(e=>e.java()),cpp:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),c:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),php:()=>import('@codemirror/lang-php').then(e=>e.php()),markdown:()=>import('@codemirror/lang-markdown').then(e=>e.markdown()),py:()=>import('@codemirror/lang-python').then(e=>e.python())},dn=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,i]=useState(false),[s,l]=useState(false),[d,c]=useState([]),[u,p]=useState(false),[g,f]=useState(false),[v,b]=useState(false),{theme:S}=fa(),w=S.colors?.accent||S.colors?.primary||"#6366f1",R=e.language?.toLowerCase()||"javascript";useEffect(()=>{i(true),l(document.documentElement.classList.contains("dark"));let h=new MutationObserver(()=>{l(document.documentElement.classList.contains("dark"));});return h.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>h.disconnect()},[]),useEffect(()=>{if(!n)return;(async()=>{p(true);try{let F=await(Qc[R]||Qc.javascript)();c([F]);}catch(N){console.error("Failed to load language extension:",N),c([]);}finally{p(false);}})();},[R,n]);let k=useCallback(h=>r?.(h),[r]),E=useCallback(()=>{navigator.clipboard.writeText(t),f(true),setTimeout(()=>f(false),1500);},[t]),A=useCallback(()=>{b(h=>!h),document.body.style.overflow=v?"":"hidden";},[v]),x=s?aura:githubLight,m=Kg.find(h=>h.value===R)?.label||R,y=(h,N=1)=>{let F=parseInt(h.slice(1,3),16),L=parseInt(h.slice(3,5),16),P=parseInt(h.slice(5,7),16);return `rgba(${F}, ${L}, ${P}, ${N})`};return n?jsxs("div",{className:"group",style:{"--accent":w,"--accent-light":y(w,.1),"--accent-light-2":y(w,.05)},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-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:u?"var(--kyro-surface-accent)":w,color:u?"var(--kyro-text-muted)":"white"},children:u?"...":m})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:E,className:"text-[10px] px-2 py-0.5 rounded font-medium transition-all",style:{backgroundColor:g?"var(--kyro-success)":"var(--kyro-surface-accent)",color:g?"white":"var(--kyro-text-secondary)"},children:g?"Copied":"Copy"}),jsx("button",{type:"button",onClick:A,className:"text-[10px] px-2 py-0.5 rounded font-medium bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] transition-all",style:{color:"var(--kyro-text-secondary)"},children:v?"Exit":"Expand"})]})]}),jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${v?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:w}}),jsx(Suspense,{fallback:jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:w,borderWidth:"2px"}})}),children:jsx(_g,{value:t??"",height:v?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:x,onChange:k,editable:!a,basicSetup:{lineNumbers:true,highlightActiveLine:true,bracketMatching:true,closeBrackets:true,autocompletion:true,foldGutter:true},style:{fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"}})}),o&&jsx("div",{className:"absolute bottom-0 left-0 right-0 px-3 py-2 text-xs font-medium",style:{backgroundColor:"var(--kyro-danger-bg)",color:"var(--kyro-error)"},children:o})]}),jsx("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:jsxs("span",{children:[t.split(`
|
|
93
|
-
`).length," lines"]})})]}):jsxs("div",{className:"space-y-3",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function
|
|
92
|
+
`}),c&&jsx(xr,{open:c,onClose:()=>u(false),title:n("tooltips.selectImage",{defaultValue:"Select Image"}),width:"xl",children:jsx(Ss,{pickerMode:true,multiple:false,onSelect:b=>{if(b&&b.length>0){let h=b[0];f.chain().focus().setImage({src:h.url,alt:h.alt||h.title||"",title:h.title||""}).run();}u(false);}})})]})}var _c=Object.keys(Gc).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Wc({open:e,onClose:t,onSelect:r}){let{t:o}=H(),[a,n]=useState(""),i=useMemo(()=>{if(!a)return _c;let s=a.toLowerCase();return _c.filter(l=>l.toLowerCase().includes(s))},[a]);return jsx(At,{open:e,onClose:t,title:o("tooltips.selectAnIcon",{defaultValue:"Select an Icon"}),size:"xl",children:jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxs("div",{className:"relative mb-6",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.searchIcons",{defaultValue:"Search icons..."}),value:a,onChange:s=>n(s.target.value),className:"w-full pl-10 pr-4 py-3 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl focus:outline-none focus:ring-2 focus:ring-[var(--kyro-primary)] transition-all text-sm font-bold"})]}),jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:i.length===0?jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:i.map(s=>{let l=Gc[s],d=s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsx("button",{type:"button",onClick:()=>{r(d),t();},className:"flex flex-col items-center justify-center p-3 gap-2 rounded-md border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface-accent)] hover:border-[var(--kyro-primary)] transition-all group",title:s,children:jsx(l,{className:"w-6 h-6 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors",strokeWidth:1.5})},s)})})})]})})}function Ts({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,i]=useState(false),s=t==null?"":String(t),l=useMemo(()=>s?s.split("-").map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""):"",[s]),d=Gc[l],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxs(pt,{field:e,error:o,children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"flex-1 relative",children:jsx("input",{id:e.name,type:"text",value:s,onChange:u=>r?.(u.target.value),placeholder:e.admin?.placeholder||"e.g., activity",disabled:a||c,required:e.required,className:`kyro-form-input ${a||c?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`})}),jsxs("button",{type:"button",onClick:()=>i(true),disabled:a||c,className:"flex items-center gap-2 h-10 px-4 shrink-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] rounded-xl text-sm font-bold text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[d?jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsx(Gc.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsx(Wc,{open:n,onClose:()=>i(false),onSelect:u=>{r?.(u);}})]})}var ga={id:"light",label:"Light",colors:{primary:"#3b82f6",secondary:"#8b5cf6",background:"#f8fafc",surface:"#ffffff",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",success:"#22c55e",error:"#ef4444",warning:"#f59e0b",info:"#06b6d4"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1)"}},ln={id:"dark",label:"Dark",colors:{primary:"#60a5fa",secondary:"#a78bfa",background:"#0b1222",surface:"#1e293b",text:"#f1f5f9",textMuted:"#94a3b8",border:"#334155",success:"#4ade80",error:"#f87171",warning:"#fbbf24",info:"#22d3ee"},typography:{fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontFamilyMono:"'Fira Code', 'Cascadia Code', monospace"},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.5)"}};function dn(e,t){return {...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows},blocks:e.blocks?{...e.blocks,...t.blocks}:t.blocks,fields:e.fields?{...e.fields,...t.fields}:t.fields}}var Yc=createContext(null);function ya(){let e=useContext(Yc);return e||{mode:"light",theme:ga,lightTheme:ga,darkTheme:ln,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Jc(e){let t=document.documentElement;t&&(e.colors&&Object.entries(e.colors).forEach(([r,o])=>{o&&(t.style.setProperty(`--kyro-${r}`,o),t.style.setProperty(`--kyro-${r}-light`,Xc(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Xc(o,.8)));}),e.typography&&(e.typography.fontFamily&&t.style.setProperty("--kyro-font-family",e.typography.fontFamily),e.typography.fontFamilyMono&&t.style.setProperty("--kyro-font-mono",e.typography.fontFamilyMono)),e.spacing&&Object.entries(e.spacing).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-spacing-${r}`,o);}),e.borderRadius&&Object.entries(e.borderRadius).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-radius-${r}`,o);}),e.shadows&&Object.entries(e.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-shadow-${r}`,o);}),e.blocks&&(e.blocks.card&&Object.entries(e.blocks.card).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-card-${r}`,o);}),e.blocks.hero?.background&&t.style.setProperty("--kyro-block-hero-bg",e.blocks.hero.background),e.blocks.code&&Object.entries(e.blocks.code).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-block-code-${r}`,o);})),e.fields&&(e.fields.input&&Object.entries(e.fields.input).forEach(([r,o])=>{o&&t.style.setProperty(`--kyro-field-input-${r}`,o);}),e.fields.upload&&e.fields.upload.dropzoneBackground&&t.style.setProperty("--kyro-field-upload-dropzone-bg",e.fields.upload.dropzoneBackground)));}function Xc(e,t){if(!e.startsWith("#"))return e;let r=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=i=>Math.round(i*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function Lr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=useState(t),[i,s]=useState(r||{}),[l,d]=useState(o||{}),c=dn(ga,i),u=dn(ln,l),m=useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?u:c:a==="dark"?u:c,[a,c,u]),[v,f]=useState(m());useEffect(()=>{let C=m();f(C),Jc(C);},[m]),useEffect(()=>{if(a!=="system")return;let C=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>{let R=m();f(R),Jc(R);};return C.addEventListener("change",x),()=>C.removeEventListener("change",x)},[a,m]);let b=useCallback(C=>{s(x=>({...x,...C})),d(x=>({...x,...C}));},[]),h=useCallback(C=>`var(--kyro-${C})`,[]);return jsx(Yc.Provider,{value:{mode:a,theme:v,lightTheme:c,darkTheme:u,setMode:n,updateTheme:b,getCssVar:h},children:e})}var Ps=e=>jsx(Lr,{defaultMode:"light",...e}),Rs=e=>jsx(Lr,{defaultMode:"dark",...e});var Wg=lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),qg=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"json",label:"JSON"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"sql",label:"SQL"},{value:"python",label:"Python"},{value:"rust",label:"Rust"},{value:"java",label:"Java"},{value:"php",label:"PHP"},{value:"markdown",label:"Markdown"}],Zc={javascript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),typescript:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true,typescript:true})),js:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),jsx:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({jsx:true})),ts:()=>import('@codemirror/lang-javascript').then(e=>e.javascript({typescript:true})),json:()=>import('@codemirror/lang-json').then(e=>e.json()),css:()=>import('@codemirror/lang-css').then(e=>e.css()),sql:()=>import('@codemirror/lang-sql').then(e=>e.sql()),python:()=>import('@codemirror/lang-python').then(e=>e.python()),html:()=>import('@codemirror/lang-html').then(e=>e.html()),rust:()=>import('@codemirror/lang-rust').then(e=>e.rust()),java:()=>import('@codemirror/lang-java').then(e=>e.java()),cpp:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),c:()=>import('@codemirror/lang-cpp').then(e=>e.cpp()),php:()=>import('@codemirror/lang-php').then(e=>e.php()),markdown:()=>import('@codemirror/lang-markdown').then(e=>e.markdown()),py:()=>import('@codemirror/lang-python').then(e=>e.python())},cn=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,i]=useState(false),[s,l]=useState(false),[d,c]=useState([]),[u,m]=useState(false),[v,f]=useState(false),[b,h]=useState(false),{theme:C}=ya(),x=C.colors?.accent||C.colors?.primary||"#6366f1",R=e.language?.toLowerCase()||"javascript";useEffect(()=>{i(true),l(document.documentElement.classList.contains("dark"));let y=new MutationObserver(()=>{l(document.documentElement.classList.contains("dark"));});return y.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>y.disconnect()},[]),useEffect(()=>{if(!n)return;(async()=>{m(true);try{let F=await(Zc[R]||Zc.javascript)();c([F]);}catch(w){console.error("Failed to load language extension:",w),c([]);}finally{m(false);}})();},[R,n]);let k=useCallback(y=>r?.(y),[r]),E=useCallback(()=>{navigator.clipboard.writeText(t),f(true),setTimeout(()=>f(false),1500);},[t]),S=useCallback(()=>{h(y=>!y),document.body.style.overflow=b?"":"hidden";},[b]),D=s?aura:githubLight,g=qg.find(y=>y.value===R)?.label||R,p=(y,w=1)=>{let F=parseInt(y.slice(1,3),16),L=parseInt(y.slice(3,5),16),P=parseInt(y.slice(5,7),16);return `rgba(${F}, ${L}, ${P}, ${w})`};return n?jsxs("div",{className:"group",style:{"--accent":x,"--accent-light":p(x,.1),"--accent-light-2":p(x,.05)},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-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:u?"var(--kyro-surface-accent)":x,color:u?"var(--kyro-text-muted)":"white"},children:u?"...":g})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:E,className:"text-[10px] px-2 py-0.5 rounded font-medium transition-all",style:{backgroundColor:v?"var(--kyro-success)":"var(--kyro-surface-accent)",color:v?"white":"var(--kyro-text-secondary)"},children:v?"Copied":"Copy"}),jsx("button",{type:"button",onClick:S,className:"text-[10px] px-2 py-0.5 rounded font-medium bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-border)] transition-all",style:{color:"var(--kyro-text-secondary)"},children:b?"Exit":"Expand"})]})]}),jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${b?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:x}}),jsx(Suspense,{fallback:jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:x,borderWidth:"2px"}})}),children:jsx(Wg,{value:t??"",height:b?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:D,onChange:k,editable:!a,basicSetup:{lineNumbers:true,highlightActiveLine:true,bracketMatching:true,closeBrackets:true,autocompletion:true,foldGutter:true},style:{fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"}})}),o&&jsx("div",{className:"absolute bottom-0 left-0 right-0 px-3 py-2 text-xs font-medium",style:{backgroundColor:"var(--kyro-danger-bg)",color:"var(--kyro-error)"},children:o})]}),jsx("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:jsxs("span",{children:[t.split(`
|
|
93
|
+
`).length," lines"]})})]}):jsxs("div",{className:"space-y-3",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function Qg(e){return e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/```(\w+)?\n([\s\S]*?)```/g,'<pre class="bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto my-2"><code>$2</code></pre>').replace(/`([^`]+)`/g,'<code class="bg-gray-100 dark:bg-gray-800 px-1 rounded text-sm font-mono">$1</code>').replace(/^### (.+)$/gm,'<h3 class="text-lg font-semibold mt-4 mb-2">$1</h3>').replace(/^## (.+)$/gm,'<h2 class="text-xl font-semibold mt-4 mb-2">$1</h2>').replace(/^# (.+)$/gm,'<h1 class="text-2xl font-bold mt-4 mb-2">$1</h1>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/___(.+?)___/g,"<strong><em>$1</em></strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/~~(.+?)~~/g,"<del>$1</del>").replace(/^> (.+)$/gm,'<blockquote class="border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic my-2 text-gray-600 dark:text-gray-400">$1</blockquote>').replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-blue-600 hover:underline" target="_blank" rel="noopener noreferrer">$1</a>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="max-w-full h-auto rounded my-2" />').replace(/^---$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^\*\*\*$/gm,'<hr class="border-gray-300 dark:border-gray-600 my-4" />').replace(/^[\*\-] (.+)$/gm,'<li class="ml-4">$1</li>').replace(/^\d+\. (.+)$/gm,'<li class="ml-4 list-decimal">$1</li>').replace(/^(?!<[a-z]|$)(.+)$/gm,'<p class="my-2">$1</p>').replace(/<p class="my-2"><\/p>/g,"").replace(/(<li class="ml-4">.*<\/li>\n?)+/g,'<ul class="list-disc pl-6 my-2">$&</ul>'):""}var Qi=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let{t:n}=H(),[i,s]=useState(false),[l,d]=useState(false);useEffect(()=>{d(true);},[]);let c=useCallback(v=>{r?.(v.target.value);},[r]),u=useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),m=t?.length||0;return l?jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[u," words \u2022 ",m," chars"]}),jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsx("button",{type:"button",onClick:()=>s(false),className:`px-3 py-1 text-xs font-medium transition-colors ${i?"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]":"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]"}`,children:"Write"}),jsx("button",{type:"button",onClick:()=>s(true),className:`px-3 py-1 text-xs font-medium transition-colors ${i?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:"Preview"})]})]})]}),jsx("div",{style:{pointerEvents:"auto",position:"relative",zIndex:50},className:`border border-[var(--kyro-border)] rounded-md overflow-hidden ${a?"opacity-50 cursor-not-allowed":""} ${o?"border-[var(--kyro-error)]":""}`,children:i?jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:Qg(t)}}):jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsx("textarea",{value:t??"",onChange:c,disabled:a,rows:12,style:{pointerEvents:"auto",cursor:"text",zIndex:100},className:"w-full p-4 font-mono text-sm resize-y focus:outline-none bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",placeholder:n("fields.enterMarkdownContentHeading",{defaultValue:`Enter markdown content...
|
|
94
94
|
|
|
95
95
|
# Heading 1
|
|
96
96
|
## Heading 2
|
|
@@ -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 Fs({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}=ge(),p=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",g=t==null?"":String(t),f={id:e.name,value:g,onChange:v=>r?.(v.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",{...f,rows:e.admin?.rows||4}):jsx("input",{type:p,...f,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?.(hs(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:g.length>60?"text-red-500":g.length>=40?"text-green-500":"text-amber-600",children:[g.length," / 60 \u2014 ",g.length>60?"Too Long":g.length>=40?"Ideal":"Short"]})})]})})}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:"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 Ls({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 Es({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 Bs({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||{}),g=JSON.stringify(i||{});useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let b=setTimeout(async()=>{try{let S="";if(s)S=`${Dr}/${s}/dynamic-options/${e.name}`;else if(l)S=`${Dr}/globals/${l}/dynamic-options/${e.name}`;else return;let w=await ct(S,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(p),siblingData:JSON.parse(g)})});if(w.ok){let R=await w.json();R.options&&u(R.options);}}catch(S){console.error("Failed to fetch dynamic options:",S);}},300);return ()=>clearTimeout(b)},[p,g,e.name,e.options,s,l]);let f=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?f=e.options({data:n||{},siblingData:i||{}}):Array.isArray(e.options)&&(f=e.options)),e.dynamicOptions==="collections"&&(f=Object.keys(la).filter(v=>v!=="media").map(v=>({label:la[v]?.label||v,value:v}))),jsx(pt,{field:e,error:o,children:jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:v=>{if(e.hasMany){let b=Array.from(v.target.selectedOptions,S=>S.value);r?.(b);}else r?.(v.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:f.find(v=>v.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..."}),f.map(v=>jsx("option",{value:v.value,style:{color:v.color||void 0,fontWeight:v.color?"bold":"normal"},children:v.label},v.value))]})})}function nl(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function ly({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 dy({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,g]=useState(false),[f,v]=useState([]),b=useRef(new Set),S=useRef(null),w=useRef(()=>{});w.current=r||(()=>{});let R=e.hasMany,k=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],E=k.length>1,[A,x]=useState(k[0]||""),m=useCallback(()=>t?(R?Array.isArray(t)?t:[]:t?[t]:[]).map(X=>typeof X=="object"&&X!==null?X.value||X.id||"":String(X)).filter(Boolean):[],[t,R]),y=useCallback(I=>{I.length!==0&&I.forEach(X=>{if(b.current.has(X))return;b.current.add(X);let ee=E?(()=>{if(!t)return A;let q=(R?Array.isArray(t)?t:[]:[t]).find(Q=>typeof Q=="object"&&Q!==null?Q.value===X||Q.id===X:false);return q&&typeof q=="object"&&q.relationTo||A})():A;Le(`/api/${ee}/${X}`).then(ie=>{let q=ie.data||ie;!q||typeof q!="object"||v(Q=>Q.some(pe=>pe.id===X)?Q:[...Q,{...q,id:String(q.id),relationTo:ee}]);}).catch(()=>{});});},[E,t,A,R]);useEffect(()=>{let I=m();y(I);},[m,y]);let h=useCallback((I="")=>{g(true);let ee=`/api/${A}?${Pn(I,["title","name","label","email"])}`;Le(ee).then(ie=>{u(q=>{let Q=new Set(q.map(Se=>Se.id)),pe=(ie.docs||[]).filter(Se=>!Q.has(Se.id)).map(Se=>({...Se,id:Se.id}));return [...q,...pe]}),g(false);}).catch(()=>{g(false);});},[A]);useEffect(()=>{i&&(u([]),h(l));},[i,A]),useEffect(()=>{let I=X=>{S.current&&!S.current.contains(X.target)&&s(false);};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);let N=I=>{if(typeof I=="object"&&I!==null){let X=I.value??I.id;return X!=null?N(X):""}return String(I)},F=I=>{let X=I.id;return t?R&&Array.isArray(t)?t.some(ee=>N(ee)===X):N(t)===X:false},L=I=>{let X=I.id;if(R){let ee=Array.isArray(t)?t:[];if(F(I))w.current?.(ee.filter(ie=>N(ie)!==X));else {let ie=E?{relationTo:A,value:X}:X;w.current?.([...ee,ie]);}}else if(F(I))w.current?.(null);else {let ee=E?{relationTo:A,value:X}:X;w.current?.(ee),s(false),d("");}},P=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),$=I=>{let{active:X,over:ee}=I;if(!ee||X.id===ee.id)return;let ie=R?Array.isArray(t)?t:[]:[],q=ie.findIndex(pe=>N(pe)===X.id),Q=ie.findIndex(pe=>N(pe)===ee.id);if(q!==-1&&Q!==-1){let pe=[...ie],[Se]=pe.splice(q,1);pe.splice(Q,0,Se),w.current?.(pe);}},z=()=>{if(!t)return null;let I=R?Array.isArray(t)?t:[]:t?[t]:[],X$1=I.map(ee=>N(ee));return R&&I.length>1?jsx(DndContext,{sensors:P,collisionDetection:closestCenter,onDragEnd:$,children:jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsx(SortableContext,{items:X$1,strategy:horizontalListSortingStrategy,children:I.map((ee,ie)=>{let q=N(ee),Q=f.find(j=>j.id===q),pe=Q?nl(Q):q?q.slice(0,12):"Item",Se=E&&Q?Q.relationTo:null;return jsx(ly,{id:q,label:pe,relation:Se,onRemove:()=>{let j=I.filter(_=>N(_)!==q);w.current?.(j);},disabled:a},`${q}-${ie}`)})})})}):jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:I.map((ee,ie)=>{let q=N(ee),Q=f.find(j=>j.id===q),pe=Q?nl(Q):q?q.slice(0,12):"Item",Se=E&&Q?Q.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:[Se&&jsxs("span",{className:"opacity-60 mr-0.5",children:[Se,":"]}),pe,!a&&jsx("button",{type:"button",onClick:()=>{let j=I.filter(_=>N(_)!==q);w.current?.(R?j:j[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]},`${q}-${ie}`)})})};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:S,className:"relative",children:[E&&jsx("div",{className:"flex gap-1 mb-1.5",children:k.map(I=>jsx("button",{type:"button",onClick:()=>{x(I),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${A===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),h(I.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${A}...`,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(ys,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:c.map(I=>jsxs("button",{type:"button",onClick:()=>L(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:nl(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 cn=dy;var Mo=createContext(null);function au(e=[],t=[]){return createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=sl(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=un(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=un(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=un(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 sl(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=sl(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?sl(a.children):a.children}))}),r}):[]}function ha(e){let t=my(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 my(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 un(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=un(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=un(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 mn({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 nu({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 il=({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 lu=({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(il,{text:a.text||"",onChange:n,compact:true})})};var cu=({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 uu=({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 dl=({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 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=(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(dl,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function Ay({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 fn=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=H(),[a,n]=na.useState(""),[i,s]=na.useState([]);na.useEffect(()=>{let f=i.map(v=>v.text);JSON.stringify(f)!==JSON.stringify(e)&&s(e.map((v,b)=>({id:`${v}-${b}-${Math.random().toString(36).substr(2,4)}`,text:v})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=f=>{f.key==="Enter"&&(f.preventDefault(),l());},c=f=>{t(e.filter((v,b)=>b!==f));},u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),p=f=>{let{active:v,over:b}=f;if(!b||v.id===b.id)return;let S=i.findIndex(R=>R.id===v.id),w=i.findIndex(R=>R.id===b.id);if(S!==-1&&w!==-1){let R=[...e],[k]=R.splice(S,1);R.splice(w,0,k),t(R);}},g=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(f=>f.id),strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-1",children:i.map((f,v)=>jsx(Ay,{id:f.id,text:f.text,onRemove:()=>c(v)},f.id))})}),jsx("input",{type:"text",value:a,onChange:f=>n(f.target.value),onKeyDown:d,className:g,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};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=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(fn,{items:l,onChange:d,compact:true})]})};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:"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(dn,{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 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=(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 gl=({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,g)=>{let f=[...e];f[p]={...f[p],title:g},t(f);},s=(p,g)=>{let f=[...e];f[p]={...f[p],content:g},t(f);},l=p=>{let g=e.filter((f,v)=>v!==p);t(g),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,g)=>{let{t:f}=H(),v=o===g;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(v?null:g),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 ${g+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(g);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:f("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3.5 h-3.5"})}),v?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:b=>i(g,b.target.value),onClick:b=>b.stopPropagation(),className:u,placeholder:f("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:b=>s(g,b.target.value),onClick:b=>b.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:f("fields.itemContent",{defaultValue:"Item content..."})})]})]},g)})}),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,g)=>{let{t:f}=H(),v=o===g;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(v?null:g),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 ${g+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(g);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:f("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})}),v?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:p.title||"",onChange:b=>i(g,b.target.value),className:c,placeholder:f("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:p.content||"",onChange:b=>s(g,b.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:f("fields.itemContent",{defaultValue:"Item content..."})})]})]},g)})}),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 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=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(gl,{items:l,onChange:d,compact:true})]})};var bu=({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 yl=({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 g={values:n,...n};if(!u.admin.condition(g,g))return null}catch(g){console.warn(`Condition error for field ${u.name}:`,g);}else if(typeof u.admin.condition=="object")try{let g=u.admin.condition,f=g.field,v=n[f],b=!0;if("equals"in g?b=v===g.equals:"notEquals"in g?b=v!==g.notEquals:"in"in g&&Array.isArray(g.in)&&(b=g.in.includes(v)),!b)return null}catch(g){console.warn(`Declarative condition error for field ${u.name}:`,g);}}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:g=>s(u.name,g)})},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=ze[e.type]||ze.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 Dy=6,yo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Dy})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,p]=useState(null),g=useContext(Mo);if(!g)throw new Error("ChildBlocksTree must be used within a BlocksContext");let f=useStore(g,m=>m.dynamicCategories),v=useStore(g,m=>m.allowedBlocks),b=o<a,S=16,w=m=>{let y=ha(m);r([...t,y]),c(y.id);},R=m=>{let y=t.filter(h=>h.id!==m);r(y);},E=(m,y)=>{let h=t.map(N=>N.id===m?{...N,children:y}:N);r(h);},A=m=>{l(y=>{let h=new Set(y);return h.has(m)?h.delete(m):h.add(m),h});},x=m=>{let y=m.children&&m.children.length>0,h=s.has(m.id);vl(m.type);let F=y,L=d===m.id,P=v.find($=>$.slug===m.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 ${L?"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"} ${b?"cursor-pointer":""}`,style:{marginLeft:o*S},onClick:()=>{b&&c(L?null:m.id);},children:[F?jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),A(m.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:h?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[m.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[m.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[vn(m),typeof m.data?.text=="string"?` - ${m.data.text.slice(0,30)}`:"",typeof m.data?.heading=="string"?` - ${m.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),y&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[m.children?.length," nested"]}),u===m.id?jsxs("div",{className:"flex items-center gap-1",onClick:$=>$.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{R(m.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:$=>{$.stopPropagation(),p(m.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"})})]}),L&&jsx(wa,{block:m,onClose:()=>c(null)}),y&&h&&jsx("div",{className:"mt-1",children:jsx(xu,{parentId:m.id,children:m.children??[],onUpdateChildren:$=>E(m.id,$),depth:o+1,maxDepth:a})})]},m.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(x)}),b&&jsxs("div",{style:{marginLeft:o*S},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(mn,{open:n,onClose:()=>i(false),onSelect:w,children:f.map(m=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:m.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:m.blocks.map(y=>jsxs("button",{type:"button",onClick:()=>{w(y.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[y.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:y.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:y.admin?.description||""})]})]},y.slug))})]},m.title))})]}),t.length===0&&b&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*S},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*S},children:["Maximum nesting level (",a,") reached"]})]})},xu=({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),g=useContext(Mo);if(!g)throw new Error("NestedChildBlocks must be used within a BlocksContext");let f=useStore(g,m=>m.dynamicCategories),v=useStore(g,m=>m.allowedBlocks),b=o<a,S=16,w=m=>{let y=ha(m);r([...t,y]),c(y.id);},R=m=>{let y=t.filter(h=>h.id!==m);r(y);},E=(m,y)=>{let h=t.map(N=>N.id===m?{...N,children:y}:N);r(h);},A=m=>{l(y=>{let h=new Set(y);return h.has(m)?h.delete(m):h.add(m),h});},x=m=>{let y=m.children&&m.children.length>0,h=s.has(m.id);vl(m.type);let F=y,L=d===m.id,P=v.find($=>$.slug===m.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 ${L?"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"} ${b?"cursor-pointer":""}`,style:{marginLeft:o*S},onClick:()=>{b&&c(L?null:m.id);},children:[F?jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),A(m.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:h?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[m.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[m.type]}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[vn(m),typeof m.data?.text=="string"?` - ${m.data.text.slice(0,30)}`:"",typeof m.data?.heading=="string"?` - ${m.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),y&&jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[m.children?.length," nested"]}),u===m.id?jsxs("div",{className:"flex items-center gap-1",onClick:$=>$.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{R(m.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:$=>{$.stopPropagation(),p(m.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)]"})})]}),L&&jsx(wa,{block:m,onClose:()=>c(null)}),y&&h&&jsx("div",{className:"mt-1",children:jsx(xu,{parentId:m.id,children:m.children??[],onUpdateChildren:$=>E(m.id,$),depth:o+1,maxDepth:a})})]},m.id)};return jsxs("div",{className:"space-y-2",children:[t.length>0&&jsx("div",{className:"space-y-1",children:t.map(x)}),b&&jsxs("div",{style:{marginLeft:o*S},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(mn,{open:n,onClose:()=>i(false),onSelect:w,children:f.map(m=>jsxs("div",{className:"mb-4",children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:m.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:m.blocks.map(y=>jsxs("button",{type:"button",onClick:()=>{w(y.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[y.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:y.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:y.admin?.description||""})]})]},y.slug))})]},m.title))})]}),t.length===0&&b&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*S},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*S},children:["Maximum nesting level (",a,") reached"]})]})};var ku=({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(yl,{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 bl=({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 Cu=({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(bl,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Su=({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 Au=({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(en,{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 Py={heading:lu,paragraph:cu,image:uu,video:mu,list:fu,code:gu,file:yu,accordion:vu,richtext:bu,hero:ku,card:Cu,array:Su,relationship:Au},ze={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 ${ze.default.text}`}),paragraph:jsx(AlignLeft,{className:`w-4 h-4 ${ze.default.text}`}),image:jsx(Image,{className:`w-4 h-4 ${ze.default.text}`}),video:jsx(Video,{className:`w-4 h-4 ${ze.default.text}`}),list:jsx(List,{className:`w-4 h-4 ${ze.default.text}`}),code:jsx(Code,{className:`w-4 h-4 ${ze.default.text}`}),file:jsx(File,{className:`w-4 h-4 ${ze.default.text}`}),accordion:jsx(ChevronDown,{className:`w-4 h-4 ${ze.default.text}`}),richtext:jsx(AlignLeft,{className:`w-4 h-4 ${ze.default.text}`}),hero:jsx(Star,{className:`w-4 h-4 ${ze.hero.text}`}),card:jsx(Box,{className:`w-4 h-4 ${ze.card.text}`}),array:jsx(ListOrdered,{className:`w-4 h-4 ${ze.default.text}`}),relationship:jsx(Link2,{className:`w-4 h-4 ${ze.default.text}`}),featureSplit:jsx(Columns3,{className:`w-4 h-4 ${ze.featureSplit.text}`}),featureGrid:jsx(Blocks,{className:`w-4 h-4 ${ze.featureGrid.text}`}),ctaBanner:jsx(Sparkles,{className:`w-4 h-4 ${ze.ctaBanner.text}`}),testimonials:jsx(Users,{className:`w-4 h-4 ${ze.testimonials.text}`}),faq:jsx(CircleHelp,{className:`w-4 h-4 ${ze.faq.text}`}),stats:jsx(Activity,{className:`w-4 h-4 ${ze.stats.text}`}),logoCloud:jsx(Image,{className:`w-4 h-4 ${ze.logoCloud.text}`}),pricing:jsx(Tag,{className:`w-4 h-4 ${ze.pricing.text}`}),team:jsx(Users,{className:`w-4 h-4 ${ze.team.text}`}),recentFeed:jsx(Database,{className:`w-4 h-4 ${ze.recentFeed.text}`}),processSteps:jsx(Clock,{className:`w-4 h-4 ${ze.processSteps.text}`}),formEmbed:jsx(Mail,{className:`w-4 h-4 ${ze.formEmbed.text}`}),videoShowcase:jsx(Video,{className:`w-4 h-4 ${ze.videoShowcase.text}`})};function vl(e){return Py[e]||null}function hl(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 vn(e){let t=e.name;return t&&t.trim()?t.trim():hl(e.type)}function Hy(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 _y=({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:g}=useSortable({id:e.id}),{removeBlock:f,updateBlock:v}=He(),b=o===e.id,[S,w]=useState(false),[R,k]=useState(false),[E,A]=useState(e.name||""),x=useRef(null),[m,y]=useState(false);useEffect(()=>{R&&x.current&&(x.current.focus(),x.current.select());},[R]);let h=useCallback(()=>{k(false);let z=E.trim();z!==(e.name||"").trim()&&v(e.id,{name:z||""});},[E,e.name,e.id,v]),N=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)),y(!0),U.success(s("notifications.blockCopied",{defaultValue:"Block copied to clipboard"})),setTimeout(()=>y(!1),2e3);}catch{U.error(s("notifications.blockCopyFailed",{defaultValue:"Failed to copy block"}));}},[e,s]),F={transform:CSS.Transform.toString(u),transition:p,zIndex:g?10:1,opacity:g?.8:1},L=vn(e),P=e.data||{},$=Hy(P,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 ${b?`${(ze[e.type]||ze.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]}),R?jsx("input",{ref:x,value:E,onChange:z=>A(z.target.value),onBlur:h,onKeyDown:z=>{z.key==="Enter"&&h(),z.key==="Escape"&&(A(e.name||""),k(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:L}),S?jsxs("div",{className:"flex items-center gap-0.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{f(e.id),w(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:()=>w(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(),A(e.name||""),k(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:N,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:m?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(),w(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"})})]})]}),b&&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 ${b?`${(ze[e.type]||ze.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:[R?jsx("input",{ref:x,value:E,onChange:z=>A(z.target.value),onBlur:h,onKeyDown:z=>{z.key==="Enter"&&h(),z.key==="Escape"&&(A(e.name||""),k(false));},onClick:z=>z.stopPropagation(),placeholder:hl(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:[L,$&&typeof $=="string"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",$.length>40?`${$.slice(0,40)}...`:$]})]}),!!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"]}),S?jsxs("div",{className:"flex items-center gap-1.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{f(e.id),w(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:()=>w(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(),A(e.name||""),k(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:N,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:m?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(),w(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"})})]})]}),b&&jsx(wa,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Ky=na.memo(_y),kl=({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),g=e.admin?.pickerMode||"drawer",f=e.blocks||[],v=f.reduce((j,_)=>{let K=_.admin?.group||"Custom Blocks";return j[K]||(j[K]=[]),j[K].push(_),j},{}),b=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],S=Object.entries(v).sort(([j],[_])=>{let K=b.indexOf(j),he=b.indexOf(_);return K!==-1&&he!==-1?K-he:K!==-1?-1:he!==-1?1:j.localeCompare(_)}).map(([j,_])=>({title:j,blocks:_})),w=useRef(null);w.current||(w.current=au(f,S));let R=w.current,k=useStore(R,j=>j.blocks),[E,A]=useState(null),[x,m]=useState(null),y=useRef(k.length),h=useRef(new Set(k.map(j=>j.id))),N=useRef(false);useEffect(()=>{if(N.current&&k.length>y.current){let j=k.find(_=>_.id&&!h.current.has(_.id));j&&m(j.id);}y.current=k.length,h.current=new Set(k.map(j=>j.id));},[k]),useEffect(()=>(o&&R.getState().setOnBlocksChange(o),()=>{R.getState().setOnBlocksChange(()=>{});}),[o,R]);let F=useRef(null);useEffect(()=>{let j=Array.isArray(t)?t:[],_=F.current||[];if(Eo(j,_))j.length===0&&!N.current&&(N.current=true,F.current=[]);else {let K=[...j];y.current=K.length,h.current=new Set(K.map(he=>he.id)),R.getState().setBlocks(K),F.current=K,N.current=true;}},[t,e.name,R]);let L=useRef(r);L.current=r,useEffect(()=>{if(!L.current)return;let j=F.current;j&&(Eo(k,j)||(F.current=[...k],L.current(k)));},[k]);let $=useCallback(j=>{R.getState().addBlock(j);},[R]),z=useCallback(j=>{if(!f.some(Me=>Me.slug===j.type)){alert(`The block type "${j.type}" is not allowed in this collection.`);return}let K=Math.random().toString(36).substring(2,11),he={...j.blockProps||{},id:K,type:j.type};R.getState().setBlocks([...k,he]),d(false);},[f,k,R]),I=useCallback(j=>{let _=document.activeElement;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.getAttribute("contenteditable")==="true"))return;let K=j.clipboardData?.getData("text");if(K)try{let he=JSON.parse(K);he&&he.__kyro_block&&(j.preventDefault(),j.stopPropagation(),z(he),U.success(`Block pasted: ${he.type}`));}catch{}},[z]),X=useCallback(j=>{let _=k.findIndex(C=>C.id===j);if(_===-1)return;let K=k[_],he=C=>{let G=Math.random().toString(36).substr(2,9);return {...C,id:G,children:C.children?C.children.map(we=>he(we)):C.children,data:C.data?JSON.parse(JSON.stringify(C.data)):C.data}},Me=he(K),ke=[...k];ke.splice(_+1,0,Me),R.getState().setBlocks(ke);},[k,R]),ee=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}}),useSensor(TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),useSensor(KeyboardSensor)),ie=j=>{A(j.active);},q=j=>{let{active:_,over:K}=j;if(A(null),!!K){if(_.id.toString().startsWith("drawer-")){let he=_.id.toString().replace("drawer-","");if(K.id.toString().startsWith("container-")){let Me=K.id.toString().replace("container-",""),ke=k.find(C=>C.id===Me);if(ke){let C=ha(he);R.getState().updateBlock(Me,{children:[...ke.children||[],C]});}}else {let Me=k.findIndex(ke=>ke.id===K.id);Me!==-1?R.getState().addBlock(he,Me):$(he);}return}if(_.id!==K.id){let he=k.findIndex(ke=>ke.id===_.id),Me=k.findIndex(ke=>ke.id===K.id);if(he!==-1&&Me!==-1){let ke=[...k],[C]=ke.splice(he,1);ke.splice(Me,0,C),R.getState().setBlocks(ke);}}}},Q=E?S.flatMap(j=>j.blocks).find(j=>`drawer-${j.type}`===E.id)||k.find(j=>j.id===E.id):null;Q?"label"in Q?Q.label:Q.type:"Block";return useEffect(()=>{if(!c)return;let j=_=>{p.current&&!p.current.contains(_.target)&&u(false);};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]),jsx(Mo.Provider,{value:w.current,children:jsxs("div",{className:"kyro-blocks-field",onPaste:I,tabIndex:0,style:{outline:"none"},children:[jsxs(DndContext,{sensors:ee,collisionDetection:closestCenter,onDragStart:ie,onDragEnd:q,children:[jsxs("div",{className:g==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsx("label",{className:`kyro-form-label ${g==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),g==="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:S.map(j=>jsxs("div",{children:[S.length>1&&jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:j.title}),j.blocks.map(_=>jsxs("button",{type:"button",onClick:()=>{$(_.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[_.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:_.label}),_.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:_.admin.description})]})]},_.slug))]},j.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(mn,{open:l,onClose:()=>d(false),onSelect:$,onPasteBlock:z,children:jsx("div",{className:"space-y-4",children:S.map(j=>jsxs("div",{children:[jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:j.title}),jsx("div",{className:"grid grid-cols-3 gap-2",children:j.blocks.map(_=>jsx(nu,{block:{type:_.slug,label:_.label,description:_.admin?.description||"",icon:null},onSelect:$,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[_.slug]||jsx(Box,{className:"w-4 h-4"})})})},_.slug))})]},j.title))})})}),jsx(SortableContext,{items:k.map(j=>j.id),strategy:verticalListSortingStrategy,children:jsxs("div",{className:g==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[k.map((j,_)=>{let K=e.blocks?.find(he=>he.slug===j.type);return jsx(Ky,{block:j,index:_,blockSchema:K,editingBlockId:x,setEditingBlockId:m,onDuplicate:X,compact:g==="dropdown"},j.id||_)}),k.length===0&&jsx("div",{className:g==="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:g==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsx(DragOverlay,{children:E&&Q&&jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:Q.label||Q.type||"Block"})})]}),a&&jsx("p",{className:"kyro-form-error",children:a})]})})};function Vs({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 ev=new Set(["text","number","checkbox","select","radio","color","email","password","url","id"]);function xn(e){if(!e||typeof e!="object")return null;let t=e,r=t.tabs,o=t.title||r?.title||t.name||t.label||t.email||t.filename||t.slug;return o&&typeof o=="string"?o:t.value&&typeof t.value=="object"?xn(t.value):t.doc&&typeof t.doc=="object"?xn(t.doc):null}function tv(e,t){let r=e.label||e.name||"Item";return /item$/i.test(r.trim())?`${r} ${t+1}`:`${r} Item ${t+1}`}function rv(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>ev.has(r.type))}function Fu({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:g,listeners:f,setNodeRef:v,transform:b,transition:S}=useSortable({id:e}),w={transform:CSS.Transform.toString(b),transition:S},R=n.fields||[];return c?jsxs("div",{ref:v,style:w,className:"flex items-start gap-3 p-3.5 mb-2 border border-[var(--kyro-border)] rounded-[var(--kyro-radius-md)] bg-[var(--kyro-surface-accent)]/15 hover:border-[var(--kyro-border-accent)] transition-all group/item shadow-xs",children:[jsx("div",{...g,...f,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 ${R.length>=3?"flex flex-col gap-2":"grid grid-cols-1 sm:grid-cols-2 gap-3"}`,children:R.map(k=>jsx("div",{className:"min-w-0",children:i(k,a,s)},k.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-1 mt-1.5 flex-shrink-0 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"})]})})]}):jsxs("div",{ref:v,style:w,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",{...g,...f,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)||tv(n,t)})}),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:R.map(k=>i(k,a,s))})]})}function js({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=(e.fields||[])[0],l=s?.name||"user",d=s?.type==="relationship",[c,u]=na.useState(0),[p,g]=na.useState({}),f=na.useRef(new Set);na.useEffect(()=>{let k=false,E=n.filter(A=>typeof A!="object"||A===null?(k=true,false):true).map(A=>!A.id&&!A._key?(k=true,{...A,id:Math.random().toString(36).substr(2,9)}):A);k&&r(E);},[t,r]),na.useEffect(()=>{let k=e.fields||[];n.forEach(E=>{!E||typeof E!="object"||k.forEach(A=>{if(A.type==="relationship"&&A.name){let x=E[A.name];if(!x)return;let m="",y=Array.isArray(A.relationTo)?A.relationTo[0]:A.relationTo;if(typeof x=="string")m=x;else if(typeof x=="object"&&x!==null){let h=x;h.relationTo&&typeof h.relationTo=="string"&&(y=h.relationTo),h.id&&typeof h.id=="string"?m=h.id:h.value&&typeof h.value=="string"&&(m=h.value);}m&&y&&!f.current.has(m)&&(f.current.add(m),Le(`/api/${y}/${m}`).then(h=>{let N=h?.data||h,F=xn(N);F&&g(L=>({...L,[m]:F}));}).catch(()=>{}));}});});},[n,e]);function v(k){for(let x of ["label","title","name","externalUrl","url"]){let m=k[x];if(m&&typeof m=="string"&&m.trim()!=="")return m}let E=e.fields||[],A=new Set(["linkType","type","blockType","kind","mode"]);for(let x of E){if(!x.name)continue;let m=k[x.name];if(m){if((x.type==="text"||x.type==="textarea")&&typeof m=="string"&&m.trim()!==""||x.type==="select"&&!A.has(x.name)&&typeof m=="string"&&m.trim()!=="")return m;if(x.type==="relationship"){let y=xn(m);if(y)return y;let h="";if(typeof m=="string")h=m;else if(typeof m=="object"&&m!==null){let N=m;N.id&&typeof N.id=="string"?h=N.id:N.value&&typeof N.value=="string"&&(h=N.value);}if(h&&p[h])return p[h]}if(x.type==="group"&&x.fields){let y=m;if(y&&typeof y=="object")for(let h of x.fields||[]){if(!h.name)continue;let N=y[h.name];if((h.type==="text"||h.type==="textarea")&&typeof N=="string"&&N.trim()!==""||h.type==="select"&&!A.has(h.name)&&typeof N=="string"&&N.trim()!=="")return N;if(h.type==="relationship"){let F=xn(N);if(F)return F;let L="";if(typeof N=="string")L=N;else if(typeof N=="object"&&N!==null){let P=N;P.id&&typeof P.id=="string"?L=P.id:P.value&&typeof P.value=="string"&&(L=P.value);}if(L&&p[L])return p[L]}}}}}return ""}let b=rv(e),S=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),w=k=>{let{active:E,over:A}=k;if(!A||E.id===A.id)return;let x=n.findIndex(y=>(y.id||y._key)===E.id),m=n.findIndex(y=>(y.id||y._key)===A.id);if(x!==-1&&m!==-1){let y=[...n],[h]=y.splice(x,1);y.splice(m,0,h),r(y);}},R=na.useMemo(()=>n.map(k=>k?.id||k?._key||""),[n]);return d?jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(cn,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:void 0},value:n.map(k=>k[l]).filter(Boolean),onChange:k=>{let E=(k||[]).map(A=>({[l]:A,id:Math.random().toString(36).substr(2,9)}));r(E);},disabled:a})]}):jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(DndContext,{sensors:S,collisionDetection:closestCenter,onDragEnd:w,children:b?jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/10 rounded-lg p-3",children:[jsx(SortableContext,{items:R,strategy:verticalListSortingStrategy,children:n.map((k,E)=>jsx(Fu,{id:k.id||k._key||`idx-${E}`,index:E,isOpen:false,setOpenIndex:()=>{},item:k,field:e,renderField:o,onChangeItem:A=>{let x=[...n];x[E]=A,r(x);},onRemove:()=>r(n.filter((A,x)=>x!==E)),disabled:a,compact:true,getItemLabel:v},k.id||k._key||E))}),jsx("button",{type:"button",className:"w-full py-2.5 border border-dashed border-[var(--kyro-border)] rounded-md text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)]/50 transition-all disabled:opacity-50 mt-1",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:R,strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-2",children:n.map((k,E)=>{let A=c===E;return jsx(Fu,{id:k.id||k._key||`idx-${E}`,index:E,isOpen:A,setOpenIndex:u,item:k,field:e,renderField:o,onChangeItem:x=>{let m=[...n];m[E]=x,r(m);},onRemove:()=>r(n.filter((x,m)=>m!==E)),disabled:a,compact:false,getItemLabel:v},k.id||k._key||E)})})}),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 k=Math.random().toString(36).substr(2,9);r([...n,{id:k}]),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=>{bs("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(Ts,{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(Fs,{field:e,value:t??void 0,onChange:r,error:o,disabled:a});case "number":return jsx(Is,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "checkbox":return jsx(Ls,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsx(Bs,{field:e,value:t??void 0,onChange:d,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l});case "date":return jsx(Es,{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(Qi,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "code":return jsx(dn,{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(cn,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsx(pt,{field:e,error:o,children:jsx(fn,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsx(js,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,p)=>{let g=u[c.name];return jsx(jo,{field:c,value:g,onChange:f=>{p({...u,[c.name]:f});},disabled:a,error:o},c.name)}});case "blocks":return jsx(kl,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsx(Vs,{field:e,value:t,onChange:r,renderField:(c,u,p)=>{let g=u[c.name];return jsx(jo,{field:c,value:g,onChange:f=>{p({...u,[c.name]:f});},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 Lu=({title:e,description:t,slug:r,collectionSlug:o})=>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 ",o||"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 Bu({field:e,formData:t,collectionSlug:r,onTabDataChange:o,renderField:a}){let[n,i]=useState(0),s=e.tabs||[],l=s[n]||s[0],d=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:s.map((c,u)=>jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${n===u?"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:()=>i(u),children:c.label},u))})}),jsx("div",{className:"space-y-6",children:l?.fields.map(c=>a(c,e.name?d:t,e.name?o:void 0))}),l?.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(Lu,{title:String((typeof d.metaTitle=="object"?"":d.metaTitle)||(typeof d.title=="object"?"":d.title)||"Untitled"),description:String((typeof d.metaDescription=="object"?"":d.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug"),collectionSlug:r})]})]})}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 kn(){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)]`,g=()=>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"})}),g()]}),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 ju({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:g}){let{t:f}=H(),[v,b]=useState(Date.now()),[S,w]=useState(false),R=useRef(null),{formData:k,hasUnsavedChanges:E,autoSaveStatus:A,lastSavedAt:x,retryCount:m,view:y,setView:h,showPreview:N,setShowPreview:F,setFormData:L,markSaved:P,lastSavedData:$}=ge(),z=!k.id;useEffect(()=>{let K=setInterval(()=>b(Date.now()),1e4);return ()=>clearInterval(K)},[]),useEffect(()=>{let K=he=>{R.current&&!R.current.contains(he.target)&&w(false);};if(S)return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[S]);let I=String(k.tabs?.title||(typeof k.title=="object"?"":k.title)||(typeof k.name=="object"?"":k.name)||"Untitled"),X=k.updatedAt?new Date(k.updatedAt).toLocaleString():"Just now",ee=k.createdAt?new Date(k.createdAt).toLocaleString():"Just now",ie=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",q=o?"Unpublished":r==="published"?"Published":"Draft",Q=r==="published"&&!E?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",pe=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",Se=(K=false)=>jsxs(Fragment,{children:[A==="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"})]}),K?"Saving\u2026":"Saving draft..."]}),A==="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"}),K?"Saved":x?`Saved ${Math.floor((Date.now()-x)/6e4)}m ago`:"Draft saved"]}),A==="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"})]}),K?`Retry ${m}/5`:`Retrying save (${m}/5)`]}),A==="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"})]}),K?"Offline":"Offline \u2014 cached locally"]}),A==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:K?"Failed":"Draft save failed"}),A==="conflict"&&(K?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:()=>g?.(),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"})]}))]}),j=()=>!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:f("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:()=>w(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(kn,{}),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"})]})]}),_=()=>S&&jsx("div",{ref:R,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:()=>w(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsx("button",{type:"button",onClick:()=>{let K=document.getElementById("schedule-datetime")?.value;K&&p(K);},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 ${pe}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Q}`}),q]})]}),jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsx(Ho,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"}),j(),_()]})]}),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(K=>jsx("button",{type:"button",onClick:()=>h(K),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${y===K?"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:K==="edit"?"Edit":K==="version"?"History":"API"},K))}),jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[Se(true),E&&A!=="saving"&&A!=="retrying"&&A!=="conflict"&&jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument($,$);},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(!N),className:`p-1.5 rounded-lg transition-all ${N?"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 ${pe}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Q}`}),ie]})]}),jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[Se(false),E&&A!=="saving"&&A!=="retrying"&&A!=="conflict"&&jsxs(Fragment,{children:[jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument($,$);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),x&&A!=="saving"&&A!=="retrying"&&A!=="success"&&jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let K=v-x,he=Math.floor(K/6e4),Me=Math.floor(K/1e3);return he>=1?`${he}m ago`:Me>=5?`${Me}s ago`:"just now"})()]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",X]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ee]})]})]}),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(K=>jsx("button",{type:"button",onClick:()=>h(K),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${y===K?"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:K.toUpperCase()},K))}),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(!N),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${N?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:f("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsx(ExternalLink,{className:"w-4 h-4"}),N&&jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),j(),_(),jsx(Ho,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"})]})]})]})]})}function Uu({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=H(),{showPreview:n,sidebarCollapsed:i,formData:s,previewUrl:l}=ge();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 zu({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}=ge();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,g)=>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")]})]},g))})]}),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,g)=>{let f=n.includes(p.id),v=(p.changeDescription||"").toLowerCase().includes("auto");return jsxs("div",{onClick:o?()=>r(p.id):void 0,className:`transition-all ${o?f?"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 ${f?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:f&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-g})}),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",v&&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 ${f?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:f&&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-g})}),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",v&&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 Hu({collectionSlug:e,globalSlug:t}){let{t:r}=H(),{formData:o}=ge();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 Gs=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=ge.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(()=>{U.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 _u(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 Cl(e,t,r){if(!e)return true;if("and"in e&&Array.isArray(e.and))return e.and.every(o=>Cl(o,t,r));if("or"in e&&Array.isArray(e.or))return e.or.some(o=>Cl(o,t,r));if("field"in e&&e.field){let o=e.field,a=_u(t,o);return a===void 0&&(a=_u(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 Ku={};function wn({config:e,data:t=Ku,errors:r=Ku,onChange:o,disabled:a,collectionSlug:n,globalSlug:i,documentId:s,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:p}){let g=e||(i?vc[i]:n?la[n]:null),[f,v]=useState(g);useEffect(()=>{i&&!g?Le("/api/kyro/schema").then(M=>{let te=M;te?.globals?.[i]&&v(te.globals[i]);}).catch(M=>console.error("[AutoForm] Failed to fetch dynamic schema",M)):v(g);},[i,g]);let b=f||g,{confirm:S}=vt(),{formData:w,hasUnsavedChanges:k,autoSaveStatus:x,lastSavedAt:m,view:z,setView:I,setShowPreview:pe,isMenuOpen:Se,setIsMenuOpen:j,loadingFields:_,setLoadingFields:K,compareSelected:ke,setCompareSelected:C,setCompareDiffs:we,setLoadingDiffs:je,setField:Ie,setFormData:mt,setLastSavedData:oe,setAutoSaveStatus:V,fetchVersions:Y,saveDocument:le,forceSave:Ae,autoSaveSkipRef:$e,lastAutoSaveTimeRef:Tt,documentStatus:gr,hasUnpublishedChanges:Or,versionsEnabled:O}=Nc({config:b,initialData:t,collectionSlug:n,globalSlug:i,documentId:s,onChange:o,onActionSuccess:c,onActionError:u}),ae=useRef(null),ue=useRef(null),[Ht,Wo]=useState(false),[ti,D]=useState("idle"),[ve,Ue]=useState(false),[nr,Ot]=useState(Date.now()),Sr=a,[ri,qo]=useState(false),[Ep,oi]=useState(false),[Bp,Mp]=useState(0),Fl=useRef(new Map),$p=3e4;useEffect(()=>{let M=i?`global:${i}`:`${n}:${s}`;if(!(i||n&&s&&s!=="new")||t&&Object.keys(t).length>0)return;let Te=Fl.current.get(M),Ge=Te&&Date.now()-Te.ts<$p,Ct=Te&&!Ge;if(Ge){ge.getState().loadDocument(Te.data,Te.data);return}Ct&&ge.getState().loadDocument(Te.data,Te.data);let St=new AbortController;oi(false),Te||qo(true);let Vr=i?`/api/globals/${i}`:`/api/${n}/${s}`;return Le(Vr,{autoToast:false,signal:St.signal}).then(bt=>{let Ao=bt.data||{};Fl.current.set(M,{data:Ao,ts:Date.now()}),ge.getState().loadDocument(Ao,Ao),qo(false);}).catch(bt=>{bt.name!=="AbortError"&&(qo(false),Te||oi(true));}),()=>St.abort()},[n,s,i,t,Bp]),useEffect(()=>{let M=setInterval(()=>Ot(Date.now()),1e4);return ()=>clearInterval(M)},[]);let Il=(M,te)=>{if(typeof M=="function")try{return M(w,te)}catch(Te){return console.warn("Error evaluating admin runtime flag:",Te),false}return !!M},Op=M=>{S({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let te=i?Ye(`/api/globals/${i}/versions/${M}/restore`):Ye(`/api/${n}/${w.id}/versions/${M}/restore`),Te=await ct(te,{method:"POST"});!Te.ok&&n&&(Te=await ct(Ye(`/api/${n}/${w.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:M,action:"restore"})}));let Ge=await Te.json();if(Ge.data){let{updatedAt:Ct,createdAt:St,...Vr}=Ge.data,bt={...w,...Vr};mt(bt),ge.getState().loadDocument(bt,bt),c?.("Version restored successfully"),Y(),I("edit");}else U.error(Ge.error||"Failed to restore version");}catch(te){console.error("Failed to restore version:",te),U.error("Failed to restore version");}}});},Vp=async()=>{if(ke.length===2){je(true);try{let te=await(await ct(Ye(`/api/${n}/${w.id}/versions?compareA=${ke[0]}&compareB=${ke[1]}`))).json();we(te.diffs||[]);}catch(M){console.error("Compare failed:",M),we([]);}finally{je(false);}}},jp=M=>{C(te=>te.includes(M)?te.filter(Te=>Te!==M):te.length>=2?[te[1],M]:[...te,M]);};useEffect(()=>{let M=te=>{(te.metaKey||te.ctrlKey)&&te.key==="s"&&(te.preventDefault(),Cn()),(te.metaKey||te.ctrlKey)&&te.shiftKey&&(te.key==="P"||te.key==="p")&&(te.preventDefault(),document.getElementById("btn-publish")?.click()),(te.metaKey||te.ctrlKey)&&!te.shiftKey&&te.key==="p"&&(te.preventDefault(),pe(Te=>!Te)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(te.key==="1"&&I("edit"),te.key==="2"&&I("version"),te.key==="3"&&I("api"));};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[]),useEffect(()=>{let M=()=>I("version");return window.addEventListener("kyro:show-version-history",M),()=>window.removeEventListener("kyro:show-version-history",M)},[]),useEffect(()=>{let M=te=>{ae.current&&!ae.current.contains(te.target)&&j(false);};if(Se)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[Se]),useEffect(()=>{let M=te=>{ue.current&&!ue.current.contains(te.target)&&Wo(false);};if(Ht)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[Ht]);let Up=()=>{k?S({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await Cn(),await new Promise(M=>setTimeout(M,1e3)),Lt(`${_e}/${n}/new`);}}):Lt(`${_e}/${n}/new`);},zp=()=>{if(!w.id){U.error("Please save the document before duplicating.");return}let M=async()=>{try{Ue(!0);let te=await ct(`/api/${n}/${w.id}/duplicate`,{method:"POST"});if(te.ok){let Te=await te.json();c?.("Document duplicated successfully"),Te.data?.id?Lt(`${_e}/${n}/${Te.data.id}`):Lt(`${_e}/${n}`);}else {let Te=await te.json();U.error(Te.error||"Failed to duplicate");}}catch{U.error("Failed to duplicate document");}finally{Ue(false);}};if(k){S({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await Cn(),await M();}});return}S({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await M();}});},Hp=()=>{S({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{$e.current=true;try{await Dt(`/api/${n}/${w.id}`),Lt(`${_e}/${n}`);}catch(M){U.error(M.message||"Failed to delete document");}finally{$e.current=false;}}});},_p=()=>{S({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{$e.current=true;try{let M=await le({...w,status:"draft"},!1);if(M?.ok)c?.("Document unpublished successfully"),ge.getState().loadDocument({...w,status:"draft"},{...w,status:"draft"});else {let te=await M?.json().catch(()=>({}));U.error(te?.error||"Failed to unpublish");}}catch{U.error("Failed to unpublish");}finally{$e.current=false;}}});},Cn=async()=>{let M=!w.id;$e.current=true,D("saving");try{let te=qt({...w},!0),Te=M&&!i,Ge=Te?await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}):await le(te);if(Ge.ok){let Ct=await Ge.json(),St=Ct.data||te;ge.getState().loadDocument(St,St),Tt.current=Date.now(),V("success"),D("saved"),O&&Y(),setTimeout(()=>{V("idle"),D("idle");},2e3),c?.(Te?"Document created successfully":"Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload")),Te&&setTimeout(()=>{Lt(`${_e}/${n}/${Ct.data.id}`);},800);}else {let Ct=await Ge.json();Ge.status===409&&V("conflict"),D("error"),U.error(Ct.error||"Failed to save"),setTimeout(()=>D("idle"),3e3);}}catch{D("error"),U.error("Failed to save document"),setTimeout(()=>D("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),$e.current=false;}},Kp=async()=>{let M=!w.id;$e.current=true,D("saving");try{let te={...w};if(M&&!i){let Ct=qt({...w},!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&&V("conflict"),D("error"),U.error(Ao.error||"Failed to create document"),setTimeout(()=>D("idle"),3e3);return}let bt=(await St.json()).data||Ct;ge.getState().loadDocument(bt,bt),te=bt;}let Te=qt(te,!0),Ge=await le(Te,!1);if(Ge?.ok){let St=(await Ge.json().catch(()=>({}))).data||Te;ge.getState().loadDocument(St,St),D("saved"),c?.("Published successfully"),setTimeout(()=>{D("idle");},2e3),M&&!i&&te.id&&setTimeout(()=>{Lt(`${_e}/${n}/${te.id}`);},800);}else {if(M&&!i&&te.id){let St=await Ge?.json().catch(()=>({}));U.warning("Document saved as draft. Publishing failed: "+(St?.error||"Unknown error")),setTimeout(()=>{Lt(`${_e}/${n}/${te.id}`);},1200);return}let Ct=await Ge?.json().catch(()=>({}));Ge?.status===409&&V("conflict"),D("error"),U.error(Ct?.error||"Failed to publish"),setTimeout(()=>D("idle"),3e3);}}catch{D("error"),U.error("Failed to publish"),setTimeout(()=>D("idle"),3e3);}finally{$e.current=false;}},Gp=async M=>{let te=!w.id;$e.current=true;try{let Te={...qt({...w},!0),_schedulePublishAt:M};if(te&&!i){let Ge=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Te)});if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));U.error(Ct.error||"Failed to schedule publish");return}}else {let Ge=await le(Te);if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));U.error(Ct.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(M).toLocaleString()}`),Wo(!1);}catch{U.error("Failed to schedule publish");}finally{$e.current=false;}},Wp=(M,te)=>{Ie(M,te);},Va=(M,te,Te)=>{let Ge=te!==void 0?te:w;if(Il(M.hidden!==void 0?M.hidden:M.admin?.hidden,Ge))return null;let St=Il(M.readOnly!==void 0?M.readOnly:M.admin?.readOnly,Ge),Vr=!!(Sr||St);if(M.admin?.condition){if(typeof M.admin.condition=="function")try{let dt={values:w||{},...w||{}};if(!M.admin.condition(dt,Ge))return null}catch(dt){console.warn(`Condition error for field ${M.name}:`,dt);}else if(typeof M.admin.condition=="object")try{if(!Cl(M.admin.condition,Ge,w))return null}catch(dt){console.warn(`Declarative condition error for field ${M.name}:`,dt);}}let bt=Ge[M.name],Ao=r[M.name],Sn=dt=>{Te?Te({...Ge,[M.name]:dt}):Wp(M.name,dt);};if(M.type==="row"&&"fields"in M){let dt=M.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||{},An=jr?.action;if((nt.type==="button"||nt.type==="action")&&An){let Ar=dt?.find(ja=>ja.type==="email");return jsx("div",{className:"flex-shrink-0",children:jsx("button",{type:"button",onClick:async()=>{let ja=M.name,Tn=Ar?.name,Dn=Tn?w[Tn]:void 0;if(!Dn&&ja&&typeof ja=="string"&&Tn&&(Dn=w[ja]?.[Tn]),!!Dn){K(Tr=>({...Tr,[nt.name]:true}));try{let Tr=await ct(Ye(An),{method:jr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Dn})}),Ua={};try{Ua=await Tr.json();}catch{Ua={};}if(Tr.ok&&Ua.success)c?.(Ua.message||"Action completed successfully");else {let qp=Ua.error||`Request failed (${Tr.status})`;u?.(qp);}}catch(Tr){u?.(Tr instanceof Error?Tr.message:"Error connecting to server");}finally{K(Tr=>({...Tr,[nt.name]:false}));}}},disabled:_[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:_[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:Va(nt,te,Te)},nt.name)})},M.name||`row-${Math.random()}`)}switch(M.type){case "tabs":return jsx(Bu,{field:M,formData:w,collectionSlug:n,onTabDataChange:dt=>{M.name&&Ie(M.name,dt);},renderField:(dt,nt,jr)=>Va(dt,nt,jr)},M.name||"tabs-layout");case "group":return jsx(Vs,{field:M,value:bt,onChange:Sn,renderField:Va},M.name);case "array":return jsx(js,{field:M,value:bt,onChange:Sn,renderField:Va,disabled:Vr},M.name);case "button":case "action":{let dt=M.name,nt=_[dt];return jsx("div",{className:"kyro-form-field",children:jsxs("button",{type:"button",disabled:nt||Vr,onClick:async()=>{let jr=M.admin?.action||M.action,An=M.admin?.method||M.method||"POST";if(jr){K(Ar=>({...Ar,[dt]:true}));try{let Ar=await ct(jr,{method:An,headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});await Ar.json(),Ar.ok;}catch(Ar){console.error("Error executing action:",Ar);}finally{K(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...":M.label||"Click"]})},dt)}case "relationship-block":return jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[M.label||M.name,M.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx(en,{relationTo:M.relationTo,hasMany:M.hasMany,selectedIds:Array.isArray(bt)?bt:bt?[bt]:[],onChange:(dt,nt)=>{Sn(nt);},compact:true}),M.admin?.description?jsx("p",{className:"kyro-form-help",children:String(M.admin?.description)}):null]},M.name);default:return jsx(jo,{field:M,value:bt,onChange:Sn,error:Ao,disabled:Vr,formData:w,siblingData:Ge,collectionSlug:n,globalSlug:i},M.name||Math.random().toString())}};return ri||!b?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})})]}):Ep?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:()=>{oi(false),qo(true),Mp(M=>M+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(ju,{collectionSlug:n,globalSlug:i,documentStatus:gr||"draft",hasUnpublishedChanges:Or,localSaveStatus:ti,isDuplicating:ve,handleCreateNew:Up,handleDuplicate:zp,handleUnpublish:_p,handleDelete:Hp,handlePublish:Kp,handleSaveDraft:Cn,handleSchedulePublish:Gp,handleConflictOverride:()=>Ae()}),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:[x==="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..."]}),x==="success"&&jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsx(Check,{className:"w-4 h-4"}),m?`Saved ${Math.floor((Date.now()-m)/6e4)}m ago`:"Saved"]}),x==="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..."]}),x==="offline"&&jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),x==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),x==="conflict"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),k&&x!=="saving"&&x!=="retrying"&&x!=="conflict"&&jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!k&&x!=="success"&&x!=="saving"&&x!=="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:w.updatedAt?`Modified ${new Date(w.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()=>{$e.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let M=await le(w);if(M.ok){let Te=(await M.json()).data||w;mt({...w,...Te}),oe({...w,...Te}),c?.("Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(M){console.error("Save error exception:",M),u?.("Save failed: "+M.message);}finally{$e.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxs(Gs,{children:[z==="edit"&&jsx(Uu,{config:b,layout:d,collectionSlug:n,renderField:Va}),z==="version"&&jsx(zu,{handleRestoreVersion:Op,handleCompareVersions:Vp,toggleCompareSelection:jp}),z==="api"&&jsx(Hu,{collectionSlug:n,globalSlug:i})]})})]})}var Gu={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Sl({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:g,onCopyData:f,onPasteData:v}){let{t:b}=H(),S=ge(h=>h.view)||"edit",w=ge(h=>h.setView),[R,k]=useState(false),E=useRef(null);useEffect(()=>{let h=N=>{E.current&&!E.current.contains(N.target)&&k(false);};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);let A=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,x=["edit","version","api"],m=A(),y="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 ${Gu[e]||"bg-[var(--kyro-text-muted)]"}`}),m&&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"}),m]}),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:x.map(h=>jsx("button",{type:"button",onClick:()=>w(h),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${S===h?"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:h==="edit"?"Edit":h==="version"?"Ver":"API"},h))}),jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsx("button",{type:"button",onClick:l,className:`${y} max-md:hidden`,title:b("tooltips.preview",{defaultValue:"Preview"}),children:jsx(Eye,{className:"w-3.5 h-3.5"})}),s&&jsx("button",{type:"button",onClick:s,className:`${y} max-md:hidden`,title:b("tooltips.viewHistory",{defaultValue:"View History"}),children:jsx(Clock,{className:"w-3.5 h-3.5"})}),i&&jsx("button",{type:"button",onClick:i,className:`${y} max-md:hidden`,title:b("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),f&&jsx("button",{type:"button",onClick:f,className:`${y} max-md:hidden`,title:b("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),v&&jsx("button",{type:"button",onClick:v,className:`${y} max-md:hidden`,title:b("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsx("button",{type:"button",onClick:d,className:`${y} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:b("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})}),u&&jsx("button",{type:"button",onClick:u,className:`${y} max-md:hidden`,title:b("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:E,className:"relative md:hidden",children:[jsx("button",{type:"button",onClick:()=>k(!R),className:y,title:b("tooltips.more",{defaultValue:"More"}),children:jsx(EllipsisVertical,{className:"w-3.5 h-3.5"})}),R&&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:[m&&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 ${Gu[e]}`}),jsx("span",{className:"capitalize",children:e}),jsx("span",{children:"\xB7"}),t==="saving"&&jsx(lr,{size:"sm",className:"inline"}),jsx("span",{children:m})]}),jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:x.map(h=>jsx("button",{type:"button",onClick:()=>{w(h),k(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${S===h?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:h==="edit"?"Edit":h==="version"?"Ver":"API"},h))}),s&&jsxs("button",{type:"button",onClick:()=>{s(),k(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(),k(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"]}),f&&jsxs("button",{type:"button",onClick:()=>{f(),k(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"]}),v&&jsxs("button",{type:"button",onClick:()=>{v(),k(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(),k(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(),k(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"}),f&&jsx(Ft,{icon:jsx(ClipboardCopy,{className:"w-4 h-4"}),onClick:f,children:"Copy Data"}),v&&jsx(Ft,{icon:jsx(ClipboardPaste,{className:"w-4 h-4"}),onClick:v,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||f||v||s||l)&&jsx(kn,{}),d&&jsx(Ft,{onClick:d,danger:true,icon:jsx(Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Al({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,g]=useState({}),[f,v]=useState({}),[b,S]=useState(true),[w,R]=useState(false),[k,E]=useState(false),[A,x]=useState(false),[m,y]=useState("idle"),[h,N]=useState("draft"),[F,L]=useState(null),[P,$]=useState(null),[z,I]=useState(null),[X,ee]=useState(false),ie=ge(V=>V.showPreview),q=ge(V=>V.setShowPreview),Q=ge(V=>V.previewUrl),pe=ge(V=>V.setPreviewUrl),Se=r?.fields||t?.fields||[],j=r?.label||t?.label||"Document",_=r?.slug||t?.slug||"",K=JSON.stringify(p)!==JSON.stringify(f);useEffect(()=>{K&&h==="published"&&N("draft");},[K,h]),useEffect(()=>{K&&m==="saved"&&y("idle");},[K,m]),useEffect(()=>{l==="global"?Me():o&&he();},[o,l,_]);let he=async()=>{try{S(!0);let V=await Le(`/api/${_}/${o}`,{autoToast:!1}),Y=V.data||{};g(Y),v(Y),N(Y?.status||V.status||"draft"),L(V.createdAt||Y.createdAt||null),$(V.updatedAt||Y.updatedAt||null),I(V.publishedAt||Y.publishedAt||null);}catch{s("Failed to load document");}finally{S(false);}},Me=async()=>{try{S(!0);let V=await Le(`/api/globals/${_}`,{autoToast:!1}),Y=V.data||{};g(Y),v(Y),L(V.createdAt||null),$(V.updatedAt||null);}catch{s("Failed to load global");}finally{S(false);}},ke=useCallback(async(V=false)=>{try{y("saving");let Y=l==="global"?`/api/globals/${_}`:`/api/${_}/${o}`,le=h==="draft"||p?.status==="draft",Ae=await er(Y,p,{autoToast:!1,headers:{"X-Draft":String(le)}}),$e=Ae&&(Ae.data||Ae)||p;V||(v($e),n()),g($e),N($e?.status||h),y("saved"),$(new Date().toISOString()),ee(!0),setTimeout(()=>ee(!1),3e3),V||(h==="draft"||$e?.status==="draft"?U.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):U.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{y("idle");},2e3),ie&&mt($e);}catch{y("error"),V||(s(d("toast.saveError",{defaultValue:"Failed to save changes"})),U.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{R(false);}},[p,l,_,o,h,n,s]),C=async()=>{try{R(!0),await er(`/api/${_}/${o}`,p,{autoToast:!1,headers:{"X-Draft":"false"}}),N("published"),I(new Date().toISOString()),U.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{s(d("toast.publishError",{defaultValue:"Failed to publish"})),U.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{R(false);}},G=async()=>{try{R(!0),await er(`/api/${_}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),N("draft"),U.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{s(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),U.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{R(false);}},we=async()=>{try{E(!0);let V=await ut(`/api/${_}/${o}/duplicate`,void 0,{autoToast:!1});U.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),V?.data?.id?Lt(`${_e}/${_}/${V.data.id}`):Lt(`${_e}/${_}`);}catch(V){U.error(V.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{E(false);}},Ve=async()=>{try{let V={...p};delete V.id,delete V.createdAt,delete V.updatedAt,delete V.status,await navigator.clipboard.writeText(JSON.stringify(V)),U.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{U.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},je=async()=>{try{let V=await navigator.clipboard.readText(),Y=JSON.parse(V);if(typeof Y!="object"||Y===null)throw new Error("Invalid format");g(le=>({...le,...Y,id:le.id,createdAt:le.createdAt,updatedAt:le.updatedAt,status:le.status})),U.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{U.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Ie=()=>{c({title:d("detailView.deleteTitle",{defaultValue:"Delete {{label}}?",label:j}),message:d("detailView.deleteMessage",{defaultValue:"This action cannot be undone."}),variant:"danger",onConfirm:async()=>{try{x(!0),await Dt(`/api/${_}/${o}`),Lt(`${_e}/${_}`);}catch{x(false);}}});},mt=async(V=p)=>{try{let Y=l==="global"?`/api/globals/${_}/preview-url`:`/api/${_}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",Y,"with data keys:",Object.keys(V||{}),"documentId:",o);let le=await ut(Y,{...V,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(le)),le&&le.url?(console.log("[Kyro Preview] Setting previewUrl:",le.url),pe(le.url)):console.warn("[Kyro Preview] No url in response:",le);}catch(Y){console.error("[Kyro Preview] Error:",Y.message,Y),U.error(Y.message||"Failed to generate preview URL");}};useEffect(()=>{ie&&mt(p);},[ie]);let Cr=()=>{let V=!ie;q(V),V&&mt(p);};if(b)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:j,href:l==="collection"?`${_e}/${_}`:void 0},{label:l==="global"?d("actions.edit",{defaultValue:"Edit"}):o?d("actions.edit",{defaultValue:"Edit"}):d("actions.new",{defaultValue:"New"})}],title:l==="global"?j:Io(t?.fields,p,t?.admin?.useAsTitle||"title")||p.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||j}),metadata:[jsx(Et,{variant:h==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${h}`,{defaultValue:h})},"status")]}),jsx(Sl,{status:h,saveStatus:m,hasChanges:K,onSave:()=>ke(false),onPublish:C,onUnpublish:h==="published"?G:void 0,onDuplicate:we,onCopyData:Ve,onPasteData:je,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:Cr,onDelete:Ie,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:z,updatedAt:P}),jsxs("div",{className:ie?"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 ${ie?"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(wn,{config:t?{...t,fields:Se}:{slug:"unknown",fields:Se},data:p,onChange:g,layout:oe?"single":"split",globalSlug:l==="global"?_:void 0,collectionSlug:l==="collection"?_:void 0,onActionSuccess:V=>U.success(V),onActionError:V=>U.error(V),documentStatus:h,justSaved:X}),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:Ie,disabled:A||w,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:A?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsx(Ho,{status:h,saveStatus:w?"saving":"idle",hasChanges:K,onPublish:()=>ke(false),disabled:w})]})]})}),ie&&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:Q||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsx("div",{className:"w-16"})]}),jsx("div",{className:"flex-1 bg-white relative",children:Q?jsx("iframe",{src:Q,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&&!ie&&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 ${h==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:h||"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:P?new Date(P).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:we,disabled:k||w,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:k?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),Q&&jsx("button",{type:"button",onClick:()=>window.open(Q,"_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:Ie,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 Tl({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),U.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(g){a(g instanceof Error?g.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(wn,{config:{...t,fields:d},data:n,onChange:i})})})})})]})}function qs(){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(Ic,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Pl({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),[g,f]=useState(false),v=Zt(w=>w.addToast);useEffect(()=>{b();},[]);let b=async()=>{try{await Le("/api/users");}catch{f(true),a("register");}},S=async w=>{w.preventDefault(),p(true);try{let R=o==="login"?"/api/auth/login":"/api/auth/register",k={email:n,password:s};o==="register"&&(k.confirmPassword=d);let E=await ut(R,k);E.isFirstUser&&f(!0),localStorage.setItem("kyro_user",JSON.stringify(E.user)),v("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e(E.token,E.user);}catch{v("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:g?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:g?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:S,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:w=>i(w.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:w=>l(w.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:w=>c(w.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"})})]}),!g&&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(qs,{})]})})}function Xu({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])=>!Bi.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 Qu(){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(""),[g,f]=useState(false),{confirm:v,alert:b}=vt();useEffect(()=>{S();},[]);let S=async()=>{try{a(!0);let x=await Le("/api/users");r(x.docs||[]);}catch(x){console.error("Failed to load users:",x);}finally{a(false);}},w=x=>{let m=!x.locked;v({title:m?"Lock User Account?":"Unlock User Account?",message:m?`Are you sure you want to lock ${x.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${x.email}?`,variant:m?"danger":"success",onConfirm:async()=>{try{await er(`/api/users/${x.id}`,{locked:m}),r(y=>y.map(h=>h.id===x.id?{...h,locked:m}:h)),U.success(m?`Account locked: ${x.email}`:`Account restored: ${x.email}`);}catch(y){console.error("Failed to toggle user lock:",y),U.error("Failed to update account status");}}});},R=x=>{v({title:"Destroy User Account",message:`You are about to permanently delete ${x.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Dt(`/api/users/${x.id}`),r(m=>m.filter(y=>y.id!==x.id)),U.success(`Identity purged: ${x.email}`);}catch(m){console.error("Failed to delete user:",m),U.error("Failed to delete user");}}});},k=async()=>{if(!d.email.trim()||!d.password.trim()){p("Email and password are required");return}f(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"}),U.success("User created successfully"),S();}catch(x){let m=x instanceof Error?x.message:"Failed to create user";p(m),U.error(m);}finally{f(false);}},E=["super_admin","admin","editor","author","customer","guest"],A=t.filter(x=>x.email.toLowerCase().includes(n.toLowerCase())||x.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:x=>i(x.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((x,m)=>jsx("tr",{className:"animate-pulse",children:jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},m)):A.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"})})}):A.map(x=>jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${x.locked?"opacity-50 grayscale":""}`,children:[jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-3",children:[jsx(vv,{user:x}),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:x.name||x.email.split("@")[0]}),x.tenantId&&jsx(Et,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:x.tenantId})]}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:x.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:x.role})]})}),jsx("td",{className:"px-6 py-3.5",children:jsx(Et,{variant:x.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:x.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"}),x.lastLogin?new Date(x.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:()=>w(x),className:`p-1.5 rounded-lg border transition-all ${x.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:x.locked?"Restore Access":"Restrict Access",children:x.locked?jsx(LockOpen,{className:"w-3.5 h-3.5"}):jsx(Lock,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>R(x),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"})})]})})]},x.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:x=>c({...d,name:x.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:x=>c({...d,email:x.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:x=>c({...d,password:x.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:x=>c({...d,role:x.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:E.map(x=>jsx("option",{value:x,children:x},x))})]}),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:k,disabled:g,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:g?"Creating...":"Create User"})]})]})]})}function vv({user:e}){let[t,r]=useState(null);return useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Le(`/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 Zu(){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 b=await Le("/api/globals/site-settings"),S=b.data||b;S&&Object.keys(S).length>0&&(S.siteName&&r(S.siteName),S.adminTitle&&a(S.adminTitle),S.primaryColor&&i(S.primaryColor),S.dashboardGreeting&&l(S.dashboardGreeting));}catch(b){console.error("Failed to load branding:",b);}})();},[]);let g=async()=>{c(true);try{await er("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:s}),p(!0),U.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.dispatchEvent(new Event("kyro:soft-reload")),800);}catch(v){U.error("Failed to save branding"),console.error(v);}finally{c(false);}},f=[{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:g,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:v=>r(v.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:v=>a(v.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:v=>l(v.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:f.map(v=>jsx("button",{type:"button",onClick:()=>i(v.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===v.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:v.hex},title:v.name},v.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 Fs({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 ha({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}=ge(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",v=t==null?"":String(t),f={id:e.name,value:v,onChange:b=>r?.(b.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",{...f,rows:e.admin?.rows||4}):jsx("input",{type:m,...f,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?.(hs(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:v.length>60?"text-red-500":v.length>=40?"text-green-500":"text-amber-600",children:[v.length," / 60 \u2014 ",v.length>60?"Too Long":v.length>=40?"Ideal":"Short"]})})]})})}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:"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 Ls({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 Es({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 Bs({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),m=JSON.stringify(n||{}),v=JSON.stringify(i||{});useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let h=setTimeout(async()=>{try{let C="";if(s)C=`${Dr}/${s}/dynamic-options/${e.name}`;else if(l)C=`${Dr}/globals/${l}/dynamic-options/${e.name}`;else return;let x=await ct(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(m),siblingData:JSON.parse(v)})});if(x.ok){let R=await x.json();R.options&&u(R.options);}}catch(C){console.error("Failed to fetch dynamic options:",C);}},300);return ()=>clearTimeout(h)},[m,v,e.name,e.options,s,l]);let f=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?f=e.options({data:n||{},siblingData:i||{}}):Array.isArray(e.options)&&(f=e.options)),e.dynamicOptions==="collections"&&(f=Object.keys(ca).filter(b=>b!=="media").map(b=>({label:ca[b]?.label||b,value:b}))),jsx(pt,{field:e,error:o,children:jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:b=>{if(e.hasMany){let h=Array.from(b.target.selectedOptions,C=>C.value);r?.(h);}else r?.(b.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,style:{color:e.hasMany?void 0:f.find(b=>b.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..."}),f.map(b=>jsx("option",{value:b.value,style:{color:b.color||void 0,fontWeight:b.color?"bold":"normal"},children:b.label},b.value))]})})}function nl(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function uy({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 py({field:e,value:t,onChange:r,error:o,disabled:a}){let{t:n}=H(),[i,s]=useState(false),[l,d]=useState(""),[c,u]=useState([]),[m,v]=useState(false),[f,b]=useState([]),h=useRef(new Set),C=useRef(null),x=useRef(()=>{});x.current=r||(()=>{});let R=e.hasMany,k=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],E=k.length>1,[S,D]=useState(k[0]||""),g=useCallback(()=>t?(R?Array.isArray(t)?t:[]:t?[t]:[]).map(X=>typeof X=="object"&&X!==null?X.value||X.id||"":String(X)).filter(Boolean):[],[t,R]),p=useCallback(I=>{I.length!==0&&I.forEach(X=>{if(h.current.has(X))return;h.current.add(X);let ee=E?(()=>{if(!t)return S;let q=(R?Array.isArray(t)?t:[]:[t]).find(Q=>typeof Q=="object"&&Q!==null?Q.value===X||Q.id===X:false);return q&&typeof q=="object"&&q.relationTo||S})():S;Ie(`/api/${ee}/${X}`).then(ie=>{let q=ie.data||ie;!q||typeof q!="object"||b(Q=>Q.some(pe=>pe.id===X)?Q:[...Q,{...q,id:String(q.id),relationTo:ee}]);}).catch(()=>{});});},[E,t,S,R]);useEffect(()=>{let I=g();p(I);},[g,p]);let y=useCallback((I="")=>{v(true);let ee=`/api/${S}?${Pn(I,["title","name","label","email"])}`;Ie(ee).then(ie=>{u(q=>{let Q=new Set(q.map(Ae=>Ae.id)),pe=(ie.docs||[]).filter(Ae=>!Q.has(Ae.id)).map(Ae=>({...Ae,id:Ae.id}));return [...q,...pe]}),v(false);}).catch(()=>{v(false);});},[S]);useEffect(()=>{i&&(u([]),y(l));},[i,S]),useEffect(()=>{let I=X=>{C.current&&!C.current.contains(X.target)&&s(false);};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);let w=I=>{if(typeof I=="object"&&I!==null){let X=I.value??I.id;return X!=null?w(X):""}return String(I)},F=I=>{let X=I.id;return t?R&&Array.isArray(t)?t.some(ee=>w(ee)===X):w(t)===X:false},L=I=>{let X=I.id;if(R){let ee=Array.isArray(t)?t:[];if(F(I))x.current?.(ee.filter(ie=>w(ie)!==X));else {let ie=E?{relationTo:S,value:X}:X;x.current?.([...ee,ie]);}}else if(F(I))x.current?.(null);else {let ee=E?{relationTo:S,value:X}:X;x.current?.(ee),s(false),d("");}},P=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),$=I=>{let{active:X,over:ee}=I;if(!ee||X.id===ee.id)return;let ie=R?Array.isArray(t)?t:[]:[],q=ie.findIndex(pe=>w(pe)===X.id),Q=ie.findIndex(pe=>w(pe)===ee.id);if(q!==-1&&Q!==-1){let pe=[...ie],[Ae]=pe.splice(q,1);pe.splice(Q,0,Ae),x.current?.(pe);}},z=()=>{if(!t)return null;let I=R?Array.isArray(t)?t:[]:t?[t]:[],X$1=I.map(ee=>w(ee));return R&&I.length>1?jsx(DndContext,{sensors:P,collisionDetection:closestCenter,onDragEnd:$,children:jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsx(SortableContext,{items:X$1,strategy:horizontalListSortingStrategy,children:I.map((ee,ie)=>{let q=w(ee),Q=f.find(U=>U.id===q),pe=Q?nl(Q):q?q.slice(0,12):"Item",Ae=E&&Q?Q.relationTo:null;return jsx(uy,{id:q,label:pe,relation:Ae,onRemove:()=>{let U=I.filter(_=>w(_)!==q);x.current?.(U);},disabled:a},`${q}-${ie}`)})})})}):jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:I.map((ee,ie)=>{let q=w(ee),Q=f.find(U=>U.id===q),pe=Q?nl(Q):q?q.slice(0,12):"Item",Ae=E&&Q?Q.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:[Ae&&jsxs("span",{className:"opacity-60 mr-0.5",children:[Ae,":"]}),pe,!a&&jsx("button",{type:"button",onClick:()=>{let U=I.filter(_=>w(_)!==q);x.current?.(R?U:U[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsx(X,{className:"w-3 h-3"})})]},`${q}-${ie}`)})})};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:C,className:"relative",children:[E&&jsx("div",{className:"flex gap-1 mb-1.5",children:k.map(I=>jsx("button",{type:"button",onClick:()=>{D(I),u([]),d("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${S===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),y(I.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${S}...`,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:m?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:m?jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):c.length===0?jsx(ys,{title:n("tooltips.noResultsFound",{defaultValue:"No results found"})}):jsx("div",{className:"py-1",children:c.map(I=>jsxs("button",{type:"button",onClick:()=>L(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:nl(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 un=py;var Mo=createContext(null);function nu(e=[],t=[]){return createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=sl(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let i=ka(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=pn(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=pn(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=pn(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 sl(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=sl(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?sl(a.children):a.children}))}),r}):[]}function ka(e){let t=yy(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 yy(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 pn(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=pn(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 m=pn(u.children,t);if(m!==u.children)return {...u,children:m}}return u});c.some((u,m)=>u!==d.columnData[m])&&(s.data={...s.data,columnData:c},l=true);}return l&&(a=true),l?s:i});return a?n:e}function fn({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let{t:n}=H(),[i,s]=ia.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 su({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 il=({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 du=({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(il,{text:a.text||"",onChange:n,compact:true})})};var uu=({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 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-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 dl=({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 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:"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(dl,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:d=>l("src",d),compact:true})]})};function Py({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 gn=({items:e=[],onChange:t,compact:r=false})=>{let{t:o}=H(),[a,n]=ia.useState(""),[i,s]=ia.useState([]);ia.useEffect(()=>{let f=i.map(b=>b.text);JSON.stringify(f)!==JSON.stringify(e)&&s(e.map((b,h)=>({id:`${b}-${h}-${Math.random().toString(36).substr(2,4)}`,text:b})));},[e]);let l=()=>{a.trim()&&(t([...e,a.trim()]),n(""));},d=f=>{f.key==="Enter"&&(f.preventDefault(),l());},c=f=>{t(e.filter((b,h)=>h!==f));},u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),m=f=>{let{active:b,over:h}=f;if(!h||b.id===h.id)return;let C=i.findIndex(R=>R.id===b.id),x=i.findIndex(R=>R.id===h.id);if(C!==-1&&x!==-1){let R=[...e],[k]=R.splice(C,1);R.splice(x,0,k),t(R);}},v=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:m,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(f=>f.id),strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-1",children:i.map((f,b)=>jsx(Py,{id:f.id,text:f.text,onRemove:()=>c(b)},f.id))})}),jsx("input",{type:"text",value:a,onChange:f=>n(f.target.value),onKeyDown:d,className:v,placeholder:o("fields.typeAndPressEnter",{defaultValue:"Type and press Enter to add..."})})]})})};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=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(gn,{items:l,onChange:d,compact:true})]})};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=(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(cn,{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 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,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 gl=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=useState(0),n=jsx("div",{className:"flex justify-end gap-1 mb-2"}),i=(m,v)=>{let f=[...e];f[m]={...f[m],title:v},t(f);},s=(m,v)=>{let f=[...e];f[m]={...f[m],content:v},t(f);},l=m=>{let v=e.filter((f,b)=>b!==m);t(v),o===m?a(null):o!==null&&o>m&&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((m,v)=>{let{t:f}=H(),b=o===v;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(b?null:v),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:m.title||`Item ${v+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:f("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-3.5 h-3.5"})}),b?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),b&&jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:m.title||"",onChange:h=>i(v,h.target.value),onClick:h=>h.stopPropagation(),className:u,placeholder:f("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:m.content||"",onChange:h=>s(v,h.target.value),onClick:h=>h.stopPropagation(),className:`${u} min-h-[60px] resize-none`,placeholder:f("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),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((m,v)=>{let{t:f}=H(),b=o===v;return jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxs("button",{type:"button",onClick:()=>a(b?null:v),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:m.title||`Item ${v+1}`}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),l(v);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:f("tooltips.remove",{defaultValue:"Remove"}),children:jsx(X,{className:"w-4 h-4"})}),b?jsx(ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsx(ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),b&&jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsx("input",{type:"text",value:m.title||"",onChange:h=>i(v,h.target.value),className:c,placeholder:f("fields.itemTitle",{defaultValue:"Item title..."})}),jsx("textarea",{value:m.content||"",onChange:h=>s(v,h.target.value),className:`${c} min-h-[60px] resize-none`,placeholder:f("fields.itemContent",{defaultValue:"Item content..."})})]})]},v)})}),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 bu=({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(gl,{items:l,onChange:d,compact:true})]})};var hu=({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(fa,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var yl=({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 Ca=({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,m)=>{a(e.id,{data:{...n,[u]:m}});},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 v={values:n,...n};if(!u.admin.condition(v,v))return null}catch(v){console.warn(`Condition error for field ${u.name}:`,v);}else if(typeof u.admin.condition=="object")try{let v=u.admin.condition,f=v.field,b=n[f],h=!0;if("equals"in v?h=b===v.equals:"notEquals"in v?h=b!==v.notEquals:"in"in v&&Array.isArray(v.in)&&(h=v.in.includes(b)),!h)return null}catch(v){console.warn(`Declarative condition error for field ${u.name}:`,v);}}let m=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:m,onChange:v=>s(u.name,v)})},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=ze[e.type]||ze.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(vo,{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 Fy=6,vo=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=Fy})=>{let[n,i]=useState(false),[s,l]=useState(new Set),[d,c]=useState(null),[u,m]=useState(null),v=useContext(Mo);if(!v)throw new Error("ChildBlocksTree must be used within a BlocksContext");let f=useStore(v,g=>g.dynamicCategories),b=useStore(v,g=>g.allowedBlocks),h=o<a,C=16,x=g=>{let p=ka(g);r([...t,p]),c(p.id);},R=g=>{let p=t.filter(y=>y.id!==g);r(p);},E=(g,p)=>{let y=t.map(w=>w.id===g?{...w,children:p}:w);r(y);},S=g=>{l(p=>{let y=new Set(p);return y.has(g)?y.delete(g):y.add(g),y});},D=g=>{let p=g.children&&g.children.length>0,y=s.has(g.id);vl(g.type);let F=p,L=d===g.id,P=b.find($=>$.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 ${L?"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"} ${h?"cursor-pointer":""}`,style:{marginLeft:o*C},onClick:()=>{h&&c(L?null:g.id);},children:[F?jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),S(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:y?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:[bn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),p&&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:$=>$.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{R(g.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>m(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:$=>{$.stopPropagation(),m(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"})})]}),L&&jsx(Ca,{block:g,onClose:()=>c(null)}),p&&y&&jsx("div",{className:"mt-1",children:jsx(ku,{parentId:g.id,children:g.children??[],onUpdateChildren:$=>E(g.id,$),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(D)}),h&&jsxs("div",{style:{marginLeft:o*C},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(fn,{open:n,onClose:()=>i(false),onSelect:x,children:f.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(p=>jsxs("button",{type:"button",onClick:()=>{x(p.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[p.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:p.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:p.admin?.description||""})]})]},p.slug))})]},g.title))})]}),t.length===0&&h&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*C},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*C},children:["Maximum nesting level (",a,") reached"]})]})},ku=({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,m]=useState(null),v=useContext(Mo);if(!v)throw new Error("NestedChildBlocks must be used within a BlocksContext");let f=useStore(v,g=>g.dynamicCategories),b=useStore(v,g=>g.allowedBlocks),h=o<a,C=16,x=g=>{let p=ka(g);r([...t,p]),c(p.id);},R=g=>{let p=t.filter(y=>y.id!==g);r(p);},E=(g,p)=>{let y=t.map(w=>w.id===g?{...w,children:p}:w);r(y);},S=g=>{l(p=>{let y=new Set(p);return y.has(g)?y.delete(g):y.add(g),y});},D=g=>{let p=g.children&&g.children.length>0,y=s.has(g.id);vl(g.type);let F=p,L=d===g.id,P=b.find($=>$.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 ${L?"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"} ${h?"cursor-pointer":""}`,style:{marginLeft:o*C},onClick:()=>{h&&c(L?null:g.id);},children:[F?jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),S(g.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:y?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:[bn(g),typeof g.data?.text=="string"?` - ${g.data.text.slice(0,30)}`:"",typeof g.data?.heading=="string"?` - ${g.data.heading.slice(0,30)}`:""]}),P?.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:P.admin.description})]}),p&&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:$=>$.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{R(g.id),m(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsx("button",{type:"button",onClick:()=>m(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:$=>{$.stopPropagation(),m(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)]"})})]}),L&&jsx(Ca,{block:g,onClose:()=>c(null)}),p&&y&&jsx("div",{className:"mt-1",children:jsx(ku,{parentId:g.id,children:g.children??[],onUpdateChildren:$=>E(g.id,$),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(D)}),h&&jsxs("div",{style:{marginLeft:o*C},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(fn,{open:n,onClose:()=>i(false),onSelect:x,children:f.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(p=>jsxs("button",{type:"button",onClick:()=>{x(p.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[p.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:p.label}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:p.admin?.description||""})]})]},p.slug))})]},g.title))})]}),t.length===0&&h&&jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*C},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*C},children:["Maximum nesting level (",a,") reached"]})]})};var wu=({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(yl,{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(vo,{blockId:e.id,children:l,onUpdateChildren:c=>a(e.id,{children:c})})]})]})]})};var bl=({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 Su=({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(bl,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Au=({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(vo,{blockId:e.id,children:l,onUpdateChildren:d=>a(e.id,{children:d})})})]})};var Tu=({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(tn,{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 Iy={heading:du,paragraph:uu,image:pu,video:fu,list:gu,code:yu,file:vu,accordion:bu,richtext:hu,hero:wu,card:Su,array:Au,relationship:Tu},ze={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 ${ze.default.text}`}),paragraph:jsx(AlignLeft,{className:`w-4 h-4 ${ze.default.text}`}),image:jsx(Image,{className:`w-4 h-4 ${ze.default.text}`}),video:jsx(Video,{className:`w-4 h-4 ${ze.default.text}`}),list:jsx(List,{className:`w-4 h-4 ${ze.default.text}`}),code:jsx(Code,{className:`w-4 h-4 ${ze.default.text}`}),file:jsx(File,{className:`w-4 h-4 ${ze.default.text}`}),accordion:jsx(ChevronDown,{className:`w-4 h-4 ${ze.default.text}`}),richtext:jsx(AlignLeft,{className:`w-4 h-4 ${ze.default.text}`}),hero:jsx(Star,{className:`w-4 h-4 ${ze.hero.text}`}),card:jsx(Box,{className:`w-4 h-4 ${ze.card.text}`}),array:jsx(ListOrdered,{className:`w-4 h-4 ${ze.default.text}`}),relationship:jsx(Link2,{className:`w-4 h-4 ${ze.default.text}`}),featureSplit:jsx(Columns3,{className:`w-4 h-4 ${ze.featureSplit.text}`}),featureGrid:jsx(Blocks,{className:`w-4 h-4 ${ze.featureGrid.text}`}),ctaBanner:jsx(Sparkles,{className:`w-4 h-4 ${ze.ctaBanner.text}`}),testimonials:jsx(Users,{className:`w-4 h-4 ${ze.testimonials.text}`}),faq:jsx(CircleHelp,{className:`w-4 h-4 ${ze.faq.text}`}),stats:jsx(Activity,{className:`w-4 h-4 ${ze.stats.text}`}),logoCloud:jsx(Image,{className:`w-4 h-4 ${ze.logoCloud.text}`}),pricing:jsx(Tag,{className:`w-4 h-4 ${ze.pricing.text}`}),team:jsx(Users,{className:`w-4 h-4 ${ze.team.text}`}),recentFeed:jsx(Database,{className:`w-4 h-4 ${ze.recentFeed.text}`}),processSteps:jsx(Clock,{className:`w-4 h-4 ${ze.processSteps.text}`}),formEmbed:jsx(Mail,{className:`w-4 h-4 ${ze.formEmbed.text}`}),videoShowcase:jsx(Video,{className:`w-4 h-4 ${ze.videoShowcase.text}`})};function vl(e){return Iy[e]||null}function hl(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 bn(e){let t=e.name;return t&&t.trim()?t.trim():hl(e.type)}function Gy(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 Wy=({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:m,isDragging:v}=useSortable({id:e.id}),{removeBlock:f,updateBlock:b}=He(),h=o===e.id,[C,x]=useState(false),[R,k]=useState(false),[E,S]=useState(e.name||""),D=useRef(null),[g,p]=useState(false);useEffect(()=>{R&&D.current&&(D.current.focus(),D.current.select());},[R]);let y=useCallback(()=>{k(false);let z=E.trim();z!==(e.name||"").trim()&&b(e.id,{name:z||""});},[E,e.name,e.id,b]),w=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)),p(!0),V.success(s("notifications.blockCopied",{defaultValue:"Block copied to clipboard"})),setTimeout(()=>p(!1),2e3);}catch{V.error(s("notifications.blockCopyFailed",{defaultValue:"Failed to copy block"}));}},[e,s]),F={transform:CSS.Transform.toString(u),transition:m,zIndex:v?10:1,opacity:v?.8:1},L=bn(e),P=e.data||{},$=Gy(P,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 ${h?`${(ze[e.type]||ze.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]}),R?jsx("input",{ref:D,value:E,onChange:z=>S(z.target.value),onBlur:y,onKeyDown:z=>{z.key==="Enter"&&y(),z.key==="Escape"&&(S(e.name||""),k(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:L}),C?jsxs("div",{className:"flex items-center gap-0.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{f(e.id),x(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:()=>x(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(),S(e.name||""),k(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:w,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(),x(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"})})]})]}),h&&jsx(Ca,{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 ${h?`${(ze[e.type]||ze.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:[R?jsx("input",{ref:D,value:E,onChange:z=>S(z.target.value),onBlur:y,onKeyDown:z=>{z.key==="Enter"&&y(),z.key==="Escape"&&(S(e.name||""),k(false));},onClick:z=>z.stopPropagation(),placeholder:hl(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:[L,$&&typeof $=="string"&&jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",$.length>40?`${$.slice(0,40)}...`:$]})]}),!!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"]}),C?jsxs("div",{className:"flex items-center gap-1.5",onClick:z=>z.stopPropagation(),children:[jsx("button",{type:"button",onClick:()=>{f(e.id),x(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:()=>x(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(),S(e.name||""),k(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:w,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(),x(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"})})]})]}),h&&jsx(Ca,{block:e,blockSchema:r,onClose:()=>a(null)})]})},qy=ia.memo(Wy),kl=({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),m=useRef(null),v=e.admin?.pickerMode||"drawer",f=e.blocks||[],b=f.reduce((U,_)=>{let K=_.admin?.group||"Custom Blocks";return U[K]||(U[K]=[]),U[K].push(_),U},{}),h=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],C=Object.entries(b).sort(([U],[_])=>{let K=h.indexOf(U),he=h.indexOf(_);return K!==-1&&he!==-1?K-he:K!==-1?-1:he!==-1?1:U.localeCompare(_)}).map(([U,_])=>({title:U,blocks:_})),x=useRef(null);x.current||(x.current=nu(f,C));let R=x.current,k=useStore(R,U=>U.blocks),[E,S]=useState(null),[D,g]=useState(null),p=useRef(k.length),y=useRef(new Set(k.map(U=>U.id))),w=useRef(false);useEffect(()=>{if(w.current&&k.length>p.current){let U=k.find(_=>_.id&&!y.current.has(_.id));U&&g(U.id);}p.current=k.length,y.current=new Set(k.map(U=>U.id));},[k]),useEffect(()=>(o&&R.getState().setOnBlocksChange(o),()=>{R.getState().setOnBlocksChange(()=>{});}),[o,R]);let F=useRef(null);useEffect(()=>{let U=Array.isArray(t)?t:[],_=F.current||[];if(Eo(U,_))U.length===0&&!w.current&&(w.current=true,F.current=[]);else {let K=[...U];p.current=K.length,y.current=new Set(K.map(he=>he.id)),R.getState().setBlocks(K),F.current=K,w.current=true;}},[t,e.name,R]);let L=useRef(r);L.current=r,useEffect(()=>{if(!L.current)return;let U=F.current;U&&(Eo(k,U)||(F.current=[...k],L.current(k)));},[k]);let $=useCallback(U=>{R.getState().addBlock(U);},[R]),z=useCallback(U=>{if(!f.some(Me=>Me.slug===U.type)){alert(`The block type "${U.type}" is not allowed in this collection.`);return}let K=Math.random().toString(36).substring(2,11),he={...U.blockProps||{},id:K,type:U.type};R.getState().setBlocks([...k,he]),d(false);},[f,k,R]),I=useCallback(U=>{let _=document.activeElement;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.getAttribute("contenteditable")==="true"))return;let K=U.clipboardData?.getData("text");if(K)try{let he=JSON.parse(K);he&&he.__kyro_block&&(U.preventDefault(),U.stopPropagation(),z(he),V.success(`Block pasted: ${he.type}`));}catch{}},[z]),X=useCallback(U=>{let _=k.findIndex(N=>N.id===U);if(_===-1)return;let K=k[_],he=N=>{let G=Math.random().toString(36).substr(2,9);return {...N,id:G,children:N.children?N.children.map(we=>he(we)):N.children,data:N.data?JSON.parse(JSON.stringify(N.data)):N.data}},Me=he(K),ke=[...k];ke.splice(_+1,0,Me),R.getState().setBlocks(ke);},[k,R]),ee=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}}),useSensor(TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),useSensor(KeyboardSensor)),ie=U=>{S(U.active);},q=U=>{let{active:_,over:K}=U;if(S(null),!!K){if(_.id.toString().startsWith("drawer-")){let he=_.id.toString().replace("drawer-","");if(K.id.toString().startsWith("container-")){let Me=K.id.toString().replace("container-",""),ke=k.find(N=>N.id===Me);if(ke){let N=ka(he);R.getState().updateBlock(Me,{children:[...ke.children||[],N]});}}else {let Me=k.findIndex(ke=>ke.id===K.id);Me!==-1?R.getState().addBlock(he,Me):$(he);}return}if(_.id!==K.id){let he=k.findIndex(ke=>ke.id===_.id),Me=k.findIndex(ke=>ke.id===K.id);if(he!==-1&&Me!==-1){let ke=[...k],[N]=ke.splice(he,1);ke.splice(Me,0,N),R.getState().setBlocks(ke);}}}},Q=E?C.flatMap(U=>U.blocks).find(U=>`drawer-${U.type}`===E.id)||k.find(U=>U.id===E.id):null;Q?"label"in Q?Q.label:Q.type:"Block";return useEffect(()=>{if(!c)return;let U=_=>{m.current&&!m.current.contains(_.target)&&u(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[c]),jsx(Mo.Provider,{value:x.current,children:jsxs("div",{className:"kyro-blocks-field",onPaste:I,tabIndex:0,style:{outline:"none"},children:[jsxs(DndContext,{sensors:ee,collisionDetection:closestCenter,onDragStart:ie,onDragEnd:q,children:[jsxs("div",{className:v==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsx("label",{className:`kyro-form-label ${v==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),v==="dropdown"?jsxs("div",{ref:m,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:C.map(U=>jsxs("div",{children:[C.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(_=>jsxs("button",{type:"button",onClick:()=>{$(_.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[_.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:_.label}),_.admin?.description&&jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:_.admin.description})]})]},_.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(fn,{open:l,onClose:()=>d(false),onSelect:$,onPasteBlock:z,children:jsx("div",{className:"space-y-4",children:C.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(_=>jsx(su,{block:{type:_.slug,label:_.label,description:_.admin?.description||"",icon:null},onSelect:$,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[_.slug]||jsx(Box,{className:"w-4 h-4"})})})},_.slug))})]},U.title))})})}),jsx(SortableContext,{items:k.map(U=>U.id),strategy:verticalListSortingStrategy,children:jsxs("div",{className:v==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[k.map((U,_)=>{let K=e.blocks?.find(he=>he.slug===U.type);return jsx(qy,{block:U,index:_,blockSchema:K,editingBlockId:D,setEditingBlockId:g,onDuplicate:X,compact:v==="dropdown"},U.id||_)}),k.length===0&&jsx("div",{className:v==="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:v==="dropdown"?"No elements added":"Click the button above to add your first block"})]})}),jsx(DragOverlay,{children:E&&Q&&jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:Q.label||Q.type||"Block"})})]}),a&&jsx("p",{className:"kyro-form-error",children:a})]})})};function Vs({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 ov=new Set(["text","number","checkbox","select","radio","color","email","password","url","id"]);function kn(e){if(!e||typeof e!="object")return null;let t=e,r=t.tabs,o=t.title||r?.title||t.name||t.label||t.email||t.filename||t.slug;return o&&typeof o=="string"?o:t.value&&typeof t.value=="object"?kn(t.value):t.doc&&typeof t.doc=="object"?kn(t.doc):null}function av(e,t){let r=e.label||e.name||"Item";return /item$/i.test(r.trim())?`${r} ${t+1}`:`${r} Item ${t+1}`}function nv(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>ov.has(r.type))}function Iu({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:m}=H(),{attributes:v,listeners:f,setNodeRef:b,transform:h,transition:C}=useSortable({id:e}),x={transform:CSS.Transform.toString(h),transition:C},R=n.fields||[];return c?jsxs("div",{ref:b,style:x,className:"flex items-start gap-3 p-3.5 mb-2 border border-[var(--kyro-border)] rounded-[var(--kyro-radius-md)] bg-[var(--kyro-surface-accent)]/15 hover:border-[var(--kyro-border-accent)] transition-all group/item shadow-xs",children:[jsx("div",{...v,...f,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 ${R.length>=3?"flex flex-col gap-2":"grid grid-cols-1 sm:grid-cols-2 gap-3"}`,children:R.map(k=>jsx("div",{className:"min-w-0",children:i(k,a,s)},k.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-1 mt-1.5 flex-shrink-0 rounded hover:bg-[var(--kyro-surface-accent)]",title:m("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"})]})})]}):jsxs("div",{ref:b,style:x,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",{...v,...f,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)||av(n,t)})}),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:m("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:R.map(k=>i(k,a,s))})]})}function js({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=(e.fields||[])[0],l=s?.name||"user",d=s?.type==="relationship",[c,u]=ia.useState(0),[m,v]=ia.useState({}),f=ia.useRef(new Set);ia.useEffect(()=>{let k=false,E=n.filter(S=>typeof S!="object"||S===null?(k=true,false):true).map(S=>!S.id&&!S._key?(k=true,{...S,id:Math.random().toString(36).substr(2,9)}):S);k&&r(E);},[t,r]),ia.useEffect(()=>{let k=e.fields||[];n.forEach(E=>{!E||typeof E!="object"||k.forEach(S=>{if(S.type==="relationship"&&S.name){let D=E[S.name];if(!D)return;let g="",p=Array.isArray(S.relationTo)?S.relationTo[0]:S.relationTo;if(typeof D=="string")g=D;else if(typeof D=="object"&&D!==null){let y=D;y.relationTo&&typeof y.relationTo=="string"&&(p=y.relationTo),y.id&&typeof y.id=="string"?g=y.id:y.value&&typeof y.value=="string"&&(g=y.value);}g&&p&&!f.current.has(g)&&(f.current.add(g),Ie(`/api/${p}/${g}`).then(y=>{let w=y?.data||y,F=kn(w);F&&v(L=>({...L,[g]:F}));}).catch(()=>{}));}});});},[n,e]);function b(k){for(let D of ["label","title","name","externalUrl","url"]){let g=k[D];if(g&&typeof g=="string"&&g.trim()!=="")return g}let E=e.fields||[],S=new Set(["linkType","type","blockType","kind","mode"]);for(let D of E){if(!D.name)continue;let g=k[D.name];if(g){if((D.type==="text"||D.type==="textarea")&&typeof g=="string"&&g.trim()!==""||D.type==="select"&&!S.has(D.name)&&typeof g=="string"&&g.trim()!=="")return g;if(D.type==="relationship"){let p=kn(g);if(p)return p;let y="";if(typeof g=="string")y=g;else if(typeof g=="object"&&g!==null){let w=g;w.id&&typeof w.id=="string"?y=w.id:w.value&&typeof w.value=="string"&&(y=w.value);}if(y&&m[y])return m[y]}if(D.type==="group"&&D.fields){let p=g;if(p&&typeof p=="object")for(let y of D.fields||[]){if(!y.name)continue;let w=p[y.name];if((y.type==="text"||y.type==="textarea")&&typeof w=="string"&&w.trim()!==""||y.type==="select"&&!S.has(y.name)&&typeof w=="string"&&w.trim()!=="")return w;if(y.type==="relationship"){let F=kn(w);if(F)return F;let L="";if(typeof w=="string")L=w;else if(typeof w=="object"&&w!==null){let P=w;P.id&&typeof P.id=="string"?L=P.id:P.value&&typeof P.value=="string"&&(L=P.value);}if(L&&m[L])return m[L]}}}}}return ""}let h=nv(e),C=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:3}})),x=k=>{let{active:E,over:S}=k;if(!S||E.id===S.id)return;let D=n.findIndex(p=>(p.id||p._key)===E.id),g=n.findIndex(p=>(p.id||p._key)===S.id);if(D!==-1&&g!==-1){let p=[...n],[y]=p.splice(D,1);p.splice(g,0,y),r(p);}},R=ia.useMemo(()=>n.map(k=>k?.id||k?._key||""),[n]);return d?jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(un,{field:{name:l,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:void 0},value:n.map(k=>k[l]).filter(Boolean),onChange:k=>{let E=(k||[]).map(S=>({[l]:S,id:Math.random().toString(36).substr(2,9)}));r(E);},disabled:a})]}):jsxs("div",{className:"kyro-form-field",children:[jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsx(DndContext,{sensors:C,collisionDetection:closestCenter,onDragEnd:x,children:h?jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/10 rounded-lg p-3",children:[jsx(SortableContext,{items:R,strategy:verticalListSortingStrategy,children:n.map((k,E)=>jsx(Iu,{id:k.id||k._key||`idx-${E}`,index:E,isOpen:false,setOpenIndex:()=>{},item:k,field:e,renderField:o,onChangeItem:S=>{let D=[...n];D[E]=S,r(D);},onRemove:()=>r(n.filter((S,D)=>D!==E)),disabled:a,compact:true,getItemLabel:b},k.id||k._key||E))}),jsx("button",{type:"button",className:"w-full py-2.5 border border-dashed border-[var(--kyro-border)] rounded-md text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] bg-[var(--kyro-surface)]/50 transition-all disabled:opacity-50 mt-1",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:R,strategy:verticalListSortingStrategy,children:jsx("div",{className:"space-y-2",children:n.map((k,E)=>{let S=c===E;return jsx(Iu,{id:k.id||k._key||`idx-${E}`,index:E,isOpen:S,setOpenIndex:u,item:k,field:e,renderField:o,onChangeItem:D=>{let g=[...n];g[E]=D,r(g);},onRemove:()=>r(n.filter((D,g)=>g!==E)),disabled:a,compact:false,getItemLabel:b},k.id||k._key||E)})})}),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 k=Math.random().toString(36).substr(2,9);r([...n,{id:k}]),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=>{bs("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsx(ha,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "icon":return jsx(Ts,{field:e,value:t??void 0,onChange:d,error:o,disabled:a});case "textarea":return jsx(ha,{field:{...e,variant:"textarea"},value:t??void 0,onChange:d,error:o,disabled:a});case "password":return jsx(ha,{field:{...e,variant:"password"},value:t??void 0,onChange:d,error:o,disabled:a});case "secret":return jsx(Fs,{field:e,value:t??void 0,onChange:r,error:o,disabled:a});case "number":return jsx(Is,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "checkbox":return jsx(Ls,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsx(Bs,{field:e,value:t??void 0,onChange:d,error:o,disabled:a,formData:n,siblingData:i,collectionSlug:s,globalSlug:l});case "date":return jsx(Es,{field:e,value:t??void 0,onChange:r,disabled:a,error:o});case "richtext":return jsx(fa,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsx(Qi,{field:e,value:t??void 0,onChange:d,disabled:a,error:o});case "code":return jsx(cn,{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(un,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsx(pt,{field:e,error:o,children:jsx(gn,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsx(js,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,u,m)=>{let v=u[c.name];return jsx(jo,{field:c,value:v,onChange:f=>{m({...u,[c.name]:f});},disabled:a,error:o},c.name)}});case "blocks":return jsx(kl,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsx(Vs,{field:e,value:t,onChange:r,renderField:(c,u,m)=>{let v=u[c.name];return jsx(jo,{field:c,value:v,onChange:f=>{m({...u,[c.name]:f});},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 Eu=({title:e,description:t,slug:r,collectionSlug:o})=>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 ",o||"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 Mu({field:e,formData:t,collectionSlug:r,onTabDataChange:o,renderField:a}){let[n,i]=useState(0),s=e.tabs||[],l=s[n]||s[0],d=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:s.map((c,u)=>jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${n===u?"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:()=>i(u),children:c.label},u))})}),jsx("div",{className:"space-y-6",children:l?.fields.map(c=>a(c,e.name?d:t,e.name?o:void 0))}),l?.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(Eu,{title:String((typeof d.metaTitle=="object"?"":d.metaTitle)||(typeof d.title=="object"?"":d.title)||"Untitled"),description:String((typeof d.metaDescription=="object"?"":d.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug"),collectionSlug:r})]})]})}function Uo({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=useState(false),i=useRef(null),s=useRef(null),[l,d]=useState({}),[c,u]=useState(false);return useEffect(()=>{u(true);},[]),useEffect(()=>{if(!a||!i.current)return;let v=i.current.closest("#kyro-sidebar")?.getAttribute("data-minimized")==="true",f=i.current.getBoundingClientRect();d(v?{left:f.right+12,bottom:Math.max(12,window.innerHeight-f.bottom)}:r==="right"?{right:Math.max(12,window.innerWidth-f.right),bottom:o==="up"?Math.max(12,window.innerHeight-f.top+8):void 0,top:o==="down"?f.bottom+8:void 0}:{left:f.left,bottom:o==="up"?Math.max(12,window.innerHeight-f.top+8):void 0,top:o==="down"?f.bottom+8:void 0});let b=C=>{i.current&&!i.current.contains(C.target)&&s.current&&!s.current.contains(C.target)&&n(false);},h=()=>{n(false);};return document.addEventListener("mousedown",b),window.addEventListener("scroll",h,{capture:true,passive:true}),window.addEventListener("resize",h),()=>{document.removeEventListener("mousedown",b),window.removeEventListener("scroll",h,{capture:true}),window.removeEventListener("resize",h);}},[a,r,o]),jsxs("div",{className:"relative inline-block",ref:i,children:[jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&c&&createPortal(jsx("div",{ref:s,style:{position:"fixed",top:l.top!==void 0?`${l.top}px`:"auto",bottom:l.bottom!==void 0?`${l.bottom}px`:"auto",left:l.left!==void 0?`${l.left}px`:"auto",right:l.right!==void 0?`${l.right}px`:"auto"},className:"z-[99999] min-w-[220px] max-h-[80vh] overflow-y-auto py-2 bg-[var(--kyro-surface)] rounded-2xl shadow-2xl border border-[var(--kyro-border)] animate-in fade-in zoom-in-95 duration-100",onClick:()=>n(false),children:t}),document.body)]})}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 wn(){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",m=()=>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)]`,v=()=>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"})}),v()]}),a&&jsx(Uo,{trigger:jsx("button",{type:"button",className:m(),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 Hu({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:m,handleConflictOverride:v}){let{t:f}=H(),[b,h]=useState(Date.now()),[C,x]=useState(false),R=useRef(null),{formData:k,hasUnsavedChanges:E,autoSaveStatus:S,lastSavedAt:D,retryCount:g,view:p,setView:y,showPreview:w,setShowPreview:F,setFormData:L,markSaved:P,lastSavedData:$}=ge(),z=!k.id;useEffect(()=>{let K=setInterval(()=>h(Date.now()),1e4);return ()=>clearInterval(K)},[]),useEffect(()=>{let K=he=>{R.current&&!R.current.contains(he.target)&&x(false);};if(C)return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[C]);let I=String(k.tabs?.title||(typeof k.title=="object"?"":k.title)||(typeof k.name=="object"?"":k.name)||"Untitled"),X=k.updatedAt?new Date(k.updatedAt).toLocaleString():"Just now",ee=k.createdAt?new Date(k.createdAt).toLocaleString():"Just now",ie=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",q=o?"Unpublished":r==="published"?"Published":"Draft",Q=r==="published"&&!E?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",pe=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",Ae=(K=false)=>jsxs(Fragment,{children:[S==="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"})]}),K?"Saving\u2026":"Saving draft..."]}),S==="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"}),K?"Saved":D?`Saved ${Math.floor((Date.now()-D)/6e4)}m ago`:"Draft saved"]}),S==="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"})]}),K?`Retry ${g}/5`:`Retrying save (${g}/5)`]}),S==="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"})]}),K?"Offline":"Offline \u2014 cached locally"]}),S==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:K?"Failed":"Draft save failed"}),S==="conflict"&&(K?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:()=>v?.(),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:f("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:()=>x(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(wn,{}),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"})]})]}),_=()=>C&&jsx("div",{ref:R,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:()=>x(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsx("button",{type:"button",onClick:()=>{let K=document.getElementById("schedule-datetime")?.value;K&&m(K);},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 ${pe}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Q}`}),q]})]}),jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsx(Ho,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"}),U(),_()]})]}),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(K=>jsx("button",{type:"button",onClick:()=>y(K),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${p===K?"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:K==="edit"?"Edit":K==="version"?"History":"API"},K))}),jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[Ae(true),E&&S!=="saving"&&S!=="retrying"&&S!=="conflict"&&jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument($,$);},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(!w),className:`p-1.5 rounded-lg transition-all ${w?"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 rounded-lg",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 ${pe}`,children:[jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Q}`}),ie]})]}),jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[Ae(false),E&&S!=="saving"&&S!=="retrying"&&S!=="conflict"&&jsxs(Fragment,{children:[jsx("span",{className:"opacity-30",children:"\u2014"}),jsx("button",{type:"button",onClick:()=>{ge.getState().loadDocument($,$);},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),D&&S!=="saving"&&S!=="retrying"&&S!=="success"&&jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let K=b-D,he=Math.floor(K/6e4),Me=Math.floor(K/1e3);return he>=1?`${he}m ago`:Me>=5?`${Me}s ago`:"just now"})()]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",X]}),jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ee]})]})]}),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(K=>jsx("button",{type:"button",onClick:()=>y(K),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${p===K?"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:K.toUpperCase()},K))}),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(!w),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${w?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:f("tooltips.livePreview",{defaultValue:"Live Preview"}),children:[jsx(ExternalLink,{className:"w-4 h-4"}),w&&jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),U(),_(),jsx(Ho,{status:r,saveStatus:a,hasChanges:E,onPublish:c,disabled:a==="saving"})]})]})]})]})}function _u({config:e,layout:t,collectionSlug:r,renderField:o}){let{t:a}=H(),{showPreview:n,sidebarCollapsed:i,formData:s,previewUrl:l}=ge();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 rounded-lg",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 rounded-lg",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 rounded-lg",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 Ku({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}=ge();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((m,v)=>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:m.field}),jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof m.oldValue=="object"?JSON.stringify(m.oldValue):String(m.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 m.newValue=="object"?JSON.stringify(m.newValue):String(m.newValue??"null")]})]},v))})]}),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((m,v)=>{let f=n.includes(m.id),b=(m.changeDescription||"").toLowerCase().includes("auto");return jsxs("div",{onClick:o?()=>r(m.id):void 0,className:`transition-all ${o?f?"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 ${f?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:f&&jsx(Check,{className:"w-4 h-4"})}):jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:u.length-v})}),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:[m.changeDescription||"Snapshot",b&&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(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsx("div",{className:"col-span-3",children:m.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${m.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]})}),jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:m.createdBy||"system"}),jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsx("button",{type:"button",onClick:()=>e(m.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 ${f?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:f&&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-v})}),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:[m.changeDescription||"Snapshot",b&&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(m.createdAt||m.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),m.status&&jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${m.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsx("span",{className:`w-1 h-1 rounded-full ${m.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),m.status]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:m.createdBy||"system"})]})]}),!o&&jsx("button",{type:"button",onClick:()=>e(m.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"})]})]},m.id)})})]})})}function Gu({collectionSlug:e,globalSlug:t}){let{t:r}=H(),{formData:o}=ge();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 Gs=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=ge.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(()=>{V.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 Wu(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 Sl(e,t,r){if(!e)return true;if("and"in e&&Array.isArray(e.and))return e.and.every(o=>Sl(o,t,r));if("or"in e&&Array.isArray(e.or))return e.or.some(o=>Sl(o,t,r));if("field"in e&&e.field){let o=e.field,a=Wu(t,o);return a===void 0&&(a=Wu(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 qu={};function Nn({config:e,data:t=qu,errors:r=qu,onChange:o,disabled:a,collectionSlug:n,globalSlug:i,documentId:s,documentName:l,layout:d="split",onActionSuccess:c,onActionError:u,justSaved:m}){let v=e||(i?bc[i]:n?ca[n]:null),[f,b]=useState(v);useEffect(()=>{i&&!v?Ie("/api/kyro/schema").then(M=>{let te=M;te?.globals?.[i]&&b(te.globals[i]);}).catch(M=>console.error("[AutoForm] Failed to fetch dynamic schema",M)):b(v);},[i,v]);let h=f||v,{confirm:C}=vt(),{formData:x,hasUnsavedChanges:k,autoSaveStatus:D,lastSavedAt:g,view:z,setView:I,setShowPreview:pe,isMenuOpen:Ae,setIsMenuOpen:U,loadingFields:_,setLoadingFields:K,compareSelected:ke,setCompareSelected:N,setCompareDiffs:we,setLoadingDiffs:je,setField:Le,setFormData:ft,setLastSavedData:oe,setAutoSaveStatus:j,fetchVersions:Y,saveDocument:le,forceSave:Te,autoSaveSkipRef:$e,lastAutoSaveTimeRef:Tt,documentStatus:gr,hasUnpublishedChanges:Or,versionsEnabled:O}=Cc({config:h,initialData:t,collectionSlug:n,globalSlug:i,documentId:s,onChange:o,onActionSuccess:c,onActionError:u}),ae=useRef(null),ue=useRef(null),[Ht,Wo]=useState(false),[ti,T]=useState("idle"),[ve,Ue]=useState(false),[nr,Ot]=useState(Date.now()),Sr=a,[ri,qo]=useState(false),[$p,oi]=useState(false),[Op,Vp]=useState(0),Il=useRef(new Map),jp=3e4;useEffect(()=>{let M=i?`global:${i}`:`${n}:${s}`;if(!(i||n&&s&&s!=="new")||t&&Object.keys(t).length>0)return;let Ce=Il.current.get(M),Ge=Ce&&Date.now()-Ce.ts<jp,Ct=Ce&&!Ge;if(Ge){ge.getState().loadDocument(Ce.data,Ce.data);return}Ct&&ge.getState().loadDocument(Ce.data,Ce.data);let St=new AbortController;oi(false),Ce||qo(true);let Vr=i?`/api/globals/${i}`:`/api/${n}/${s}`;return Ie(Vr,{autoToast:false,signal:St.signal}).then(bt=>{let Ao=bt.data||{};Il.current.set(M,{data:Ao,ts:Date.now()}),ge.getState().loadDocument(Ao,Ao),qo(false);}).catch(bt=>{bt.name!=="AbortError"&&(qo(false),Ce||oi(true));}),()=>St.abort()},[n,s,i,t,Op]),useEffect(()=>{let M=setInterval(()=>Ot(Date.now()),1e4);return ()=>clearInterval(M)},[]);let Ll=(M,te)=>{if(typeof M=="function")try{return M(x,te)}catch(Ce){return console.warn("Error evaluating admin runtime flag:",Ce),false}return !!M},Up=M=>{C({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let te=i?Ye(`/api/globals/${i}/versions/${M}/restore`):Ye(`/api/${n}/${x.id}/versions/${M}/restore`),Ce=await ct(te,{method:"POST"});!Ce.ok&&n&&(Ce=await ct(Ye(`/api/${n}/${x.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:M,action:"restore"})}));let Ge=await Ce.json();if(Ge.data){let{updatedAt:Ct,createdAt:St,...Vr}=Ge.data,bt={...x,...Vr};ft(bt),ge.getState().loadDocument(bt,bt),c?.("Version restored successfully"),Y(),I("edit");}else V.error(Ge.error||"Failed to restore version");}catch(te){console.error("Failed to restore version:",te),V.error("Failed to restore version");}}});},zp=async()=>{if(ke.length===2){je(true);try{let te=await(await ct(Ye(`/api/${n}/${x.id}/versions?compareA=${ke[0]}&compareB=${ke[1]}`))).json();we(te.diffs||[]);}catch(M){console.error("Compare failed:",M),we([]);}finally{je(false);}}},Hp=M=>{N(te=>te.includes(M)?te.filter(Ce=>Ce!==M):te.length>=2?[te[1],M]:[...te,M]);};useEffect(()=>{let M=te=>{(te.metaKey||te.ctrlKey)&&te.key==="s"&&(te.preventDefault(),Sn()),(te.metaKey||te.ctrlKey)&&te.shiftKey&&(te.key==="P"||te.key==="p")&&(te.preventDefault(),document.getElementById("btn-publish")?.click()),(te.metaKey||te.ctrlKey)&&!te.shiftKey&&te.key==="p"&&(te.preventDefault(),pe(Ce=>!Ce)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(te.key==="1"&&I("edit"),te.key==="2"&&I("version"),te.key==="3"&&I("api"));};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[]),useEffect(()=>{let M=()=>I("version");return window.addEventListener("kyro:show-version-history",M),()=>window.removeEventListener("kyro:show-version-history",M)},[]),useEffect(()=>{let M=te=>{ae.current&&!ae.current.contains(te.target)&&U(false);};if(Ae)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[Ae]),useEffect(()=>{let M=te=>{ue.current&&!ue.current.contains(te.target)&&Wo(false);};if(Ht)return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[Ht]);let _p=()=>{k?C({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await Sn(),await new Promise(M=>setTimeout(M,1e3)),Lt(`${_e}/${n}/new`);}}):Lt(`${_e}/${n}/new`);},Kp=()=>{if(!x.id){V.error("Please save the document before duplicating.");return}let M=async()=>{try{Ue(!0);let te=await ct(`/api/${n}/${x.id}/duplicate`,{method:"POST"});if(te.ok){let Ce=await te.json();c?.("Document duplicated successfully"),Ce.data?.id?Lt(`${_e}/${n}/${Ce.data.id}`):Lt(`${_e}/${n}`);}else {let Ce=await te.json();V.error(Ce.error||"Failed to duplicate");}}catch{V.error("Failed to duplicate document");}finally{Ue(false);}};if(k){C({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await Sn(),await M();}});return}C({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await M();}});},Gp=()=>{C({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{$e.current=true;try{await Dt(`/api/${n}/${x.id}`),Lt(`${_e}/${n}`);}catch(M){V.error(M.message||"Failed to delete document");}finally{$e.current=false;}}});},Wp=()=>{C({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{$e.current=true;try{let M=await le({...x,status:"draft"},!1);if(M?.ok)c?.("Document unpublished successfully"),ge.getState().loadDocument({...x,status:"draft"},{...x,status:"draft"});else {let te=await M?.json().catch(()=>({}));V.error(te?.error||"Failed to unpublish");}}catch{V.error("Failed to unpublish");}finally{$e.current=false;}}});},Sn=async()=>{let M=!x.id;$e.current=true,T("saving");try{let te=qt({...x},!0),Ce=M&&!i,Ge=Ce?await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}):await le(te);if(Ge.ok){let Ct=await Ge.json(),St=Ct.data||te;ge.getState().loadDocument(St,St),Tt.current=Date.now(),j("success"),T("saved"),O&&Y(),setTimeout(()=>{j("idle"),T("idle");},2e3),c?.(Ce?"Document created successfully":"Changes saved"),V.success(Ce?"Document created successfully":"Changes saved successfully"),i&&window.dispatchEvent(new Event("kyro:soft-reload")),Ce&&setTimeout(()=>{Lt(`${_e}/${n}/${Ct.data.id}`);},800);}else {let Ct=await Ge.json();Ge.status===409&&j("conflict"),T("error"),V.error(Ct.error||"Failed to save"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),V.error("Failed to save document"),setTimeout(()=>T("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),$e.current=false;}},qp=async()=>{let M=!x.id;$e.current=true,T("saving");try{let te={...x};if(M&&!i){let Ct=qt({...x},!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&&j("conflict"),T("error"),V.error(Ao.error||"Failed to create document"),setTimeout(()=>T("idle"),3e3);return}let bt=(await St.json()).data||Ct;ge.getState().loadDocument(bt,bt),te=bt;}let Ce=qt(te,!0),Ge=await le(Ce,!1);if(Ge?.ok){let St=(await Ge.json().catch(()=>({}))).data||Ce;ge.getState().loadDocument(St,St),T("saved"),c?.("Published successfully"),V.success("Published changes successfully"),setTimeout(()=>{T("idle");},2e3),M&&!i&&te.id&&setTimeout(()=>{Lt(`${_e}/${n}/${te.id}`);},800);}else {if(M&&!i&&te.id){let St=await Ge?.json().catch(()=>({}));V.warning("Document saved as draft. Publishing failed: "+(St?.error||"Unknown error")),setTimeout(()=>{Lt(`${_e}/${n}/${te.id}`);},1200);return}let Ct=await Ge?.json().catch(()=>({}));Ge?.status===409&&j("conflict"),T("error"),V.error(Ct?.error||"Failed to publish"),setTimeout(()=>T("idle"),3e3);}}catch{T("error"),V.error("Failed to publish"),setTimeout(()=>T("idle"),3e3);}finally{$e.current=false;}},Jp=async M=>{let te=!x.id;$e.current=true;try{let Ce={...qt({...x},!0),_schedulePublishAt:M};if(te&&!i){let Ge=await ct(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ce)});if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));V.error(Ct.error||"Failed to schedule publish");return}}else {let Ge=await le(Ce);if(!Ge.ok){let Ct=await Ge.json().catch(()=>({}));V.error(Ct.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(M).toLocaleString()}`),Wo(!1);}catch{V.error("Failed to schedule publish");}finally{$e.current=false;}},Xp=(M,te)=>{Le(M,te);},Ua=(M,te,Ce)=>{let Ge=te!==void 0?te:x;if(Ll(M.hidden!==void 0?M.hidden:M.admin?.hidden,Ge))return null;let St=Ll(M.readOnly!==void 0?M.readOnly:M.admin?.readOnly,Ge),Vr=!!(Sr||St);if(M.admin?.condition){if(typeof M.admin.condition=="function")try{let dt={values:x||{},...x||{}};if(!M.admin.condition(dt,Ge))return null}catch(dt){console.warn(`Condition error for field ${M.name}:`,dt);}else if(typeof M.admin.condition=="object")try{if(!Sl(M.admin.condition,Ge,x))return null}catch(dt){console.warn(`Declarative condition error for field ${M.name}:`,dt);}}let bt=Ge[M.name],Ao=r[M.name],An=dt=>{Ce?Ce({...Ge,[M.name]:dt}):Xp(M.name,dt);};if(M.type==="row"&&"fields"in M){let dt=M.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||{},Tn=jr?.action;if((nt.type==="button"||nt.type==="action")&&Tn){let Ar=dt?.find(za=>za.type==="email");return jsx("div",{className:"flex-shrink-0",children:jsx("button",{type:"button",onClick:async()=>{let za=M.name,Dn=Ar?.name,Jo=Dn?x[Dn]:void 0;if(!Jo&&za&&typeof za=="string"&&Dn&&(Jo=x[za]?.[Dn]),!Jo){V.error("Please enter a test recipient email address.");return}K(Tr=>({...Tr,[nt.name]:true}));try{let Tr=await ct(Ye(Tn),{method:jr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,email:Jo,testEmail:Jo,testEmailSection:{testEmail:Jo}})}),Xo={};try{Xo=await Tr.json();}catch{Xo={};}if(Tr.ok&&(Xo.success||Xo.message))c?.(Xo.message||"Test email sent successfully!");else {let Yp=Xo.error||`Request failed (${Tr.status})`;u?.(Yp);}}catch(Tr){u?.(Tr instanceof Error?Tr.message:"Error connecting to server");}finally{K(Tr=>({...Tr,[nt.name]:false}));}},disabled:_[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:_[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:Ua(nt,te,Ce)},nt.name)})},M.name||`row-${Math.random()}`)}switch(M.type){case "tabs":return jsx(Mu,{field:M,formData:x,collectionSlug:n,onTabDataChange:dt=>{M.name&&Le(M.name,dt);},renderField:(dt,nt,jr)=>Ua(dt,nt,jr)},M.name||"tabs-layout");case "group":return jsx(Vs,{field:M,value:bt,onChange:An,renderField:Ua},M.name);case "array":return jsx(js,{field:M,value:bt,onChange:An,renderField:Ua,disabled:Vr},M.name);case "button":case "action":{let dt=M.name,nt=_[dt];return jsx("div",{className:"kyro-form-field",children:jsxs("button",{type:"button",disabled:nt||Vr,onClick:async()=>{let jr=M.admin?.action||M.action,Tn=M.admin?.method||M.method||"POST";if(jr){K(Ar=>({...Ar,[dt]:true}));try{let Ar=await ct(jr,{method:Tn,headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});await Ar.json(),Ar.ok;}catch(Ar){console.error("Error executing action:",Ar);}finally{K(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...":M.label||"Click"]})},dt)}case "relationship-block":return jsxs("div",{className:"kyro-form-field",children:[jsxs("label",{className:"kyro-form-label",children:[M.label||M.name,M.required&&jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsx(tn,{relationTo:M.relationTo,hasMany:M.hasMany,selectedIds:Array.isArray(bt)?bt:bt?[bt]:[],onChange:(dt,nt)=>{An(nt);},compact:true}),M.admin?.description?jsx("p",{className:"kyro-form-help",children:String(M.admin?.description)}):null]},M.name);default:return jsx(jo,{field:M,value:bt,onChange:An,error:Ao,disabled:Vr,formData:x,siblingData:Ge,collectionSlug:n,globalSlug:i},M.name||Math.random().toString())}};return ri||!h?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})})]}):$p?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:()=>{oi(false),qo(true),Vp(M=>M+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(Hu,{collectionSlug:n,globalSlug:i,documentStatus:gr||"draft",hasUnpublishedChanges:Or,localSaveStatus:ti,isDuplicating:ve,handleCreateNew:_p,handleDuplicate:Kp,handleUnpublish:Wp,handleDelete:Gp,handlePublish:qp,handleSaveDraft:Sn,handleSchedulePublish:Jp,handleConflictOverride:()=>Te()}),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:[D==="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..."]}),D==="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"]}),D==="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..."]}),D==="offline"&&jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),D==="error"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),D==="conflict"&&jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),k&&D!=="saving"&&D!=="retrying"&&D!=="conflict"&&jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!k&&D!=="success"&&D!=="saving"&&D!=="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:x.updatedAt?`Modified ${new Date(x.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()=>{$e.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let M=await le(x);if(M.ok){let Ce=(await M.json()).data||x;ft({...x,...Ce}),oe({...x,...Ce}),c?.("Changes saved"),i&&window.dispatchEvent(new Event("kyro:soft-reload"));}}catch(M){console.error("Save error exception:",M),u?.("Save failed: "+M.message);}finally{$e.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxs(Gs,{children:[z==="edit"&&jsx(_u,{config:h,layout:d,collectionSlug:n,renderField:Ua}),z==="version"&&jsx(Ku,{handleRestoreVersion:Up,handleCompareVersions:zp,toggleCompareSelection:Hp}),z==="api"&&jsx(Gu,{collectionSlug:n,globalSlug:i})]})})]})}var Ju={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function Al({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:m,updatedAt:v,onCopyData:f,onPasteData:b}){let{t:h}=H(),C=ge(y=>y.view)||"edit",x=ge(y=>y.setView),[R,k]=useState(false),E=useRef(null);useEffect(()=>{let y=w=>{E.current&&!E.current.contains(w.target)&&k(false);};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);let S=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,D=["edit","version","api"],g=S(),p="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 ${Ju[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:D.map(y=>jsx("button",{type:"button",onClick:()=>x(y),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${C===y?"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:y==="edit"?"Edit":y==="version"?"Ver":"API"},y))}),jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[l&&jsx("button",{type:"button",onClick:l,className:`${p} max-md:hidden`,title:h("tooltips.preview",{defaultValue:"Preview"}),children:jsx(Eye,{className:"w-3.5 h-3.5"})}),s&&jsx("button",{type:"button",onClick:s,className:`${p} max-md:hidden`,title:h("tooltips.viewHistory",{defaultValue:"View History"}),children:jsx(Clock,{className:"w-3.5 h-3.5"})}),i&&jsx("button",{type:"button",onClick:i,className:`${p} max-md:hidden`,title:h("tooltips.duplicate",{defaultValue:"Duplicate"}),children:jsx(Copy,{className:"w-3.5 h-3.5"})}),f&&jsx("button",{type:"button",onClick:f,className:`${p} max-md:hidden`,title:h("tooltips.copyData",{defaultValue:"Copy Data"}),children:jsx(ClipboardCopy,{className:"w-3.5 h-3.5"})}),b&&jsx("button",{type:"button",onClick:b,className:`${p} max-md:hidden`,title:h("tooltips.pasteData",{defaultValue:"Paste Data"}),children:jsx(ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsx("button",{type:"button",onClick:d,className:`${p} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:h("tooltips.delete",{defaultValue:"Delete"}),children:jsx(Trash2,{className:"w-3.5 h-3.5"})}),u&&jsx("button",{type:"button",onClick:u,className:`${p} max-md:hidden`,title:h("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:E,className:"relative md:hidden",children:[jsx("button",{type:"button",onClick:()=>k(!R),className:p,title:h("tooltips.more",{defaultValue:"More"}),children:jsx(EllipsisVertical,{className:"w-3.5 h-3.5"})}),R&&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 ${Ju[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:D.map(y=>jsx("button",{type:"button",onClick:()=>{x(y),k(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${C===y?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:y==="edit"?"Edit":y==="version"?"Ver":"API"},y))}),s&&jsxs("button",{type:"button",onClick:()=>{s(),k(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(),k(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"]}),f&&jsxs("button",{type:"button",onClick:()=>{f(),k(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"]}),b&&jsxs("button",{type:"button",onClick:()=>{b(),k(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(),k(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(),k(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"}),f&&jsx(Ft,{icon:jsx(ClipboardCopy,{className:"w-4 h-4"}),onClick:f,children:"Copy Data"}),b&&jsx(Ft,{icon:jsx(ClipboardPaste,{className:"w-4 h-4"}),onClick:b,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||f||b||s||l)&&jsx(wn,{}),d&&jsx(Ft,{onClick:d,danger:true,icon:jsx(Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function Tl({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(),[m,v]=useState({}),[f,b]=useState({}),[h,C]=useState(true),[x,R]=useState(false),[k,E]=useState(false),[S,D]=useState(false),[g,p]=useState("idle"),[y,w]=useState("draft"),[F,L]=useState(null),[P,$]=useState(null),[z,I]=useState(null),[X,ee]=useState(false),ie=ge(j=>j.showPreview),q=ge(j=>j.setShowPreview),Q=ge(j=>j.previewUrl),pe=ge(j=>j.setPreviewUrl),Ae=r?.fields||t?.fields||[],U=r?.label||t?.label||"Document",_=r?.slug||t?.slug||"",K=JSON.stringify(m)!==JSON.stringify(f);useEffect(()=>{K&&y==="published"&&w("draft");},[K,y]),useEffect(()=>{K&&g==="saved"&&p("idle");},[K,g]),useEffect(()=>{l==="global"?Me():o&&he();},[o,l,_]);let he=async()=>{try{C(!0);let j=await Ie(`/api/${_}/${o}`,{autoToast:!1}),Y=j.data||{};v(Y),b(Y),w(Y?.status||j.status||"draft"),L(j.createdAt||Y.createdAt||null),$(j.updatedAt||Y.updatedAt||null),I(j.publishedAt||Y.publishedAt||null);}catch{s("Failed to load document");}finally{C(false);}},Me=async()=>{try{C(!0);let j=await Ie(`/api/globals/${_}`,{autoToast:!1}),Y=j.data||{};v(Y),b(Y),L(j.createdAt||null),$(j.updatedAt||null);}catch{s("Failed to load global");}finally{C(false);}},ke=useCallback(async(j=false)=>{try{p("saving");let Y=l==="global"?`/api/globals/${_}`:`/api/${_}/${o}`,le=y==="draft"||m?.status==="draft",Te=await er(Y,m,{autoToast:!1,headers:{"X-Draft":String(le)}}),$e=Te&&(Te.data||Te)||m;j||(b($e),n()),v($e),w($e?.status||y),p("saved"),$(new Date().toISOString()),ee(!0),setTimeout(()=>ee(!1),3e3),j||(y==="draft"||$e?.status==="draft"?V.warning(d("toast.draftSaved",{defaultValue:"Draft saved"})):V.success(d("toast.updated",{defaultValue:"Updated"}))),setTimeout(()=>{p("idle");},2e3),ie&&ft($e);}catch{p("error"),j||(s(d("toast.saveError",{defaultValue:"Failed to save changes"})),V.error(d("toast.saveError",{defaultValue:"Failed to save changes"})));}finally{R(false);}},[m,l,_,o,y,n,s]),N=async()=>{try{R(!0),await er(`/api/${_}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),w("published"),I(new Date().toISOString()),V.success(d("toast.published",{defaultValue:"Published successfully"})),n();}catch{s(d("toast.publishError",{defaultValue:"Failed to publish"})),V.error(d("toast.publishError",{defaultValue:"Failed to publish"}));}finally{R(false);}},G=async()=>{try{R(!0),await er(`/api/${_}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),w("draft"),V.warning(d("toast.unpublished",{defaultValue:"Document unpublished"})),n();}catch{s(d("toast.unpublishError",{defaultValue:"Failed to unpublish"})),V.error(d("toast.unpublishError",{defaultValue:"Failed to unpublish"}));}finally{R(false);}},we=async()=>{try{E(!0);let j=await ut(`/api/${_}/${o}/duplicate`,void 0,{autoToast:!1});V.success(d("toast.duplicated",{defaultValue:"Document duplicated"})),j?.data?.id?Lt(`${_e}/${_}/${j.data.id}`):Lt(`${_e}/${_}`);}catch(j){V.error(j.message||d("toast.duplicateError",{defaultValue:"Failed to duplicate document"}));}finally{E(false);}},Ve=async()=>{try{let j={...m};delete j.id,delete j.createdAt,delete j.updatedAt,delete j.status,await navigator.clipboard.writeText(JSON.stringify(j)),V.success(d("toast.dataCopied",{defaultValue:"Document data copied to clipboard"}));}catch{V.error(d("toast.copyError",{defaultValue:"Failed to copy document data"}));}},je=async()=>{try{let j=await navigator.clipboard.readText(),Y=JSON.parse(j);if(typeof Y!="object"||Y===null)throw new Error("Invalid format");v(le=>({...le,...Y,id:le.id,createdAt:le.createdAt,updatedAt:le.updatedAt,status:le.status})),V.success(d("toast.dataPasted",{defaultValue:"Document data pasted"}));}catch{V.error(d("toast.pasteError",{defaultValue:"Clipboard does not contain valid document JSON"}));}},Le=()=>{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{D(!0),await Dt(`/api/${_}/${o}`),Lt(`${_e}/${_}`);}catch{D(false);}}});},ft=async(j=m)=>{try{let Y=l==="global"?`/api/globals/${_}/preview-url`:`/api/${_}/preview-url`;console.log("[Kyro Preview] Calling endpoint:",Y,"with data keys:",Object.keys(j||{}),"documentId:",o);let le=await ut(Y,{...j,id:o},{autoToast:!1});console.log("[Kyro Preview] Response:",JSON.stringify(le)),le&&le.url?(console.log("[Kyro Preview] Setting previewUrl:",le.url),pe(le.url)):console.warn("[Kyro Preview] No url in response:",le);}catch(Y){console.error("[Kyro Preview] Error:",Y.message,Y),V.error(Y.message||"Failed to generate preview URL");}};useEffect(()=>{ie&&ft(m);},[ie]);let Cr=()=>{let j=!ie;q(j),j&&ft(m);};if(h)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}/${_}`: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,m,t?.admin?.useAsTitle||"title")||m.name||o||d("detailView.newDocument",{defaultValue:"New {{label}}",label:t?.singularLabel||U}),metadata:[jsx(Et,{variant:y==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:d(`status.${y}`,{defaultValue:y})},"status")]}),jsx(Al,{status:y,saveStatus:g,hasChanges:K,onSave:()=>ke(false),onPublish:N,onUnpublish:y==="published"?G:void 0,onDuplicate:we,onCopyData:Ve,onPasteData:je,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:t?.admin?.disablePreview||r?.admin?.disablePreview?void 0:Cr,onDelete:Le,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:z,updatedAt:P}),jsxs("div",{className:ie?"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 ${ie?"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(Nn,{config:t?{...t,fields:Ae}:{slug:"unknown",fields:Ae},data:m,onChange:v,layout:oe?"single":"split",globalSlug:l==="global"?_:void 0,collectionSlug:l==="collection"?_:void 0,onActionSuccess:j=>V.success(j),onActionError:j=>V.error(j),documentStatus:y,justSaved:X}),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:Le,disabled:S||x,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:S?d("actions.deleting",{defaultValue:"Deleting..."}):d("actions.deleteDocument",{defaultValue:"Delete Document"})}),jsx(Ho,{status:y,saveStatus:x?"saving":"idle",hasChanges:K,onPublish:()=>ke(false),disabled:x})]})]})}),ie&&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:Q||d("detailView.generatingPreview",{defaultValue:"Generating preview URL..."})}),jsx("div",{className:"w-16"})]}),jsx("div",{className:"flex-1 bg-white relative",children:Q?jsx("iframe",{src:Q,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&&!ie&&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 ${y==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:y||"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:P?new Date(P).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:we,disabled:k||x,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:k?d("actions.duplicating",{defaultValue:"Duplicating..."}):d("actions.duplicateDocument",{defaultValue:"Duplicate Document"})}),Q&&jsx("button",{type:"button",onClick:()=>window.open(Q,"_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:Le,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 Dl({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 m=>{try{l(!0),await ut(`/api/${t.slug}`,n),V.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(v){a(v instanceof Error?v.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(Nn,{config:{...t,fields:d},data:n,onChange:i})})})})})]})}function qs(){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(Lc,{type:r.type,message:r.message,duration:r.duration,onClose:()=>t(r.id)})},r.id))})}function Rl({onAuth:e,theme:t="light"}){let{t:r}=H(),[o,a]=useState("login"),[n,i]=useState(""),[s,l]=useState(""),[d,c]=useState(""),[u,m]=useState(false),[v,f]=useState(false),b=Zt(x=>x.addToast);useEffect(()=>{h();},[]);let h=async()=>{try{await Ie("/api/users");}catch{f(true),a("register");}},C=async x=>{x.preventDefault(),m(true);try{let R=o==="login"?"/api/auth/login":"/api/auth/register",k={email:n,password:s};o==="register"&&(k.confirmPassword=d);let E=await ut(R,k);E.isFirstUser&&f(!0),localStorage.setItem("kyro_user",JSON.stringify(E.user)),b("success",o==="login"?r("toast.welcomeBack",{defaultValue:"Welcome back!"}):r("toast.accountCreated",{defaultValue:"Account created!"})),e(E.token,E.user);}catch{b("error",r("toast.connectionFailed",{defaultValue:"Connection failed"}));}finally{m(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:v?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:v?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:C,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:x=>i(x.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:x=>l(x.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:x=>c(x.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"})})]}),!v&&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(qs,{})]})})}function Zu({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])=>!Bi.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 rounded-lg 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 tp(){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,m]=useState(""),[v,f]=useState(false),{confirm:b,alert:h}=vt(),[C,x]=useState(()=>typeof window<"u"&&window.__kyroAuth?.user?.role||"");useEffect(()=>{R(),window.__kyroAuth?.user?.role?x(window.__kyroAuth.user.role):Ie("/api/auth/me").then(y=>{y?.user?.role&&x(y.user.role);}).catch(()=>{});let p=y=>{y.detail?.user?.role&&x(y.detail.user.role);};return window.addEventListener("kyro:auth-ready",p),()=>window.removeEventListener("kyro:auth-ready",p)},[]);let R=async()=>{try{a(!0);let p=await Ie("/api/users");r(p.docs||[]);}catch(p){console.error("Failed to load users:",p);}finally{a(false);}},k=p=>{let y=!p.locked;b({title:y?"Lock User Account?":"Unlock User Account?",message:y?`Are you sure you want to lock ${p.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${p.email}?`,variant:y?"danger":"success",onConfirm:async()=>{try{await er(`/api/users/${p.id}`,{locked:y}),r(w=>w.map(F=>F.id===p.id?{...F,locked:y}:F)),V.success(y?`Account locked: ${p.email}`:`Account restored: ${p.email}`);}catch(w){console.error("Failed to toggle user lock:",w),V.error("Failed to update account status");}}});},E=p=>{b({title:"Destroy User Account",message:`You are about to permanently delete ${p.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await Dt(`/api/users/${p.id}`),r(y=>y.filter(w=>w.id!==p.id)),V.success(`Identity purged: ${p.email}`);}catch(y){console.error("Failed to delete user:",y),V.error("Failed to delete user");}}});},S=async()=>{if(!d.email.trim()||!d.password.trim()){m("Email and password are required");return}f(true),m("");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"}),V.success("User created successfully"),R();}catch(p){let y=p instanceof Error?p.message:"Failed to create user";m(y),V.error(y);}finally{f(false);}},D=["super_admin","admin","editor","author","customer","guest"],g=t.filter(p=>p.email.toLowerCase().includes(n.toLowerCase())||p.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"}),m(""),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:p=>i(p.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((p,y)=>jsx("tr",{className:"animate-pulse",children:jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},y)):g.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"})})}):g.map(p=>jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${p.locked?"opacity-50 grayscale":""}`,children:[jsx("td",{className:"px-6 py-3.5",children:jsxs("div",{className:"flex items-center gap-3",children:[jsx(bv,{user:p}),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:p.name||p.email.split("@")[0]}),p.tenantId&&jsx(Et,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:p.tenantId})]}),jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:p.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:p.role})]})}),jsx("td",{className:"px-6 py-3.5",children:jsx(Et,{variant:p.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:p.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"}),p.lastLogin?new Date(p.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:()=>k(p),className:`p-1.5 rounded-lg border transition-all ${p.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:p.locked?"Restore Access":"Restrict Access",children:p.locked?jsx(LockOpen,{className:"w-3.5 h-3.5"}):jsx(Lock,{className:"w-3.5 h-3.5"})}),jsx("button",{onClick:()=>E(p),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"})})]})})]},p.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:p=>c({...d,name:p.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:p=>c({...d,email:p.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:p=>c({...d,password:p.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"}),(()=>{let p=C==="super_admin";return jsxs("div",{children:[jsx("select",{value:d.role,disabled:!p,onChange:y=>c({...d,role:y.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)] disabled:opacity-60 disabled:cursor-not-allowed",children:D.map(y=>jsx("option",{value:y,children:y},y))}),!p&&jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] mt-1 font-medium",children:"Only Super Admin can assign administrative roles."})]})})()]}),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:S,disabled:v,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:v?"Creating...":"Create User"})]})]})]})}function bv({user:e}){let[t,r]=useState(null);return useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Ie(`/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 rp(){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,m]=useState(false);useEffect(()=>{(async()=>{try{let h=await Ie("/api/globals/site-settings"),C=h.data||h;C&&Object.keys(C).length>0&&(C.siteName&&r(C.siteName),C.adminTitle&&a(C.adminTitle),C.primaryColor&&i(C.primaryColor),C.dashboardGreeting&&l(C.dashboardGreeting));}catch(h){console.error("Failed to load branding:",h);}})();},[]);let v=async()=>{c(true);try{await er("/api/globals/site-settings",{siteName:t,adminTitle:o,primaryColor:n,dashboardGreeting:s}),m(!0),V.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",n),setTimeout(()=>window.dispatchEvent(new Event("kyro:soft-reload")),800);}catch(b){V.error("Failed to save branding"),console.error(b);}finally{c(false);}},f=[{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:v,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:b=>r(b.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:b=>a(b.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:b=>l(b.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:f.map(b=>jsx("button",{type:"button",onClick:()=>i(b.hex),className:`aspect-square rounded-xl transition-all border-4 ${n===b.hex?"border-white ring-2 ring-[var(--kyro-primary)]":"border-transparent opacity-60 hover:opacity-100"}`,style:{backgroundColor:b.hex},title:b.name},b.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 Nv=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function ep({collections:e}){let{t}=H(),[r,o]=useState([]),[a,n]=useState(false),[i,s]=useState(null),[l,d]=useState(""),[c,u]=useState(null),[p,g]=useState(false),{confirm:f,alert:v}=vt(),[b,S]=useState(false),[w,R]=useState(""),k=async()=>{try{let y=await Le("/api/keys");o(y);}catch(y){console.error(y);}};useEffect(()=>{k();},[]);let E=async()=>{R(""),S(true);},A=async()=>{if(w.trim())try{await ut("/api/keys",{name:w}),k(),S(!1),R(""),U.success("API key generated");}catch(y){console.error(y),U.error("Failed to generate API key");}},x=y=>{f({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/${y}`),k(),U.success("API key revoked");}catch(h){console.error(h),U.error("Failed to revoke API key");}}});},m=async()=>{if(l){g(true);try{let h=await(await fetch(Ye(`/api/${l}`))).json();u(h);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{g(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:E,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(y=>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:y.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===y.id?y.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===y.id?null:y.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:i===y.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(y.key),U.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(y.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:()=>x(y.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"})})]})},y.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 ",Nv,"/"]}),jsx("input",{type:"text",value:l,onChange:y=>d(y.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:m,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(xv,{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:b,onClose:()=>S(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:w,onChange:y=>R(y.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:y=>y.key==="Enter"&&A()})]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>S(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:A,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 tp(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 f=await Le(e.endpoint),v=Array.isArray(f)?f:f.docs||[],b=e.transformLoad?e.transformLoad(v):v;r(b),e.onSuccess?.("load",b);}catch(f){let v=f instanceof Error?f.message:"Failed to load resources";i(v),e.onError?.("load",f);}finally{a(false);}},[e.endpoint,e.transformLoad]);useEffect(()=>{c();},[c]);let u=useCallback((f,v="item")=>{d({title:`Delete ${v}`,message:`Are you sure you want to delete this ${v.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`${e.endpoint}/${f}`),r(b=>b.filter(S=>S.id!==f)),e.onSuccess?.("delete",f),U.success(`${v} deleted`);}catch(b){let S=b instanceof Error?b.message:`Failed to delete ${v}`;U.error(S),e.onError?.("delete",b);}}});},[e.endpoint,d]),p=useCallback(async f=>{i(null);try{let v=await ut(e.endpoint,f);return r(b=>[v,...b]),l(!1),e.onSuccess?.("create",v),v}catch(v){let b=v instanceof Error?v.message:"Failed to create resource";throw i(b),e.onError?.("create",v),v}},[e.endpoint]),g=useCallback(async(f,v)=>{i(null);try{let b=await er(`${e.endpoint}/${f}`,v);return r(S=>S.map(w=>w.id===f?b:w)),e.onSuccess?.("update",b),b}catch(b){let S=b instanceof Error?b.message:"Failed to update resource";throw i(S),e.onError?.("update",b),b}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:p,update:g,isCreateModalOpen:s,setIsCreateModalOpen:l}}var Av={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function rp(){let{t:e}=H(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:i,setIsCreateModalOpen:s}=tp({endpoint:"/api/webhooks"}),{confirm:l}=vt(),[d,c]=useState(false),[u,p]=useState(false),[g,f]=useState(null),[v,b]=useState(null),[S,w]=useState({}),[R,k]=useState(true),[E,A]=useState("action"),[x,m]=useState("generic"),[y,h]=useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[N,F]=useState(""),[L,P]=useState(false),[$,z]=useState(null),[I,X]=useState([]),[ee,ie]=useState(false);useEffect(()=>{q();},[]);let q=async()=>{try{let C=await Le("/api/webhooks/actions");w(C.actions);}catch(C){console.error("Failed to load webhook actions:",C);}finally{k(false);}},Q=()=>{A("action"),m("generic"),h({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),F("");},pe=C=>{m(C),h(G=>({...G,action:C,config:{}})),A("config");},Se=(C,G)=>{h(we=>({...we,config:{...we.config,[C]:G}}));},j=async()=>{if(!y.name.trim()){F("Name is required");return}if(x==="generic"&&!y.url.trim()){F("URL is required for custom webhooks");return}let C=S[x];if(C){for(let G of C.configFields)if(G.required&&!y.config[G.name]?.trim()){F(`${G.label} is required`);return}}try{await o(y),Q(),U.success(`Webhook created: ${y.name}`);}catch(G){let we=G.message||"Failed to create webhook";F(we),U.error(we);}},_=async C=>{b(C),f(null),c(true);try{let G=await ut(`/api/webhooks/${C}/test`);f({success:!0,message:G.message||"Webhook triggered successfully"}),U.success("Test delivered successfully");}catch{f({success:false,message:"Failed to trigger webhook"});}},K=async(C,G)=>{try{let we=G==="active"?"paused":"active";await n(C,{status:we}),U.success(we==="active"?"Webhook activated":"Webhook paused");}catch(we){console.error(we),U.error("Failed to toggle webhook status");}},he=async C=>{z(C),P(true),ie(true);try{let G=await Le(`/api/webhooks/${C}/history`);X(G.docs||[]);}catch(G){console.error("Failed to load history:",G),U.error("Failed to load delivery history");}finally{ie(false);}},Me=[{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"}],ke=C=>S[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:()=>{Q(),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:()=>{Q(),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:ke(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||`${ke(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:()=>he(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:()=>_(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:()=>K(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&&E==="action",onClose:()=>s(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsx(Ir,{children:jsx("div",{className:"space-y-4",children:R?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(S).map(([C,G])=>jsxs("button",{type:"button",onClick:()=>pe(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:Av[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(we=>jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:we},we))})]},C))})})})}),jsxs(At,{open:i&&E==="config",onClose:()=>s(false),title:S[x]?.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:y.name,onChange:C=>h({...y,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)]"})]}),x==="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:y.url,onChange:C=>h({...y,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)]"})]}),x!=="generic"&&S[x]?.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:y.config[C.name]||"",onChange:G=>Se(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)),x==="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:y.secret,onChange:C=>h({...y,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)]"})]})]}),x!=="generic"&&S[x]?.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:S[x].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:Me.map(C=>jsxs("button",{type:"button",onClick:()=>{let G=y.events.includes(C.value)?y.events.filter(we=>we!==C.value):[...y.events,C.value];h({...y,events:G});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${y.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 ${y.events.includes(C.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:y.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))})]})]}),N&&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"}),N]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>A("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:j,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:g?jsxs("div",{className:"space-y-4",children:[jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${g.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:g.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:g.success?"Delivered":"Failed"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:g.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:L,onClose:()=>P(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsx(Ir,{children:jsx("div",{className:"space-y-4",children:ee?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:()=>P(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 np({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,g]=useState(false),[f,v]=useState([]),b=useRef(null),S=useRef(null);useEffect(()=>{e&&(d(""),u(0),v([]),g(false),setTimeout(()=>b.current?.focus(),100));},[e]);let w=useCallback(async P=>{if(!P||P.length<2){v([]);return}g(true);try{let z=await(await fetch(Ye(`/api/search?q=${encodeURIComponent(P)}&limit=15`))).json();z.results&&v(z.results);}catch($){console.error("Search error:",$),v([]);}finally{g(false);}},[]);if(useEffect(()=>(S.current&&clearTimeout(S.current),l.length>=2?S.current=setTimeout(()=>w(l),300):v([]),()=>{S.current&&clearTimeout(S.current);}),[l,w]),!e)return null;let R=Object.entries(r).filter(([P])=>s?.collections?.[P]?.read!==false).map(([P,$])=>({id:`col-${P}`,label:$.label||P,type:"collection",slug:P,icon:FileText})),k=Object.entries(o).filter(([P])=>s?.globals?.[P]?.read!==false).map(([P,$])=>({id:`global-${P}`,label:$.label||P,type:"global",slug:P,icon:Settings})),E=typeof document<"u"&&document.documentElement.classList.contains("dark"),A=i?.role==="admin",x=[{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:A},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:File,visible:A},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Shield,visible:A},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Database,visible:A},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Hexagon,visible:A},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Network,visible:A},{id:"action-theme",label:E?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:E?Sun:Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:LogOut,visible:true}].filter(P=>P.visible),m=f.map((P,$)=>({id:`doc-${P.collection}-${P.id}`,label:P.title,type:"document",collection:P.collection,label2:P.label,docId:P.id,icon:File,doc:P.doc})),y=l.length>=2?[...x,...R,...k,...m]:[...x,...R,...k],h=l===""?y:y.filter(P=>P.label.toLowerCase().includes(l.toLowerCase())),N=P=>{if(P.key==="ArrowDown")P.preventDefault(),u($=>($+1)%h.length);else if(P.key==="ArrowUp")P.preventDefault(),u($=>($-1+h.length)%h.length);else if(P.key==="Enter"){let $=h[c];$&&F($);}else P.key==="Escape"&&t();},F=P=>{P.type==="collection"?P.slug==="users"?a(P.slug,P.slug):a("list",P.slug):P.type==="global"?a("settings",P.slug):P.type==="document"?P.collection==="users"?a("users","users",P.docId):a("edit",P.collection,P.docId):P.type==="action"&&(P.view==="users"?a("users","users"):P.view==="media"?a("media","media"):a(P.view,P.view)),t();},L=()=>l===""?"Quick Actions & Collections":f.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:b,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:P=>d(P.target.value),onKeyDown:N}),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:h.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:L()}),h.map((P,$)=>jsxs("div",{onClick:()=>F(P),onMouseEnter:()=>u($),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${$===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 ${$===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsx(P.icon,{className:"w-4 h-4"})}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"font-bold text-sm",children:P.label}),P.type==="document"&&P.label2&&jsx("span",{className:`text-[10px] font-bold tracking-widest ${$===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:P.label2})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${$===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:P.type}),$===c&&jsx(ArrowRight,{className:"w-4 h-4 mr-2"})]})]},P.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 sp(){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(Ui,{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 Rv({config:e,theme:t="light",onThemeChange:r}){let[o,a]=useState(false),[n,i]=useState(null),s=useMemo(()=>fs(Za(e.collections)),[e.collections]),l=useMemo(()=>gs(Za(e.globals)),[e.globals]),[d,c]=useState(null),[u,p]=useState(null),[g,f]=useState("list"),[v,b]=useState(null),[S,w]=useState(false);useEffect(()=>{(async()=>{try{let x=await fetch("/api/users/me");if(x.ok){let m=await x.json();i(m),a(!0);}}catch(x){console.error("Auth check failed",x);}})();},[]),useEffect(()=>{if(o&&!d){let A=Object.keys(s)[0];A&&c(A);}},[o,s,d]);let R=(A,x=null,m=null)=>{f(A),x&&c(x),m&&b(m),w(false);};useEffect(()=>{let A=x=>{(x.metaKey||x.ctrlKey)&&x.key==="k"&&(x.preventDefault(),w(m=>!m));};return window.addEventListener("keydown",A),window.openCommandPalette=()=>w(true),()=>{window.removeEventListener("keydown",A),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(np,{isOpen:S,onClose:()=>w(false),collections:s,globals:l,onNavigate:R}),(()=>{let A=d?s[d]:null;switch(g){case "create":return A?jsx(Tl,{config:e,collection:A,onSuccess:()=>f("list"),onCancel:()=>f("list"),onError:x=>U.error(x)}):null;case "detail":return A&&v?jsx(Al,{config:e,collection:A,documentId:v,onBack:()=>f("list"),onSave:()=>{},onError:x=>U.error(x)}):null;case "users":return jsx(Qu,{});case "media":return jsx(Ss,{});case "branding":return jsx(Zu,{});case "developer":return jsx(ep,{collections:s});case "webhooks":return jsx(rp,{});default:return A?jsx(Li,{config:e,collection:A,onCreate:()=>f("create"),onEdit:x=>R("detail",d,x)}):jsx(Xu,{onNavigate:R,collections:s,user:n})}})()]})})}),jsx(sp,{}),jsx(qs,{})]})}):jsx(Pl,{onAuth:(A,x)=>{i(x),a(true);},theme:t})}function Fv({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(fi,{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 Vv({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 g=Date.parse(u);return isNaN(g)?"Invalid date":new Date(g).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 f=new Date().getTime()-p.getTime();if(f<0)return "Just now";let v=Math.floor(f/6e4),b=Math.floor(f/36e5),S=Math.floor(f/864e5);return v<1?"Just now":v<60?`${v}m ago`:b<24?`${b}h ago`:S<7?`${S}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(g=>g.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 dB({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 ei(e){return fr.ready.push(e),()=>{fr.ready=fr.ready.filter(t=>t!==e);}}function dp(e){return fr.beforeDeploy.push(e),()=>{fr.beforeDeploy=fr.beforeDeploy.filter(t=>t!==e);}}function cp(e){return fr.afterDeploy.push(e),()=>{fr.afterDeploy=fr.afterDeploy.filter(t=>t!==e);}}async function up(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 pp(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 mp(e,t){for(let r of fr.afterDeploy)try{await r(e,t);}catch{}}function gp(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function yp(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=`${gp(`/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 vp(e,t="POST"){let[r,o]=useState(false),[a,n]=useState(null);return {mutate:useCallback(async s=>{o(true),n(null);try{let l=gp(`/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 La=new Map;function Ea(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");La.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),La.set(e.name,e),e.apply&&e.apply({});}function bp(e){La.delete(e);}function hp(e){return La.get(e)}function xp(){return Array.from(La.values())}function kp(e){return Array.from(La.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Uv={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};Ea(Uv);var zv={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};Ea(zv);var Ba=new Map;function Ma(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");Ba.set(e.id,e);}function wp(e){Ba.delete(e);}function Np(e){return Ba.get(e)}function Cp(){return Array.from(Ba.values())}function Sp(e){return Array.from(Ba.values()).filter(t=>t.category===e)}function Ap(e){let t=Ba.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Hv=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)})]})},_v={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Hv};Ma(_v);var Gv=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)})]})},Wv={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Gv};Ma(Wv);var $a=new Map;function Oa(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");$a.set(e.id,e);}function Pp(e){$a.delete(e);}function Rp(e){return $a.get(e)}function Fp(){return Array.from($a.values())}function Ip(e){return Array.from($a.values()).find(t=>t.type===e)}function Lp(e,t){let r=$a.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsx(o,{...t})}var Xv=({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"})})},Yv={id:"sample-text",type:"text",label:"Sample Text",editor:Xv};Oa(Yv);var Zv=({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"})})},eb={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:Zv};Oa(eb);
|
|
117
|
-
export{
|
|
116
|
+
`}})]})]})]})}var Cv=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function op({collections:e}){let{t}=H(),[r,o]=useState([]),[a,n]=useState(false),[i,s]=useState(null),[l,d]=useState(""),[c,u]=useState(null),[m,v]=useState(false),{confirm:f,alert:b}=vt(),[h,C]=useState(false),[x,R]=useState(""),k=async()=>{try{let p=await Ie("/api/keys");o(p);}catch(p){console.error(p);}};useEffect(()=>{k();},[]);let E=async()=>{R(""),C(true);},S=async()=>{if(x.trim())try{await ut("/api/keys",{name:x}),k(),C(!1),R(""),V.success("API key generated");}catch(p){console.error(p),V.error("Failed to generate API key");}},D=p=>{f({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/${p}`),k(),V.success("API key revoked");}catch(y){console.error(y),V.error("Failed to revoke API key");}}});},g=async()=>{if(l){v(true);try{let y=await(await fetch(Ye(`/api/${l}`))).json();u(y);}catch{u({error:"Failed to fetch. Ensure the endpoint exists."});}finally{v(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:E,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(p=>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:p.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===p.id?p.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===p.id?null:p.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:i===p.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(p.key),V.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(p.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:()=>D(p.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"})})]})},p.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 ",Cv,"/"]}),jsx("input",{type:"text",value:l,onChange:p=>d(p.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:m||!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:[m?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(kv,{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:h,onClose:()=>C(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:x,onChange:p=>R(p.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:p=>p.key==="Enter"&&S()})]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>C(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:S,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 ap(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 f=await Ie(e.endpoint),b=Array.isArray(f)?f:f.docs||[],h=e.transformLoad?e.transformLoad(b):b;r(h),e.onSuccess?.("load",h);}catch(f){let b=f instanceof Error?f.message:"Failed to load resources";i(b),e.onError?.("load",f);}finally{a(false);}},[e.endpoint,e.transformLoad]);useEffect(()=>{c();},[c]);let u=useCallback((f,b="item")=>{d({title:`Delete ${b}`,message:`Are you sure you want to delete this ${b.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await Dt(`${e.endpoint}/${f}`),r(h=>h.filter(C=>C.id!==f)),e.onSuccess?.("delete",f),V.success(`${b} deleted`);}catch(h){let C=h instanceof Error?h.message:`Failed to delete ${b}`;V.error(C),e.onError?.("delete",h);}}});},[e.endpoint,d]),m=useCallback(async f=>{i(null);try{let b=await ut(e.endpoint,f);return r(h=>[b,...h]),l(!1),e.onSuccess?.("create",b),b}catch(b){let h=b instanceof Error?b.message:"Failed to create resource";throw i(h),e.onError?.("create",b),b}},[e.endpoint]),v=useCallback(async(f,b)=>{i(null);try{let h=await er(`${e.endpoint}/${f}`,b);return r(C=>C.map(x=>x.id===f?h:x)),e.onSuccess?.("update",h),h}catch(h){let C=h instanceof Error?h.message:"Failed to update resource";throw i(C),e.onError?.("update",h),h}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:u,create:m,update:v,isCreateModalOpen:s,setIsCreateModalOpen:l}}var Tv={generic:"\u{1F517}","github-push":"\u2699\uFE0F"};function np(){let{t:e}=H(),{items:t,loading:r,create:o,remove:a,update:n,isCreateModalOpen:i,setIsCreateModalOpen:s}=ap({endpoint:"/api/webhooks"}),{confirm:l}=vt(),[d,c]=useState(false),[u,m]=useState(false),[v,f]=useState(null),[b,h]=useState(null),[C,x]=useState({}),[R,k]=useState(true),[E,S]=useState("action"),[D,g]=useState("generic"),[p,y]=useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[w,F]=useState(""),[L,P]=useState(false),[$,z]=useState(null),[I,X]=useState([]),[ee,ie]=useState(false);useEffect(()=>{q();},[]);let q=async()=>{try{let N=await Ie("/api/webhooks/actions");x(N.actions);}catch(N){console.error("Failed to load webhook actions:",N);}finally{k(false);}},Q=()=>{S("action"),g("generic"),y({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),F("");},pe=N=>{g(N),y(G=>({...G,action:N,config:{}})),S("config");},Ae=(N,G)=>{y(we=>({...we,config:{...we.config,[N]:G}}));},U=async()=>{if(!p.name.trim()){F("Name is required");return}if(D==="generic"&&!p.url.trim()){F("URL is required for custom webhooks");return}let N=C[D];if(N){for(let G of N.configFields)if(G.required&&!p.config[G.name]?.trim()){F(`${G.label} is required`);return}}try{await o(p),Q(),V.success(`Webhook created: ${p.name}`);}catch(G){let we=G.message||"Failed to create webhook";F(we),V.error(we);}},_=async N=>{h(N),f(null),c(true);try{let G=await ut(`/api/webhooks/${N}/test`);f({success:!0,message:G.message||"Webhook triggered successfully"}),V.success("Test delivered successfully");}catch{f({success:false,message:"Failed to trigger webhook"});}},K=async(N,G)=>{try{let we=G==="active"?"paused":"active";await n(N,{status:we}),V.success(we==="active"?"Webhook activated":"Webhook paused");}catch(we){console.error(we),V.error("Failed to toggle webhook status");}},he=async N=>{z(N),P(true),ie(true);try{let G=await Ie(`/api/webhooks/${N}/history`);X(G.docs||[]);}catch(G){console.error("Failed to load history:",G),V.error("Failed to load delivery history");}finally{ie(false);}},Me=[{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"}],ke=N=>C[N||"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:()=>{Q(),s(true);},icon:Plus},{label:"Guide",onClick:()=>m(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:()=>{Q(),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(N=>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:N.name}),jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsx("span",{className:`text-[10px] font-medium ${N.status==="active"?"text-green-500":"text-amber-500"}`,children:N.status}),jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:ke(N.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:N.url,children:N.url||`${ke(N.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:[N.events.slice(0,3).map(G=>jsx(Et,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:G},G)),N.events.length>3&&jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",N.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"}),N.lastTriggered?`Last triggered ${new Date(N.lastTriggered).toLocaleDateString()}`:"Never triggered"]}),N.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:N.lastError,children:N.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:()=>he(N.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:()=>_(N.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:()=>K(N.id,N.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${N.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:N.status==="active"?"Pause":"Activate",children:N.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(N.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"})})]})]})},N.id))})]}),jsx(At,{open:i&&E==="action",onClose:()=>s(false),title:e("tooltips.newWebhook",{defaultValue:"New webhook"}),children:jsx(Ir,{children:jsx("div",{className:"space-y-4",children:R?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(C).map(([N,G])=>jsxs("button",{type:"button",onClick:()=>pe(N),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:Tv[N]||"\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(we=>jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:we},we))})]},N))})})})}),jsxs(At,{open:i&&E==="config",onClose:()=>s(false),title:C[D]?.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:p.name,onChange:N=>y({...p,name:N.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)]"})]}),D==="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:p.url,onChange:N=>y({...p,url:N.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)]"})]}),D!=="generic"&&C[D]?.configFields.map(N=>jsxs("div",{children:[jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[N.label," ",N.required&&jsx("span",{className:"text-red-500",children:"*"})]}),jsx("input",{type:"text",value:p.config[N.name]||"",onChange:G=>Ae(N.name,G.target.value),placeholder:N.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)]"})]},N.name)),D==="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:p.secret,onChange:N=>y({...p,secret:N.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)]"})]})]}),D!=="generic"&&C[D]?.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:C[D].envVars.map(N=>jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[N,"=..."]},N))})]}),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:Me.map(N=>jsxs("button",{type:"button",onClick:()=>{let G=p.events.includes(N.value)?p.events.filter(we=>we!==N.value):[...p.events,N.value];y({...p,events:G});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${p.events.includes(N.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 ${p.events.includes(N.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:p.events.includes(N.value)&&jsx(CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxs("div",{children:[jsx("div",{className:"text-xs font-medium",children:N.label}),jsx("div",{className:"text-[10px] opacity-40",children:N.description})]})]},N.value))})]})]}),w&&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"}),w]})]})}),jsxs(Kr,{children:[jsx("button",{type:"button",onClick:()=>S("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:v?jsxs("div",{className:"space-y-4",children:[jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${v.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:v.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:v.success?"Delivered":"Failed"}),jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:v.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:()=>m(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:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-2.5 rounded-lg text-sm font-medium",children:"Got it"})})]}),jsxs(At,{open:L,onClose:()=>P(false),title:e("tooltips.deliveryHistory",{defaultValue:"Delivery History"}),children:[jsx(Ir,{children:jsx("div",{className:"space-y-4",children:ee?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(N=>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:[N.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:N.event})]}),jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:new Date(N.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 ${N.status==="success"?"text-green-500":"text-red-500"}`,children:N.responseStatus||N.status})]}),jsxs("div",{children:[jsx("span",{className:"opacity-50",children:"Duration: "}),N.duration?`${N.duration}ms`:"-"]})]}),N.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:N.error}),N.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:N.responseBody})]},N.id))})})}),jsx(Kr,{children:jsx("button",{type:"button",onClick:()=>P(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 lp({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),[m,v]=useState(false),[f,b]=useState([]),h=useRef(null),C=useRef(null);useEffect(()=>{e&&(d(""),u(0),b([]),v(false),setTimeout(()=>h.current?.focus(),100));},[e]);let x=useCallback(async P=>{if(!P||P.length<2){b([]);return}v(true);try{let z=await(await fetch(Ye(`/api/search?q=${encodeURIComponent(P)}&limit=15`))).json();z.results&&b(z.results);}catch($){console.error("Search error:",$),b([]);}finally{v(false);}},[]);if(useEffect(()=>(C.current&&clearTimeout(C.current),l.length>=2?C.current=setTimeout(()=>x(l),300):b([]),()=>{C.current&&clearTimeout(C.current);}),[l,x]),!e)return null;let R=Object.entries(r).filter(([P])=>s?.collections?.[P]?.read!==false).map(([P,$])=>({id:`col-${P}`,label:$.label||P,type:"collection",slug:P,icon:FileText})),k=Object.entries(o).filter(([P])=>s?.globals?.[P]?.read!==false).map(([P,$])=>({id:`global-${P}`,label:$.label||P,type:"global",slug:P,icon:Settings})),E=typeof document<"u"&&document.documentElement.classList.contains("dark"),S=i?.role==="admin",D=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Image,visible:S||s?.collections?.media?.read===true},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Clock,visible:S},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:File,visible:S},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Shield,visible:S},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Database,visible:S},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Hexagon,visible:S},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Network,visible:S},{id:"action-theme",label:E?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:E?Sun:Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:LogOut,visible:true}].filter(P=>P.visible),g=f.map((P,$)=>({id:`doc-${P.collection}-${P.id}`,label:P.title,type:"document",collection:P.collection,label2:P.label,docId:P.id,icon:File,doc:P.doc})),p=l.length>=2?[...D,...R,...k,...g]:[...D,...R,...k],y=l===""?p:p.filter(P=>P.label.toLowerCase().includes(l.toLowerCase())),w=P=>{if(P.key==="ArrowDown")P.preventDefault(),u($=>($+1)%y.length);else if(P.key==="ArrowUp")P.preventDefault(),u($=>($-1+y.length)%y.length);else if(P.key==="Enter"){let $=y[c];$&&F($);}else P.key==="Escape"&&t();},F=P=>{P.type==="collection"?P.slug==="users"?a(P.slug,P.slug):a("list",P.slug):P.type==="global"?a("settings",P.slug):P.type==="document"?P.collection==="users"?a("users","users",P.docId):a("edit",P.collection,P.docId):P.type==="action"&&(P.view==="users"?a("users","users"):P.view==="media"?a("media","media"):a(P.view,P.view)),t();},L=()=>l===""?"Quick Actions & Collections":f.length>0?"Documents":m?"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:[m?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:h,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:P=>d(P.target.value),onKeyDown:w}),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:y.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:L()}),y.map((P,$)=>jsxs("div",{onClick:()=>F(P),onMouseEnter:()=>u($),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${$===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 ${$===c?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsx(P.icon,{className:"w-4 h-4"})}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"font-bold text-sm",children:P.label}),P.type==="document"&&P.label2&&jsx("span",{className:`text-[10px] font-bold tracking-widest ${$===c?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:P.label2})]})]}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${$===c?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:P.type}),$===c&&jsx(ArrowRight,{className:"w-4 h-4 mr-2"})]})]},P.id))]}):jsx("div",{className:"py-12 text-center",children:jsx("p",{className:"text-[var(--kyro-text-secondary)] italic opacity-60",children:l.length>=2&&!m?`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 dp(){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(Ui,{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 Fv({config:e,theme:t="light",onThemeChange:r}){let[o,a]=useState(false),[n,i]=useState(null),s=useMemo(()=>fs(en(e.collections)),[e.collections]),l=useMemo(()=>gs(en(e.globals)),[e.globals]),[d,c]=useState(null),[u,m]=useState(null),[v,f]=useState("list"),[b,h]=useState(null),[C,x]=useState(false);useEffect(()=>{(async()=>{try{let D=await fetch("/api/users/me");if(D.ok){let g=await D.json();i(g),a(!0);}}catch(D){console.error("Auth check failed",D);}})();},[]),useEffect(()=>{if(o&&!d){let S=Object.keys(s)[0];S&&c(S);}},[o,s,d]);let R=(S,D=null,g=null)=>{f(S),D&&c(D),g&&h(g),x(false);};useEffect(()=>{let S=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),x(g=>!g));};return window.addEventListener("keydown",S),window.openCommandPalette=()=>x(true),()=>{window.removeEventListener("keydown",S),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(lp,{isOpen:C,onClose:()=>x(false),collections:s,globals:l,onNavigate:R}),(()=>{let S=d?s[d]:null;switch(v){case "create":return S?jsx(Dl,{config:e,collection:S,onSuccess:()=>f("list"),onCancel:()=>f("list"),onError:D=>V.error(D)}):null;case "detail":return S&&b?jsx(Tl,{config:e,collection:S,documentId:b,onBack:()=>f("list"),onSave:()=>{},onError:D=>V.error(D)}):null;case "users":return jsx(tp,{});case "media":return jsx(Ss,{});case "branding":return jsx(rp,{});case "developer":return jsx(op,{collections:s});case "webhooks":return jsx(np,{});default:return S?jsx(Li,{config:e,collection:S,onCreate:()=>f("create"),onEdit:D=>R("detail",d,D)}):jsx(Zu,{onNavigate:R,collections:s,user:n})}})()]})})}),jsx(dp,{}),jsx(qs,{})]})}):jsx(Rl,{onAuth:(S,D)=>{i(D),a(true);},theme:t})}function Iv({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(fi,{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 jv({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 m=new Date(u);if(isNaN(m.getTime())){let v=Date.parse(u);return isNaN(v)?"Invalid date":new Date(v).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}return m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})},c=u=>{if(!u)return "Unknown date";let m=new Date(u);if(isNaN(m.getTime()))return d(u);let f=new Date().getTime()-m.getTime();if(f<0)return "Just now";let b=Math.floor(f/6e4),h=Math.floor(f/36e5),C=Math.floor(f/864e5);return b<1?"Just now":b<60?`${b}m ago`:h<24?`${h}h ago`:C<7?`${C}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 m=u.id===o;return jsxs("div",{className:`p-4 rounded-xl border transition-all duration-200 group relative overflow-hidden ${m?"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:[m&&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]}),m&&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(v=>v.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"})}),!m&&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 uB({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 ei(e){return fr.ready.push(e),()=>{fr.ready=fr.ready.filter(t=>t!==e);}}function pp(e){return fr.beforeDeploy.push(e),()=>{fr.beforeDeploy=fr.beforeDeploy.filter(t=>t!==e);}}function mp(e){return fr.afterDeploy.push(e),()=>{fr.afterDeploy=fr.afterDeploy.filter(t=>t!==e);}}async function fp(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 gp(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 yp(e,t){for(let r of fr.afterDeploy)try{await r(e,t);}catch{}}function bp(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function hp(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=`${bp(`/api/${e}`)}?${d.toString()}`,u=await fetch(c,{credentials:"include"});if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);let m=await u.json();o(m.data??m);}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 xp(e,t="POST"){let[r,o]=useState(false),[a,n]=useState(null);return {mutate:useCallback(async s=>{o(true),n(null);try{let l=bp(`/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 Ba=new Map;function Ma(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");Ba.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),Ba.set(e.name,e),e.apply&&e.apply({});}function kp(e){Ba.delete(e);}function wp(e){return Ba.get(e)}function Np(){return Array.from(Ba.values())}function Cp(e){return Array.from(Ba.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var zv={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};Ma(zv);var Hv={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};Ma(Hv);var $a=new Map;function Oa(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");$a.set(e.id,e);}function Sp(e){$a.delete(e);}function Ap(e){return $a.get(e)}function Tp(){return Array.from($a.values())}function Dp(e){return Array.from($a.values()).filter(t=>t.category===e)}function Pp(e){let t=$a.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var _v=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)})]})},Kv={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:_v};Oa(Kv);var Wv=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)})]})},qv={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Wv};Oa(qv);var Va=new Map;function ja(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");Va.set(e.id,e);}function Ip(e){Va.delete(e);}function Lp(e){return Va.get(e)}function Ep(){return Array.from(Va.values())}function Bp(e){return Array.from(Va.values()).find(t=>t.type===e)}function Mp(e,t){let r=Va.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsx(o,{...t})}var Yv=({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"})})},Qv={id:"sample-text",type:"text",label:"Sample Text",editor:Yv};ja(Qv);var eb=({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"})})},tb={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:eb};ja(tb);
|
|
117
|
+
export{Al as ActionBar,Fv as Admin,Nn as AutoForm,Et as Badge,Iv as BulkActionsBar,gi as Button,Ui as ConfirmModal,fi as CountBadge,Dl as CreateView,ln as DARK_THEME,Rs as DarkThemeProvider,Tl as DetailView,Uo as Dropdown,Ft as DropdownItem,wn as DropdownSeparator,Rs as ExtDarkThemeProvider,Ps as ExtLightThemeProvider,Lr as ExtThemeProvider,uB as Header,ga as LIGHT_THEME,Ps as LightThemeProvider,Li as ListView,Rl as LoginPage,At as Modal,jt as PageHeader,xr as SlidePanel,lr as Spinner,Lr as ThemeProvider,Lc as Toast,U2 as ToastProvider,jv as VersionHistoryPanel,_e as adminPath,mp as afterDeploy,Dr as apiPath,pp as beforeDeploy,fp as emitAdminReady,yp as emitAfterDeploy,gp as emitBeforeDeploy,Ap as getBlock,Tp as getBlocks,Dp as getBlocksByCategory,Lp as getField,Bp as getFieldByType,Ep as getFields,wp as getPlugin,Np as getPlugins,Cp as getPluginsWithHook,dn as mergeThemes,ei as onAdminReady,sm as paths,Oa as registerBlock,ja as registerField,Ma as registerPlugin,ai as resolveAdmin,Ye as resolveApi,Sp as unregisterBlock,Ip as unregisterField,kp as unregisterPlugin,Pp as useBlockRenderer,ya as useExtTheme,Mp as useFieldRenderer,xp as useKyroMutation,hp as useKyroQuery,ya as useTheme,Ec as useToast};
|