@kyro-cms/admin 0.11.6 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.cjs +25 -25
  2. package/dist/index.d.cts +4 -2
  3. package/dist/index.d.ts +4 -2
  4. package/dist/index.js +20 -20
  5. package/package.json +1 -1
  6. package/src/components/ActionBar.tsx +35 -5
  7. package/src/components/AutoForm.tsx +97 -40
  8. package/src/components/DetailView.tsx +41 -0
  9. package/src/components/FieldRenderer.tsx +11 -0
  10. package/src/components/GraphQLPlayground.tsx +259 -12
  11. package/src/components/MediaGallery.tsx +65 -51
  12. package/src/components/WebhookManager.tsx +338 -188
  13. package/src/components/autoform/AutoFormHeader.tsx +19 -9
  14. package/src/components/autoform/ErrorBoundary.tsx +93 -0
  15. package/src/components/blocks/HeadingSubheadingBlock.tsx +2 -2
  16. package/src/components/blocks/HeroBlock.tsx +2 -2
  17. package/src/components/fields/BlocksField.tsx +69 -17
  18. package/src/components/fields/HeadingSubheadingField.tsx +2 -2
  19. package/src/components/fields/HeroField.tsx +4 -4
  20. package/src/components/fields/IconField.tsx +79 -0
  21. package/src/components/fields/RelationshipField.tsx +2 -2
  22. package/src/components/fields/UploadField.tsx +7 -5
  23. package/src/components/fields/extensions/blocksStore.ts +1 -1
  24. package/src/components/fields/index.ts +1 -0
  25. package/src/components/ui/BlockDrawer.tsx +39 -0
  26. package/src/components/ui/IconPickerModal.tsx +80 -0
  27. package/src/components/ui/ImageFocalEditor.tsx +112 -71
  28. package/src/components/ui/Modal.tsx +4 -2
  29. package/src/components/ui/icons.tsx +1 -1
  30. package/src/hooks/useAutoFormState.ts +51 -1
  31. package/src/integration.ts +4 -4
  32. package/src/pages/settings/[slug].astro +1 -1
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var Ca=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),react=require('@tiptap/react'),Dp=require('@tiptap/starter-kit'),Pp=require('@tiptap/extension-link'),Ip=require('@tiptap/extension-image'),Bp=require('@tiptap/extension-text-align'),Lp=require('@tiptap/extension-underline'),Mp=require('@tiptap/extension-highlight'),Ep=require('@tiptap/extension-task-list'),$p=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),Up=require('@tiptap/extension-color'),hp=require('react-image-crop');require('react-image-crop/dist/ReactCrop.css');var codemirrorThemeGithub=require('@uiw/codemirror-theme-github'),codemirrorThemeAura=require('@uiw/codemirror-theme-aura'),unstorage=require('unstorage'),km=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Do=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Zu=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var yr=require('path'),url=require('url'),esbuild=require('esbuild'),dotenv=require('dotenv'),worker_threads=require('worker_threads');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Ca__default=/*#__PURE__*/_interopDefault(Ca);var Dp__default=/*#__PURE__*/_interopDefault(Dp);var Pp__default=/*#__PURE__*/_interopDefault(Pp);var Ip__default=/*#__PURE__*/_interopDefault(Ip);var Bp__default=/*#__PURE__*/_interopDefault(Bp);var Lp__default=/*#__PURE__*/_interopDefault(Lp);var Mp__default=/*#__PURE__*/_interopDefault(Mp);var Ep__default=/*#__PURE__*/_interopDefault(Ep);var $p__default=/*#__PURE__*/_interopDefault($p);var Up__default=/*#__PURE__*/_interopDefault(Up);var hp__default=/*#__PURE__*/_interopDefault(hp);var km__default=/*#__PURE__*/_interopDefault(km);var Do__default=/*#__PURE__*/_interopDefault(Do);var Zu__default=/*#__PURE__*/_interopDefault(Zu);var yr__default=/*#__PURE__*/_interopDefault(yr);var Ge=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",br=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function tt(e){if(e.startsWith("http")||e.startsWith(br))return e;if(e.startsWith("/api/"))return br+e.slice(4);let t=e.startsWith("/")?"":"/";return `${br}${t}${e}`}function ss(e){return e.startsWith("http")||e.startsWith(Ge)?e:e.startsWith("/admin/")?Ge+e.slice(6):e.startsWith("/")?Ge+e:e}function ba(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var Yc={admin:Ge,api:br,resolveApi:tt,resolveAdmin:ss,resolveMedia:ba};var Ur=zustand.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 Kt=zustand.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:[]})})),M={success:e=>Kt.getState().addToast("success",e),error:e=>Kt.getState().addToast("error",e),warning:e=>Kt.getState().addToast("warning",e),info:e=>Kt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var dt=zustand.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})}));zustand.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}})}));zustand.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 Zc="/api/auth/refresh";async function vi(){try{return (await fetch(tt(Zc),{method:"POST",credentials:"include"})).ok}catch{return false}}async function at(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(tt(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await vi()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(tt(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Be(e,t){let{autoToast:r=true,...o}=t||{},a=await at(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&M.error(n),new Error(n)}return a.json()}async function nt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await at(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&M.error(s),new Error(s)}return n.json()}async function Gt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await at(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&M.error(s),new Error(s)}return n.json()}async function xt(e,t){let{autoToast:r=true,...o}={},a=await at(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let l=await a.json();l.error&&(s=l.error);}catch{}throw r&&M.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function zr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function Za(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function en(e,t,r){if(!r){let o=await at(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",tt(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.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?vi().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let l=new XMLHttpRequest;l.open("POST",tt(e)),l.withCredentials=true,l.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300)try{o(JSON.parse(l.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${l.status}`));}),l.addEventListener("error",()=>a(new Error("Network error"))),l.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function kr({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function Et({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 jsxRuntime.jsx(jsxRuntime.Fragment,{children:Array.from({length:t}).map((a,n)=>jsxRuntime.jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function ol({back:e}){return e.href?jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function tp({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[r>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsxRuntime.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}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function al({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all shadow-lg shadow-[var(--kyro-primary)]/10 ${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||""}`,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function nl({action:e}){return jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:`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 shadow-lg shadow-[var(--kyro-primary)]/10 w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Dt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:l,children:i}){let d=o?.[o.length-1];return jsxRuntime.jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxRuntime.jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx(ol,{back:n}),jsxRuntime.jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxRuntime.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsxRuntime.jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsxRuntime.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:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o.map((c,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:f=>{c.onClick&&(f.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}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},m))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,m)=>jsxRuntime.jsx(Ca__default.default.Fragment,{children:c},m))}),i]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsxRuntime.jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))})]})]}),jsxRuntime.jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsxRuntime.jsx(ol,{back:n}),o&&jsxRuntime.jsx(tp,{breadcrumbs:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,m)=>jsxRuntime.jsxs(Ca__default.default.Fragment,{children:[m===0&&(t||m>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},m))}),i]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[l&&jsxRuntime.jsx(al,{actions:l}),s&&jsxRuntime.jsx(nl,{action:s})]})]}),(l||s)&&jsxRuntime.jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[s&&jsxRuntime.jsx(nl,{action:s}),l&&jsxRuntime.jsx(al,{actions:l})]})]})}var op={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 Pt({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=op[n],l=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${l} ${r}`,children:[a&&jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||s?.label||n]})}function vs({count:e,max:t=99}){return e===0?null:jsxRuntime.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 gs({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let l="kyro-btn",i=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${l} ${i} ${d} ${a}`,disabled:n||r,...s,children:[r?jsxRuntime.jsx("span",{className:"kyro-btn-loading",children:jsxRuntime.jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsxRuntime.jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function il({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxRuntime.jsxs("div",{className:"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?jsxRuntime.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]}):jsxRuntime.jsx("span",{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxRuntime.jsxs("select",{value:o,onChange:s=>n(Number(s.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:[jsxRuntime.jsx("option",{value:10,children:"10/page"}),jsxRuntime.jsx("option",{value:25,children:"25/page"}),jsxRuntime.jsx("option",{value:50,children:"50/page"}),jsxRuntime.jsx("option",{value:100,children:"100/page"})]}),jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx(gs,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(gs,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}function go(e,t,r){return r in t?t[r]:bs(e,t,r)}function bs(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=bs(o.tabs?.flatMap(s=>s.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=bs(o.fields||[],a,r);if(n!==void 0)return n}}}}function ks({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let l=t||e.slug,{permissions:i}=Ur(),d=i?.collections?.[l]?.create!==false,c=i?.collections?.[l]?.delete!==false,m=i?.collections?.[l]?.update!==false,f=()=>{d&&(a?a():window.location.href=`${Ge}/${l}/new`);},v=I=>{n?n(I):window.location.href=`${Ge}/${l}/${I}`;},[b,g]=Ca.useState(r),[x,u]=Ca.useState(o),[y,h]=Ca.useState(false),[R,P]=Ca.useState(1),[w,k]=Ca.useState(10),[p,T]=Ca.useState(new Set),[B,S]=Ca.useState(""),[F,A]=Ca.useState([]),{confirm:X,alert:K}=dt(),$=()=>{A([...F,{field:"",operator:"equals",value:""}]);},j=()=>{S(""),A([]),re(null);},ae=I=>{A(F.filter((W,ie)=>ie!==I));},ne=(I,W)=>{A(F.map((ie,sr)=>sr===I?{...ie,...W}:ie));},[H,re]=Ca.useState(null),[ve,L]=Ca.useState(false),[O,pe]=Ca.useState(false);function ge(I){let W=[];for(let ie of I||[])if(!(!ie.name||ie.hidden===true||ie.admin?.hidden||ie.name==="id"))if(ie.type==="tabs"&&ie.tabs)for(let sr of ie.tabs)sr.fields&&W.push(...ge(sr.fields));else (ie.type==="row"||ie.type==="collapsible")&&ie.fields?W.push(...ge(ie.fields)):W.push(ie);return W}let Se=Ca.useMemo(()=>ge(e.fields),[e.fields]),Ne=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:Se.find(I=>I.type!=="group"&&typeof I.name=="string")?.name,[U,Y]=Ca.useState(()=>{let I;return e.admin?.defaultColumns?I=[...e.admin?.defaultColumns||[]]:I=Se.slice(0,4).map(W=>W.name).filter(W=>!!W),Ne&&I.includes(Ne)&&(I=[Ne,...I.filter(W=>W!==Ne)]),I.includes("updatedAt")||I.push("updatedAt"),new Set(I)}),le=Ca.useCallback(I=>{Y(W=>{let ie=new Set(W);return ie.has(I)?ie.delete(I):ie.add(I),ie});},[]);function Re(I){let W=Se.find(ie=>ie.name===I);return W&&W.type==="group"&&W.fields?.[0]?.name?`${I}.${W.fields[0].name}`:I}let Ue=Ca.useCallback(I=>{let W=Re(I);re(ie=>ie&&ie.field===W?{field:W,direction:ie.direction==="asc"?"desc":"asc"}:{field:W,direction:"asc"});},[]),Ie=Ca.useMemo(()=>{let I=Se.filter(W=>!!W.name&&U.has(W.name));return U.has("status")&&I.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]}),I},[Se,U]);function et(I){return !I.name||!Ne?false:I.name===Ne||I.type==="group"&&I.fields?.[0]?.name===Ne}function Ct(I,W){return W.name?go(e.fields,I,W.name)??null:null}let St=Ca.useCallback(async()=>{h(true);try{let I=new URLSearchParams({page:R.toString(),limit:w.toString()});B&&I.append("search",B),H&&I.append("sort",H.field),H&&I.append("order",H.direction),F.length>0&&I.append("filters",JSON.stringify(F));let W=await Be(zr(`/api/${l}?${I}`),{autoToast:!1});g(W.docs||[]),u(W.totalDocs||0);}catch(I){console.error("Failed to load docs:",I);}finally{h(false);}},[l,R,w,B,H,F]);Ca.useEffect(()=>{b.length===0&&o===0&&St();},[]);let Q=Ca.useRef(true);Ca.useEffect(()=>{if(Q.current){Q.current=false;return}St();},[R,w,B,H,F]);let te=()=>{p.size===b.length?T(new Set):T(new Set(b.map(I=>I.id)));},ce=I=>{let W=new Set(p);W.has(I)?W.delete(I):W.add(I),T(W);},Te=()=>{X({title:"Delete Documents",message:`Are you sure you want to delete ${p.size} document(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let I of Array.from(p))await xt(`/api/${l}/${I}`);T(new Set),St(),M.success("Documents deleted");}catch(I){console.error("Bulk delete failed:",I),M.error("Failed to delete some documents");}}});},Fe=I=>{X({title:"Delete Document",message:"Are you sure you want to delete this document? This cannot be undone.",variant:"danger",onConfirm:async()=>{try{await xt(`/api/${l}/${I}`),St(),M.success("Document deleted");}catch(W){console.error("Delete failed:",W),M.error("Failed to delete document");}}});},lt=Math.ceil(x/w),Tt=B||F.length>0||H;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Dt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:x>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[x," documents"]},"count")]:void 0,action:d?{label:`Create ${e.singularLabel||e.label||l}`,onClick:f,icon:lucideReact.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search...",value:B,onChange:I=>S(I.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>L(!ve),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${ve||F.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:[jsxRuntime.jsx(lucideReact.Filter,{className:"w-4 h-4"}),"Filters",F.length>0&&jsxRuntime.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:F.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>pe(!O),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:[jsxRuntime.jsx(lucideReact.Columns3,{className:"w-4 h-4"}),"Columns"]}),O&&jsxRuntime.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:[jsxRuntime.jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:"Toggle Columns"})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:Se.map(I=>I.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:U.has(I.name),onChange:()=>le(I.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:I.label||I.name})]},I.name):null)})]})]}),Tt&&jsxRuntime.jsx("button",{type:"button",onClick:j,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:"Clear All"})]})]}),ve&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:"Advanced Filters"}),jsxRuntime.jsxs("button",{type:"button",onClick:$,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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4"}),"Add Filter"]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[F.map((I,W)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:I.field,onChange:ie=>ne(W,{field:ie.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:Se.map(ie=>jsxRuntime.jsx("option",{value:ie.name,children:ie.label||ie.name},ie.name))}),jsxRuntime.jsxs("select",{value:I.operator,onChange:ie=>ne(W,{operator:ie.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:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:I.value,onChange:ie=>ne(W,{value:ie.target.value}),placeholder:"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)]"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ae(W),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]},W)),F.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:'No filters applied. Click "Add Filter" to create one.'})]})]}),p.size>0&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:[p.size," selected"]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[c&&jsxRuntime.jsxs("button",{type:"button",onClick:Te,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:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),"Delete Selected"]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(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:"Cancel"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:y?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(Et,{variant:"table-row",count:8})}):b.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(lucideReact.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:"No documents found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:Tt?"Try adjusting your filters or search query.":`Get started by creating your first ${(e.singularLabel||e.label||l).toLowerCase()}.`}),!Tt&&d&&jsxRuntime.jsxs("button",{type:"button",onClick:f,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4"}),"Create"," ",String(e.singularLabel||e.label||l)]})]}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-4 py-4 w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:p.size===b.length&&b.length>0,onChange:te,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Ie.map(I=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Ue(I.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[lp(Ie,I.type)??(I.label||I.name),H&&H.field===I.name&&jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4"})]})},I.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Created"}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Last Modified"}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:b.map(I=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>v(I.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:W=>W.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:p.has(I.id),onChange:()=>ce(I.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),Ie.map(W=>{let ie=Ct(I,W),sr=W.type==="select"&&ie&&Array.isArray(W.options)?W.options.find(po=>po.value===ie)?.label||ie:ip(ie,W.type);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${et(W)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:sr},W.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:I.createdAt?new Date(I.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:I.updatedAt?new Date(I.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:W=>W.stopPropagation(),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>v(I.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?"Edit":"View",children:jsxRuntime.jsx(lucideReact.Pencil,{className:"w-4 h-4"})}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Fe(I.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:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"})})]})})]},I.id))})]})})}),jsxRuntime.jsx(il,{page:R,totalPages:lt,totalDocs:x,limit:w,onPageChange:P,onLimitChange:I=>{k(I),P(1);}})]})}function ip(e,t){return e==null?"\u2014":typeof e=="boolean"?e?"Yes":"No":t==="number"||t==="price"?String(e):t==="date"||t==="datetime"?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):Array.isArray(e)?e.map(r=>r&&typeof r=="object"?r.title||r.name||r.email||r.filename||r.url||JSON.stringify(r).slice(0,30):String(r??"").slice(0,30)).filter(Boolean).join(", "):typeof e=="object"?e.title?e.title:e.name?e.name:e.email?e.email:JSON.stringify(e).slice(0,50):String(e).slice(0,60)}function lp(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var hs=(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"},ul=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(lucideReact.Image,{className:t});case "video":return jsxRuntime.jsx(lucideReact.Film,{className:t});case "audio":return jsxRuntime.jsx(lucideReact.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(lucideReact.FileText,{className:t});default:return jsxRuntime.jsx(lucideReact.File,{className:t})}};function lr({field:e,value:t,onChange:r,disabled:o}){let a=Ca.useRef(null),n=Ca.useRef(null),[s,l]=Ca.useState(false),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),[f,v]=Ca.useState([]),[b,g]=Ca.useState([]),[x,u]=Ca.useState(""),[y,h]=Ca.useState(false),[R,P]=Ca.useState(""),[w,k]=Ca.useState(false),[p,T]=Ca.useState(""),[B,S]=Ca.useState(""),[F,A]=Ca.useState([]),X=e?.label||e?.name||"File",K=e.maxCount??(e.hasMany?999:1),$=K>1,j=Array.isArray(t)?t:t?[t]:[],ae=j.length<K;Ca.useEffect(()=>{(async()=>{let Y=j.filter(Ue=>typeof Ue=="string").map(Ue=>Ue),le=j.filter(Ue=>typeof Ue=="object"&&Ue!==null&&typeof Ue.id=="string"&&!Ue.url&&!Ue.filename&&!Ue.mimeType).map(Ue=>Ue.id),Re=[...Y,...le];if(Re.length!==0)try{let Ue=await Promise.all(Re.map(et=>Be(`/api/media/${et}`))),Ie=[...j];Ue.forEach(et=>{let Ct=et.id,St=Ie.findIndex(te=>te===Ct);if(St!==-1){Ie[St]=et;return}let Q=Ie.findIndex(te=>typeof te=="object"&&te!==null&&te.id===Ct);Q!==-1&&(Ie[Q]=et);}),r($?Ie:Ie[0]);}catch(Ue){console.error("Failed to fetch media details:",Ue);}})();},[t]),Ca.useEffect(()=>{i&&(ne(),H());},[i,x]);let ne=async()=>{try{let U=await Be(zr("/api/media/folders"));g(U.folders||[]);}catch{g([]);}},H=async()=>{h(true);try{let U=zr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");x&&(U+="&folder="+encodeURIComponent(x));let Y=await Be(U);v(Y.docs||[]);}catch{v([]);}finally{h(false);}},re=async U=>{l(true);try{let Y=new FormData;Y.append("file",U),x&&Y.append("folder",x);let le=await en("/api/media/upload",Y),Re={id:le.id,filename:le.filename,originalName:le.originalName??U.name,url:le.url,mimeType:U.type};r($?[...j,Re]:Re),M.success(`Asset synchronized: ${Re.filename}`);}catch(Y){console.error("Upload failed:",Y),M.error(`Upload failed: ${Y instanceof Error?Y.message:"Unknown error"}`);}finally{l(false);}},ve=async()=>{let U=p.trim();if(U){S("");try{let Y=await nt("/api/media/upload",{url:U}),le=(()=>{try{return new URL(U).pathname.split("/").pop()||Y.originalName||"url-image"}catch{return Y.originalName||"url-image"}})(),Re={id:Y.id,filename:Y.filename,originalName:le,url:Y.url,mimeType:Y.mimeType||"image/*"};r($?[...j,Re]:Re),M.success(`URL asset established: ${Re.filename}`),T(""),k(!1);}catch(Y){let le=Y instanceof Error?Y.message:"Invalid URL";S(le);}}},L=U=>({id:U.id,filename:U.filename,url:U.url,mimeType:U.mimeType}),O=U=>{$?A(Y=>Y.find(Re=>Re.id===U.id)?Y.filter(Re=>Re.id!==U.id):[...Y,U]):(r(L(U)),d(false),P(""));},pe=()=>{if(F.length>0){let U=[...j,...F.map(L)];r(U);}A([]),d(false),P("");},ge=U=>{let Y=[...j];Y.splice(U,1),r($?Y:Y[0]||null);},Se=Ca.useMemo(()=>f.filter(U=>!R||U.filename?.toLowerCase().includes(R.toLowerCase())||U.title?.toLowerCase().includes(R.toLowerCase())),[f,R]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let Ne=(U,Y)=>{if(!U)return null;let le=hs(U.mimeType,U.filename||U.url);return jsxRuntime.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:[jsxRuntime.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:le==="image"?jsxRuntime.jsx("img",{src:ba(U.url),alt:U.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(ul,{type:le,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:U.originalName||U.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:X})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y!==void 0?ge(Y):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:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]},Y)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:U=>{let Y=U.target.files?.[0];Y&&re(Y);},disabled:o,className:"hidden"}),j.length>0&&jsxRuntime.jsx("div",{className:$?"grid grid-cols-2 gap-2":"space-y-2",children:j.map((U,Y)=>Ne(U,Y))}),(!j.length||ae)&&jsxRuntime.jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxRuntime.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 ",X]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{A([]),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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>k(!w),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"})]}),w&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:p,onChange:U=>{T(U.target.value),S("");},onKeyDown:U=>U.key==="Enter"&&ve(),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)]"}),jsxRuntime.jsx("button",{type:"button",onClick:ve,disabled:o||!p.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"}),B&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:B})]}),i&&(c?reactDom.createPortal(jsxRuntime.jsx(ml,{isFullscreen:true,isMultiple:$,selectedItems:F,pickerSearch:R,setPickerSearch:P,folders:b,selectedFolder:x,setSelectedFolder:u,mediaLoading:y,filteredMedia:Se,selectFromLibrary:O,onDone:pe,setIsPickerFullscreen:m,setShowPicker:d}),document.body):jsxRuntime.jsx(ml,{isFullscreen:false,isMultiple:$,selectedItems:F,pickerSearch:R,setPickerSearch:P,folders:b,selectedFolder:x,setSelectedFolder:u,mediaLoading:y,filteredMedia:Se,selectFromLibrary:O,onDone:pe,setIsPickerFullscreen:m,setShowPicker:d}))]})}function ml({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:l,mediaLoading:i,filteredMedia:d,selectFromLibrary:c,onDone:m,setIsPickerFullscreen:f,setShowPicker:v}){let b=g=>r.some(x=>x.id===g);return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:"Search media...",value:o,onChange:g=>a(g.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&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(g=>jsxRuntime.jsx("button",{type:"button",onClick:()=>l(g.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===g.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:g.name},g.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:i?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsxRuntime.jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(g=>{let x=b(g.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(g),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${x?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsxRuntime.jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:hs(g.mimeType,g.filename)==="image"?jsxRuntime.jsx("img",{src:ba(g.thumbnailUrl||g.url),alt:g.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(ul,{type:hs(g.mimeType,g.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&x&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.Check,{className:"w-3 h-3 text-white"})})]},g.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxRuntime.jsxs("button",{type:"button",onClick:m,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})`:""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(!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?jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.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"})}):jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(false),f(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 jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.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&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.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:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function dr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let l=Ca.useRef(null),[i,d]=Ca.useState(false);Ca.useEffect(()=>{d(true);},[]),Ca.useEffect(()=>{let m=f=>{f.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",m),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",m),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||!i?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{ref:l,"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)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.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:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
1
+ 'use strict';var Ta=require('react'),zustand=require('zustand'),middleware=require('zustand/middleware'),Hl=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),react=require('@tiptap/react'),Yp=require('@tiptap/starter-kit'),Qp=require('@tiptap/extension-link'),Zp=require('@tiptap/extension-image'),em=require('@tiptap/extension-text-align'),tm=require('@tiptap/extension-underline'),rm=require('@tiptap/extension-highlight'),om=require('@tiptap/extension-task-list'),am=require('@tiptap/extension-task-item'),extensionTextStyle=require('@tiptap/extension-text-style'),sm=require('@tiptap/extension-color'),jp=require('react-image-crop');require('react-image-crop/dist/ReactCrop.css');var codemirrorThemeGithub=require('@uiw/codemirror-theme-github'),codemirrorThemeAura=require('@uiw/codemirror-theme-aura'),unstorage=require('unstorage'),Km=require('unstorage/drivers/indexedb'),templates=require('@kyro-cms/core/templates'),Bo=require('fs'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),utilities=require('@dnd-kit/utilities'),vanilla=require('zustand/vanilla'),Ry=require('@uiw/react-codemirror'),langJson=require('@codemirror/lang-json');require('@kyro-cms/core');var yr=require('path'),url=require('url'),esbuild=require('esbuild'),dotenv=require('dotenv'),worker_threads=require('worker_threads');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Ta__default=/*#__PURE__*/_interopDefault(Ta);var Hl__namespace=/*#__PURE__*/_interopNamespace(Hl);var Yp__default=/*#__PURE__*/_interopDefault(Yp);var Qp__default=/*#__PURE__*/_interopDefault(Qp);var Zp__default=/*#__PURE__*/_interopDefault(Zp);var em__default=/*#__PURE__*/_interopDefault(em);var tm__default=/*#__PURE__*/_interopDefault(tm);var rm__default=/*#__PURE__*/_interopDefault(rm);var om__default=/*#__PURE__*/_interopDefault(om);var am__default=/*#__PURE__*/_interopDefault(am);var sm__default=/*#__PURE__*/_interopDefault(sm);var jp__default=/*#__PURE__*/_interopDefault(jp);var Km__default=/*#__PURE__*/_interopDefault(Km);var Bo__default=/*#__PURE__*/_interopDefault(Bo);var Ry__default=/*#__PURE__*/_interopDefault(Ry);var yr__default=/*#__PURE__*/_interopDefault(yr);var Oe=typeof __KYRO_ADMIN_PATH__<"u"?__KYRO_ADMIN_PATH__:"/admin",xr=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function We(e){if(e.startsWith("http")||e.startsWith(xr))return e;if(e.startsWith("/api/"))return xr+e.slice(4);let t=e.startsWith("/")?"":"/";return `${xr}${t}${e}`}function ks(e){return e.startsWith("http")||e.startsWith(Oe)?e:e.startsWith("/admin/")?Oe+e.slice(6):e.startsWith("/")?Oe+e:e}function xa(e){return !e||typeof e!="string"?"":e.startsWith("http")||e.startsWith("blob:")||e.startsWith("data:")||e.startsWith("/")?e:`/${e}`}var vp={admin:Oe,api:xr,resolveApi:We,resolveAdmin:ks,resolveMedia:xa};var _r=zustand.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 Gt=zustand.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:[]})})),L={success:e=>Gt.getState().addToast("success",e),error:e=>Gt.getState().addToast("error",e),warning:e=>Gt.getState().addToast("warning",e),info:e=>Gt.getState().addToast("info",e)};zustand.create()(middleware.persist(e=>({mode:"light",setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="light"?"dark":"light"}))}),{name:"kyro-theme"}));var ut=zustand.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})}));zustand.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}})}));zustand.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 bp="/api/auth/refresh";async function Pi(){try{return (await fetch(We(bp),{method:"POST",credentials:"include"})).ok}catch{return false}}async function st(e,t={}){let r={};t.body instanceof FormData||(r["Content-Type"]="application/json"),Object.assign(r,t.headers);let o=await fetch(We(e),{...t,credentials:"include",headers:r});if(o.status===401){if(await Pi()){let n={};return t.body instanceof FormData||(n["Content-Type"]="application/json"),Object.assign(n,t.headers),await fetch(We(e),{...t,credentials:"include",headers:n})}window.location.href="/admin/login";}return o}async function Ae(e,t){let{autoToast:r=true,...o}=t||{},a=await st(e,o);if(!a.ok){let n=`GET Failed: ${a.status}`;throw r&&L.error(n),new Error(n)}return a.json()}async function dt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await st(e,{method:"POST",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`POST Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&L.error(s),new Error(s)}return n.json()}async function Wt(e,t,r){let{autoToast:o=true,...a}=r||{},n=await st(e,{method:"PATCH",body:t?JSON.stringify(t):void 0,...a});if(!n.ok){let s=`Update Failed: ${n.status}`;try{let l=await n.json();l.error&&(s=l.error);}catch{}throw o&&L.error(s),new Error(s)}return n.json()}async function wt(e,t){let{autoToast:r=true,...o}={},a=await st(e,{method:"DELETE",...o});if(!a.ok){let s=`Delete Failed: ${a.status}`;try{let l=await a.json();l.error&&(s=l.error);}catch{}throw r&&L.error(s),new Error(s)}let n=await a.text();return n?JSON.parse(n):{}}function Hr(e){let t=e.includes("?")?"&":"?";return `${e}${t}t=${Date.now()}`}function ln(e,t,r=50){return !e||t.length===0?`limit=${r}`:`${t.map(a=>`where[${a}][contains]=${encodeURIComponent(e)}`).join("&")}&limit=${r}`}async function dn(e,t,r){if(!r){let o=await st(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",We(e)),n.withCredentials=true,n.upload.addEventListener("progress",s=>{s.lengthComputable&&r(Math.round(s.loaded/s.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?Pi().then(s=>{if(!s){a(new Error(`Upload Error: ${n.status}`));return}let l=new XMLHttpRequest;l.open("POST",We(e)),l.withCredentials=true,l.upload.addEventListener("progress",i=>{i.lengthComputable&&r(Math.round(i.loaded/i.total*100));}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300)try{o(JSON.parse(l.responseText));}catch{a(new Error("Invalid JSON"));}else a(new Error(`Upload Error: ${l.status}`));}),l.addEventListener("error",()=>a(new Error("Network error"))),l.send(t);}):a(new Error(`Upload Error: ${n.status}`));}),n.addEventListener("error",()=>a(new Error("Network error during upload"))),n.send(t);})}function hr({size:e="md",className:t=""}){return jsxRuntime.jsx("svg",{className:`kyro-spinner kyro-spinner-${e} ${t}`,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"40 20"})})}function _t({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 jsxRuntime.jsx(jsxRuntime.Fragment,{children:Array.from({length:t}).map((a,n)=>jsxRuntime.jsx("div",{className:`kyro-shimmer ${o[e]} ${r}`},n))})}function vl({back:e}){return e.href?jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}):jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})})}function kp({breadcrumbs:e}){return e?.map((t,r)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[r>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),t.href||t.onClick?jsxRuntime.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}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:t.label})]},r))}function gl({actions:e}){return Array.isArray(e)?jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:e.map((t,r)=>jsxRuntime.jsxs("button",{type:"button",onClick:t.onClick,disabled:t.disabled,className:`flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm transition-all shadow-lg shadow-[var(--kyro-primary)]/10 ${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||""}`,children:[t.icon&&jsxRuntime.jsx(t.icon,{className:"w-4 h-4"}),t.label]},r))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function bl({action:e}){return jsxRuntime.jsxs("button",{type:"button",onClick:e.onClick,disabled:e.disabled,className:`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 shadow-lg shadow-[var(--kyro-primary)]/10 w-full lg:w-auto justify-center ${e.disabled?"opacity-50 cursor-wait pointer-events-none":""} ${e.className||""}`,children:[e.icon&&jsxRuntime.jsx(e.icon,{className:"w-4 h-4"}),e.label]})}function Lt({title:e,description:t,icon:r,breadcrumbs:o,metadata:a,back:n,action:s,actions:l,children:i}){let d=o?.[o.length-1];return jsxRuntime.jsxs("div",{className:"surface-tile px-3 md:px-6 py-3 md:pt-4 mb-4 md:mb-8",children:[jsxRuntime.jsxs("div",{className:"md:hidden space-y-2",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n&&jsxRuntime.jsx(vl,{back:n}),jsxRuntime.jsxs("details",{className:"group [&::-webkit-details-marker]:hidden flex-1 min-w-0",children:[jsxRuntime.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[jsxRuntime.jsx("span",{className:"flex-1 text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] truncate",children:d?.label||""}),jsxRuntime.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:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-[var(--kyro-border)] space-y-2",children:[o&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o.map((c,p)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[p>0&&jsxRuntime.jsx("span",{className:"opacity-20 text-[10px]",children:"/"}),c.href||c.onClick?jsxRuntime.jsx("a",{href:c.href,onClick:y=>{c.onClick&&(y.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}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:c.label})]},p))}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.map((c,p)=>jsxRuntime.jsx(Ta__default.default.Fragment,{children:c},p))}),i]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r&&jsxRuntime.jsx(r,{className:"w-5 h-5 text-[var(--kyro-primary)] shrink-0"}),e&&jsxRuntime.jsx("h1",{className:"text-lg font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e}),a&&!t&&jsxRuntime.jsx("span",{className:"h-2 w-2 rounded-full bg-[var(--kyro-primary)] shrink-0"})]}),t&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0 text-xs",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,p)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[p===0&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},p))})]})]}),jsxRuntime.jsxs("div",{className:"hidden md:flex md:flex-row md:items-center justify-between gap-6",children:[jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[(o||n)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n&&jsxRuntime.jsx(vl,{back:n}),o&&jsxRuntime.jsx(kp,{breadcrumbs:o})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[r&&jsxRuntime.jsx(r,{className:"w-6 h-6 text-[var(--kyro-primary)]"}),e&&jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)] truncate",children:e})]}),(t||a)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-1",children:[t&&jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] font-medium opacity-60 line-clamp-1 min-w-0",children:t}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:a.map((c,p)=>jsxRuntime.jsxs(Ta__default.default.Fragment,{children:[p===0&&(t||p>0)&&jsxRuntime.jsx("span",{className:"opacity-20 ml-1",children:"\xB7"}),c]},p))}),i]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[l&&jsxRuntime.jsx(gl,{actions:l}),s&&jsxRuntime.jsx(bl,{action:s})]})]}),(l||s)&&jsxRuntime.jsxs("div",{className:"md:hidden flex items-center gap-2 mt-3 pt-3 border-t border-[var(--kyro-border)]",children:[s&&jsxRuntime.jsx(bl,{action:s}),l&&jsxRuntime.jsx(gl,{actions:l})]})]})}var wp={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 At({variant:e,status:t,className:r="",children:o,dot:a=false}){let n=e||t||"default",s=wp[n],l=s?s.class:`kyro-badge-${n}`;return jsxRuntime.jsxs("span",{className:`kyro-badge ${l} ${r}`,children:[a&&jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current mr-1.5 opacity-60"}),o||s?.label||n]})}function Fs({count:e,max:t=99}){return e===0?null:jsxRuntime.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 Ps({variant:e="secondary",size:t="md",loading:r=false,children:o,className:a="",disabled:n,...s}){let l="kyro-btn",i=`kyro-btn-${e}`,d=`kyro-btn-${t}`;return jsxRuntime.jsxs("button",{type:"button",className:`${l} ${i} ${d} ${a}`,disabled:n||r,...s,children:[r?jsxRuntime.jsx("span",{className:"kyro-btn-loading",children:jsxRuntime.jsx("svg",{className:"kyro-btn-spinner",viewBox:"0 0 24 24",children:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"60 30"})})}):null,jsxRuntime.jsx("span",{className:r?"kyro-btn-text-hidden":"",children:o})]})}function kl({page:e,totalPages:t,totalDocs:r,limit:o,onPageChange:a,onLimitChange:n}){return t<=1?null:jsxRuntime.jsxs("div",{className:"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?jsxRuntime.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]}):jsxRuntime.jsx("span",{}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[n&&jsxRuntime.jsxs("select",{value:o,onChange:s=>n(Number(s.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:[jsxRuntime.jsx("option",{value:10,children:"10/page"}),jsxRuntime.jsx("option",{value:25,children:"25/page"}),jsxRuntime.jsx("option",{value:50,children:"50/page"}),jsxRuntime.jsx("option",{value:100,children:"100/page"})]}),jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-secondary)] font-medium",children:["Page ",e," of ",t]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx(Ps,{variant:"ghost",size:"sm",disabled:e<=1,onClick:()=>a(e-1),children:"\u2190 Previous"}),jsxRuntime.jsx(Ps,{variant:"ghost",size:"sm",disabled:e>=t,onClick:()=>a(e+1),children:"Next \u2192"})]})]})]})}function ko(e,t,r){return r in t?t[r]:Ds(e,t,r)}function Ds(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=Ds(o.tabs?.flatMap(s=>s.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=Ds(o.fields||[],a,r);if(n!==void 0)return n}}}}function Bs({collection:e,collectionSlug:t,initialDocs:r=[],initialTotal:o=0,onCreate:a,onEdit:n,config:s}){let l=t||e.slug,{permissions:i}=_r(),d=i?.collections?.[l]?.create!==false,c=i?.collections?.[l]?.delete!==false,p=i?.collections?.[l]?.update!==false,y=()=>{d&&(a?a():window.location.href=`${Oe}/${l}/new`);},g=D=>{n?n(D):window.location.href=`${Oe}/${l}/${D}`;},[b,v]=Ta.useState(r),[k,f]=Ta.useState(o),[u,x]=Ta.useState(false),[A,F]=Ta.useState(1),[h,w]=Ta.useState(10),[m,T]=Ta.useState(new Set),[B,I]=Ta.useState(""),[V,C]=Ta.useState([]),{confirm:K,alert:E}=ut(),$=()=>{C([...V,{field:"",operator:"equals",value:""}]);},O=()=>{I(""),C([]),S(null);},ne=D=>{C(V.filter((Q,pe)=>pe!==D));},ie=(D,Q)=>{C(V.map((pe,fr)=>fr===D?{...pe,...Q}:pe));},[H,S]=Ta.useState(null),[J,fe]=Ta.useState(false),[U,re]=Ta.useState(false);function j(D){let Q=[];for(let pe of D||[])if(!(!pe.name||pe.hidden===true||pe.admin?.hidden||pe.name==="id"))if(pe.type==="tabs"&&pe.tabs)for(let fr of pe.tabs)fr.fields&&Q.push(...j(fr.fields));else (pe.type==="row"||pe.type==="collapsible")&&pe.fields?Q.push(...j(pe.fields)):Q.push(pe);return Q}let ye=Ta.useMemo(()=>j(e.fields),[e.fields]),Te=typeof e.admin?.useAsTitle=="string"?e.admin.useAsTitle:ye.find(D=>D.type!=="group"&&typeof D.name=="string")?.name,[z,G]=Ta.useState(()=>{let D;return e.admin?.defaultColumns?D=[...e.admin?.defaultColumns||[]]:D=ye.slice(0,4).map(Q=>Q.name).filter(Q=>!!Q),Te&&D.includes(Te)&&(D=[Te,...D.filter(Q=>Q!==Te)]),D.includes("updatedAt")||D.push("updatedAt"),new Set(D)}),_e=Ta.useCallback(D=>{G(Q=>{let pe=new Set(Q);return pe.has(D)?pe.delete(D):pe.add(D),pe});},[]);function Me(D){let Q=ye.find(pe=>pe.name===D);return Q&&Q.type==="group"&&Q.fields?.[0]?.name?`${D}.${Q.fields[0].name}`:D}let Z=Ta.useCallback(D=>{let Q=Me(D);S(pe=>pe&&pe.field===Q?{field:Q,direction:pe.direction==="asc"?"desc":"asc"}:{field:Q,direction:"asc"});},[]),ge=Ta.useMemo(()=>{let D=ye.filter(Q=>!!Q.name&&z.has(Q.name));return z.has("status")&&D.push({name:"status",type:"select",label:"Status",options:[{value:"draft",label:"Draft"},{value:"published",label:"Published"}]}),D},[ye,z]);function Ge(D){return !D.name||!Te?false:D.name===Te||D.type==="group"&&D.fields?.[0]?.name===Te}function ft(D,Q){return Q.name?ko(e.fields,D,Q.name)??null:null}let lt=Ta.useCallback(async()=>{x(true);try{let D=new URLSearchParams({page:A.toString(),limit:h.toString()});B&&D.append("search",B),H&&D.append("sort",H.field),H&&D.append("order",H.direction),V.length>0&&D.append("filters",JSON.stringify(V));let Q=await Ae(Hr(`/api/${l}?${D}`),{autoToast:!1});v(Q.docs||[]),f(Q.totalDocs||0);}catch(D){console.error("Failed to load docs:",D);}finally{x(false);}},[l,A,h,B,H,V]);Ta.useEffect(()=>{b.length===0&&o===0&&lt();},[]);let sr=Ta.useRef(true);Ta.useEffect(()=>{if(sr.current){sr.current=false;return}lt();},[A,h,B,H,V]);let X=()=>{m.size===b.length?T(new Set):T(new Set(b.map(D=>D.id)));},le=D=>{let Q=new Set(m);Q.has(D)?Q.delete(D):Q.add(D),T(Q);},ce=()=>{K({title:"Delete Documents",message:`Are you sure you want to delete ${m.size} document(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let D of Array.from(m))await wt(`/api/${l}/${D}`);T(new Set),lt(),L.success("Documents deleted");}catch(D){console.error("Bulk delete failed:",D),L.error("Failed to delete some documents");}}});},Se=D=>{K({title:"Delete Document",message:"Are you sure you want to delete this document? This cannot be undone.",variant:"danger",onConfirm:async()=>{try{await wt(`/api/${l}/${D}`),lt(),L.success("Document deleted");}catch(Q){console.error("Delete failed:",Q),L.error("Failed to delete document");}}});},Ee=Math.ceil(k/h),He=B||V.length>0||H;return jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Lt,{title:e.label||l,description:e.admin?.description||`Manage your ${e.label||l}`,metadata:k>0?[jsxRuntime.jsxs("span",{className:"text-xs font-bold opacity-60",children:[k," documents"]},"count")]:void 0,action:d?{label:`Create ${e.singularLabel||e.label||l}`,onClick:y,icon:Hl.Plus}:void 0}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex flex-col lg:flex-row gap-4 items-start lg:items-center",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 w-full lg:max-w-md",children:[jsxRuntime.jsx(Hl.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search...",value:B,onChange:D=>I(D.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>fe(!J),className:`flex items-center gap-2 px-4 py-2 rounded-xl font-bold text-sm transition-all ${J||V.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:[jsxRuntime.jsx(Hl.Filter,{className:"w-4 h-4"}),"Filters",V.length>0&&jsxRuntime.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:V.length})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>re(!U),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:[jsxRuntime.jsx(Hl.Columns3,{className:"w-4 h-4"}),"Columns"]}),U&&jsxRuntime.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:[jsxRuntime.jsx("div",{className:"p-3 border-b border-[var(--kyro-border)]",children:jsxRuntime.jsx("span",{className:"text-xs font-bold tracking-wider text-[var(--kyro-text-secondary)]",children:"Toggle Columns"})}),jsxRuntime.jsx("div",{className:"p-2 max-h-64 overflow-y-auto",children:ye.map(D=>D.name?jsxRuntime.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--kyro-surface-accent)] cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:z.has(D.name),onChange:()=>_e(D.name),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:D.label||D.name})]},D.name):null)})]})]}),He&&jsxRuntime.jsx("button",{type:"button",onClick:O,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:"Clear All"})]})]}),J&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("h3",{className:"font-medium text-[var(--kyro-text-primary)]",children:"Advanced Filters"}),jsxRuntime.jsxs("button",{type:"button",onClick:$,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:[jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4"}),"Add Filter"]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[V.map((D,Q)=>jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[jsxRuntime.jsx("select",{value:D.field,onChange:pe=>ie(Q,{field:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:ye.map(pe=>jsxRuntime.jsx("option",{value:pe.name,children:pe.label||pe.name},pe.name))}),jsxRuntime.jsxs("select",{value:D.operator,onChange:pe=>ie(Q,{operator:pe.target.value}),className:"px-3 py-2 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-lg text-sm font-medium text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("option",{value:"equals",children:"Equals"}),jsxRuntime.jsx("option",{value:"contains",children:"Contains"}),jsxRuntime.jsx("option",{value:"gt",children:"Greater than"}),jsxRuntime.jsx("option",{value:"lt",children:"Less than"}),jsxRuntime.jsx("option",{value:"gte",children:"Greater or equal"}),jsxRuntime.jsx("option",{value:"lte",children:"Less or equal"})]}),jsxRuntime.jsx("input",{type:"text",value:D.value,onChange:pe=>ie(Q,{value:pe.target.value}),placeholder:"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)]"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ne(Q),className:"p-2 text-[var(--kyro-text-muted)] hover:text-red-500 transition-colors",children:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]},Q)),V.length===0&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)]",children:'No filters applied. Click "Add Filter" to create one.'})]})]}),m.size>0&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 flex items-center justify-between border-l-4 border-[var(--kyro-sidebar-active)]",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:[m.size," selected"]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[c&&jsxRuntime.jsxs("button",{type:"button",onClick:ce,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:[jsxRuntime.jsx(Hl.Trash2,{className:"w-4 h-4"}),"Delete Selected"]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(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:"Cancel"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden",children:u?jsxRuntime.jsx("div",{className:"space-y-2 p-4",children:jsxRuntime.jsx(_t,{variant:"table-row",count:8})}):b.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-8",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:jsxRuntime.jsx(Hl.Archive,{className:"w-4 h-4"})}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:"No documents found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:He?"Try adjusting your filters or search query.":`Get started by creating your first ${(e.singularLabel||e.label||l).toLowerCase()}.`}),!He&&d&&jsxRuntime.jsxs("button",{type:"button",onClick:y,className:"mt-4 kyro-btn kyro-btn-md kyro-btn-primary shadow-md flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4"}),"Create"," ",String(e.singularLabel||e.label||l)]})]}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[var(--kyro-text-secondary)] font-bold text-[10px] tracking-[0.3em] border-b border-[var(--kyro-border)] whitespace-nowrap",children:[jsxRuntime.jsx("th",{className:"px-4 py-4 w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:m.size===b.length&&b.length>0,onChange:X,className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),ge.map(D=>jsxRuntime.jsx("th",{className:"px-4 py-4 cursor-pointer hover:text-[var(--kyro-text-primary)] transition-colors",onClick:()=>Z(D.name),children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[Rp(ge,D.type)??(D.label||D.name),H&&H.field===D.name&&jsxRuntime.jsx(Hl.ChevronUp,{className:"w-4 h-4"})]})},D.name)),e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Created"}):null,e.timestamps?jsxRuntime.jsx("th",{className:"px-4 py-4",children:"Last Modified"}):null,jsxRuntime.jsx("th",{className:"px-4 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:b.map(D=>jsxRuntime.jsxs("tr",{className:"hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer group",onClick:()=>g(D.id),children:[jsxRuntime.jsx("td",{className:"px-4 py-3",onClick:Q=>Q.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:m.has(D.id),onChange:()=>le(D.id),className:"w-4 h-4 rounded border-[var(--kyro-border-strong)] text-[var(--kyro-sidebar-active)] focus:ring-[var(--kyro-sidebar-active)]"})}),ge.map(Q=>{let pe=ft(D,Q),fr=Q.type==="select"&&pe&&Array.isArray(Q.options)?Q.options.find(fo=>fo.value===pe)?.label||pe:Tp(pe,Q.type);return jsxRuntime.jsx("td",{className:`px-4 py-3 ${Ge(Q)?"font-medium text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)]"}`,children:fr},Q.name)}),e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:D.createdAt?new Date(D.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,e.timestamps?jsxRuntime.jsx("td",{className:"px-4 py-3 text-sm text-[var(--kyro-text-secondary)]",children:D.updatedAt?new Date(D.updatedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"\u2014"}):null,jsxRuntime.jsx("td",{className:"px-4 py-3 text-right",onClick:Q=>Q.stopPropagation(),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>g(D.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?"Edit":"View",children:jsxRuntime.jsx(Hl.Pencil,{className:"w-4 h-4"})}),c&&jsxRuntime.jsx("button",{type:"button",onClick:()=>Se(D.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:"Delete",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-4 h-4"})})]})})]},D.id))})]})})}),jsxRuntime.jsx(kl,{page:A,totalPages:Ee,totalDocs:k,limit:h,onPageChange:F,onLimitChange:D=>{w(D),F(1);}})]})}function Tp(e,t){return e==null?"\u2014":typeof e=="boolean"?e?"Yes":"No":t==="number"||t==="price"?String(e):t==="date"||t==="datetime"?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):Array.isArray(e)?e.map(r=>r&&typeof r=="object"?r.title||r.name||r.email||r.filename||r.url||JSON.stringify(r).slice(0,30):String(r??"").slice(0,30)).filter(Boolean).join(", "):typeof e=="object"?e.title?e.title:e.name?e.name:e.email?e.email:JSON.stringify(e).slice(0,50):String(e).slice(0,60)}function Rp(e,t){return t!=="tabs"?void 0:e[0]?.tabs?.[0]?.fields?.[0]?.label}var Ls=(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"},Tl=({type:e,className:t})=>{switch(e){case "image":return jsxRuntime.jsx(Hl.Image,{className:t});case "video":return jsxRuntime.jsx(Hl.Film,{className:t});case "audio":return jsxRuntime.jsx(Hl.Music,{className:t});case "pdf":case "document":return jsxRuntime.jsx(Hl.FileText,{className:t});default:return jsxRuntime.jsx(Hl.File,{className:t})}};function lr({field:e,value:t,onChange:r,disabled:o}){let a=Ta.useRef(null),n=Ta.useRef(null),[s,l]=Ta.useState(false),[i,d]=Ta.useState(false),[c,p]=Ta.useState(false),[y,g]=Ta.useState([]),[b,v]=Ta.useState([]),[k,f]=Ta.useState(""),[u,x]=Ta.useState(false),[A,F]=Ta.useState(""),[h,w]=Ta.useState(false),[m,T]=Ta.useState(""),[B,I]=Ta.useState(""),[V,C]=Ta.useState([]),K=e?.label||e?.name||"File",E=e.maxCount??(e.hasMany?999:1),$=E>1,O=Array.isArray(t)?t:t?[t]:[],ne=O.length<E;Ta.useEffect(()=>{(async()=>{let G=O.filter(Z=>typeof Z=="string").map(Z=>Z),_e=O.filter(Z=>typeof Z=="object"&&Z!==null&&typeof Z.id=="string"&&!Z.url&&!Z.filename&&!Z.mimeType).map(Z=>Z.id),Me=[...G,..._e];if(Me.length!==0)try{let Z=await Promise.all(Me.map(Ge=>Ae(`/api/media/${Ge}`))),ge=[...O];Z.forEach(Ge=>{let ft=Ge.id,lt=ge.findIndex(X=>X===ft);if(lt!==-1){ge[lt]=Ge;return}let sr=ge.findIndex(X=>typeof X=="object"&&X!==null&&X.id===ft);sr!==-1&&(ge[sr]=Ge);}),r($?ge:ge[0]);}catch(Z){console.error("Failed to fetch media details:",Z);}})();},[t]),Ta.useEffect(()=>{i&&(ie(),H());},[i,k]);let ie=async()=>{try{let z=await Ae(Hr("/api/media/folders"));v(z.folders||[]);}catch{v([]);}},H=async()=>{x(true);try{let z=Hr("/api/media?limit=60&sortBy=createdAt&sortDir=desc");k&&(z+="&folder="+encodeURIComponent(k));let G=await Ae(z);g(G.docs||[]);}catch{g([]);}finally{x(false);}},S=async z=>{l(true);try{let G=new FormData;G.append("file",z),k&&G.append("folder",k);let _e=await dn("/api/media/upload",G),Me=_e.data||_e.doc||_e,Z={...Me,id:Me.id,filename:Me.filename,originalName:Me.originalName??z.name,url:Me.url,mimeType:Me.mimeType||z.type};r($?[...O,Z]:Z),L.success(`Asset synchronized: ${Z.filename}`);}catch(G){console.error("Upload failed:",G),L.error(`Upload failed: ${G instanceof Error?G.message:"Unknown error"}`);}finally{l(false);}},J=async()=>{let z=m.trim();if(z){I("");try{let G=await dt("/api/media/upload",{url:z}),_e=(()=>{try{return new URL(z).pathname.split("/").pop()||G.originalName||"url-image"}catch{return G.originalName||"url-image"}})(),Me={id:G.id,filename:G.filename,originalName:_e,url:G.url,mimeType:G.mimeType||"image/*"};r($?[...O,Me]:Me),L.success(`URL asset established: ${Me.filename}`),T(""),w(!1);}catch(G){let _e=G instanceof Error?G.message:"Invalid URL";I(_e);}}},fe=z=>({id:z.id,filename:z.filename,url:z.url,mimeType:z.mimeType}),U=z=>{$?C(G=>G.find(Me=>Me.id===z.id)?G.filter(Me=>Me.id!==z.id):[...G,z]):(r(fe(z)),d(false),F(""));},re=()=>{if(V.length>0){let z=[...O,...V.map(fe)];r(z);}C([]),d(false),F("");},j=z=>{let G=[...O];G.splice(z,1),r($?G:G[0]||null);},ye=Ta.useMemo(()=>y.filter(z=>!A||z.filename?.toLowerCase().includes(A.toLowerCase())||z.title?.toLowerCase().includes(A.toLowerCase())),[y,A]);if(s)return jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] p-2",children:"Uploading..."});let Te=(z,G)=>{if(!z)return null;let _e=Ls(z.mimeType,z.filename||z.url);return jsxRuntime.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:[jsxRuntime.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:_e==="image"?jsxRuntime.jsx("img",{src:xa(z.url),alt:z.filename||"Preview",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Tl,{type:_e,className:"w-5 h-5 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-[11px] font-medium truncate text-[var(--kyro-text-primary)]",children:z.originalName||z.filename||"Unnamed File"}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] tracking-wider font-bold",children:K})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>G!==void 0?j(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:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]},G)};return jsxRuntime.jsxs("div",{className:"space-y-2 relative",children:[jsxRuntime.jsx("input",{ref:a,type:"file",accept:e.allowedTypes?.join(",")||"*/*",onChange:z=>{let G=z.target.files?.[0];G&&S(G);},disabled:o,className:"hidden"}),O.length>0&&jsxRuntime.jsx("div",{className:$?"grid grid-cols-2 gap-2":"space-y-2",children:O.map((z,G)=>Te(z,G))}),(!O.length||ne)&&jsxRuntime.jsxs("div",{className:"flex gap-2 flex-wrap",children:[jsxRuntime.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 ",K]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{C([]),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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>w(!h),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"})]}),h&&jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[jsxRuntime.jsx("input",{ref:n,type:"url",placeholder:"https://example.com/image.jpg",value:m,onChange:z=>{T(z.target.value),I("");},onKeyDown:z=>z.key==="Enter"&&J(),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)]"}),jsxRuntime.jsx("button",{type:"button",onClick:J,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"}),B&&jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-error)]",children:B})]}),i&&(c?reactDom.createPortal(jsxRuntime.jsx(Sl,{isFullscreen:true,isMultiple:$,selectedItems:V,pickerSearch:A,setPickerSearch:F,folders:b,selectedFolder:k,setSelectedFolder:f,mediaLoading:u,filteredMedia:ye,selectFromLibrary:U,onDone:re,setIsPickerFullscreen:p,setShowPicker:d}),document.body):jsxRuntime.jsx(Sl,{isFullscreen:false,isMultiple:$,selectedItems:V,pickerSearch:A,setPickerSearch:F,folders:b,selectedFolder:k,setSelectedFolder:f,mediaLoading:u,filteredMedia:ye,selectFromLibrary:U,onDone:re,setIsPickerFullscreen:p,setShowPicker:d}))]})}function Sl({isFullscreen:e,isMultiple:t,selectedItems:r,pickerSearch:o,setPickerSearch:a,folders:n,selectedFolder:s,setSelectedFolder:l,mediaLoading:i,filteredMedia:d,selectFromLibrary:c,onDone:p,setIsPickerFullscreen:y,setShowPicker:g}){let b=v=>r.some(k=>k.id===v);return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"p-2 border-b border-[var(--kyro-border)] flex flex-col gap-2",children:[jsxRuntime.jsx("input",{type:"text",placeholder:"Search media...",value:o,onChange:v=>a(v.target.value),className:"w-full px-2 py-1.5 text-xs rounded border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)]"}),n.length>0&&jsxRuntime.jsxs("div",{className:"flex gap-1 flex-wrap",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l(""),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===""?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:"All"}),n.slice(0,6).map(v=>jsxRuntime.jsx("button",{type:"button",onClick:()=>l(v.path),className:`kyro-btn-primary px-2 py-1 text-xs rounded transition-colors ${s===v.path?"":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:v.name},v.path))]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto p-2",children:i?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx("div",{className:"text-center py-5 text-xs text-[var(--kyro-text-muted)]",children:"No media found"}):jsxRuntime.jsx("div",{className:`grid gap-1 ${e?"grid-cols-[repeat(auto-fill,minmax(140px,1fr))]":"grid-cols-3"}`,children:d.map(v=>{let k=b(v.id);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(v),className:`border rounded-md overflow-hidden cursor-pointer p-0 bg-[var(--kyro-surface)] transition-all relative group ${k?"border-[var(--kyro-primary)] ring-2 ring-[var(--kyro-primary)]":"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]"}`,children:[jsxRuntime.jsx("div",{className:`w-full flex items-center justify-center bg-[var(--kyro-surface-accent)] ${e?"h-[120px]":"h-[80px]"}`,children:Ls(v.mimeType,v.filename)==="image"?jsxRuntime.jsx("img",{src:xa(v.thumbnailUrl||v.url),alt:v.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(Tl,{type:Ls(v.mimeType,v.filename),className:e?"w-10 h-10":"w-8 h-8"})}),t&&k&&jsxRuntime.jsx("div",{className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-[var(--kyro-primary)] flex items-center justify-center",children:jsxRuntime.jsx(Hl.Check,{className:"w-3 h-3 text-white"})})]},v.id)})})}),jsxRuntime.jsxs("div",{className:"p-2 border-t border-[var(--kyro-border)] flex justify-between items-center",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[d.length," items"]}),jsxRuntime.jsxs("div",{className:"flex gap-2 items-center",children:[t&&jsxRuntime.jsxs("button",{type:"button",onClick:p,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})`:""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>y(!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?jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.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"})}):jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(false),y(false);},className:"text-xs text-[var(--kyro-text-secondary)] bg-transparent border-none cursor-pointer hover:text-[var(--kyro-text-primary)]",children:"Close"})]})]})]})}function it({field:e,error:t,children:r,hideLabel:o=false}){return jsxRuntime.jsxs("div",{className:"space-y-2.5 w-full group",children:[e.label&&!o&&jsxRuntime.jsx("div",{className:"flex justify-between items-end mb-1",children:jsxRuntime.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&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})}),jsxRuntime.jsx("div",{className:"relative transform transition-transform duration-200 focus-within:scale-[1.002]",children:r}),(e.admin?.description||t)&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-1.5 px-1",children:[e.admin?.description&&!t&&jsxRuntime.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--kyro-text-muted)] font-medium opacity-60 italic",children:e.admin.description}),t&&jsxRuntime.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:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-error)] shadow-[0_0_8px_var(--kyro-error)]"}),t]})]})]})}function dr({open:e,onClose:t,title:r,children:o,width:a="md",showOverlay:n=false,accentClass:s}){let l=Ta.useRef(null),[i,d]=Ta.useState(false);Ta.useEffect(()=>{d(true);},[]),Ta.useEffect(()=>{let p=y=>{y.key==="Escape"&&t();};return e&&(document.addEventListener("keydown",p),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",p),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||!i?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-[99998] bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.jsxs("div",{ref:l,"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)] ${s?`border-l-2 ${s}`:"border-l border-[var(--kyro-border)]"} shadow-2xl flex flex-col animate-slideIn`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsx("h2",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.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:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:o})]}),jsxRuntime.jsx("style",{children:`
2
2
  @keyframes slideIn {
3
3
  from { transform: translateX(100%); }
4
4
  to { transform: translateX(0); }
@@ -6,24 +6,24 @@
6
6
  .animate-slideIn {
7
7
  animation: slideIn 300ms ease-out;
8
8
  }
9
- `})]}),document.body)}function Hr({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Vr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function Ot({open:e,onClose:t,title:r,children:o,footer:a,size:n="md",variant:s="default"}){if(Ca.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 l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",full:"w-full h-full max-w-none rounded-none border-0"},i=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${i?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${l[n]} ${i?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!i&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${i?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!i&&jsxRuntime.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:[jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.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:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${i?"":"px-8 py-8"}`,children:o}),a&&!i&&jsxRuntime.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 Ns({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:l="default",loading:i=false}){return jsxRuntime.jsx(Ot,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:i,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:i,className:`kyro-btn kyro-btn-md ${l==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:i?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function fl({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,l]=Ca.useState(n),i=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),l(""),t());};return e?reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsxRuntime.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:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:i,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>l(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"})}),jsxRuntime.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:[jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"submit",disabled:!s.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 gl({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,l]=Ca.useState("crop"),[i,d]=Ca.useState(t?{unit:"%",...t}:void 0),[c,m]=Ca.useState(r||{x:40,y:40,width:20,height:20}),[f,v]=Ca.useState(!!r),b=Ca.useRef(null),g=Ca.useRef(null),[x,u]=Ca.useState(false),[y,h]=Ca.useState(null),R=Ca.useRef(null),P=(S,F)=>{s==="hotspot"&&(S.stopPropagation(),S.preventDefault(),F?h(F):u(true),R.current={x:S.clientX,y:S.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},w=Ca.useCallback(S=>{if(!R.current||!b.current)return;let F=b.current.getBoundingClientRect(),A=(S.clientX-R.current.x)/F.width*100,X=(S.clientY-R.current.y)/F.height*100,K=R.current;if(x){let $=K.hX+A,j=K.hY+X;$=Math.max(0,Math.min($,100-K.hW)),j=Math.max(0,Math.min(j,100-K.hH)),m(ae=>({...ae,x:$,y:j}));}else if(y){let $=K.hX,j=K.hY,ae=K.hW,ne=K.hH;y.includes("e")&&(ae=K.hW+A),y.includes("w")&&($=K.hX+A,ae=K.hW-A),y.includes("s")&&(ne=K.hH+X),y.includes("n")&&(j=K.hY+X,ne=K.hH-X),ae<5&&(ae=5,y.includes("w")&&($=K.hX+K.hW-5)),ne<5&&(ne=5,y.includes("n")&&(j=K.hY+K.hH-5)),$=Math.max(0,Math.min($,100-ae)),j=Math.max(0,Math.min(j,100-ne)),ae=Math.min(ae,100-$),ne=Math.min(ne,100-j),m({x:$,y:j,width:ae,height:ne});}},[x,y,c]),k=Ca.useCallback(()=>{u(false),h(null),R.current=null;},[]);return Ca.useEffect(()=>((x||y)&&(window.addEventListener("pointermove",w),window.addEventListener("pointerup",k)),()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",k);}),[x,y,w,k]),jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>l("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(lucideReact.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{l("hotspot"),f||v(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(lucideReact.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:()=>{d(void 0),v(false);},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:[jsxRuntime.jsx(lucideReact.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{onClick:()=>{let S=i?.width&&i?.height?{x:i.x,y:i.y,width:i.width,height:i.height}:void 0;o(S,f?c:void 0);},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?jsxRuntime.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:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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"})]})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:g,children:[jsxRuntime.jsx(hp__default.default,{crop:i,onChange:(S,F)=>d(F),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:b,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:S=>{}})}),f&&b.current&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"relative",style:{width:b.current.width,height:b.current.height},children:jsxRuntime.jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${s==="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:S=>P(S),children:[jsxRuntime.jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),s==="hotspot"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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:S=>P(S,"n")}),jsxRuntime.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:S=>P(S,"s")}),jsxRuntime.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:S=>P(S,"w")}),jsxRuntime.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:S=>P(S,"e")})]})]})})})]})}),jsxRuntime.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:s==="crop"?"Drag to define the crop area. This creates a bounding box for the image.":"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 wn(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 Sp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Tp(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 Nn({onSelect:e,multiple:t=true,pickerMode:r=false}){let{permissions:o}=Ur(),a=o?.media?.create!==false,n=o?.media?.delete!==false,s=o?.media?.update!==false,[l,i]=Ca.useState([]),[d,c]=Ca.useState(true),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),[g,x]=Ca.useState(""),[u,y]=Ca.useState(""),[h,R]=Ca.useState("all"),[P,w]=Ca.useState("grid"),[k,p]=Ca.useState(null),[T,B]=Ca.useState(false),[S,F]=Ca.useState(false),[A,X]=Ca.useState(false),[K,$]=Ca.useState({}),[j,ae]=Ca.useState(false),[ne,H]=Ca.useState(false),[re,ve]=Ca.useState(null),[L,O]=Ca.useState(false),[pe,ge]=Ca.useState(false),[Se,Ne]=Ca.useState(1),[U,Y]=Ca.useState(0),[le,Re]=Ca.useState(1),Ue=40,[Ie,et]=Ca.useState(new Set),{confirm:Ct,alert:St}=dt(),[Q,te]=Ca.useState(false),ce=Ca.useRef(null),Te=Ca.useCallback(async C=>{C===1?c(true):f(true);try{let me=new URLSearchParams({page:C.toString(),limit:Ue.toString()});g&&me.append("folder",g),u&&me.append("search",u),h!=="all"&&me.append("type",h);let De=await Be(zr(`/api/media?${me}`)),qt=(De.docs||[]).map(Rt=>({...Rt,type:Tp(Rt.mimeType)}));i(Rt=>C===1?qt:[...Rt,...qt]),Y(De.totalDocs||0),Re(De.totalPages||1);}catch(me){console.error("Failed to load media:",me);}finally{c(false),f(false);}},[g,u,h,Ue]),Fe=Ca.useCallback(async()=>{try{let C=await Be(zr("/api/media/folders"));b(Array.isArray(C)?C:C.folders||[]);}catch(C){console.error("Failed to load folders:",C);}},[]),lt=Ca.useCallback(async()=>{try{let me=!!(await Be("/api/globals/storage-settings"))?.data?.provider;ve(me);}catch{ve(false);}},[]);Ca.useEffect(()=>{r||lt();},[lt,r]),Ca.useEffect(()=>{r||re===false&&!L&&(O(true),ge(true));},[r,re,L]),Ca.useEffect(()=>{Ne(1),Te(1);},[g,u,h,Te]);let Tt=()=>{if(m||Se>=le)return;let C=Se+1;Ne(C),Te(C);};Ca.useEffect(()=>{Fe();},[Fe]),Ca.useEffect(()=>{if(r)return;let C=me=>{let De=me.clipboardData?.files;De&&De.length>0&&I(De);};return window.addEventListener("paste",C),()=>window.removeEventListener("paste",C)},[r,g,re]);let I=async C=>{if(!re){ge(true);return}X(true);let me=0,De=0;for(let qt=0;qt<C.length;qt++){let Rt=C[qt];try{let fr=new FormData;fr.append("file",Rt),g&&fr.append("folder",g),await en("/api/media/upload",fr,os=>{$(Po=>({...Po,[Rt.name]:os}));}),me++;}catch(fr){console.error(`Upload failed for ${Rt.name}:`,fr),De++;}}X(false),$({}),Ne(1),Te(1),Fe(),De>0&&M.error(`${De} file(s) failed to upload`),me>0&&M.success(`${me} file(s) uploaded successfully`);},W=()=>{Ct({title:"Delete Media",message:`Are you sure you want to delete ${Ie.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let C of Array.from(Ie))await xt(`/api/media/${C}`);et(new Set),Ne(1),Te(1),M.success(`${Ie.size} item(s) deleted`);}catch(C){console.error("Bulk delete failed:",C),M.error("Failed to delete some items");}}});},ie=(C,me)=>{me.stopPropagation();let De=new Set(Ie);De.has(C)?De.delete(C):(t||De.clear(),De.add(C)),et(De);},sr=async C=>{try{await nt("/api/media/folders",{name:C}),Fe(),ae(!1),M.success(`Folder "${C}" created`);}catch(me){console.error("Failed to create folder:",me),M.error("Failed to create folder");}},po=C=>{Ct({title:"Delete Folder",message:`Are you sure you want to delete the folder "${C}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await xt(`/api/media/folders?path=${encodeURIComponent(C)}`),g===C&&x(""),Fe(),Ne(1),Te(1),M.success(`Folder "${C}" deleted`);}catch(me){console.error("Failed to delete folder:",me),M.error("Failed to delete folder");}}});},ya=async(C,me)=>{try{let De=await Gt(`/api/media/${C}`,me);i(qt=>qt.map(Rt=>Rt.id===C?De.doc:Rt)),k?.id===C&&p(De.doc),M.success("Metadata updated");}catch(De){console.error("Failed to update metadata:",De),M.error("Failed to update metadata");}},qa=async(C,me)=>{if(k)try{X(!0);let De={...k.metadata,crop:C,hotspot:me},qt=await Gt(`/api/media/${k.id}`,{metadata:De});i(Rt=>Rt.map(fr=>fr.id===k.id?qt.doc:fr)),p(qt.doc),F(!1),M.success("Focal metadata saved");}catch(De){console.error("Save failed:",De),M.error("Failed to save focal metadata");}finally{X(false);}},rs=Ca.useMemo(()=>l.reduce((C,me)=>(C.totalSize+=me.fileSize||0,C),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${Q?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:C=>{C.preventDefault(),te(true);},onDragLeave:()=>te(false),onDrop:C=>{C.preventDefault(),te(false),C.dataTransfer.files&&I(C.dataTransfer.files);}},children:[jsxRuntime.jsxs("div",{className:`flex flex-col lg:flex-row lg:items-center justify-between gap-6 border-b border-[var(--kyro-border)] backdrop-blur-md sticky top-0 ${r?"p-2":"p-6 rounded-xl surface-tile"}`,children:[!r&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-3 mt-1",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[U," Items \xB7 ",wn(rs.totalSize)]})})]})}),jsxRuntime.jsxs("div",{className:`flex items-center gap-3 flex-wrap lg:flex-nowrap ${r?"w-full":""}`,children:[jsxRuntime.jsxs("div",{className:"relative group flex-1 min-w-[200px]",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search assets...",value:u,onChange:C=>y(C.target.value),className:"w-full pl-11 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"})]}),!r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{onClick:()=>w("grid"),className:`p-2 rounded-lg transition-all ${P==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(lucideReact.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>w("list"),className:`p-2 rounded-lg transition-all ${P==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(lucideReact.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>H(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:jsxRuntime.jsx(lucideReact.Filter,{className:"w-4 h-4"})})]}),a&&jsxRuntime.jsxs("button",{onClick:()=>ce.current?.click(),className:"flex items-center gap-2 px-6 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:[jsxRuntime.jsx(lucideReact.Maximize2,{className:"w-4 h-4"}),"Upload"]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsxs("button",{onClick:()=>R(C),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${h===C?"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:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${h===C?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),C]},C))})]}),jsxRuntime.jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>ae(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(lucideReact.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>x(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===""?"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:[jsxRuntime.jsx(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),v.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>x(C),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===C?"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:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(lucideReact.Folder,{fill:g===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),po(C);},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:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.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:[d?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(Et,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.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&&a&&jsxRuntime.jsx("button",{onClick:()=>ce.current?.click(),className:"mt-8 px-8 py-3 bg-[var(--kyro-text-primary)] text-[var(--kyro-bg)] rounded-2xl font-bold text-xs hover:scale-105 transition-all shadow-xl",children:"Start Uploading"})]}):P==="grid"?jsxRuntime.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((C,me)=>jsxRuntime.jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${Ie.has(C.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>p(C),onContextMenu:De=>{De.preventDefault(),ie(C.id,De);},children:[C.type==="image"?jsxRuntime.jsx("img",{src:C.url,alt:C.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsxRuntime.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:C.type==="video"?jsxRuntime.jsx(lucideReact.Film,{className:"w-8 h-8"}):C.type==="audio"?jsxRuntime.jsx(lucideReact.Music,{className:"w-8 h-8"}):C.type==="document"?jsxRuntime.jsx(lucideReact.FileText,{className:"w-8 h-8"}):C.type==="archive"?jsxRuntime.jsx(lucideReact.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:C.title})]}),jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:C.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:De=>ie(C.id,De),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${Ie.has(C.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})})})]})}),Ie.has(C.id)&&jsxRuntime.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:jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})})]},C.id))}):jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-12",children:jsxRuntime.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:Ie.size===l.length,onChange:C=>{C.target.checked?et(new Set(l.map(me=>me.id))):et(new Set);}})}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Asset"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Type"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Size"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Date"}),jsxRuntime.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(C=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${Ie.has(C.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>p(C),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:me=>me.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:Ie.has(C.id),onChange:me=>ie(C.id,me),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.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:C.type==="image"?jsxRuntime.jsx("img",{src:C.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(lucideReact.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C.title||C.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:C.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[9px]",children:C.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:wn(C.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Sp(C.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),ie(C.id,me);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${Ie.has(C.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(lucideReact.Grid3X3,{className:"w-4 h-4"})})})]},C.id))})]})}),!d&&Se<le&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.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?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(kr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&A&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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:jsxRuntime.jsx(kr,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(K).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(K).map(([C,me])=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:C}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[me,"%"]})]}),jsxRuntime.jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${me}%`}})})]},C))})]})}),Ie.size>0&&jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsxRuntime.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:Ie.size}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsxRuntime.jsx("button",{onClick:()=>et(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[e&&jsxRuntime.jsx("button",{onClick:()=>{let C=l.filter(me=>Ie.has(me.id));e(C);},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&&n&&jsxRuntime.jsx("button",{onClick:W,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:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-5 h-5"})})]})]}),ne&&!r&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>H(false)}),jsxRuntime.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:[jsxRuntime.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:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsxRuntime.jsx("button",{onClick:()=>H(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(C=>jsxRuntime.jsx("button",{onClick:()=>{R(C),H(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${h===C?"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:C},C))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>{ae(true),H(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(lucideReact.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{x(""),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===""?"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:[jsxRuntime.jsx(lucideReact.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),v.map(C=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{x(C),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${g===C?"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:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(lucideReact.Folder,{fill:g===C?"currentColor":"none"})}),C]}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),po(C),H(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:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]},C))]})]})]})]})]}),jsxRuntime.jsx(dr,{open:!!k,onClose:()=>p(null),title:"Asset Details",subtitle:k?.filename,children:k&&jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[k.type==="image"?jsxRuntime.jsx("img",{src:Gr(k.url),alt:"",className:"w-full h-full object-contain p-4"}):k.type==="video"?jsxRuntime.jsx("video",{src:Gr(k.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(Pt,{variant:"outline",className:"text-xs font-bold",children:k.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>B(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(lucideReact.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:k.type==="image"?"Original Resolution":"N/A"})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:wn(k.fileSize)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:Gr(k.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"}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(Gr(k.url)),M.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:jsxRuntime.jsx(lucideReact.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:k.alt||"",onChange:C=>ya(k.id,{alt:C.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:"Describe this asset..."})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsxRuntime.jsx("textarea",{value:k.caption||"",onChange:C=>ya(k.id,{caption:C.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:"Add a caption..."})]})]})]})]}),!r&&jsxRuntime.jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxRuntime.jsxs("button",{onClick:()=>{let C=document.createElement("a");C.href=Gr(k.url),C.download=k.filename,C.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:[jsxRuntime.jsx(lucideReact.Download,{className:"w-4 h-4"}),"Download"]}),k.type==="image"&&s&&jsxRuntime.jsx("button",{onClick:()=>F(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:jsxRuntime.jsx(lucideReact.Crop,{className:"w-4 h-4"})}),n&&jsxRuntime.jsx("button",{onClick:()=>{Ct({title:"Delete Asset",message:`Are you sure you want to delete ${k.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await xt(`/api/media/${k.id}`),p(null),Te();}catch(C){console.error("Delete failed:",C),M.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"})})]})]})}),T&&k&&jsxRuntime.jsxs(Ot,{open:T,onClose:()=>B(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:k.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[wn(k.fileSize)," \xB7 ",k.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>B(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(lucideReact.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:k.type==="image"?jsxRuntime.jsx("img",{src:Gr(k.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):k.type==="video"?jsxRuntime.jsx("video",{src:Gr(k.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(lucideReact.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&S&&k&&jsxRuntime.jsx(Ot,{open:S,onClose:()=>F(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(gl,{url:Gr(k.url),initialCrop:k.metadata?.crop,initialHotspot:k.metadata?.hotspot,onSave:qa,onCancel:()=>F(false),isSaving:A})}),!r&&jsxRuntime.jsx(fl,{open:j,onClose:()=>ae(false),onSubmit:sr,title:"Create New Folder",placeholder:"Folder name"}),!r&&jsxRuntime.jsx(Ot,{open:pe,onClose:()=>ge(false),title:"Storage Not Configured",size:"md",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.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."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:"/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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{nt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{ge(false),ve(true),window.location.reload();}).catch(()=>{M.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&&jsxRuntime.jsx("input",{type:"file",ref:ce,onChange:C=>{C.target.files&&I(C.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var tm=[{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"}],Al=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let[a,n]=Ca.useState(null),s=Ca.useRef(null);if(Ca.useEffect(()=>{function u(y){s.current&&!s.current.contains(y.target)&&n(null);}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),!e)return null;let l=()=>{o();},i=()=>{let u=e.getAttributes("link").href,y=window.prompt("URL",u);if(y!==null){if(y===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:y}).run();}},d=u=>{u==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(u).run(),n(null);},c=u=>{n(a===u?null:u);},m=()=>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",f=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(lucideReact.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(lucideReact.AlignRight,{size:12}):jsxRuntime.jsx(lucideReact.AlignLeft,{size:12}),v=()=>e.isActive("orderedList")?jsxRuntime.jsx(lucideReact.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(lucideReact.CheckSquare,{size:12}):jsxRuntime.jsx(lucideReact.List,{size:12}),b=()=>e.isActive("codeBlock")?jsxRuntime.jsx(lucideReact.Terminal,{size:12}):jsxRuntime.jsx(lucideReact.Quote,{size:12}),g=({onClick:u,isActive:y=false,disabled:h=false,children:R,title:P})=>jsxRuntime.jsx("button",{type:"button",onClick:u,disabled:h,title:P,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
10
- ${y?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
11
- ${h?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:R}),x=({onClick:u,isActive:y,children:h,title:R})=>jsxRuntime.jsxs("button",{type:"button",onClick:u,title:R,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
12
- ${y?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[h,jsxRuntime.jsx(lucideReact.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:s,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:[jsxRuntime.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:[jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:"Undo (Ctrl+Z)",children:jsxRuntime.jsx(lucideReact.Undo,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:"Redo (Ctrl+Y)",children:jsxRuntime.jsx(lucideReact.Redo,{size:12})})]}),jsxRuntime.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:[jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:"Bold (Ctrl+B)",children:jsxRuntime.jsx(lucideReact.Bold,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:"Italic (Ctrl+I)",children:jsxRuntime.jsx(lucideReact.Italic,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:"Underline (Ctrl+U)",children:jsxRuntime.jsx(lucideReact.Underline,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:"Strikethrough",children:jsxRuntime.jsx(lucideReact.Strikethrough,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:"Inline Code",children:jsxRuntime.jsx(lucideReact.Code,{size:12})}),jsxRuntime.jsx(g,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:"Highlight Text",children:jsxRuntime.jsx(lucideReact.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(g,{onClick:()=>c("color"),title:"Text Color",isActive:a==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(lucideReact.Palette,{size:12})}),a==="color"&&jsxRuntime.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:tm.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>d(u.value),title:u.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:u.value==="inherit"?"transparent":u.value},children:u.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},u.name))})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(x,{onClick:()=>c("heading"),isActive:a==="heading",title:"Heading hierarchy",children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:m()})}),a==="heading"&&jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),n(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
13
- ${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(u=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:u}).run(),n(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
14
- ${e.isActive("heading",{level:u})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",u]},u))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(x,{onClick:()=>c("lists"),isActive:a==="lists",title:"List Types",children:v()}),a==="lists"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),n(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
15
- ${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),n(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
16
- ${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),n(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
17
- ${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(x,{onClick:()=>c("blocks"),isActive:a==="blocks",title:"Structural Blocks",children:b()}),a==="blocks"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),n(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
18
- ${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),n(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
19
- ${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),n(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:[jsxRuntime.jsx(lucideReact.Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(x,{onClick:()=>c("align"),isActive:a==="align",title:"Alignment",children:f()}),a==="align"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),n(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
20
- ${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),n(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
21
- ${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),n(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
22
- ${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(lucideReact.AlignRight,{size:12}),"Align Right"]})]})]}),jsxRuntime.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:[jsxRuntime.jsx(g,{onClick:i,isActive:e.isActive("link"),title:"Link",children:jsxRuntime.jsx(lucideReact.Link,{size:12})}),jsxRuntime.jsx(g,{onClick:l,title:"Add Image",children:jsxRuntime.jsx(lucideReact.Image,{size:12})})]}),jsxRuntime.jsx("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:jsxRuntime.jsx(g,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(lucideReact.Minimize2,{size:12}):jsxRuntime.jsx(lucideReact.Maximize2,{size:12})})})]})};function jo({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false);return Ca.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(rm,{field:e,value:t,onChange:r,error:o,disabled:a}):jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.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
9
+ `})]}),document.body)}function Br({children:e}){return jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:e})}function Gr({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-3 mt-6",children:e})}function Nt({open:e,onClose:t,title:r,children:o,footer:a,size:n="lg",variant:s="default"}){if(Ta.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 l={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"},i=s==="lightbox";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[jsxRuntime.jsx("div",{className:`absolute inset-0 transition-all duration-500 ${i?"bg-black/95 backdrop-blur-none":"bg-[var(--kyro-black)]/40 backdrop-blur-md"}`,onClick:t}),jsxRuntime.jsxs("div",{className:`relative ${l[n]} ${i?"bg-transparent text-white":"bg-[var(--kyro-surface)]"} ${!i&&n!=="full"?"rounded-[var(--kyro-radius-lg)]":""} shadow-2xl animate-in fade-in zoom-in-95 duration-300 ${i?"":"border"} ${s==="danger"?"border-red-500/30":"border-[var(--kyro-border)]"} flex flex-col overflow-hidden`,children:[!i&&jsxRuntime.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:[jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--kyro-text-primary)]",children:r}),jsxRuntime.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:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:`flex-1 overflow-auto ${i?"":"px-8 py-8"}`,children:o}),a&&!i&&jsxRuntime.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 Es({open:e,onClose:t,onConfirm:r,title:o,message:a,confirmLabel:n="Confirm",cancelLabel:s="Cancel",variant:l="default",loading:i=false}){return jsxRuntime.jsx(Nt,{open:e,onClose:t,title:o,size:"sm",footer:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:i,className:"kyro-btn kyro-btn-md kyro-btn-secondary",children:s}),jsxRuntime.jsx("button",{type:"button",onClick:r,disabled:i,className:`kyro-btn kyro-btn-md ${l==="danger"?"kyro-btn-danger":"kyro-btn-primary"}`,children:i?"Loading...":n})]}),children:jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)]",children:a})})}function Al({open:e,onClose:t,onSubmit:r,title:o,placeholder:a="",defaultValue:n=""}){let[s,l]=Ta.useState(n),i=d=>{d.preventDefault(),s.trim()&&(r(s.trim()),l(""),t());};return e?reactDom.createPortal(jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-[var(--kyro-text-primary)]",children:o}),jsxRuntime.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:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("form",{onSubmit:i,children:[jsxRuntime.jsx("div",{className:"px-6 py-4",children:jsxRuntime.jsx("input",{type:"text",value:s,onChange:d=>l(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"})}),jsxRuntime.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:[jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"submit",disabled:!s.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 Pl({url:e,initialCrop:t,initialHotspot:r,onSave:o,onCancel:a,isSaving:n=false}){let[s,l]=Ta.useState("crop"),[i,d]=Ta.useState(t?{unit:"%",...t}:void 0),[c,p]=Ta.useState(r||{x:40,y:40,width:20,height:20}),[y,g]=Ta.useState(!!r),b=Ta.useRef(null),v=Ta.useRef(null),[k,f]=Ta.useState(false),[u,x]=Ta.useState(null),A=Ta.useRef(null),F=(C,K)=>{s==="hotspot"&&(C.stopPropagation(),C.preventDefault(),K?x(K):f(true),A.current={x:C.clientX,y:C.clientY,hX:c.x,hY:c.y,hW:c.width,hH:c.height});},h=Ta.useCallback(C=>{if(!A.current||!b.current)return;let K=b.current.getBoundingClientRect(),E=(C.clientX-A.current.x)/K.width*100,$=(C.clientY-A.current.y)/K.height*100,O=A.current;if(k){let ne=O.hX+E,ie=O.hY+$;ne=Math.max(0,Math.min(ne,100-O.hW)),ie=Math.max(0,Math.min(ie,100-O.hH)),p(H=>({...H,x:ne,y:ie}));}else if(u){let ne=O.hX,ie=O.hY,H=O.hW,S=O.hH;u.includes("e")&&(H=O.hW+E),u.includes("w")&&(ne=O.hX+E,H=O.hW-E),u.includes("s")&&(S=O.hH+$),u.includes("n")&&(ie=O.hY+$,S=O.hH-$),H<5&&(H=5,u.includes("w")&&(ne=O.hX+O.hW-5)),S<5&&(S=5,u.includes("n")&&(ie=O.hY+O.hH-5)),ne=Math.max(0,Math.min(ne,100-H)),ie=Math.max(0,Math.min(ie,100-S)),H=Math.min(H,100-ne),S=Math.min(S,100-ie),p({x:ne,y:ie,width:H,height:S});}},[k,u,c]),w=Ta.useCallback(()=>{f(false),x(null),A.current=null;},[]);Ta.useEffect(()=>((k||u)&&(window.addEventListener("pointermove",h),window.addEventListener("pointerup",w)),()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",w);}),[k,u,h,w]);let m=C=>{},T=()=>{let C=i?.width&&i?.height?{x:i.x,y:i.y,width:i.width,height:i.height}:void 0;o(C,y?c:void 0);},B=()=>{d(void 0),g(false);},I=Ta.useMemo(()=>{if(!i||!i.width||!i.height)return null;let C=new URLSearchParams({url:e});return C.set("cx",String(i.x)),C.set("cy",String(i.y)),C.set("cw",String(i.width)),C.set("ch",String(i.height)),`/api/media/resize?${C.toString()}`},[e,i]),V=i?.width&&i.height;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full bg-[var(--kyro-bg)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>l("crop"),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="crop"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Hl.Crop,{className:"w-4 h-4"}),"Crop"]}),jsxRuntime.jsxs("button",{onClick:()=>{l("hotspot"),y||g(true);},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${s==="hotspot"?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,children:[jsxRuntime.jsx(Hl.MousePointerClick,{className:"w-4 h-4"}),"Hotspot"]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("button",{onClick:B,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:[jsxRuntime.jsx(Hl.RefreshCcw,{className:"w-4 h-4"}),"Reset"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{onClick:T,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?jsxRuntime.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:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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"})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-8 overflow-hidden relative select-none",children:jsxRuntime.jsxs("div",{className:"relative max-w-full max-h-full flex items-center justify-center",ref:v,children:[jsxRuntime.jsx(jp__default.default,{crop:i,onChange:(C,K)=>d(K),locked:s==="hotspot",className:s==="hotspot"?"opacity-70 transition-opacity":"transition-opacity",children:jsxRuntime.jsx("img",{ref:b,src:e,alt:"Focal Editor",className:"max-h-[70vh] object-contain pointer-events-none",onLoad:m})}),y&&b.current&&jsxRuntime.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"relative",style:{width:b.current.width,height:b.current.height},children:jsxRuntime.jsxs("div",{className:`absolute border-2 shadow-2xl transition-colors duration-200 ${s==="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:C=>F(C),children:[jsxRuntime.jsx("div",{className:"absolute top-1/2 left-1/2 w-2 h-2 -ml-1 -mt-1 bg-blue-500 rounded-full"}),s==="hotspot"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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:C=>F(C,"n")}),jsxRuntime.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:C=>F(C,"s")}),jsxRuntime.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:C=>F(C,"w")}),jsxRuntime.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:C=>F(C,"e")})]})]})})})]})}),V&&jsxRuntime.jsxs("div",{className:"w-[280px] border-l border-[var(--kyro-border)] bg-[var(--kyro-surface)] flex flex-col overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx(Hl.Eye,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)] tracking-wide uppercase",children:"Preview"})]}),jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center p-4 overflow-hidden",children:I&&jsxRuntime.jsx("img",{src:I,alt:"Crop preview",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg border border-[var(--kyro-border)]"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-t border-[var(--kyro-border)] text-[10px] text-[var(--kyro-text-secondary)] font-mono",children:[jsxRuntime.jsxs("div",{children:["x: ",i?.x?.toFixed(1),"% y: ",i?.y?.toFixed(1),"%"]}),jsxRuntime.jsxs("div",{children:["w: ",i?.width?.toFixed(1),"% h: ",i?.height?.toFixed(1),"%"]})]})]})]}),jsxRuntime.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:s==="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 Lr(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 Bn(e,t){if(!e.metadata?.crop)return null;let{x:r,y:o,width:a,height:n}=e.metadata.crop;if(!a||!n||!Lr(e.url))return null;let l=new URLSearchParams({url:e.url});l.set("cx",String(r)),l.set("cy",String(o)),l.set("cw",String(a)),l.set("ch",String(n)),t&&l.set("w",String(t));let i=`/api/media/resize?${l.toString()}`;return typeof window>"u"?i:`${window.location.origin}${i}`}function Ln(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 Kp(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Gp(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 Mn({onSelect:e,multiple:t=true,pickerMode:r=false}){let{permissions:o}=_r(),a=o?.media?.create!==false,n=o?.media?.delete!==false,s=o?.media?.update!==false,[l,i]=Ta.useState([]),[d,c]=Ta.useState(true),[p,y]=Ta.useState(false),[g,b]=Ta.useState([]),[v,k]=Ta.useState(""),[f,u]=Ta.useState(""),[x,A]=Ta.useState("all"),[F,h]=Ta.useState("grid"),[w,m]=Ta.useState(null),[T,B]=Ta.useState(false),[I,V]=Ta.useState(false),[C,K]=Ta.useState(false),[E,$]=Ta.useState({}),[O,ne]=Ta.useState(false),[ie,H]=Ta.useState(false),[S,J]=Ta.useState(null),[fe,U]=Ta.useState(false),[re,j]=Ta.useState(false),[ye,Te]=Ta.useState(1),[z,G]=Ta.useState(0),[_e,Me]=Ta.useState(1),Z=40,[ge,Ge]=Ta.useState(new Set),{confirm:ft,alert:lt}=ut(),[sr,X]=Ta.useState(false),le=Ta.useRef(null),ce=Ta.useCallback(async R=>{R===1?c(true):y(true);try{let oe=new URLSearchParams({page:R.toString(),limit:Z.toString()});v&&oe.append("folder",v),f&&oe.append("search",f),x!=="all"&&oe.append("type",x);let Ie=await Ae(Hr(`/api/media?${oe}`)),$t=(Ie.docs||[]).map(Ot=>({...Ot,type:Gp(Ot.mimeType)}));i(Ot=>R===1?$t:[...Ot,...$t]),G(Ie.totalDocs||0),Me(Ie.totalPages||1);}catch(oe){console.error("Failed to load media:",oe);}finally{c(false),y(false);}},[v,f,x,Z]),Se=Ta.useCallback(async()=>{try{let R=await Ae(Hr("/api/media/folders"));b(Array.isArray(R)?R:R.folders||[]);}catch(R){console.error("Failed to load folders:",R);}},[]),Ee=Ta.useCallback(async()=>{try{let oe=!!(await Ae("/api/globals/storage-settings"))?.data?.provider;J(oe);}catch{J(false);}},[]);Ta.useEffect(()=>{r||Ee();},[Ee,r]),Ta.useEffect(()=>{r||S===false&&!fe&&(U(true),j(true));},[r,S,fe]),Ta.useEffect(()=>{Te(1),ce(1);},[v,f,x,ce]);let He=()=>{if(p||ye>=_e)return;let R=ye+1;Te(R),ce(R);};Ta.useEffect(()=>{Se();},[Se]),Ta.useEffect(()=>{if(r)return;let R=oe=>{let Ie=oe.clipboardData?.files;Ie&&Ie.length>0&&D(Ie);};return window.addEventListener("paste",R),()=>window.removeEventListener("paste",R)},[r,v,S]);let D=async R=>{if(!S){j(true);return}K(true);let oe=0,Ie=0;for(let $t=0;$t<R.length;$t++){let Ot=R[$t];try{let vr=new FormData;vr.append("file",Ot),v&&vr.append("folder",v),await dn("/api/media/upload",vr,gs=>{$(bs=>({...bs,[Ot.name]:gs}));}),oe++;}catch(vr){console.error(`Upload failed for ${Ot.name}:`,vr),Ie++;}}K(false),$({}),Te(1),ce(1),Se(),Ie>0&&L.error(`${Ie} file(s) failed to upload`),oe>0&&L.success(`${oe} file(s) uploaded successfully`);},Q=()=>{ft({title:"Delete Media",message:`Are you sure you want to delete ${ge.size} item(s)? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{for(let R of Array.from(ge))await wt(`/api/media/${R}`);Ge(new Set),Te(1),ce(1),L.success(`${ge.size} item(s) deleted`);}catch(R){console.error("Bulk delete failed:",R),L.error("Failed to delete some items");}}});},pe=(R,oe)=>{oe.stopPropagation();let Ie=new Set(ge);Ie.has(R)?Ie.delete(R):(t||Ie.clear(),Ie.add(R)),Ge(Ie);},fr=async R=>{try{await dt("/api/media/folders",{name:R}),Se(),ne(!1),L.success(`Folder "${R}" created`);}catch(oe){console.error("Failed to create folder:",oe),L.error("Failed to create folder");}},fo=R=>{ft({title:"Delete Folder",message:`Are you sure you want to delete the folder "${R}"? All media in this folder will be moved to the root.`,variant:"danger",confirmLabel:"Delete Folder",onConfirm:async()=>{try{await wt(`/api/media/folders?path=${encodeURIComponent(R)}`),v===R&&k(""),Se(),Te(1),ce(1),L.success(`Folder "${R}" deleted`);}catch(oe){console.error("Failed to delete folder:",oe),L.error("Failed to delete folder");}}});},fa=async(R,oe)=>{try{let Ie=await Wt(`/api/media/${R}`,oe);i($t=>$t.map(Ot=>Ot.id===R?Ie.doc:Ot)),w?.id===R&&m(Ie.doc),L.success("Metadata updated");}catch(Ie){console.error("Failed to update metadata:",Ie),L.error("Failed to update metadata");}},Za=async(R,oe)=>{if(w)try{K(!0);let Ie={...w.metadata,crop:R,hotspot:oe},$t=await Wt(`/api/media/${w.id}`,{metadata:Ie});i(Ot=>Ot.map(vr=>vr.id===w.id?$t.doc:vr)),m($t.doc),V(!1),L.success("Crop & hotspot saved");}catch(Ie){console.error("Save failed:",Ie),L.error("Failed to save focal metadata");}finally{K(false);}},en=Ta.useMemo(()=>l.reduce((R,oe)=>(R.totalSize+=oe.fileSize||0,R),{totalSize:0}),[l]);return jsxRuntime.jsxs("div",{className:`flex flex-col h-full bg-[var(--kyro-bg)] transition-all duration-300 ${sr?"ring-4 ring-[var(--kyro-sidebar-active)] ring-inset":""}`,...r?{}:{onDragOver:R=>{R.preventDefault(),X(true);},onDragLeave:()=>X(false),onDrop:R=>{R.preventDefault(),X(false),R.dataTransfer.files&&D(R.dataTransfer.files);}},children:[jsxRuntime.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&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg md:text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:"Media Library"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50",children:[z," Items ",jsxRuntime.jsxs("span",{className:"hidden sm:inline",children:["\xB7 ",Ln(en.totalSize)]})]})})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)] hidden sm:flex",children:[jsxRuntime.jsx("button",{onClick:()=>h("grid"),className:`p-1.5 md:p-2 rounded-lg transition-all ${F==="grid"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Hl.Grid3X3,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{onClick:()=>h("list"),className:`p-1.5 md:p-2 rounded-lg transition-all ${F==="list"?"bg-[var(--kyro-surface)] shadow-sm text-[var(--kyro-text-primary)]":"text-[var(--kyro-text-secondary)] opacity-50 hover:opacity-100"}`,children:jsxRuntime.jsx(Hl.File,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("button",{onClick:()=>H(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:jsxRuntime.jsx(Hl.Filter,{className:"w-4 h-4"})}),a&&jsxRuntime.jsxs("button",{onClick:()=>le.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:[jsxRuntime.jsx("span",{className:"md:hidden text-lg leading-none",children:"+"}),jsxRuntime.jsx(Hl.Maximize2,{className:"w-4 h-4 hidden md:block"}),jsxRuntime.jsx("span",{className:"hidden md:inline",children:"Upload"})]})]})]}),jsxRuntime.jsx("div",{className:"flex items-center w-full",children:jsxRuntime.jsxs("div",{className:"relative group flex-1",children:[jsxRuntime.jsx(Hl.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search assets...",value:f,onChange:R=>u(R.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"})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[!r&&jsxRuntime.jsx("div",{className:"w-64 border-r border-[var(--kyro-border)] surface-tile mt-6 overflow-y-auto hidden md:block",children:jsxRuntime.jsxs("div",{className:"p-6 space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"space-y-1",children:["all","image","video","audio","document","archive"].map(R=>jsxRuntime.jsxs("button",{onClick:()=>A(R),className:`w-full flex items-center gap-3 px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all ${x===R?"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:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x===R?"bg-[var(--kyro-primary)]":"bg-transparent border border-current opacity-30"}`}),R]},R))})]}),jsxRuntime.jsxs("div",{className:"pt-6 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>ne(true),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Hl.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>k(""),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Hl.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),g.map(R=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>k(R),className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===R?"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:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Hl.Folder,{fill:v===R?"currentColor":"none"})}),R]}),jsxRuntime.jsx("button",{onClick:oe=>{oe.stopPropagation(),fo(R);},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:jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5"})})]},R))]})]})]})}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-[var(--kyro-bg)]",children:jsxRuntime.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:[d?jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:jsxRuntime.jsx(_t,{variant:"media-card",count:12})}):l.length===0?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center py-32 text-center",children:[jsxRuntime.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:jsxRuntime.jsx(Hl.Grid3X3,{className:"w-10 h-10 text-[var(--kyro-text-muted)] opacity-30"})}),jsxRuntime.jsx("h3",{className:"text-xl font-bold text-[var(--kyro-text-primary)] tracking-tight",children:"No assets found"}),jsxRuntime.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&&a&&jsxRuntime.jsx("button",{onClick:()=>le.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"})]}):F==="grid"?jsxRuntime.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((R,oe)=>jsxRuntime.jsxs("div",{className:`group relative aspect-square rounded-lg overflow-hidden bg-[var(--kyro-surface-accent)] border-2 transition-all duration-300 cursor-pointer ${ge.has(R.id)?"border-[var(--kyro-primary)]":"border-transparent hover:border-[var(--kyro-border-strong)] hover:shadow-2xl hover:-translate-y-1"}`,onClick:()=>m(R),onContextMenu:Ie=>{Ie.preventDefault(),pe(R.id,Ie);},children:[R.type==="image"?jsxRuntime.jsx("img",{src:Bn(R,400)||R.url,alt:R.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-6 gap-4",children:[jsxRuntime.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:R.type==="video"?jsxRuntime.jsx(Hl.Film,{className:"w-8 h-8"}):R.type==="audio"?jsxRuntime.jsx(Hl.Music,{className:"w-8 h-8"}):R.type==="document"?jsxRuntime.jsx(Hl.FileText,{className:"w-8 h-8"}):R.type==="archive"?jsxRuntime.jsx(Hl.Archive,{className:"w-8 h-8"}):jsxRuntime.jsx(Hl.File,{className:"w-8 h-8"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 text-center px-4 line-clamp-2",children:R.title})]}),jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-[10px] truncate max-w-[120px]",children:R.filename}),jsxRuntime.jsx("div",{className:"flex gap-1",children:jsxRuntime.jsx("button",{onClick:Ie=>pe(R.id,Ie),className:`kyro-btn-primary p-1.5 rounded-lg transition-all ${ge.has(R.id)?"":"bg-white/10 text-white hover:bg-white/20"}`,children:jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"})})})]})}),ge.has(R.id)&&jsxRuntime.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:jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"})})]},R.id))}):jsxRuntime.jsx("div",{className:"surface-tile overflow-hidden animate-in fade-in duration-500",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-12",children:jsxRuntime.jsx("input",{type:"checkbox",className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]",checked:ge.size===l.length,onChange:R=>{R.target.checked?Ge(new Set(l.map(oe=>oe.id))):Ge(new Set);}})}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Asset"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Type"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Size"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Date"}),jsxRuntime.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:l.map(R=>jsxRuntime.jsxs("tr",{className:`group hover:bg-[var(--kyro-surface-accent)] transition-colors cursor-pointer ${ge.has(R.id)?"bg-[var(--kyro-surface-accent)]":""}`,onClick:()=>m(R),children:[jsxRuntime.jsx("td",{className:"px-6 py-4",onClick:oe=>oe.stopPropagation(),children:jsxRuntime.jsx("input",{type:"checkbox",checked:ge.has(R.id),onChange:oe=>pe(R.id,oe),className:"w-4 h-4 rounded border-[var(--kyro-border)] text-[var(--kyro-primary)] focus:ring-[var(--kyro-primary)]"})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.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:R.type==="image"?jsxRuntime.jsx("img",{src:Bn(R,96)||R.url,alt:"",className:"w-full h-full object-cover"}):jsxRuntime.jsx(Hl.File,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50"})}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[jsxRuntime.jsx("span",{className:"font-bold text-xs text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:R.title||R.filename}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:R.filename})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-4",children:jsxRuntime.jsx(At,{variant:"outline",className:"text-[9px]",children:R.mimeType})}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Ln(R.fileSize)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-[11px] font-bold text-[var(--kyro-text-secondary)]",children:Kp(R.createdAt)}),jsxRuntime.jsx("td",{className:"px-6 py-4 text-right",children:jsxRuntime.jsx("button",{onClick:oe=>{oe.stopPropagation(),pe(R.id,oe);},className:`kyro-btn-primary p-2 rounded-lg transition-all ${ge.has(R.id)?"":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] opacity-0 group-hover:opacity-100"}`,children:jsxRuntime.jsx(Hl.Grid3X3,{className:"w-4 h-4"})})})]},R.id))})]})}),!d&&ye<_e&&jsxRuntime.jsx("div",{className:"flex justify-center mt-8 pb-8",children:jsxRuntime.jsx("button",{onClick:He,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?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(hr,{size:"sm"})," Loading..."]}):"Load More"})})]})})]}),!r&&C&&jsxRuntime.jsx("div",{className:"fixed bottom-12 left-1/2 -translate-x-1/2 z-[60] w-full max-w-lg",children:jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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:jsxRuntime.jsx(hr,{})}),jsxRuntime.jsx("span",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Uploading Files"})]}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-50",children:[Object.keys(E).length," Total"]})]}),jsxRuntime.jsx("div",{className:"space-y-4 max-h-[160px] overflow-y-auto pr-2 custom-scrollbar",children:Object.entries(E).map(([R,oe])=>jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] font-bold",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-primary)] truncate max-w-[200px]",children:R}),jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)]",children:[oe,"%"]})]}),jsxRuntime.jsx("div",{className:"h-1.5 w-full bg-[var(--kyro-surface-accent)] rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)] transition-all duration-300 rounded-full",style:{width:`${oe}%`}})})]},R))})]})}),ge.size>0&&jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-5 border-r border-[var(--kyro-border)] ",children:[jsxRuntime.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:ge.size}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[11px] font-bold tracking-[0.2em] text-[var(--kyro-text-primary)]",children:"Selected"}),jsxRuntime.jsx("button",{onClick:()=>Ge(new Set),className:"text-[10px] font-bold text-[var(--kyro-primary)] hover:underline opacity-80",children:"Clear all"})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[e&&jsxRuntime.jsx("button",{onClick:()=>{let R=l.filter(oe=>ge.has(oe.id));e(R);},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&&n&&jsxRuntime.jsx("button",{onClick:Q,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:jsxRuntime.jsx(Hl.Trash2,{className:"w-5 h-5"})})]})]}),ie&&!r&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[70] md:hidden",children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>H(false)}),jsxRuntime.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:[jsxRuntime.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:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Filters"}),jsxRuntime.jsx("button",{onClick:()=>H(false),className:"p-2 rounded-xl hover:bg-[var(--kyro-surface-accent)] transition-colors text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("div",{className:"p-6 space-y-8",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40 block mb-4",children:"Quick Filters"}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:["all","image","video","audio","document","archive"].map(R=>jsxRuntime.jsx("button",{onClick:()=>{A(R),H(false);},className:`px-4 py-2 rounded-xl text-[11px] font-bold capitalize transition-all border ${x===R?"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:R},R))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-[0.2em] text-[var(--kyro-text-secondary)] opacity-40",children:"Folders"}),jsxRuntime.jsx("button",{onClick:()=>{ne(true),H(false);},className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-colors text-[var(--kyro-text-primary)]",children:jsxRuntime.jsx(Hl.FolderPlus,{className:"w-4 h-4"})})]}),jsxRuntime.jsxs("nav",{className:"space-y-1",children:[jsxRuntime.jsxs("button",{onClick:()=>{k(""),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===""?"bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] shadow-md":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] hover:text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx(Hl.FolderInput,{className:"w-4 h-4 opacity-70"}),"All Assets"]}),g.map(R=>jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.jsxs("button",{onClick:()=>{k(R),H(false);},className:`w-full flex items-center gap-3 px-4 py-2.5 rounded-xl text-xs font-bold transition-all ${v===R?"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:[jsxRuntime.jsx("div",{className:"w-4 h-4 flex items-center justify-center opacity-70",children:jsxRuntime.jsx(Hl.Folder,{fill:v===R?"currentColor":"none"})}),R]}),jsxRuntime.jsx("button",{onClick:oe=>{oe.stopPropagation(),fo(R),H(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:jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5"})})]},R))]})]})]})]})]}),jsxRuntime.jsx(dr,{open:!!w,onClose:()=>m(null),title:"Asset Details",subtitle:w?.filename,children:w&&jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"aspect-video w-full rounded-2xl bg-[var(--kyro-bg)] border border-[var(--kyro-border)] overflow-hidden relative group",children:[w.type==="image"?jsxRuntime.jsx("img",{src:Bn(w)||Lr(w.url),alt:"",className:"w-full h-full object-contain p-4"}):w.type==="video"?jsxRuntime.jsx("video",{src:Lr(w.url),controls:true,className:"w-full h-full"}):jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center p-12 gap-6",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 rounded-[2rem] bg-[var(--kyro-surface-accent)] flex items-center justify-center",children:jsxRuntime.jsx(Hl.File,{className:"w-10 h-10 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsx(At,{variant:"outline",className:"text-xs font-bold",children:w.mimeType})]}),jsxRuntime.jsx("div",{className:"absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:jsxRuntime.jsx("button",{onClick:()=>B(true),className:"p-2.5 bg-black/50 backdrop-blur-md text-white rounded-xl hover:bg-black/70 transition-all",children:jsxRuntime.jsx(Hl.Maximize2,{className:"w-4 h-4"})})})]}),jsxRuntime.jsxs("div",{className:"mt-8 space-y-8 flex-1",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"Dimensions"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:w.type==="image"?"Original Resolution":"N/A"})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-2xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-1",children:"File Size"}),jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-primary)]",children:Ln(w.fileSize)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Public Link"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{type:"text",readOnly:true,value:Lr(w.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"}),jsxRuntime.jsx("button",{onClick:()=>{navigator.clipboard.writeText(Lr(w.url)),L.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:jsxRuntime.jsx(Hl.Link,{className:"w-4 h-4 text-[var(--kyro-text-primary)]"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Alt Text"}),jsxRuntime.jsx("textarea",{value:w.alt||"",onChange:R=>fa(w.id,{alt:R.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:"Describe this asset..."})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-secondary)] opacity-50 block mb-2 px-1",children:"Caption"}),jsxRuntime.jsx("textarea",{value:w.caption||"",onChange:R=>fa(w.id,{caption:R.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:"Add a caption..."})]})]})]})]}),!r&&jsxRuntime.jsxs("div",{className:"pt-8 border-t border-[var(--kyro-border)] mt-8 flex gap-3 pb-8",children:[jsxRuntime.jsxs("button",{onClick:()=>{let R=document.createElement("a");R.href=Lr(w.url),R.download=w.filename,R.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:[jsxRuntime.jsx(Hl.Download,{className:"w-4 h-4"}),"Download"]}),w.type==="image"&&s&&jsxRuntime.jsx("button",{onClick:()=>V(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:jsxRuntime.jsx(Hl.Crop,{className:"w-4 h-4"})}),n&&jsxRuntime.jsx("button",{onClick:()=>{ft({title:"Delete Asset",message:`Are you sure you want to delete ${w.filename}? This cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await wt(`/api/media/${w.id}`),m(null),ce();}catch(R){console.error("Delete failed:",R),L.error("Failed to delete asset");}}});},className:"p-3 border border-red-100 text-red-500 rounded-xl hover:bg-red-50 transition-all",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-4 h-4"})})]})]})}),T&&w&&jsxRuntime.jsxs(Nt,{open:T,onClose:()=>B(false),title:"",size:"full",variant:"lightbox",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-white font-bold text-lg tracking-tight",children:w.filename}),jsxRuntime.jsxs("span",{className:"text-white/40 text-[10px] font-bold tracking-widest mt-1",children:[Ln(w.fileSize)," \xB7 ",w.mimeType]})]}),jsxRuntime.jsx("button",{onClick:()=>B(false),className:"p-3 bg-white/10 hover:bg-white/20 text-white rounded-2xl transition-all active:scale-90",children:jsxRuntime.jsx(Hl.X,{className:"w-6 h-6"})})]}),jsxRuntime.jsx("div",{className:"flex-1 w-full flex items-center justify-center p-12",children:w.type==="image"?jsxRuntime.jsx("img",{src:Bn(w)||Lr(w.url),alt:"",className:"max-h-full max-w-full object-contain shadow-2xl rounded-lg animate-in zoom-in-95 duration-500"}):w.type==="video"?jsxRuntime.jsx("video",{src:Lr(w.url),controls:true,autoPlay:true,className:"max-h-full max-w-full rounded-lg shadow-2xl"}):jsxRuntime.jsxs("div",{className:"text-white text-center",children:[jsxRuntime.jsx(Hl.File,{className:"w-24 h-24 mx-auto mb-6 opacity-20"}),jsxRuntime.jsx("p",{className:"text-xl font-bold opacity-50",children:"Preview not available for this file type"})]})})]}),!r&&I&&w&&jsxRuntime.jsx(Nt,{open:I,onClose:()=>V(false),title:"",size:"full",variant:"lightbox",children:jsxRuntime.jsx(Pl,{url:Lr(w.url),initialCrop:w.metadata?.crop,initialHotspot:w.metadata?.hotspot,onSave:Za,onCancel:()=>V(false),isSaving:C})}),!r&&jsxRuntime.jsx(Al,{open:O,onClose:()=>ne(false),onSubmit:fr,title:"Create New Folder",placeholder:"Folder name"}),!r&&jsxRuntime.jsx(Nt,{open:re,onClose:()=>j(false),title:"Storage Not Configured",size:"md",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-[var(--kyro-sidebar-active)] flex items-center justify-center",children:jsxRuntime.jsx(Hl.Server,{className:"w-8 h-8 text-[var(--kyro-sidebar-text-active)]"})}),jsxRuntime.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."}),jsxRuntime.jsxs("div",{className:"flex gap-3",children:[jsxRuntime.jsx("a",{href:"/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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{dt("/api/globals/storage-settings",{provider:"local",local:{uploadDir:"./public/uploads",baseUrl:"/uploads"}}).then(()=>{j(false),J(true),window.location.reload();}).catch(()=>{L.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&&jsxRuntime.jsx("input",{type:"file",ref:le,onChange:R=>{R.target.files&&D(R.target.files);},multiple:true,className:"hidden",accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip,.rar,.tar"})]})}var wm=[{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"}],zl=({editor:e,isExpanded:t,setIsExpanded:r,onOpenMediaPicker:o})=>{let[a,n]=Ta.useState(null),s=Ta.useRef(null);if(Ta.useEffect(()=>{function f(u){s.current&&!s.current.contains(u.target)&&n(null);}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]),!e)return null;let l=()=>{o();},i=()=>{let f=e.getAttributes("link").href,u=window.prompt("URL",f);if(u!==null){if(u===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}e.chain().focus().extendMarkRange("link").setLink({href:u}).run();}},d=f=>{f==="inherit"?e.chain().focus().unsetColor().run():e.chain().focus().setColor(f).run(),n(null);},c=f=>{n(a===f?null:f);},p=()=>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",y=()=>e.isActive({textAlign:"center"})?jsxRuntime.jsx(Hl.AlignCenter,{size:12}):e.isActive({textAlign:"right"})?jsxRuntime.jsx(Hl.AlignRight,{size:12}):jsxRuntime.jsx(Hl.AlignLeft,{size:12}),g=()=>e.isActive("orderedList")?jsxRuntime.jsx(Hl.ListOrdered,{size:12}):e.isActive("taskList")?jsxRuntime.jsx(Hl.CheckSquare,{size:12}):jsxRuntime.jsx(Hl.List,{size:12}),b=()=>e.isActive("codeBlock")?jsxRuntime.jsx(Hl.Terminal,{size:12}):jsxRuntime.jsx(Hl.Quote,{size:12}),v=({onClick:f,isActive:u=false,disabled:x=false,children:A,title:F})=>jsxRuntime.jsx("button",{type:"button",onClick:f,disabled:x,title:F,className:`p-1 rounded flex items-center justify-center transition-all duration-150 relative
10
+ ${u?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)] shadow-xs scale-95":"text-[var(--kyro-text)] hover:bg-[var(--kyro-bg-hover)]"}
11
+ ${x?"opacity-35 cursor-not-allowed":"cursor-pointer active:scale-90"}`,children:A}),k=({onClick:f,isActive:u,children:x,title:A})=>jsxRuntime.jsxs("button",{type:"button",onClick:f,title:A,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
12
+ ${u?"bg-[var(--kyro-bg-hover)] border-[var(--kyro-border)]":""}`,children:[x,jsxRuntime.jsx(Hl.ChevronDown,{size:10,className:"opacity-60"})]});return jsxRuntime.jsxs("div",{ref:s,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:[jsxRuntime.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:[jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().undo().run(),disabled:!e.can().chain().focus().undo().run(),title:"Undo (Ctrl+Z)",children:jsxRuntime.jsx(Hl.Undo,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().redo().run(),disabled:!e.can().chain().focus().redo().run(),title:"Redo (Ctrl+Y)",children:jsxRuntime.jsx(Hl.Redo,{size:12})})]}),jsxRuntime.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:[jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleBold().run(),disabled:!e.can().chain().focus().toggleBold().run(),isActive:e.isActive("bold"),title:"Bold (Ctrl+B)",children:jsxRuntime.jsx(Hl.Bold,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleItalic().run(),disabled:!e.can().chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),title:"Italic (Ctrl+I)",children:jsxRuntime.jsx(Hl.Italic,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleUnderline().run(),disabled:!e.can().chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),title:"Underline (Ctrl+U)",children:jsxRuntime.jsx(Hl.Underline,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleStrike().run(),disabled:!e.can().chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),title:"Strikethrough",children:jsxRuntime.jsx(Hl.Strikethrough,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleCode().run(),disabled:!e.can().chain().focus().toggleCode().run(),isActive:e.isActive("code"),title:"Inline Code",children:jsxRuntime.jsx(Hl.Code,{size:12})}),jsxRuntime.jsx(v,{onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),title:"Highlight Text",children:jsxRuntime.jsx(Hl.Highlighter,{size:12})}),jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",children:[jsxRuntime.jsx(v,{onClick:()=>c("color"),title:"Text Color",isActive:a==="color"||e.isActive("textStyle"),children:jsxRuntime.jsx(Hl.Palette,{size:12})}),a==="color"&&jsxRuntime.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:wm.map(f=>jsxRuntime.jsx("button",{type:"button",onClick:()=>d(f.value),title:f.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:f.value==="inherit"?"transparent":f.value},children:f.value==="inherit"&&jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[10px] text-[var(--kyro-text)] font-semibold",children:"\u2205"})},f.name))})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(k,{onClick:()=>c("heading"),isActive:a==="heading",title:"Heading hierarchy",children:jsxRuntime.jsx("span",{className:"font-medium text-[11px] leading-none min-w-[70px] text-left",children:p()})}),a==="heading"&&jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{e.chain().focus().setParagraph().run(),n(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
13
+ ${e.isActive("heading")?"":"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]"}`,children:"Normal Text"}),[1,2,3,4].map(f=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleHeading({level:f}).run(),n(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
14
+ ${e.isActive("heading",{level:f})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:["Heading ",f]},f))]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(k,{onClick:()=>c("lists"),isActive:a==="lists",title:"List Types",children:g()}),a==="lists"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBulletList().run(),n(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
15
+ ${e.isActive("bulletList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.List,{size:12}),"Bullet List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleOrderedList().run(),n(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
16
+ ${e.isActive("orderedList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.ListOrdered,{size:12}),"Ordered List"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleTaskList().run(),n(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
17
+ ${e.isActive("taskList")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.CheckSquare,{size:12}),"Task Checklist"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(k,{onClick:()=>c("blocks"),isActive:a==="blocks",title:"Structural Blocks",children:b()}),a==="blocks"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleBlockquote().run(),n(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
18
+ ${e.isActive("blockquote")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.Quote,{size:12}),"Blockquote"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().toggleCodeBlock().run(),n(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
19
+ ${e.isActive("codeBlock")?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.Terminal,{size:12}),"Code Block"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setHorizontalRule().run(),n(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:[jsxRuntime.jsx(Hl.Minus,{size:12}),"Horizontal Rule"]})]})]}),jsxRuntime.jsxs("div",{className:"relative flex items-center p-0.5 bg-[var(--kyro-bg)] border border-[var(--kyro-border)] rounded-md shadow-xs",children:[jsxRuntime.jsx(k,{onClick:()=>c("align"),isActive:a==="align",title:"Alignment",children:y()}),a==="align"&&jsxRuntime.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:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("left").run(),n(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
20
+ ${e.isActive({textAlign:"left"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.AlignLeft,{size:12}),"Align Left"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("center").run(),n(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
21
+ ${e.isActive({textAlign:"center"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.AlignCenter,{size:12}),"Align Center"]}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{e.chain().focus().setTextAlign("right").run(),n(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
22
+ ${e.isActive({textAlign:"right"})?"font-semibold text-[var(--kyro-primary)] bg-[var(--kyro-bg-hover)]":""}`,children:[jsxRuntime.jsx(Hl.AlignRight,{size:12}),"Align Right"]})]})]}),jsxRuntime.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:[jsxRuntime.jsx(v,{onClick:i,isActive:e.isActive("link"),title:"Link",children:jsxRuntime.jsx(Hl.Link,{size:12})}),jsxRuntime.jsx(v,{onClick:l,title:"Add Image",children:jsxRuntime.jsx(Hl.Image,{size:12})})]}),jsxRuntime.jsx("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:jsxRuntime.jsx(v,{onClick:()=>r(!t),title:t?"Collapse Workspace":"Enlarge Workspace",children:t?jsxRuntime.jsx(Hl.Minimize2,{size:12}):jsxRuntime.jsx(Hl.Maximize2,{size:12})})})]})};function Ho({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false);return Ta.useEffect(()=>{s(true);},[]),n?jsxRuntime.jsx(Nm,{field:e,value:t,onChange:r,error:o,disabled:a}):jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.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
23
23
  ${o?"border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]":"border-[var(--kyro-border)]"}
24
- ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.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]"}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function rm({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(0),[d,c]=Ca.useState(false);Ca.useEffect(()=>{if(!n){i(0);return}let f=document.querySelector('[data-kyro-slide-panel="true"]'),v=()=>{i(f?f.getBoundingClientRect().width:0);};v();let b=new MutationObserver(()=>{v();});f&&b.observe(f),window.addEventListener("resize",v);let g=setInterval(v,100);return ()=>{b&&b.disconnect(),window.removeEventListener("resize",v),clearInterval(g);}},[n]);let m=react.useEditor({extensions:[Dp__default.default.configure({codeBlock:true,link:false,underline:false}),Pp__default.default.configure({openOnClick:false}),Ip__default.default,Bp__default.default.configure({types:["heading","paragraph"]}),Lp__default.default,Mp__default.default.configure({multicolor:true}),Ep__default.default,$p__default.default.configure({nested:true}),extensionTextStyle.TextStyle,Up__default.default],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:f})=>{r(f.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 Ca.useEffect(()=>{m&&t&&JSON.stringify(t)!==JSON.stringify(m.getJSON())&&m.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,m]),jsxRuntime.jsxs(pt,{field:e,error:o,children:[n?jsxRuntime.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:[jsxRuntime.jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsxRuntime.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"})]}):jsxRuntime.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
24
+ ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.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]"}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px] p-4"})]})})}function Nm({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),[l,i]=Ta.useState(0),[d,c]=Ta.useState(false);Ta.useEffect(()=>{if(!n){i(0);return}let y=document.querySelector('[data-kyro-slide-panel="true"]'),g=()=>{i(y?y.getBoundingClientRect().width:0);};g();let b=new MutationObserver(()=>{g();});y&&b.observe(y),window.addEventListener("resize",g);let v=setInterval(g,100);return ()=>{b&&b.disconnect(),window.removeEventListener("resize",g),clearInterval(v);}},[n]);let p=react.useEditor({extensions:[Yp__default.default.configure({codeBlock:true,link:false,underline:false}),Qp__default.default.configure({openOnClick:false}),Zp__default.default,em__default.default.configure({types:["heading","paragraph"]}),tm__default.default,rm__default.default.configure({multicolor:true}),om__default.default,am__default.default.configure({nested:true}),extensionTextStyle.TextStyle,sm__default.default],content:Array.isArray(t)?{type:"doc",content:t}:t||{type:"doc",content:[]},editable:!a,onUpdate:({editor:y})=>{r(y.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 Ta.useEffect(()=>{p&&t&&JSON.stringify(t)!==JSON.stringify(p.getJSON())&&p.commands.setContent(Array.isArray(t)?{type:"doc",content:t}:t);},[t,p]),jsxRuntime.jsxs(it,{field:e,error:o,children:[n?jsxRuntime.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:[jsxRuntime.jsx("span",{className:"font-medium",children:"Rich text editor workspace is currently maximized."}),jsxRuntime.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"})]}):jsxRuntime.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
25
25
  ${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)]"}
26
- ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx(Al,{editor:m,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),n&&typeof document<"u"&&reactDom.createPortal(jsxRuntime.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:[jsxRuntime.jsx(Al,{editor:m,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1 h-[calc(100vh-140px)] bg-[var(--kyro-bg)]",children:jsxRuntime.jsx(react.EditorContent,{editor:m})})]}),document.body),jsxRuntime.jsx("style",{children:`
26
+ ${a?"opacity-60 cursor-not-allowed":""}`,children:[jsxRuntime.jsx(zl,{editor:p,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto min-h-[160px] max-h-[400px]",children:jsxRuntime.jsx(react.EditorContent,{editor:p})})]}),n&&typeof document<"u"&&reactDom.createPortal(jsxRuntime.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:[jsxRuntime.jsx(zl,{editor:p,isExpanded:n,setIsExpanded:s,onOpenMediaPicker:()=>c(true)}),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1 h-[calc(100vh-140px)] bg-[var(--kyro-bg)]",children:jsxRuntime.jsx(react.EditorContent,{editor:p})})]}),document.body),jsxRuntime.jsx("style",{children:`
27
27
  .kyro-richtext ul[data-type="taskList"] {
28
28
  list-style: none !important;
29
29
  padding: 0 !important;
@@ -79,8 +79,8 @@
79
79
  font-style: italic !important;
80
80
  }
81
81
 
82
- `}),d&&jsxRuntime.jsx(dr,{open:d,onClose:()=>c(false),title:"Select Image",width:"xl",children:jsxRuntime.jsx(Nn,{pickerMode:true,multiple:false,onSelect:f=>{if(f&&f.length>0){let v=f[0];m.chain().focus().setImage({src:v.url,alt:v.alt||v.title||"",title:v.title||""}).run();}c(false);}})})]})}var _o={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)"}},Fa={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 Da(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 Il=Ca.createContext(null);function Ho(){let e=Ca.useContext(Il);return e||{mode:"light",theme:_o,lightTheme:_o,darkTheme:Fa,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Dl(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`,Pl(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Pl(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 Pl(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=s=>Math.round(s*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function hr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Ca.useState(t),[s,l]=Ca.useState(r||{}),[i,d]=Ca.useState(o||{}),c=Da(_o,s),m=Da(Fa,i),f=Ca.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?m:c:a==="dark"?m:c,[a,c,m]),[v,b]=Ca.useState(f());Ca.useEffect(()=>{let u=f();b(u),Dl(u);},[f]),Ca.useEffect(()=>{if(a!=="system")return;let u=window.matchMedia("(prefers-color-scheme: dark)"),y=()=>{let h=f();b(h),Dl(h);};return u.addEventListener("change",y),()=>u.removeEventListener("change",y)},[a,f]);let g=Ca.useCallback(u=>{l(y=>({...y,...u})),d(y=>({...y,...u}));},[]),x=Ca.useCallback(u=>`var(--kyro-${u})`,[]);return jsxRuntime.jsx(Il.Provider,{value:{mode:a,theme:v,lightTheme:c,darkTheme:m,setMode:n,updateTheme:g,getCssVar:x},children:e})}var Tn=e=>jsxRuntime.jsx(hr,{defaultMode:"light",...e}),Rn=e=>jsxRuntime.jsx(hr,{defaultMode:"dark",...e});var dm=Ca.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),cm=[{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"}],Ll={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())},Pa=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false),[d,c]=Ca.useState([]),[m,f]=Ca.useState(false),[v,b]=Ca.useState(false),[g,x]=Ca.useState(false),{theme:u}=Ho(),y=u.colors?.accent||u.colors?.primary||"#6366f1",h=e.language?.toLowerCase()||"javascript";Ca.useEffect(()=>{s(true),i(document.documentElement.classList.contains("dark"));let B=new MutationObserver(()=>{i(document.documentElement.classList.contains("dark"));});return B.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>B.disconnect()},[]),Ca.useEffect(()=>{if(!n)return;(async()=>{f(true);try{let F=await(Ll[h]||Ll.javascript)();c([F]);}catch(S){console.error("Failed to load language extension:",S),c([]);}finally{f(false);}})();},[h,n]);let R=Ca.useCallback(B=>r?.(B),[r]),P=Ca.useCallback(()=>{navigator.clipboard.writeText(t),b(true),setTimeout(()=>b(false),1500);},[t]),w=Ca.useCallback(()=>{x(B=>!B),document.body.style.overflow=g?"":"hidden";},[g]),k=l?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,p=cm.find(B=>B.value===h)?.label||h,T=(B,S=1)=>{let F=parseInt(B.slice(1,3),16),A=parseInt(B.slice(3,5),16),X=parseInt(B.slice(5,7),16);return `rgba(${F}, ${A}, ${X}, ${S})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":y,"--accent-light":T(y,.1),"--accent-light-2":T(y,.05)},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:m?"var(--kyro-surface-accent)":y,color:m?"var(--kyro-text-muted)":"white"},children:m?"...":p})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:P,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"}),jsxRuntime.jsx("button",{type:"button",onClick:w,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:g?"Exit":"Expand"})]})]}),jsxRuntime.jsxs("div",{className:`relative rounded-md overflow-hidden transition-all duration-200 ${g?"fixed inset-4 z-50":""}`,style:{backgroundColor:"var(--kyro-surface)",borderColor:o?"var(--kyro-error)":"var(--kyro-border)",borderWidth:"1px"},children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:y}}),jsxRuntime.jsx(Ca.Suspense,{fallback:jsxRuntime.jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:y,borderWidth:"2px"}})}),children:jsxRuntime.jsx(dm,{value:t??"",height:g?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:k,onChange:R,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&&jsxRuntime.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})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:[jsxRuntime.jsxs("span",{children:[t.split(`
83
- `).length," lines"]}),jsxRuntime.jsx("span",{style:{color:y},children:"CodeMirror"})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsxRuntime.jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function ym(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").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 Fs=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false);Ca.useEffect(()=>{i(true);},[]);let d=Ca.useCallback(f=>{r?.(f.target.value);},[r]),c=Ca.useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),m=t?.length||0;return l?jsxRuntime.jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[c," words \u2022 ",m," chars"]}),jsxRuntime.jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(false),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(true),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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"})]})]})]}),jsxRuntime.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:n?jsxRuntime.jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:ym(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:d,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:`Enter markdown content...
82
+ `}),d&&jsxRuntime.jsx(dr,{open:d,onClose:()=>c(false),title:"Select Image",width:"xl",children:jsxRuntime.jsx(Mn,{pickerMode:true,multiple:false,onSelect:y=>{if(y&&y.length>0){let g=y[0];p.chain().focus().setImage({src:g.url,alt:g.alt||g.title||"",title:g.title||""}).run();}c(false);}})})]})}var jl=Object.keys(Hl__namespace).filter(e=>/^[A-Z]/.test(e)&&e!=="LucideProps"&&e!=="Icon");function Vl({open:e,onClose:t,onSelect:r}){let[o,a]=Ta.useState(""),n=Ta.useMemo(()=>{if(!o)return jl;let s=o.toLowerCase();return jl.filter(l=>l.toLowerCase().includes(s))},[o]);return jsxRuntime.jsx(Nt,{open:e,onClose:t,title:"Select an Icon",size:"xl",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-[60vh]",children:[jsxRuntime.jsxs("div",{className:"relative mb-6",children:[jsxRuntime.jsx(Hl.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search icons...",value:o,onChange:s=>a(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"})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 custom-scrollbar pr-2",children:n.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-[var(--kyro-text-secondary)] font-medium",children:"No icons found"}):jsxRuntime.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-3 pb-8",children:n.map(s=>{let l=Hl__namespace[s],i=s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(i),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:jsxRuntime.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 $n({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),l=t==null?"":String(t),i=Ta.useMemo(()=>l?l.split("-").map(p=>p.charAt(0).toUpperCase()+p.slice(1)).join(""):"",[l]),d=Hl__namespace[i],c=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsxs(it,{field:e,error:o,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"flex-1 relative",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:l,onChange:p=>r?.(p.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":""}`})}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(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?jsxRuntime.jsx(d,{className:"w-5 h-5",strokeWidth:2}):jsxRuntime.jsx(Hl__namespace.Search,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"}),"Browse"]})]}),n&&jsxRuntime.jsx(Vl,{open:n,onClose:()=>s(false),onSelect:p=>{r?.(p);}})]})}var Vo={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)"}},Ia={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 Ba(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 Jl=Ta.createContext(null);function Ko(){let e=Ta.useContext(Jl);return e||{mode:"light",theme:Vo,lightTheme:Vo,darkTheme:Ia,setMode:()=>{},updateTheme:()=>{},getCssVar:t=>`var(--kyro-${t})`}}function Gl(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`,Wl(o,.9)),t.style.setProperty(`--kyro-${r}-dark`,Wl(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 Wl(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=s=>Math.round(s*t).toString(16).padStart(2,"0");return `#${n(r)}${n(o)}${n(a)}`}function wr({children:e,defaultMode:t="light",light:r,dark:o}){let[a,n]=Ta.useState(t),[s,l]=Ta.useState(r||{}),[i,d]=Ta.useState(o||{}),c=Ba(Vo,s),p=Ba(Ia,i),y=Ta.useCallback(()=>a==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?p:c:a==="dark"?p:c,[a,c,p]),[g,b]=Ta.useState(y());Ta.useEffect(()=>{let f=y();b(f),Gl(f);},[y]),Ta.useEffect(()=>{if(a!=="system")return;let f=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{let x=y();b(x),Gl(x);};return f.addEventListener("change",u),()=>f.removeEventListener("change",u)},[a,y]);let v=Ta.useCallback(f=>{l(u=>({...u,...f})),d(u=>({...u,...f}));},[]),k=Ta.useCallback(f=>`var(--kyro-${f})`,[]);return jsxRuntime.jsx(Jl.Provider,{value:{mode:a,theme:g,lightTheme:c,darkTheme:p,setMode:n,updateTheme:v,getCssVar:k},children:e})}var Un=e=>jsxRuntime.jsx(wr,{defaultMode:"light",...e}),zn=e=>jsxRuntime.jsx(wr,{defaultMode:"dark",...e});var Lm=Ta.lazy(()=>import('@uiw/react-codemirror').then(e=>({default:e.default}))),Mm=[{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"}],Xl={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())},La=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ta.useState(false),[l,i]=Ta.useState(false),[d,c]=Ta.useState([]),[p,y]=Ta.useState(false),[g,b]=Ta.useState(false),[v,k]=Ta.useState(false),{theme:f}=Ko(),u=f.colors?.accent||f.colors?.primary||"#6366f1",x=e.language?.toLowerCase()||"javascript";Ta.useEffect(()=>{s(true),i(document.documentElement.classList.contains("dark"));let B=new MutationObserver(()=>{i(document.documentElement.classList.contains("dark"));});return B.observe(document.documentElement,{attributes:true,attributeFilter:["class"]}),()=>B.disconnect()},[]),Ta.useEffect(()=>{if(!n)return;(async()=>{y(true);try{let V=await(Xl[x]||Xl.javascript)();c([V]);}catch(I){console.error("Failed to load language extension:",I),c([]);}finally{y(false);}})();},[x,n]);let A=Ta.useCallback(B=>r?.(B),[r]),F=Ta.useCallback(()=>{navigator.clipboard.writeText(t),b(true),setTimeout(()=>b(false),1500);},[t]),h=Ta.useCallback(()=>{k(B=>!B),document.body.style.overflow=v?"":"hidden";},[v]),w=l?codemirrorThemeAura.aura:codemirrorThemeGithub.githubLight,m=Mm.find(B=>B.value===x)?.label||x,T=(B,I=1)=>{let V=parseInt(B.slice(1,3),16),C=parseInt(B.slice(3,5),16),K=parseInt(B.slice(5,7),16);return `rgba(${V}, ${C}, ${K}, ${I})`};return n?jsxRuntime.jsxs("div",{className:"group",style:{"--accent":u,"--accent-light":T(u,.1),"--accent-light-2":T(u,.05)},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-[var(--kyro-text-primary)]",children:e.label||e.name}),jsxRuntime.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold transition-colors",style:{backgroundColor:p?"var(--kyro-surface-accent)":u,color:p?"var(--kyro-text-muted)":"white"},children:p?"...":m})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:F,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"}),jsxRuntime.jsx("button",{type:"button",onClick:h,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"})]})]}),jsxRuntime.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:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 transition-all duration-200",style:{backgroundColor:u}}),jsxRuntime.jsx(Ta.Suspense,{fallback:jsxRuntime.jsx("div",{className:"h-[280px] flex items-center justify-center",style:{backgroundColor:"var(--kyro-surface)"},children:jsxRuntime.jsx("div",{className:"w-6 h-6 rounded-full animate-spin",style:{borderColor:"var(--kyro-border)",borderTopColor:u,borderWidth:"2px"}})}),children:jsxRuntime.jsx(Lm,{value:t??"",height:v?"calc(100vh - 100px)":"280px",width:"100%",extensions:d,theme:w,onChange:A,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&&jsxRuntime.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})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between mt-2 text-[10px]",style:{color:"var(--kyro-text-muted)"},children:[jsxRuntime.jsxs("span",{children:[t.split(`
83
+ `).length," lines"]}),jsxRuntime.jsx("span",{style:{color:u},children:"CodeMirror"})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-5 w-24 rounded bg-[var(--kyro-surface-accent)] animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-16 rounded bg-[var(--kyro-surface-accent)] animate-pulse"})]}),jsxRuntime.jsx("div",{className:"h-[280px] rounded-xl bg-[var(--kyro-surface-accent)] animate-pulse"})]})};function Um(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").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 Vs=({field:e,value:t="",onChange:r,error:o,disabled:a})=>{let[n,s]=Ta.useState(false),[l,i]=Ta.useState(false);Ta.useEffect(()=>{i(true);},[]);let d=Ta.useCallback(y=>{r?.(y.target.value);},[r]),c=Ta.useMemo(()=>t?t.trim().split(/\s+/).filter(Boolean).length:0,[t]),p=t?.length||0;return l?jsxRuntime.jsxs("div",{className:"kyro-form-field",style:{position:"relative",zIndex:10,pointerEvents:"auto"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:[c," words \u2022 ",p," chars"]}),jsxRuntime.jsxs("div",{className:"flex rounded-md overflow-hidden border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(false),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(true),className:`px-3 py-1 text-xs font-medium transition-colors ${n?"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"})]})]})]}),jsxRuntime.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:n?jsxRuntime.jsx("div",{className:"p-6 min-h-[300px] overflow-auto bg-[var(--kyro-surface)] text-[var(--kyro-text-primary)]",children:t?jsxRuntime.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:Um(t)}}):jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-muted)] italic",children:"Nothing to preview"})}):jsxRuntime.jsx("textarea",{value:t??"",onChange:d,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:`Enter markdown content...
84
84
 
85
85
  # Heading 1
86
86
  ## Heading 2
@@ -96,16 +96,16 @@
96
96
 
97
97
  \`\`\`
98
98
  code block
99
- \`\`\``})}),!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx("span",{children:"**bold**"}),jsxRuntime.jsx("span",{children:"*italic*"}),jsxRuntime.jsx("span",{children:"`code`"}),jsxRuntime.jsx("span",{children:"[link](url)"}),jsxRuntime.jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"kyro-form-help",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:o})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function An({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(false),d=t??"",c=d.length>8?d.slice(0,-8)+"*".repeat(8):d,m=async()=>{if(d)try{await navigator.clipboard.writeText(d),s(!0),setTimeout(()=>s(!1),1800);}catch{let v=document.createElement("textarea");v.value=d,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v),s(true),setTimeout(()=>s(false),1800);}},f=()=>{if(l||a)return;i(true);let v=new Uint8Array(32);crypto.getRandomValues(v);let b=Array.from(v).map(g=>g.toString(16).padStart(2,"0")).join("");r?.(b),setTimeout(()=>i(false),400);};return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"relative flex-1",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:c,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider pr-10 opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})}),jsxRuntime.jsx("button",{type:"button",onClick:m,disabled:!d||a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:n?"Copied!":"Copy full secret",children:n?jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 text-[var(--kyro-success)]"}):jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:f,disabled:a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-warning)] hover:bg-[var(--kyro-warning)]/10 transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:"Regenerate secret",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})})}var Fn=null,$l=false,Ds=async()=>(Fn&&$l||(Fn=unstorage.createStorage({driver:km__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),$l=true),Fn),hm=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Ds()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Ds()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Ds()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},$e=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields);JSON.stringify(o)!==JSON.stringify(a.lastSavedData[r])?n.add(r):n.delete(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},l=s;for(let i=0;i<n.length-1;i++)l[n[i]]===void 0&&(l[n[i]]={}),l[n[i]]={...l[n[i]]},l=l[n[i]];return l[n[n.length-1]]=o,{formData:s}});},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})),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,l]of Object.entries(a))o-new Date(l.draftUpdatedAt).getTime()<6048e5&&(n[s]=l);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:middleware.createJSONStorage(()=>hm()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function Dn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Go({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:i,setIsSlugLocked:d,formData:c}=$e(),m=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",f=t==null?"":String(t),v={id:e.name,value:f,onChange:b=>r?.(b.target.value),placeholder:e.admin?.placeholder,disabled:a||n||l&&i,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||n||l&&i?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[s?jsxRuntime.jsx("textarea",{...v,rows:e.rows||4}):jsxRuntime.jsx("input",{type:m,...v,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!i&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(Dn(c[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:"Regenerate slug",children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>d(!i),className:`p-1.5 rounded transition-colors ${i?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:i?"Unlock slug":"Lock slug",children:i?jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsxRuntime.jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxRuntime.jsxs("span",{className:f.length>60?"text-red-500":f.length>=40?"text-green-500":"text-amber-600",children:[f.length," / 60 \u2014 ",f.length>60?"Too Long":f.length>=40?"Ideal":"Short"]})})]})})}function Pn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.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 In({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange:l=>r?.(l.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"}`}),jsxRuntime.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&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Bn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.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 Ba(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Mn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function En(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ia(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 Nm={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function bo(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let s of e){if(s.name===a)if(n){if(s.fields&&Array.isArray(s.fields))return bo(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&bo(i.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let i=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===i&&c.fields&&Array.isArray(c.fields))return bo(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?bo(s.fields,n,r):false}else return Object.assign(s,r),true;if(!s.name||s.type==="tabs"||s.type==="row"||s.type==="collapsible"){if(s.fields&&Array.isArray(s.fields)&&bo(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&bo(i.fields,t,r))return true}}}return false}function Cm(e,t){for(let[r,o]of Object.entries(e)){let a=Nm[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...l}=n;if(o.admin={...o.admin,...l},s&&o.fields&&Array.isArray(o.fields))for(let[i,d]of Object.entries(s))bo(o.fields,i,d);}}}function Sm(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(templates.minimalCollections)),r.push(...templates.coreSettingsGlobals);break;case "starter":t.push(...Object.values(templates.starterCollections)),r.push(...templates.coreSettingsGlobals);break;case "blog":t.push(...Object.values(templates.blogCollections)),r.push(...templates.coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(templates.ecommerceCollections)),r.push(...templates.allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(templates.minimalCollections),...Object.values(templates.starterCollections),...Object.values(templates.blogCollections),...Object.values(templates.ecommerceCollections),...Object.values(templates.kitchenSinkCollections)),r.push(...templates.allSettingsGlobals);break}return Ia(t,Object.values(templates.mediaCollections)),Ia(t,Object.values(templates.authCollections)),{collections:Mn(t),globals:En(r)}}function Tm(e){let t=Ba(e.collections),r=Ba(e.globals);if(t.length===0&&r.length===0)return Sm("kitchen-sink");let o=[];return Ia(o,Object.values(templates.mediaCollections)),Ia(o,Object.values(templates.authCollections)),Ia(o,t),{collections:Mn(o),globals:En(r)}}var Ln=null;function Rm(){if(Ln)return Ln;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Do__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Ln=JSON.parse(Do__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Ln}catch{}return null}var ql=Rm()||{collections:[],globals:[]},Xl=Tm(ql);Cm(Xl.collections,ql.collectionOverrides);var Yl=Xl,Wo=Yl.collections,Ql=Yl.globals,Bs=["users","audit_logs"];Object.values(Wo).filter(e=>!Bs.includes(e.slug)&&e.admin?.hidden!==true);function $n({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,m]=Ca.useState(null),f=JSON.stringify(n||{}),v=JSON.stringify(s||{});Ca.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let x=setTimeout(async()=>{try{let u="";if(l)u=`${br}/${l}/dynamic-options/${e.name}`;else if(i)u=`${br}/globals/${i}/dynamic-options/${e.name}`;else return;let y=await at(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(f),siblingData:JSON.parse(v)})});if(y.ok){let h=await y.json();h.options&&m(h.options);}}catch(u){console.error("Failed to fetch dynamic options:",u);}},300);return ()=>clearTimeout(x)},[f,v,e.name,e.options,l,i]);let b=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?b=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(b=e.options)),e.dynamicOptions==="collections"&&(b=Object.keys(Wo).filter(g=>g!=="media").map(g=>({label:Wo[g]?.label||g,value:g}))),jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:g=>{if(e.hasMany){let x=Array.from(g.target.selectedOptions,u=>u.value);r?.(x);}else r?.(g.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),b.map(g=>jsxRuntime.jsx("option",{value:g.value,children:g.label},g.value))]})})}function On({icon:e,title:t,description:r,action:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function Us(e){let t=e?.mainTabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function jm({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:l,transform:i,transition:d,isDragging:c}=sortable.useSortable({id:e}),m={transform:utilities.CSS.Transform.toString(i),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:l,style:m,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&&jsxRuntime.jsx("div",{...n,...s,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:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})}function _m({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ca.useState(false),[l,i]=Ca.useState(""),[d,c]=Ca.useState([]),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),g=Ca.useRef(new Set),x=Ca.useRef(null),u=Ca.useRef(()=>{});u.current=r||(()=>{});let y=e.hasMany,h=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],R=h.length>1,[P,w]=Ca.useState(h[0]||""),k=Ca.useCallback(()=>t?(y?Array.isArray(t)?t:[]:t?[t]:[]).map(j=>typeof j=="object"&&j!==null?j.value||j.id||"":String(j)).filter(Boolean):[],[t,y]),p=Ca.useCallback($=>{$.length!==0&&$.forEach(j=>{if(g.current.has(j))return;g.current.add(j);let ae=R?(()=>{if(!t)return P;let H=(y?Array.isArray(t)?t:[]:[t]).find(re=>typeof re=="object"&&re!==null?re.value===j||re.id===j:false);return H&&typeof H=="object"&&H.relationTo||P})():P;Be(`/api/${ae}/${j}`).then(ne=>{let H=ne.data||ne;!H||typeof H!="object"||b(re=>re.some(ve=>ve.id===j)?re:[...re,{...H,id:String(H.id),relationTo:ae}]);}).catch(()=>{});});},[R,t,P,y]);Ca.useEffect(()=>{let $=k();p($);},[k,p]);let T=Ca.useCallback(($="")=>{f(true);let ae=`/api/${P}?${Za($,["title","name","label","email"])}`;Be(ae).then(ne=>{c(H=>{let re=new Set(H.map(L=>L.id)),ve=(ne.docs||[]).filter(L=>!re.has(L.id)).map(L=>({...L,id:L.id}));return [...H,...ve]}),f(false);}).catch(()=>{f(false);});},[P]);Ca.useEffect(()=>{n&&(c([]),T(l));},[n,P]),Ca.useEffect(()=>{let $=j=>{x.current&&!x.current.contains(j.target)&&s(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let B=$=>typeof $=="object"&&$!==null?$.value||$.id||"":String($),S=$=>{let j=$.id;return t?y&&Array.isArray(t)?t.some(ae=>B(ae)===j):B(t)===j:false},F=$=>{let j=$.id;if(y){let ae=Array.isArray(t)?t:[];if(S($))u.current?.(ae.filter(ne=>B(ne)!==j));else {let ne=R?{relationTo:P,value:j}:j;u.current?.([...ae,ne]);}}else if(S($))u.current?.(null);else {let ae=R?{relationTo:P,value:j}:j;u.current?.(ae),s(false),i("");}},A=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),X=$=>{let{active:j,over:ae}=$;if(!ae||j.id===ae.id)return;let ne=y?Array.isArray(t)?t:[]:[],H=ne.findIndex(ve=>B(ve)===j.id),re=ne.findIndex(ve=>B(ve)===ae.id);if(H!==-1&&re!==-1){let ve=[...ne],[L]=ve.splice(H,1);ve.splice(re,0,L),u.current?.(ve);}},K=()=>{if(!t)return null;let $=y?Array.isArray(t)?t:[]:t?[t]:[],j=$.map(ae=>B(ae));return y&&$.length>1?jsxRuntime.jsx(core.DndContext,{sensors:A,collisionDetection:core.closestCenter,onDragEnd:X,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:j,strategy:sortable.horizontalListSortingStrategy,children:$.map(ae=>{let ne=B(ae),H=v.find(L=>L.id===ne),re=H?Us(H):ne.slice(0,12),ve=R&&H?H.relationTo:null;return jsxRuntime.jsx(jm,{id:ne,label:re,relation:ve,onRemove:()=>{let L=$.filter(O=>B(O)!==ne);u.current?.(L);},disabled:a},ne)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:$.map(ae=>{let ne=B(ae),H=v.find(L=>L.id===ne),re=H?Us(H):ne.slice(0,12),ve=R&&H?H.relationTo:null;return jsxRuntime.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:[ve&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[ve,":"]}),re,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let L=$.filter(O=>B(O)!==ne);u.current?.(y?L:L[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},ne)})})};return jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxRuntime.jsxs("div",{ref:x,className:"relative",children:[R&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:h.map($=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{w($),c([]),i("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${P===$?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:$},$))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:$=>{i($.target.value),s(true),T($.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${P}...`,disabled:a||(typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly),className:"w-full pl-9 pr-10 py-2 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent disabled:opacity-50"}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:m?jsxRuntime.jsx(lucideReact.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${n?"rotate-180":""}`})})]}),n&&jsxRuntime.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?jsxRuntime.jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx(On,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:d.map($=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>F($),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${S($)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:Us($)}),S($)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in $&&typeof $.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:$.slug})]},$.id))})}),K()]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var La=_m;var xo=Ca.createContext(null);function ed(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=zs(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=qo(a),{blocks:l}=o(),i=[...l];n!==void 0?i.splice(n,0,s):i.push(s),r({blocks:i});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),l=Ma(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=[...i];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=Ma(n,l=>{let i=l.filter(d=>d.id!==a);return i.length!==l.length?{newList:i,found:true}:{newList:l,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},moveBlock:(a,n)=>{let{blocks:s}=o(),l=Ma(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<i.length){let m=[...i];return [m[d],m[c]]=[m[c],m[d]],{newList:m,found:true}}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}}}))}function zs(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};return r.children&&Array.isArray(r.children)&&(r.children=zs(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?zs(o.children):o.children}))}),r}):[]}function qo(e){let t=Gm(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substr(2,9),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function Gm(e){return {heading:{level:1,text:""},"heading-subheading":{heading:"",subheading:""},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 je(e){let t=Ca.useContext(xo);if(t)return zustand.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}if(n.data?.columnData){for(let s of n.data.columnData)if(s&&s.children&&s.children.length>0){let l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function Le(){let e=Ca.useContext(xo);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 Ma(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let l={...s},i=false;if(s.children&&s.children.length>0){let d=Ma(s.children,t);d!==s.children&&(l.children=d,i=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let d=s.data.columnData.map(c=>{if(c.children&&c.children.length>0){let m=Ma(c.children,t);if(m!==c.children)return {...c,children:m}}return c});d.some((c,m)=>c!==s.data.columnData[m])&&(l.data={...l.data,columnData:d},i=true);}return i&&(a=true),i?l:s});return a?n:e}function $a({open:e,onClose:t,onSelect:r,children:o}){return e?jsxRuntime.jsxs(dr,{open:e,onClose:t,title:"Insert Block",width:"md",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o]}):null}function td({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:s}=core.useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxRuntime.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 ${s?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:s?.5:1},children:[jsxRuntime.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||jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var _s=({text:e="",onChange:t,compact:r=false})=>jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:a=>t("text",a.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:"Enter heading text..."})});var ko=({id:e,type:t,label:r,children:o,className:a=""})=>{let{moveBlock:n,removeBlock:s}=Le();return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var ad=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(_s,{text:a.text||"",onChange:n,compact:true})})};var sd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:a.text||"",onChange:s=>n("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:"Enter paragraph text..."})})};var id=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(lr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:i=>l("src",i)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsxRuntime.jsx("input",{type:"text",value:s.alt||"",onChange:i=>l("alt",i.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:"Alternative text..."})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsxRuntime.jsx("input",{type:"text",value:s.caption||"",onChange:i=>l("caption",i.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:"Image caption..."})]})]})]})};var Vs=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.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:"Video title (optional)..."})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(lr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.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:"Video title (optional)..."})]})};var dd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Vs,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:i=>l("src",i),compact:true})]})};function ou({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:l,isDragging:i}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:l,zIndex:i?10:1,opacity:i?.8:1};return jsxRuntime.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 ${i?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.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 Oa=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ca__default.default.useState(""),[n,s]=Ca__default.default.useState([]);Ca__default.default.useEffect(()=>{let v=n.map(b=>b.text);JSON.stringify(v)!==JSON.stringify(e)&&s(e.map((b,g)=>({id:`${b}-${g}-${Math.random().toString(36).substr(2,4)}`,text:b})));},[e]);let l=()=>{o.trim()&&(t([...e,o.trim()]),a(""));},i=v=>{v.key==="Enter"&&(v.preventDefault(),l());},d=v=>{t(e.filter((b,g)=>g!==v));},c=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),m=v=>{let{active:b,over:g}=v;if(!g||b.id===g.id)return;let x=n.findIndex(y=>y.id===b.id),u=n.findIndex(y=>y.id===g.id);if(x!==-1&&u!==-1){let y=[...e],[h]=y.splice(x,1);y.splice(u,0,h),t(y);}},f=r?"w-full px-2.5 py-1.5 border border-[var(--kyro-border)] rounded-md bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent":"w-full px-3 py-2.5 border border-[var(--kyro-border)] rounded-lg bg-[var(--kyro-bg-secondary)] text-sm text-[var(--kyro-text-primary)] focus:outline-none focus:ring-1 focus:ring-[var(--kyro-sidebar-active)] focus:border-transparent";return jsxRuntime.jsx(core.DndContext,{sensors:c,collisionDetection:core.closestCenter,onDragEnd:m,children:jsxRuntime.jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsxRuntime.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."}):jsxRuntime.jsx(sortable.SortableContext,{items:n.map(v=>v.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:n.map((v,b)=>jsxRuntime.jsx(ou,{id:v.id,text:v.text,onRemove:()=>d(b)},v.id))})}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:v=>a(v.target.value),onKeyDown:i,className:f,placeholder:"Type and press Enter to add..."})]})})};var cd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=Array.isArray(s.items)?s.items:[];return jsxRuntime.jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Oa,{items:l,onChange:d=>{o(e.id,{data:{...s,items:d}});},compact:true})]})};var pd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",s.language||"javascript"]})]})]}),jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(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:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(Pa,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:i=>l("code",i)}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("select",{value:s.language||"javascript",onChange:i=>l("language",i.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:[jsxRuntime.jsx("option",{value:"plaintext",children:"Plain Text"}),jsxRuntime.jsx("option",{value:"javascript",children:"JavaScript"}),jsxRuntime.jsx("option",{value:"typescript",children:"TypeScript"}),jsxRuntime.jsx("option",{value:"python",children:"Python"}),jsxRuntime.jsx("option",{value:"json",children:"JSON"}),jsxRuntime.jsx("option",{value:"html",children:"HTML"}),jsxRuntime.jsx("option",{value:"css",children:"CSS"}),jsxRuntime.jsx("option",{value:"sql",children:"SQL"}),jsxRuntime.jsx("option",{value:"rust",children:"Rust"}),jsxRuntime.jsx("option",{value:"markdown",children:"Markdown"})]}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var md=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(lr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:i=>l("file",i)})]})};var Xs=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ca__default.default.useState(0),n=(m,f)=>{let v=[...e];v[m]={...v[m],title:f},t(v);},s=(m,f)=>{let v=[...e];v[m]={...v[m],content:f},t(v);},l=m=>{let f=e.filter((v,b)=>b!==m);t(f),o===m?a(null):o!==null&&o>m&&a(o-1);},i=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},d="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",c="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?jsxRuntime.jsxs("div",{className:"space-y-2",children:[e.length===0?jsxRuntime.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.'}):jsxRuntime.jsx("div",{className:"space-y-1.5",children:e.map((m,f)=>{let v=o===f;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(v?null:f),className:"w-full flex items-center justify-between p-2.5 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})}),v?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(f,b.target.value),onClick:b=>b.stopPropagation(),className:c,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(f,b.target.value),onClick:b=>b.stopPropagation(),className:`${c} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[e.length===0?jsxRuntime.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.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((m,f)=>{let v=o===f;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(v?null:f),className:"w-full flex items-center justify-between p-3 bg-[var(--kyro-surface-accent)] hover:bg-[var(--kyro-sidebar-active)]/10 transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:m.title||`Item ${f+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(f);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})}),v?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),v&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:m.title||"",onChange:b=>n(f,b.target.value),className:d,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:m.content||"",onChange:b=>s(f,b.target.value),className:`${d} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},f)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var ud=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],i=d=>{o(e.id,{data:{...s,items:d}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Xs,{items:l,onChange:i,compact:true})]})};var yd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data||e.data||{},l=i=>{o(e.id,{data:{...s,content:i}});};return jsxRuntime.jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(jo,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var Ys=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let 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?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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://..."})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:i=>a("heading",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subheading",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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://..."})]})]})};function jn({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxRuntime.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:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)] mb-6 border-b border-[var(--kyro-border)] pb-2 inline-block",children:e.label||e.name}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(n=>o(n,a,r))})]})}var uu=new Set(["text","number","checkbox","select","radio","color","email","password"]);function yu(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>uu.has(r.type))}function bd({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:l,onRemove:i,disabled:d,compact:c,getItemLabel:m}){let{attributes:f,listeners:v,setNodeRef:b,transform:g,transition:x,isDragging:u}=sortable.useSortable({id:e}),y={transform:utilities.CSS.Transform.toString(g),transition:x,zIndex:u?10:1,opacity:u?.8:1};return c?jsxRuntime.jsxs("div",{ref:b,style:y,className:`flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0 hover:bg-[var(--kyro-sidebar-active)]/5 transition-colors ${u?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...f,...v,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:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(h=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(h,a,l)},h.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:i,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:"Remove",children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxRuntime.jsxs("div",{ref:b,style:y,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${u?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...f,...v,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o(r?null:t));},className:"text-xs font-bold tracking-widest text-[var(--kyro-text-muted)] truncate cursor-pointer flex-1 py-1 text-left",children:m(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:h=>{h.stopPropagation(),i();},className:"text-[11px] font-bold text-[var(--kyro-error)] opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30 hover:bg-[var(--kyro-danger-bg)] rounded px-1.5 py-0.5",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",children:r?jsxRuntime.jsx(lucideReact.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(h=>s(h,a,l))})]})}function _n({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],l=s[0],i=l?.name||"user",d=l?.type==="relationship",[c,m]=Ca__default.default.useState(0);Ca__default.default.useEffect(()=>{let u=false,y=n.filter(h=>typeof h!="object"||h===null?(u=true,false):true).map(h=>!h.id&&!h._key?(u=true,{...h,id:Math.random().toString(36).substr(2,9)}):h);u&&r(y);},[t,r]);function f(u){for(let y of ["label","title","name"]){let h=u[y];if(h&&typeof h=="string")return h}for(let y of s){if(y.type==="text"||y.type==="textarea"){let h=u[y.name];if(h&&typeof h=="string")return h}if(y.type==="group"&&y.fields){for(let h of y.fields)if(h.type==="text"||h.type==="textarea"){let P=u[y.name]?.[h.name];if(P&&typeof P=="string")return P}}}return ""}let v=yu(e),b=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),g=u=>{let{active:y,over:h}=u;if(!h||y.id===h.id)return;let R=n.findIndex(w=>(w.id||w._key)===y.id),P=n.findIndex(w=>(w.id||w._key)===h.id);if(R!==-1&&P!==-1){let w=[...n],[k]=w.splice(R,1);w.splice(P,0,k),r(w);}},x=Ca__default.default.useMemo(()=>n.map(u=>u?.id||u?._key||""),[n]);return d?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(La,{field:{name:i,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(u=>u[i]).filter(Boolean),onChange:u=>{let y=(u||[]).map(h=>({[i]:h,id:Math.random().toString(36).substr(2,9)}));r(y);},disabled:a})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(core.DndContext,{sensors:b,collisionDetection:core.closestCenter,onDragEnd:g,children:v?jsxRuntime.jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsxRuntime.jsx(sortable.SortableContext,{items:x,strategy:sortable.verticalListSortingStrategy,children:n.map((u,y)=>jsxRuntime.jsx(bd,{id:u.id||u._key||`idx-${y}`,index:y,isOpen:false,setOpenIndex:()=>{},item:u,field:e,renderField:o,onChangeItem:h=>{let R=[...n];R[y]=h,r(R);},onRemove:()=>r(n.filter((h,R)=>R!==y)),disabled:a,compact:true,getItemLabel:f},u.id||u._key||y))}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxRuntime.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:[jsxRuntime.jsx(sortable.SortableContext,{items:x,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((u,y)=>{let h=c===y;return jsxRuntime.jsx(bd,{id:u.id||u._key||`idx-${y}`,index:y,isOpen:h,setOpenIndex:m,item:u,field:e,renderField:o,onChangeItem:R=>{let P=[...n];P[y]=R,r(P);},onRemove:()=>r(n.filter((R,P)=>P!==y)),disabled:a,compact:false,getItemLabel:f},u.id||u._key||y)})})}),jsxRuntime.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 u=Math.random().toString(36).substr(2,9);r([...n,{id:u}]),m(n.length);},children:"+ Add Item"})]})})]})}var xd="other";function kd(){return xd}function Hn(e){xd=e;}var wo=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{Hn("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Go,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Go,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Go,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(An,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Pn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(In,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx($n,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i});case "date":return jsxRuntime.jsx(Bn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(jo,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Fs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(Pa,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx(lr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx(La,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsx(Oa,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(_n,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,m,f)=>{let v=m[c.name];return jsxRuntime.jsx(wo,{field:c,value:v,onChange:b=>{f({...m,[c.name]:b});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(Zs,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(jn,{field:e,value:t,onChange:r,renderField:(c,m,f)=>{let v=m[c.name];return jsxRuntime.jsx(wo,{field:c,value:v,onChange:b=>{f({...m,[c.name]:b});},disabled:a,error:o,collectionSlug:l,globalSlug:i},c.name)}});case "color":return jsxRuntime.jsx(pt,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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"}),jsxRuntime.jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxRuntime.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 Qo=({block:e,blockSchema:t,onClose:r})=>{let o=je(e.id),{updateBlock:a}=Le(),n=o?.data||e.data||{},s=o?.children||e.children||[],l=(m,f)=>{a(e.id,{data:{...n,[m]:f}});},i=m=>{a(e.id,{children:m});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(m=>{if(m.admin?.condition){if(typeof m.admin.condition=="function")try{let v={values:n,...n};if(!m.admin.condition(v,v))return null}catch(v){console.warn(`Condition error for field ${m.name}:`,v);}else if(typeof m.admin.condition=="object")try{let v=m.admin.condition,b=v.field,g=n[b],x=!0;if("equals"in v?x=g===v.equals:"notEquals"in v?x=g!==v.notEquals:"in"in v&&Array.isArray(v.in)&&(x=v.in.includes(g)),!x)return null}catch(v){console.warn(`Declarative condition error for field ${m.name}:`,v);}}let f=n[m.name];return jsxRuntime.jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsxRuntime.jsx(wo,{field:m,value:f,onChange:v=>l(m.name,v)})},m.name)})}):jsxRuntime.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=Pe[e.type]||Pe.default;return jsxRuntime.jsxs(dr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[d(),s.length>0&&jsxRuntime.jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",s.length,")"]}),jsxRuntime.jsx(Zr,{blockId:e.id,children:s,onUpdateChildren:i})]})]}),jsxRuntime.jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsxRuntime.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 fu=6,Zr=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=fu})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(new Set),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),v=Ca.useContext(xo);if(!v)throw new Error("ChildBlocksTree must be used within a BlocksContext");let b=zustand.useStore(v,p=>p.dynamicCategories),g=zustand.useStore(v,p=>p.allowedBlocks),x=o<a,u=16,y=p=>{let T=qo(p);r([...t,T]),c(T.id);},h=p=>{let T=t.filter(B=>B.id!==p);r(T);},P=(p,T)=>{let B=t.map(S=>S.id===p?{...S,children:T}:S);r(B);},w=p=>{i(T=>{let B=new Set(T);return B.has(p)?B.delete(p):B.add(p),B});},k=p=>{let T=p.children&&p.children.length>0,B=l.has(p.id);ei(p.type);let F=T,A=d===p.id,X=g.find(K=>K.slug===p.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${A?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*u},onClick:()=>{x&&c(A?null:p.id);},children:[F?jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),zt[p.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:zt[p.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[ja(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),X?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:X.admin.description})]}),T&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:K=>K.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),f(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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"})]}):jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),f(p.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),A&&jsxRuntime.jsx(Qo,{block:p,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Nd,{parentId:p.id,children:p.children,onUpdateChildren:K=>P(p.id,K),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*u},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx($a,{open:n,onClose:()=>s(false),onSelect:y,children:b.map(p=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(T.slug),s(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:[jsxRuntime.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:zt[T.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*u},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*u},children:["Maximum nesting level (",a,") reached"]})]})},Nd=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Ca.useState(false),[l,i]=Ca.useState(new Set),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),v=Ca.useContext(xo);if(!v)throw new Error("NestedChildBlocks must be used within a BlocksContext");let b=zustand.useStore(v,p=>p.dynamicCategories),g=zustand.useStore(v,p=>p.allowedBlocks),x=o<a,u=16,y=p=>{let T=qo(p);r([...t,T]),c(T.id);},h=p=>{let T=t.filter(B=>B.id!==p);r(T);},P=(p,T)=>{let B=t.map(S=>S.id===p?{...S,children:T}:S);r(B);},w=p=>{i(T=>{let B=new Set(T);return B.has(p)?B.delete(p):B.add(p),B});},k=p=>{let T=p.children&&p.children.length>0,B=l.has(p.id);ei(p.type);let F=T,A=d===p.id,X=g.find(K=>K.slug===p.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${A?"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"} ${x?"cursor-pointer":""}`,style:{marginLeft:o*u},onClick:()=>{x&&c(A?null:p.id);},children:[F?jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),w(p.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),zt[p.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:zt[p.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[ja(p),p.data?.text?` - ${p.data.text.slice(0,30)}`:"",p.data?.heading?` - ${p.data.heading.slice(0,30)}`:""]}),X?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:X.admin.description})]}),T&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[p.children.length," nested"]}),m===p.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:K=>K.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{h(p.id),f(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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"})]}):jsxRuntime.jsx("button",{type:"button",onClick:K=>{K.stopPropagation(),f(p.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),A&&jsxRuntime.jsx(Qo,{block:p,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Nd,{parentId:p.id,children:p.children,onUpdateChildren:K=>P(p.id,K),depth:o+1,maxDepth:a})})]},p.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(k)}),x&&jsxRuntime.jsxs("div",{style:{marginLeft:o*u},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx($a,{open:n,onClose:()=>s(false),onSelect:y,children:b.map(p=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:p.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:p.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{y(T.slug),s(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:[jsxRuntime.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:zt[T.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},p.title))})]}),t.length===0&&x&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*u},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*u},children:["Maximum nesting level (",a,") reached"]})]})};var Cd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=r?.children??e.children??[],i=(d,c)=>{o(e.id,{data:{...s,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Ys,{heading:s.heading||"",subheading:s.subheading||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:i,compact:true}),jsxRuntime.jsx(lr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:d=>i("bgImage",d)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(Zr,{blockId:e.id,children:l,onUpdateChildren:d=>o(e.id,{children:d})})]})]})]})};var ti=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let l=s?"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",i=s?"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 jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>n("title",d.target.value),className:`${l} font-bold text-base`,placeholder:"Card title..."}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>n("description",d.target.value),className:i,placeholder:"Card description..."}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>n("icon",d.target.value),className:l,placeholder:"Icon (emoji or name)..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:d=>n("linkText",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:"Link text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>n("link",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://..."})]})]})};var Rd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o}=Le(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(ko,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(ti,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Ad=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le();r?.data??e.data??{};let l=r?.children??e.children??[];return jsxRuntime.jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(Zr,{blockId:e.id,children:l,onUpdateChildren:i=>o(e.id,{children:i})})})]})};var Ha=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let[l,i]=Ca.useState(false),[d,c]=Ca.useState(""),[m,f]=Ca.useState([]),[v,b]=Ca.useState(false),[g,x]=Ca.useState([]),[u,y]=Ca.useState(true);Ca.useEffect(()=>{Be("/api/collections").then(S=>{x((S.collections||[]).map(F=>F.slug||F.name||F)),y(false);}).catch(()=>y(false));},[]);let h=(S="")=>{b(true);let F=`/api/${e}?${Za(S,[a],20)}`;Be(F).then(A=>{f(A.docs||[]),b(false);}).catch(()=>b(false));};Ca.useEffect(()=>{l&&h(d);},[l,d,e,a]);let R=S=>S?.[a]||S?.title||S?.name||S?.label||S?.filename||S?.slug||S?.id||"Untitled",P=t?r:o?[o]:[],w=S=>{t?P.includes(S.id)?n("selectedIds",P.filter(F=>F!==S.id)):n("selectedIds",[...P,S.id]):(n("selectedId",S.id),n("selectedIds",[S.id]),i(false));},k=S=>P.includes(S),p=s?"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",T=s?"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",B=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!B&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:u?jsxRuntime.jsx("div",{className:T+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:S=>n("relationTo",S.target.value),className:T,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),g.map(S=>jsxRuntime.jsx("option",{value:S,children:S},S))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:S=>n("hasMany",S.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:d,onChange:S=>{c(S.target.value),i(true);},onFocus:()=>i(true),onBlur:()=>setTimeout(()=>i(false),200),placeholder:`Search ${e}...`,className:`${p} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:v&&jsxRuntime.jsx(lucideReact.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.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:v?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):m.length===0?jsxRuntime.jsx(On,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:m.map(S=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:F=>F.preventDefault(),onClick:()=>w(S),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${k(S.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:R(S)}),k(S.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},S.id))})})]}),P.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(S=>{let F=m.find(A=>A.id===S)||{id:S};return jsxRuntime.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:[R(F),jsxRuntime.jsx("button",{type:"button",onMouseDown:A=>A.preventDefault(),onClick:()=>{t?n("selectedIds",P.filter(A=>A!==S)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]},S)})})]})};var Dd=({block:e,index:t})=>{let r=je(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Le(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",s.relationTo||"pages"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ha,{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 gu={heading:ad,paragraph:sd,image:id,video:dd,list:cd,code:pd,file:md,accordion:ud,richtext:yd,hero:Cd,card:Rd,array:Ad,relationship:Dd},Pe={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"}},zt={heading:jsxRuntime.jsx(lucideReact.Heading1,{className:`w-4 h-4 ${Pe.default.text}`}),paragraph:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Pe.default.text}`}),image:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Pe.default.text}`}),video:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Pe.default.text}`}),list:jsxRuntime.jsx(lucideReact.List,{className:`w-4 h-4 ${Pe.default.text}`}),code:jsxRuntime.jsx(lucideReact.Code,{className:`w-4 h-4 ${Pe.default.text}`}),file:jsxRuntime.jsx(lucideReact.File,{className:`w-4 h-4 ${Pe.default.text}`}),accordion:jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-4 h-4 ${Pe.default.text}`}),richtext:jsxRuntime.jsx(lucideReact.AlignLeft,{className:`w-4 h-4 ${Pe.default.text}`}),hero:jsxRuntime.jsx(lucideReact.Star,{className:`w-4 h-4 ${Pe.hero.text}`}),card:jsxRuntime.jsx(lucideReact.Box,{className:`w-4 h-4 ${Pe.card.text}`}),array:jsxRuntime.jsx(lucideReact.ListOrdered,{className:`w-4 h-4 ${Pe.default.text}`}),relationship:jsxRuntime.jsx(lucideReact.Link2,{className:`w-4 h-4 ${Pe.default.text}`}),featureSplit:jsxRuntime.jsx(lucideReact.Columns3,{className:`w-4 h-4 ${Pe.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(lucideReact.Blocks,{className:`w-4 h-4 ${Pe.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(lucideReact.Sparkles,{className:`w-4 h-4 ${Pe.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Pe.testimonials.text}`}),faq:jsxRuntime.jsx(lucideReact.CircleHelp,{className:`w-4 h-4 ${Pe.faq.text}`}),stats:jsxRuntime.jsx(lucideReact.Activity,{className:`w-4 h-4 ${Pe.stats.text}`}),logoCloud:jsxRuntime.jsx(lucideReact.Image,{className:`w-4 h-4 ${Pe.logoCloud.text}`}),pricing:jsxRuntime.jsx(lucideReact.Tag,{className:`w-4 h-4 ${Pe.pricing.text}`}),team:jsxRuntime.jsx(lucideReact.Users,{className:`w-4 h-4 ${Pe.team.text}`}),recentFeed:jsxRuntime.jsx(lucideReact.Database,{className:`w-4 h-4 ${Pe.recentFeed.text}`}),processSteps:jsxRuntime.jsx(lucideReact.Clock,{className:`w-4 h-4 ${Pe.processSteps.text}`}),formEmbed:jsxRuntime.jsx(lucideReact.Mail,{className:`w-4 h-4 ${Pe.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(lucideReact.Video,{className:`w-4 h-4 ${Pe.videoShowcase.text}`})};function ei(e){return gu[e]||null}function ri(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 ja(e){let t=e.name;return t&&t.trim()?t.trim():ri(e.type)}function Pu(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.heading||e.title||e.text||e.name||e.label||e.sectionTitle||""}var Iu=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{attributes:l,listeners:i,setNodeRef:d,transform:c,transition:m,isDragging:f}=sortable.useSortable({id:e.id}),{removeBlock:v,updateBlock:b}=Le(),g=o===e.id,[x,u]=Ca.useState(false),[y,h]=Ca.useState(false),[R,P]=Ca.useState(e.name||""),w=Ca.useRef(null);Ca.useEffect(()=>{y&&w.current&&(w.current.focus(),w.current.select());},[y]);let k=Ca.useCallback(()=>{h(false);let F=R.trim();F!==(e.name||"").trim()&&b(e.id,{name:F||""});},[R,e.name,e.id,b]),p={transform:utilities.CSS.Transform.toString(c),transition:m,zIndex:f?10:1,opacity:f?.8:1},T=ja(e),B=e.data||{},S=Pu(B,r);return s?jsxRuntime.jsxs("div",{ref:d,style:p,className:"relative group",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-1 pl-5 pr-1.5 py-1 bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-xs whitespace-nowrap ${g?`${(Pe[e.type]||Pe.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.jsx("div",{className:"absolute left-0.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,...i,onClick:F=>F.stopPropagation(),children:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-2.5 h-2.5"})}),zt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:zt[e.type]}),y?jsxRuntime.jsx("input",{ref:w,value:R,onChange:F=>P(F.target.value),onBlur:k,onKeyDown:F=>{F.key==="Enter"&&k(),F.key==="Escape"&&(P(e.name||""),h(false));},onClick:F=>F.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"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] truncate max-w-[120px] transition-colors",children:T}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:F=>F.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(e.id),u(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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u(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"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),P(e.name||""),h(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Rename",children:jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),u(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:"Remove",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})]}),g&&jsxRuntime.jsx(Qo,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:d,style:p,className:"relative group mb-2",children:[jsxRuntime.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 ${g?`${(Pe[e.type]||Pe.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.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,...i,onClick:F=>F.stopPropagation(),children:jsxRuntime.jsx(lucideReact.GripVertical,{className:"w-4 h-4"})}),zt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:zt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[y?jsxRuntime.jsx("input",{ref:w,value:R,onChange:F=>P(F.target.value),onBlur:k,onKeyDown:F=>{F.key==="Enter"&&k(),F.key==="Escape"&&(P(e.name||""),h(false));},onClick:F=>F.stopPropagation(),placeholder:ri(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"}):jsxRuntime.jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[T,S&&typeof S=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",S.length>40?`${S.slice(0,40)}...`:S]})]}),r?.admin?.description&&jsxRuntime.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&&jsxRuntime.jsxs("span",{className:"text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium",children:[e.children.length," nested"]}),x?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:F=>F.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{v(e.id),u(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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>u(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"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),P(e.name||""),h(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Rename Block",children:jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate Block",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),u(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove Block",children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})})]})]}),g&&jsxRuntime.jsx(Qo,{block:e,blockSchema:r,onClose:()=>a(null)})]})},Bu=Ca__default.default.memo(Iu),Zs=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:l})=>{let[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),f=Ca.useRef(null),v=e.admin?.pickerMode||"drawer",b=e.blocks||[],g=b.reduce((L,O)=>{let pe=O.admin?.group||"Custom Blocks";return L[pe]||(L[pe]=[]),L[pe].push(O),L},{}),x=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],u=Object.entries(g).sort(([L],[O])=>{let pe=x.indexOf(L),ge=x.indexOf(O);return pe!==-1&&ge!==-1?pe-ge:pe!==-1?-1:ge!==-1?1:L.localeCompare(O)}).map(([L,O])=>({title:L,blocks:O})),y=Ca.useRef(null);y.current||(y.current=ed(b,u));let h=y.current,R=zustand.useStore(h,L=>L.blocks),[P,w]=Ca.useState(null),[k,p]=Ca.useState(null),T=Ca.useRef(R.length),B=Ca.useRef(new Set(R.map(L=>L.id))),S=Ca.useRef(false);Ca.useEffect(()=>{if(S.current&&R.length>T.current){let L=R.find(O=>O.id&&!B.current.has(O.id));L&&p(L.id);}T.current=R.length,B.current=new Set(R.map(L=>L.id));},[R]),Ca.useEffect(()=>(o&&h.getState().setOnBlocksChange(o),()=>{h.getState().setOnBlocksChange(()=>{});}),[o,h]);let F=Ca.useRef(null);Ca.useEffect(()=>{let L=Array.isArray(t)?t:[],O=F.current||[];if(JSON.stringify(L)!==JSON.stringify(O)){let pe=[...L];T.current=pe.length,B.current=new Set(pe.map(ge=>ge.id)),h.getState().setBlocks(pe),F.current=pe,S.current=true;}else L.length===0&&!S.current&&(S.current=true,F.current=[]);},[t,e.name,h]);let A=Ca.useRef(r);A.current=r,Ca.useEffect(()=>{if(!A.current)return;let L=F.current;L&&JSON.stringify(R)!==JSON.stringify(L)&&(F.current=[...R],A.current(R));},[R]);let K=Ca.useCallback(L=>{h.getState().addBlock(L);},[h]),$=Ca.useCallback(L=>{let O=R.findIndex(U=>U.id===L);if(O===-1)return;let pe=R[O],ge=U=>{let Y=Math.random().toString(36).substr(2,9);return {...U,id:Y,children:U.children?U.children.map(le=>ge(le)):U.children,data:U.data?JSON.parse(JSON.stringify(U.data)):U.data}},Se=ge(pe),Ne=[...R];Ne.splice(O+1,0,Se),h.getState().setBlocks(Ne);},[R,h]),j=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ae=L=>{w(L.active);},ne=L=>{let{active:O,over:pe}=L;if(w(null),!!pe){if(O.id.toString().startsWith("drawer-")){let ge=O.id.toString().replace("drawer-","");if(pe.id.toString().startsWith("container-")){let Se=pe.id.toString().replace("container-",""),Ne=R.find(U=>U.id===Se);if(Ne){let U=qo(ge);h.getState().updateBlock(Se,{children:[...Ne.children||[],U]});}}else {let Se=R.findIndex(Ne=>Ne.id===pe.id);Se!==-1?h.getState().addBlock(ge,Se):K(ge);}return}if(O.id!==pe.id){let ge=R.findIndex(Ne=>Ne.id===O.id),Se=R.findIndex(Ne=>Ne.id===pe.id);if(ge!==-1&&Se!==-1){let Ne=[...R],[U]=Ne.splice(ge,1);Ne.splice(Se,0,U),h.getState().setBlocks(Ne);}}}},H=P?u.flatMap(L=>L.blocks).find(L=>`drawer-${L.type}`===P.id)||R.find(L=>L.id===P.id):null;H?"label"in H?H.label:H.type:"Block";return Ca.useEffect(()=>{if(!c)return;let L=O=>{f.current&&!f.current.contains(O.target)&&m(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[c]),jsxRuntime.jsx(xo.Provider,{value:y.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",children:[jsxRuntime.jsxs(core.DndContext,{sensors:j,collisionDetection:core.closestCenter,onDragStart:ae,onDragEnd:ne,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),v==="dropdown"?jsxRuntime.jsxs("div",{ref:f,className:"relative",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(!c),disabled:n,className:"flex items-center gap-1.5 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:[jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add Element",jsxRuntime.jsx(lucideReact.ChevronDown,{className:`w-3.5 h-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&jsxRuntime.jsx("div",{className:"absolute right-0 top-full mt-1 w-56 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-lg shadow-xl z-50 py-2 max-h-80 overflow-y-auto",children:u.map(L=>jsxRuntime.jsxs("div",{children:[u.length>1&&jsxRuntime.jsx("div",{className:"px-3 py-1.5 text-[10px] font-bold tracking-wider text-[var(--kyro-text-muted)] uppercase",children:L.title}),L.blocks.map(O=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{K(O.slug),m(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:[jsxRuntime.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:zt[O.slug]||jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:O.label}),O.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:O.admin.description})]})]},O.slug))]},L.title))})]}):jsxRuntime.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:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx($a,{open:i,onClose:()=>d(false),onSelect:K,children:jsxRuntime.jsx("div",{className:"space-y-4",children:u.map(L=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:L.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:L.blocks.map(O=>jsxRuntime.jsx(td,{block:{type:O.slug,label:O.label,description:O.admin?.description||"",icon:null},onSelect:K,children:jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:zt[O.slug]||jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4"})})})},O.slug))})]},L.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:R.map(L=>L.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:v==="dropdown"?"flex flex-wrap gap-1.5":"space-y-4",children:[R.map((L,O)=>{let pe=e.blocks?.find(ge=>ge.slug===L.type);return jsxRuntime.jsx(Bu,{block:L,index:O,blockSchema:pe,editingBlockId:k,setEditingBlockId:p,onDuplicate:$,compact:v==="dropdown"},L.id||O)}),R.length===0&&jsxRuntime.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"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:P&&H&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:H.label||H.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function Sr(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(Sr);if(typeof e=="object"){let t=e,r=Object.keys(t),o="id"in t&&(typeof t.id=="string"||t.id===null),a="url"in t&&("filename"in t||"mimeType"in t);if(o&&a&&r.length<=25)return t.id;let n={};for(let s of r)n[s]=Sr(t[s]);return n}return e}function Id(){let e=Ca.useRef([]),t=Ca.useRef(false);return {queueTask:Ca.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 s=e.current.pop();e.current=[],t.current=true;try{await s();}catch(l){console.error("Error in queued function:",l);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function Bd({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:l}){let i=$e(),{confirm:d}=dt(),{formData:c,setFormData:m,setField:f,lastSavedData:v,setLastSavedData:b,setHasUnsavedChanges:g,isSlugLocked:x,loadDocument:u,setIsAutoSaving:y,setAutoSaveStatus:h,setVersions:R,setLoadingVersions:P,sidebarCollapsed:w,setSidebarCollapsed:k,getDraftCache:p,setDraftCache:T,clearDraftCache:B,resetForm:S}=i,F=!!e.versions,A=o||t?.id||a||r,X=Ca.useRef(false);!o&&A&&c&&Object.keys(c).length>0&&c.id!==A&&(X.current=true),Ca.useEffect(()=>{X.current&&(X.current=false,S());},[S]);let K=Ca.useRef(null),$=Ca.useRef(null),j=Ca.useRef(null),ae=Ca.useRef(typeof navigator<"u"?navigator.onLine:true),ne=Ca.useRef(0),H=Ca.useRef(false),re=Ca.useRef(null),ve=Ca.useRef(""),L=Ca.useRef(""),{queueTask:O}=Id(),pe=Ca.useCallback(Q=>o?`global:${o}`:r&&Q?`${r}:${Q}`:null,[r,o]),ge=Ca.useCallback((Q,te,ce)=>{T(Q,{data:te,baseUpdatedAt:v.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:ce?.lastSyncedAt??null});},[v.updatedAt,T]),Se=Ca.useCallback(async()=>{let Q=o?tt(`/api/globals/${o}/versions`):r&&c.id?tt(`/api/${r}/${c.id}/versions`):null;if(Q){P(true);try{let ce=await(await at(Q)).json();R(ce.docs||[]);}catch(te){console.error("Failed to fetch versions:",te);}finally{P(false);}}},[c.id,r,o,P,R]),Ne=Ca.useCallback(()=>{let Q=$e.getState(),te=Q.formData;if(H.current||!r||!te.id||!Q.hasDirtyFields())return;let ce=pe(te.id);ce&&ge(ce,te);},[r,pe,ge]),U=Ca.useCallback(async Q=>{let te=$e.getState(),ce=te.formData,Te=te.lastSavedData;if(H.current||!F&&o||!o&&(!r||!ce.id)||!te.hasDirtyFields())return;let Fe=pe(ce.id);if(Fe&&ge(Fe,ce),!ae.current){h("offline");return}y(true),h("saving"),te.setBackgroundProcessing(true);try{let lt=o?tt(`/api/globals/${o}?autosave=true`):tt(`/api/${r}/${ce.id}?autosave=true`),Tt=await at(lt,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:Q?.keepalive,body:JSON.stringify({...Sr(ce),baseUpdatedAt:Te.updatedAt??null})});if(Tt.ok)ne.current=Date.now(),te.setRetryCount(0),te.setLastSavedAt(Date.now()),j.current&&clearTimeout(j.current),Fe&&T(Fe,{data:ce,baseUpdatedAt:Te.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await Tt.clone().json()).data?.updatedAt||new Date().toISOString()}),h("success"),setTimeout(()=>{$e.getState().autoSaveStatus==="success"&&h("idle");},2e3);else if(Tt.status===409)h("conflict");else throw new Error(`Draft auto-save failed with status ${Tt.status}`)}catch(lt){console.error("Auto-save failed:",lt);let Tt=$e.getState(),I=Tt.retryCount;if(I<5){Tt.setRetryCount(I+1),h("retrying");let W=Math.min(1e3*Math.pow(2,I),6e4);j.current&&clearTimeout(j.current),j.current=setTimeout(()=>Y(Q),W);}else h("offline");}finally{y(false),$e.getState().setBackgroundProcessing(false);}},[r,pe,o,ge,h,T,y,F]),Y=Ca.useCallback(Q=>{O(()=>U(Q),{beforeProcess:()=>true,afterProcess:()=>{}});},[U,O]),le=Ca.useCallback(async(Q,te=true)=>{let ce=$e.getState(),Te=Q||ce.formData,Fe=o?tt(`/api/globals/${o}`):tt(`/api/${r}/${Te.id}`),lt=await at(Fe,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(te)},body:JSON.stringify({...Sr(Te),baseUpdatedAt:ce.lastSavedData.updatedAt??null})});return lt.status===409&&h("conflict"),lt},[r,o,h]);Ca.useEffect(()=>{let Q=()=>{k(!w);};return window.addEventListener("toggle-sidebar",Q),()=>window.removeEventListener("toggle-sidebar",Q)},[w,k]);let Re=Ca.useRef(null),Ue=Ca.useRef(""),Ie=Ca.useRef(false);Ca.useEffect(()=>{let Q=o||t?.id,te=JSON.stringify(t);Ie.current&&Re.current===Q&&Ue.current===te||(u(t||{},t||{}),Ie.current=true,Re.current=Q,Ue.current=te);},[r,c.id,o,t,u]),Ca.useEffect(()=>{if(!r||!t?.id)return;let Q=pe(t.id);if(!Q||re.current===Q)return;let te=false;return (async()=>{if(!F)return;let Te=p(Q);if(Te){if(JSON.stringify(Te.data)===JSON.stringify(t)){B(Q);return}re.current=Q,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(te)return;let lt={...$e.getState().formData,...Te.data};m(lt),s?.("Recovered autosaved draft");},onCancel:async()=>{B(Q);}});}})(),()=>{te=true;}},[B,r,d,pe,p,t,s,m,F]);function et(Q,te){for(let ce of Q){if(ce.name===te&&ce.admin?.autoGenerate==="title")return ce;if(ce.type==="tabs"&&"tabs"in ce)for(let Te of ce.tabs){let Fe=et(Te.fields,te);if(Fe)return Fe}if((ce.type==="group"||ce.type==="collapsible")&&"fields"in ce){let Te=et(ce.fields,te);if(Te)return Te}}}Ca.useEffect(()=>{let Q=e.fields;if(!et(Q,"metaTitle"))return;let ce=go(Q,c,"title"),Te=ce?String(ce):"";Te&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&f("metaTitle",Te);},[c,e.fields,f]),Ca.useEffect(()=>{let Q=e.fields,te=Q.find(Fe=>Fe.name==="slug"&&Fe.admin?.autoGenerate);if(!te?.admin?.autoGenerate)return;let ce=te.admin.autoGenerate,Te=go(Q,c,ce);if(x&&Te){let Fe=Dn(Te);Fe!==c.slug&&f("slug",Fe);}},[c,x,e.fields,f]),Ca.useEffect(()=>{if(w||!o&&(!r||!c.id)||!$e.getState().hasDirtyFields()||kd()!=="keystroke")return;Hn("other");let te=JSON.stringify(c);te!==ve.current&&(K.current&&clearTimeout(K.current),K.current=setTimeout(Ne,1500),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{ve.current=te,Y();},8e3));},[c,w,r,o,Ne,Y]),Ca.useEffect(()=>{if(!o&&(!r||!c.id))return;let Q=()=>{H.current||!$e.getState().hasDirtyFields()||Y({keepalive:true});},te=()=>{document.hidden&&Q();},ce=()=>{ae.current=true,Q();},Te=()=>{ae.current=false;let Fe=$e.getState();Fe.hasDirtyFields()&&Fe.setAutoSaveStatus("offline");};return window.addEventListener("blur",Q),window.addEventListener("pagehide",Q),window.addEventListener("online",ce),window.addEventListener("offline",Te),document.addEventListener("visibilitychange",te),()=>{window.removeEventListener("blur",Q),window.removeEventListener("pagehide",Q),window.removeEventListener("online",ce),window.removeEventListener("offline",Te),document.removeEventListener("visibilitychange",te);}},[r,o,c.id,Y]),Ca.useEffect(()=>{let Q=JSON.stringify(c);if(Q===L.current)return;L.current=Q;let te=document.getElementById("form-data");te&&(te.value=Q),n?.(c);},[c,n]),Ca.useEffect(()=>{(o||c.id)&&Se();},[c.id,o,Se]);let Ct=!c.id&&!o?"draft":F&&c.status||"published",St=(!!c.id||!!o)&&Ct==="draft";return {...i,fetchVersions:Se,performAutoSave:Y,saveDocument:le,autoSaveSkipRef:H,lastAutoSaveTimeRef:ne,documentStatus:Ct,hasUnpublishedChanges:St,versionsEnabled:F}}function So({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Ca.useState(false),s=Ca.useRef(null);return Ca.useEffect(()=>{let l=i=>{s.current&&!s.current.contains(i.target)&&n(false);};return a&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[a]),jsxRuntime.jsxs("div",{className:"relative",ref:s,children:[jsxRuntime.jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsxRuntime.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 jt({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.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&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function Ka(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Ro({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let l=e==="published"&&!r&&t!=="saving"&&t!=="error",i=n||t==="saving"||l,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-success)] border-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)]`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:l?`${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)]`,m="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",f=()=>t==="saving"?`${m} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${m} bg-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-success)]`:t==="error"?`${m} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:l?`${m} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${m} 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 \u2713":t==="error"?"Retry":l?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:i,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(kr,{size:"sm",className:"inline mr-1.5"}),l&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),v()]}),a&&jsxRuntime.jsx(So,{trigger:jsxRuntime.jsx("button",{type:"button",className:f(),disabled:t==="saving",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:s,children:a})]})}var Ed=({title:e,description:t,slug:r})=>jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxRuntime.jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsxRuntime.jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsxRuntime.jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function Od({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Ca.useState(0),s=e.tabs||[],l=s[a]||s[0],i=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--kyro-border)] mb-6 overflow-x-auto hide-scrollbar",children:s.map((d,c)=>jsxRuntime.jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))}),jsxRuntime.jsx("div",{className:"space-y-6",children:l?.fields.map(d=>o(d,i,r))}),l?.label==="SEO Settings"&&jsxRuntime.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsxRuntime.jsx(Ed,{title:String((typeof i.metaTitle=="object"?"":i.metaTitle)||(typeof i.title=="object"?"":i.title)||"Untitled"),description:String((typeof i.metaDescription=="object"?"":i.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function jd({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:l,handleUnpublish:i,handleDelete:d,handlePublish:c,handleSchedulePublish:m}){let[f,v]=Ca.useState(Date.now()),[b,g]=Ca.useState(false),x=Ca.useRef(null),{formData:u,hasUnsavedChanges:y,autoSaveStatus:h,lastSavedAt:R,retryCount:P,view:w,setView:k,showPreview:p,setShowPreview:T,setFormData:B,markSaved:S,lastSavedData:F}=$e(),A=!u.id;Ca.useEffect(()=>{let O=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(O)},[]),Ca.useEffect(()=>{let O=pe=>{x.current&&!x.current.contains(pe.target)&&g(false);};if(b)return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[b]);let X=String(u.mainTabs?.title||(typeof u.title=="object"?"":u.title)||(typeof u.name=="object"?"":u.name)||"Untitled"),K=u.updatedAt?new Date(u.updatedAt).toLocaleString():"Just now",$=u.createdAt?new Date(u.createdAt).toLocaleString():"Just now",j=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",ae=o?"Unpublished":r==="published"?"Published":"Draft",ne=r==="published"&&!y?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",H=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",re=(O=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[h==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),O?"Saving\u2026":"Saving draft..."]}),h==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Check,{className:"w-3.5 h-3.5 shrink-0"}),O?"Saved":R?`Saved ${Math.floor((Date.now()-R)/6e4)}m ago`:"Draft saved"]}),h==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),O?`Retry ${P}/5`:`Retrying save (${P}/5)`]}),h==="offline"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsxRuntime.jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsxRuntime.jsx("path",{d:"m2 2 20 20"}),jsxRuntime.jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsxRuntime.jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),O?"Offline":"Offline \u2014 cached locally"]}),h==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:O?"Failed":"Draft save failed"}),h==="conflict"&&(O?jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:async()=>{},className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),ve=()=>!A&&jsxRuntime.jsxs(So,{trigger:jsxRuntime.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:"More actions",children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[!t&&jsxRuntime.jsx(jt,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(jt,{onClick:l,disabled:n,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.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"}),jsxRuntime.jsx(jt,{onClick:()=>g(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(jt,{onClick:i,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.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"}),jsxRuntime.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ka,{}),jsxRuntime.jsx(jt,{onClick:d,danger:true,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.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"})]})]}),L=()=>b&&jsxRuntime.jsx("div",{ref:x,className:"relative",children:jsxRuntime.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:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.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)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>g(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let O=document.getElementById("schedule-datetime")?.value;O&&m(O);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${Ge}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:X}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${H}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ne}`}),ae]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:y,onPublish:c,disabled:a==="saving"}),ve(),L()]})]}),jsxRuntime.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:[jsxRuntime.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(O=>jsxRuntime.jsx("button",{type:"button",onClick:()=>k(O),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${w===O?"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:O==="edit"?"Edit":O==="version"?"History":"API"},O))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[re(true),y&&h!=="saving"&&h!=="retrying"&&h!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{B(F),S();},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>T(!p),className:`p-1.5 rounded-lg transition-all ${p?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${Ge}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:X}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${H}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ne}`}),j]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[re(false),y&&h!=="saving"&&h!=="retrying"&&h!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{B(F),S();},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),R&&h!=="saving"&&h!=="retrying"&&h!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let O=f-R,pe=Math.floor(O/6e4),ge=Math.floor(O/1e3);return pe>=1?`${pe}m ago`:ge>=5?`${ge}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",K]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",$]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.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(O=>jsxRuntime.jsx("button",{type:"button",onClick:()=>k(O),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${w===O?"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:O.toUpperCase()},O))}),jsxRuntime.jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>T(!p),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${p?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:"Live Preview",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4"}),p&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),ve(),L(),jsxRuntime.jsx(Ro,{status:r,saveStatus:a,hasChanges:y,onPublish:c,disabled:a==="saving"})]})]})]})]})}function _d({config:e,layout:t,collectionSlug:r,renderField:o}){let{showPreview:a,sidebarCollapsed:n,formData:s}=$e();if(t==="single")return jsxRuntime.jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(d=>o(d))})});let i=e.fields.some(d=>d.admin?.position==="sidebar")&&!a;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${a?"grid-cols-1 lg:grid-cols-2":n||!i?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.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}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(d=>!d.admin?.position||d.admin.position==="main").map(d=>o(d))})}),a?jsxRuntime.jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsxRuntime.jsx("iframe",{src:`/${r}/${s.slug||s.id}?preview=true`,className:"w-full h-full border-none",title:"Live Preview"}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):n?null:jsxRuntime.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(d=>d.admin?.position==="sidebar")&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(d=>d.admin?.position==="sidebar").map(d=>o(d))]})})]})}function Hd({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:l,setCompareDiffs:i,loadingDiffs:d,loadingVersions:c,versions:m}=$e();return jsxRuntime.jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxRuntime.jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxRuntime.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:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${m.length} snapshot${m.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{a(!o),s([]),i([]);},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"})]})]}),l.length>0&&jsxRuntime.jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[l.length," change",l.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:l.map((f,v)=>jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:f.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof f.oldValue=="object"?JSON.stringify(f.oldValue):String(f.oldValue??"null")}),jsxRuntime.jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsxRuntime.jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof f.newValue=="object"?JSON.stringify(f.newValue):String(f.newValue??"null")]})]},v))})]}),c?jsxRuntime.jsx("div",{className:"flex justify-center py-16",children:jsxRuntime.jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):m.length===0?jsxRuntime.jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsxRuntime.jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:m.map((f,v)=>{let b=n.includes(f.id),g=(f.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(f.id):void 0,className:`transition-all ${o?b?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsxRuntime.jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:m.length-v})}),jsxRuntime.jsxs("div",{className:"col-span-4 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[f.changeDescription||"Snapshot",g&&jsxRuntime.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"})]}),jsxRuntime.jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(f.createdAt||f.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:f.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${f.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),f.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:f.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(f.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"})})]}),jsxRuntime.jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsxRuntime.jsx("div",{className:"pt-0.5 shrink-0",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:m.length-v})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[f.changeDescription||"Snapshot",g&&jsxRuntime.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(f.createdAt||f.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),f.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${f.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${f.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),f.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:f.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(f.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"})]})]},f.id)})})]})})}function Vd({collectionSlug:e,globalSlug:t}){let{formData:r}=$e();return jsxRuntime.jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsxRuntime.jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsxRuntime.jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(r,null,2)})})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsxRuntime.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()`:r.id?`kyro.collection('${e}').get('${r.id}')`:"Not saved yet"})]}),r.id&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.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(r.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(r.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:"Copy ID",children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsxRuntime.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 Kd={};function Wa({config:e,data:t=Kd,errors:r=Kd,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:l,documentName:i,layout:d="split",onActionSuccess:c,onActionError:m,justSaved:f}){let v=e||(s?Ql[s]:n?Wo[n]:null),[b,g]=Ca.useState(v);Ca.useEffect(()=>{s==="storage-settings"?Be("/api/kyro/schema").then(D=>{D?.globals?.["storage-settings"]&&g(D.globals["storage-settings"]);}).catch(D=>console.error("[AutoForm] Failed to fetch dynamic schema",D)):g(v);},[s,v]);let x=b||v,{confirm:u}=dt(),{formData:y,hasUnsavedChanges:R,autoSaveStatus:k,lastSavedAt:p,view:$,setView:j,setShowPreview:L,isMenuOpen:O,setIsMenuOpen:pe,loadingFields:ge,setLoadingFields:Se,compareSelected:Y,setCompareSelected:le,setCompareDiffs:Ue,setLoadingDiffs:et,setField:Ct,setFormData:St,setLastSavedData:te,setAutoSaveStatus:ce,fetchVersions:Te,saveDocument:Fe,autoSaveSkipRef:lt,lastAutoSaveTimeRef:Tt,documentStatus:I,hasUnpublishedChanges:W,versionsEnabled:ie}=Bd({config:x,initialData:t,collectionSlug:n,globalSlug:s,documentId:l,onChange:o,onActionSuccess:c,onActionError:m}),sr=Ca.useRef(null),po=Ca.useRef(null),[ya,qa]=Ca.useState(false),[rs,C]=Ca.useState("idle"),[me,De]=Ca.useState(false),[qt,Rt]=Ca.useState(Date.now()),fr=a,[os,Po]=Ca.useState(false),[Ec,as]=Ca.useState(false),[$c,Oc]=Ca.useState(0),yi=Ca.useRef(new Map),Uc=3e4;Ca.useEffect(()=>{let D=s?`global:${s}`:`${n}:${l}`;if(!(s||n&&l&&l!=="new")||t&&Object.keys(t).length>0)return;let be=yi.current.get(D),Ee=be&&Date.now()-be.ts<Uc,At=be&&!Ee;if(Ee){$e.getState().loadDocument(be.data,be.data);return}At&&$e.getState().loadDocument(be.data,be.data);let Ht=new AbortController;as(false),be||Po(true);let Ar=s?`/api/globals/${s}`:`/api/${n}/${l}`;return Be(Ar,{autoToast:false,signal:Ht.signal}).then(ut=>{let mo=ut.data||{};yi.current.set(D,{data:mo,ts:Date.now()}),$e.getState().loadDocument(mo,mo),Po(false);}).catch(ut=>{ut.name!=="AbortError"&&(Po(false),be||as(true));}),()=>Ht.abort()},[n,l,s,t,$c]),Ca.useEffect(()=>{let D=setInterval(()=>Rt(Date.now()),1e4);return ()=>clearInterval(D)},[]);let fi=(D,J)=>{if(typeof D=="function")try{return D(y,J)}catch(be){return console.warn("Error evaluating admin runtime flag:",be),false}return !!D},zc=D=>{u({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let J=s?tt(`/api/globals/${s}/versions/${D}/restore`):tt(`/api/${n}/${y.id}/versions/${D}/restore`),be=await at(J,{method:"POST"});!be.ok&&n&&(be=await at(tt(`/api/${n}/${y.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:D,action:"restore"})}));let Ee=await be.json();if(Ee.data){let{updatedAt:At,createdAt:Ht,...Ar}=Ee.data,ut={...y,...Ar};St(ut),$e.getState().loadDocument(ut,ut),c?.("Version restored successfully"),Te(),j("edit");}else M.error(Ee.error||"Failed to restore version");}catch(J){console.error("Failed to restore version:",J),M.error("Failed to restore version");}}});},jc=async()=>{if(Y.length===2){et(true);try{let J=await(await at(tt(`/api/${n}/${y.id}/versions?compareA=${Y[0]}&compareB=${Y[1]}`))).json();Ue(J.diffs||[]);}catch(D){console.error("Compare failed:",D),Ue([]);}finally{et(false);}}},_c=D=>{le(J=>J.includes(D)?J.filter(be=>be!==D):J.length>=2?[J[1],D]:[...J,D]);};Ca.useEffect(()=>{let D=J=>{(J.metaKey||J.ctrlKey)&&J.key==="s"&&(J.preventDefault(),ns()),(J.metaKey||J.ctrlKey)&&J.shiftKey&&(J.key==="P"||J.key==="p")&&(J.preventDefault(),document.getElementById("btn-publish")?.click()),(J.metaKey||J.ctrlKey)&&!J.shiftKey&&J.key==="p"&&(J.preventDefault(),L(be=>!be)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(J.key==="1"&&j("edit"),J.key==="2"&&j("version"),J.key==="3"&&j("api"));};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]),Ca.useEffect(()=>{let D=()=>j("version");return window.addEventListener("kyro:show-version-history",D),()=>window.removeEventListener("kyro:show-version-history",D)},[]),Ca.useEffect(()=>{let D=J=>{sr.current&&!sr.current.contains(J.target)&&pe(false);};if(O)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[O]),Ca.useEffect(()=>{let D=J=>{po.current&&!po.current.contains(J.target)&&qa(false);};if(ya)return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[ya]);let Hc=()=>{R?u({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await ns(),await new Promise(D=>setTimeout(D,1e3)),window.location.href=`${Ge}/${n}/new`;}}):window.location.href=`${Ge}/${n}/new`;},Vc=()=>{if(!y.id){M.error("Please save the document before duplicating.");return}let D=async()=>{try{De(!0);let J=await at(`/api/${n}/${y.id}/duplicate`,{method:"POST"});if(J.ok){let be=await J.json();c?.("Document duplicated successfully"),be.data?.id?window.location.href=`${Ge}/${n}/${be.data.id}`:window.location.href=`${Ge}/${n}`;}else {let be=await J.json();M.error(be.error||"Failed to duplicate");}}catch{M.error("Failed to duplicate document");}finally{De(false);}};if(R){u({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await ns(),await D();}});return}u({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await D();}});},Kc=()=>{u({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{try{await xt(`/api/${n}/${y.id}`),window.location.href=`${Ge}/${n}`;}catch(D){M.error(D.message||"Failed to delete document");}}});},Gc=()=>{u({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{try{let D=await Fe({...y,status:"draft"},!1);if(D?.ok)c?.("Document unpublished successfully"),$e.getState().loadDocument({...y,status:"draft"},{...y,status:"draft"});else {let J=await D?.json().catch(()=>({}));M.error(J?.error||"Failed to unpublish");}}catch{M.error("Failed to unpublish");}}});},ns=async()=>{let D=!y.id;lt.current=true,C("saving");try{let J=Sr({...y}),be=D&&!s,Ee=be?await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}):await Fe(J);if(Ee.ok){let Ht=(await Ee.json()).data||J;St({...y,...Ht}),te({...y,...Ht}),Tt.current=Date.now(),ce("success"),C("saved"),ie&&Te(),setTimeout(()=>{ce("idle"),C("idle");},2e3),c?.(be?"Document created successfully":"Changes saved"),be&&setTimeout(()=>{window.location.href=`${Ge}/${n}`;},800);}else {let At=await Ee.json();Ee.status===409&&ce("conflict"),C("error"),M.error(At.error||"Failed to save"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),M.error("Failed to save document"),setTimeout(()=>C("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),lt.current=false;}},Wc=async()=>{let D=!y.id;lt.current=true,C("saving");try{let J={...y};if(D&&!s){let At=Sr({...y}),Ht=await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(At)});if(!Ht.ok){let mo=await Ht.json().catch(()=>({}));Ht.status===409&&ce("conflict"),C("error"),M.error(mo.error||"Failed to create document"),setTimeout(()=>C("idle"),3e3);return}let ut=(await Ht.json()).data||At;St({...y,...ut}),te({...y,...ut}),J={...y,...ut};}let be=Sr(J),Ee=await Fe(be,!1);if(Ee?.ok)C("saved"),c?.("Published successfully");else {let At=await Ee?.json().catch(()=>({}));Ee?.status===409&&ce("conflict"),C("error"),M.error(At?.error||"Failed to publish"),setTimeout(()=>C("idle"),3e3);}}catch{C("error"),M.error("Failed to publish"),setTimeout(()=>C("idle"),3e3);}finally{lt.current=false;}},Jc=async D=>{let J=!y.id;lt.current=true;try{let be={...Sr({...y}),_schedulePublishAt:D};if(J&&!s){let Ee=await at(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)});if(!Ee.ok){let At=await Ee.json().catch(()=>({}));M.error(At.error||"Failed to schedule publish");return}}else {let Ee=await Fe(be);if(!Ee.ok){let At=await Ee.json().catch(()=>({}));M.error(At.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(D).toLocaleString()}`),qa(!1);}catch{M.error("Failed to schedule publish");}finally{lt.current=false;}},qc=(D,J)=>{Ct(D,J);},fa=(D,J,be)=>{let Ee=J!==void 0?J:y;if(fi(D.hidden!==void 0?D.hidden:D.admin?.hidden,Ee))return null;let Ht=fi(D.readOnly!==void 0?D.readOnly:D.admin?.readOnly,Ee),Ar=!!(fr||Ht);if(D.admin?.condition){if(typeof D.admin.condition=="function")try{let Oe={values:y||{},...y||{}};if(!D.admin.condition(Oe,Ee))return null}catch(Oe){console.warn(`Condition error for field ${D.name}:`,Oe);}else if(typeof D.admin.condition=="object")try{let Oe=D.admin.condition,He=Oe.field,Vt=Ee&&Ee[He]!==void 0?Ee[He]:y&&y[He]!==void 0?y[He]:void 0,Fr=!0;if("equals"in Oe?Fr=Vt===Oe.equals:"notEquals"in Oe?Fr=Vt!==Oe.notEquals:"in"in Oe&&Array.isArray(Oe.in)&&(Fr=Oe.in.includes(Vt)),!Fr)return null}catch(Oe){console.warn(`Declarative condition error for field ${D.name}:`,Oe);}}let ut=Ee[D.name],mo=r[D.name],Xa=Oe=>{be?be({...Ee,[D.name]:Oe}):qc(D.name,Oe);};if(D.type==="row"&&"fields"in D){let Oe=D.fields;return jsxRuntime.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:Oe?.map(He=>{let Vt=He.admin||{},Fr=Vt?.action;if((He.type==="button"||He.type==="action")&&Fr){let vr=Oe?.find(va=>va.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let va=D.name,Ya=vr?.name,Qa=Ya?y[Ya]:void 0;if(!Qa&&va&&typeof va=="string"&&Ya&&(Qa=y[va]?.[Ya]),!!Qa){Se(gr=>({...gr,[He.name]:true}));try{let gr=await at(tt(Fr),{method:Vt.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Qa})}),ga={};try{ga=await gr.json();}catch{ga={};}if(gr.ok&&ga.success)c?.(ga.message||"Action completed successfully");else {let Xc=ga.error||`Request failed (${gr.status})`;m?.(Xc);}}catch(gr){m?.(gr instanceof Error?gr.message:"Error connecting to server");}finally{Se(gr=>({...gr,[He.name]:false}));}}},disabled:ge[He.name]||Ar,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:ge[He.name]?"Sending...":He.label||"Click"})},He.name)}return jsxRuntime.jsx("div",{className:He.type==="button"||He.type==="action"?"flex-shrink-0":"flex-1",style:Vt?.width?{width:Vt.width,flex:"none"}:{},children:fa(He,J,be)},He.name)})},D.name||`row-${Math.random()}`)}switch(D.type){case "tabs":return jsxRuntime.jsx(Od,{field:D,formData:y,onTabDataChange:Oe=>{Ct(D.name,Oe);},renderField:(Oe,He,Vt)=>fa(Oe,He,Vt)},D.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(jn,{field:D,value:ut,onChange:Xa,renderField:fa},D.name);case "array":return jsxRuntime.jsx(_n,{field:D,value:ut,onChange:Xa,renderField:fa,disabled:Ar},D.name);case "button":case "action":{let Oe=D.name,He=ge[Oe];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:He||Ar,onClick:async()=>{let Vt=D.admin?.action||D.action,Fr=D.admin?.method||D.method||"POST";if(Vt){Se(vr=>({...vr,[Oe]:true}));try{let vr=await at(Vt,{method:Fr,headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});await vr.json(),vr.ok;}catch(vr){console.error("Error executing action:",vr);}finally{Se(vr=>({...vr,[Oe]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${He?"opacity-70 cursor-not-allowed":""}`,children:[He&&jsxRuntime.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:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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"})]}),He?"Processing...":D.label||"Click"]})},Oe)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[D.label||D.name,D.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(Ha,{relationTo:D.relationTo,hasMany:D.hasMany,selectedIds:Array.isArray(ut)?ut:ut?[ut]:[],onChange:(Oe,He)=>{Xa(He);},compact:true}),D.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(D.admin?.description)}):null]},D.name);default:return jsxRuntime.jsx(wo,{field:D,value:ut,onChange:Xa,error:mo,disabled:Ar,formData:y,siblingData:Ee,collectionSlug:n,globalSlug:s},D.name||Math.random().toString())}};return os?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Et,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Et,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Et,{variant:"rect",count:4})})]}):Ec?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{as(false),Po(true),Oc(D=>D+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsxRuntime.jsx(jd,{collectionSlug:n,globalSlug:s,documentStatus:I||"draft",hasUnpublishedChanges:W,localSaveStatus:rs,isDuplicating:me,handleCreateNew:Hc,handleDuplicate:Vc,handleUnpublish:Gc,handleDelete:Kc,handlePublish:Wc,handleSchedulePublish:Jc}),d==="single"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[k==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),k==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"}),p?`Saved ${Math.floor((Date.now()-p)/6e4)}m ago`:"Saved"]}),k==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),k==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),k==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),k==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),R&&k!=="saving"&&k!=="retrying"&&k!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!R&&k!=="success"&&k!=="saving"&&k!=="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:y.updatedAt?`Modified ${new Date(y.updatedAt).toLocaleString()}`:""})]}),jsxRuntime.jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{try{let D=await Fe(y);if(D.ok){let be=(await D.json()).data||y;St({...y,...be}),te({...y,...be}),c?.("Changes saved");}}catch(D){console.error("Save error exception:",D),m?.("Save failed: "+D.message);}}})]}),jsxRuntime.jsxs("main",{className:"w-full pt-6 md:pt-0",children:[$==="edit"&&jsxRuntime.jsx(_d,{config:x,layout:d,collectionSlug:n,renderField:fa}),$==="version"&&jsxRuntime.jsx(Hd,{handleRestoreVersion:zc,handleCompareVersions:jc,toggleCompareSelection:_c}),$==="api"&&jsxRuntime.jsx(Vd,{collectionSlug:n,globalSlug:s})]})]})}var Gd={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function si({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:l,onPreview:i,onDelete:d,onBack:c,onToggleSidebar:m,publishedAt:f,updatedAt:v}){let b=$e(k=>k.view)||"edit",g=$e(k=>k.setView),[x,u]=Ca.useState(false),y=Ca.useRef(null);Ca.useEffect(()=>{let k=p=>{y.current&&!y.current.contains(p.target)&&u(false);};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);let h=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,R=["edit","version","api"],P=h(),w="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 jsxRuntime.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&&jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Gd[e]||"bg-[var(--kyro-text-muted)]"}`}),P&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(kr,{size:"sm",className:"inline mr-0.5"}),P]}),jsxRuntime.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:R.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>g(k),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${b===k?"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:k==="edit"?"Edit":k==="version"?"Ver":"API"},k))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${w} max-md:hidden`,title:"Preview",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-3.5 h-3.5"})}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${w} max-md:hidden`,title:"View History",children:jsxRuntime.jsx(lucideReact.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${w} max-md:hidden`,title:"Duplicate",children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:d,className:`${w} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:"Delete",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})}),m&&jsxRuntime.jsx("button",{type:"button",onClick:m,className:`${w} max-md:hidden`,title:"Toggle Sidebar",children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxRuntime.jsxs("div",{ref:y,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>u(!x),className:w,title:"More",children:jsxRuntime.jsx(lucideReact.EllipsisVertical,{className:"w-3.5 h-3.5"})}),x&&jsxRuntime.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:[P&&jsxRuntime.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:[jsxRuntime.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${Gd[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(kr,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:P})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:R.map(k=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(k),u(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${b===k?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:k==="edit"?"Edit":k==="version"?"Ver":"API"},k))}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),u(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:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),u(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:[jsxRuntime.jsx(lucideReact.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),u(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:[jsxRuntime.jsx(lucideReact.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{d(),u(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:[jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.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:[jsxRuntime.jsx(lucideReact.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.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:[jsxRuntime.jsx(lucideReact.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Ro,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(jt,{icon:jsxRuntime.jsx(lucideReact.Copy,{className:"w-4 h-4"}),children:"Duplicate"}),l&&jsxRuntime.jsx(jt,{icon:jsxRuntime.jsx(lucideReact.Clock,{className:"w-4 h-4"}),children:"View History"}),i&&jsxRuntime.jsx(jt,{icon:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"}),children:"Preview"}),(s||l||i)&&jsxRuntime.jsx(Ka,{}),d&&jsxRuntime.jsx(jt,{onClick:d,danger:true,icon:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function li({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:l,mode:i="collection"}){let{confirm:d,alert:c}=dt(),[m,f]=Ca.useState({}),[v,b]=Ca.useState({}),[g,x]=Ca.useState(true),[u,y]=Ca.useState(false),[h,R]=Ca.useState(false),[P,w]=Ca.useState(false),[k,p]=Ca.useState("idle"),[T,B]=Ca.useState("draft"),[S,F]=Ca.useState(null),[A,X]=Ca.useState(null),[K,$]=Ca.useState(null),[j,ae]=Ca.useState(false),ne=r?.fields||t?.fields||[],H=r?.label||t?.label||"Document",re=r?.slug||t?.slug||"",ve=JSON.stringify(m)!==JSON.stringify(v);Ca.useEffect(()=>{ve&&T==="published"&&B("draft");},[ve,T]),Ca.useEffect(()=>{ve&&k==="saved"&&p("idle");},[ve,k]),Ca.useEffect(()=>{i==="global"?O():o&&L();},[o,i,re]);let L=async()=>{try{x(!0);let le=await Be(`/api/${re}/${o}`,{autoToast:!1}),Re=le.data||{};f(Re),b(Re),B(Re?.status||le.status||"draft"),F(le.createdAt||Re.createdAt||null),X(le.updatedAt||Re.updatedAt||null),$(le.publishedAt||Re.publishedAt||null);}catch{l("Failed to load document");}finally{x(false);}},O=async()=>{try{x(!0);let le=await Be(`/api/globals/${re}`,{autoToast:!1}),Re=le.data||{};f(Re),b(Re),F(le.createdAt||null),X(le.updatedAt||null);}catch{l("Failed to load global");}finally{x(false);}},pe=Ca.useCallback(async(le=false)=>{try{p("saving");let Re=i==="global"?`/api/globals/${re}`:`/api/${re}/${o}`,Ue=T==="draft"||m?.status==="draft",Ie=await Gt(Re,m,{autoToast:!1,headers:{"X-Draft":String(Ue)}}),et=Ie&&(Ie.data||Ie)||m;le||(b(et),n()),f(et),B(et?.status||T),p("saved"),X(new Date().toISOString()),ae(!0),setTimeout(()=>ae(!1),3e3),le||(T==="draft"||et?.status==="draft"?M.warning("Draft saved"):M.success("Updated")),setTimeout(()=>{p("idle");},2e3);}catch{p("error"),le||(l("Failed to save changes"),M.error("Failed to save changes"));}finally{y(false);}},[m,i,re,o,T,n,l]),ge=async()=>{try{y(!0),await Gt(`/api/${re}/${o}`,m,{autoToast:!1,headers:{"X-Draft":"false"}}),B("published"),$(new Date().toISOString()),M.success("Published successfully"),n();}catch{l("Failed to publish"),M.error("Failed to publish");}finally{y(false);}},Se=async()=>{try{y(!0),await Gt(`/api/${re}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),B("draft"),M.warning("Document unpublished"),n();}catch{l("Failed to unpublish"),M.error("Failed to unpublish");}finally{y(false);}},Ne=async()=>{try{R(!0);let le=await nt(`/api/${re}/${o}/duplicate`,void 0,{autoToast:!1});M.success("Document duplicated"),le?.data?.id?window.location.href=`${Ge}/${re}/${le.data.id}`:window.location.href=`${Ge}/${re}`;}catch(le){M.error(le.message||"Failed to duplicate document");}finally{R(false);}},U=()=>{d({title:`Delete ${H}?`,message:"This action cannot be undone.",variant:"danger",onConfirm:async()=>{try{w(!0),await xt(`/api/${re}/${o}`),window.location.href=`${Ge}/${re}`;}catch{w(false);}}});};if(g)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Et,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(Et,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(Et,{variant:"rect",count:4})})]})});let Y=i==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Dt,{back:{onClick:a},breadcrumbs:[{label:i==="global"?"Globals":"Collections"},{label:H,href:i==="collection"?`${Ge}/${re}`:void 0},{label:i==="global"||o?"Edit":"New"}],title:i==="global"?H:go(t?.fields,m,t?.admin?.useAsTitle||"title")||m.name||o||`New ${t?.singularLabel||H}`,metadata:[jsxRuntime.jsx(Pt,{variant:T==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:T},"status")]}),jsxRuntime.jsx(si,{status:T,saveStatus:k,hasChanges:ve,onSave:()=>pe(false),onPublish:ge,onUnpublish:T==="published"?Se:void 0,onDuplicate:Ne,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:()=>window.open(`/preview/${re}/${o}`,"_blank"),onDelete:U,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:K,updatedAt:A}),jsxRuntime.jsxs("div",{className:Y?"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:[jsxRuntime.jsx("div",{className:"space-y-4 md:space-y-8 min-w-0",children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Core Configuration"}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Wa,{config:t?{...t,fields:ne}:{slug:"unknown",fields:ne},data:m,onChange:f,layout:Y?"single":"split",globalSlug:i==="global"?re:void 0,collectionSlug:i==="collection"?re:void 0,onActionSuccess:le=>M.success(le),onActionError:le=>M.error(le),documentStatus:T,justSaved:j}),Y&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[i==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:U,disabled:P||u,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:P?"Deleting...":"Delete Document"}),jsxRuntime.jsx(Ro,{status:T,saveStatus:u?"saving":"idle",hasChanges:ve,onPublish:()=>pe(false),disabled:u})]})]})}),!Y&&jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:"Metadata"}),jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Dynamic Status"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${T==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:T||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Date Created"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:S?new Date(S).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Last Modified"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:A?new Date(A).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"Just now"})]}),K&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Public At"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(K).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:"Quick Links"}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:Ne,disabled:h||u,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:h?"Duplicating...":"Duplicate Document"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(`/preview/${re}/${o}`,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"View Public Page"}),jsxRuntime.jsx("button",{type:"button",onClick:U,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:"Delete Entry"})]})]})]})]})]})}function di({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Ca.useState({}),[l,i]=Ca.useState(false),d=t.fields||[],c=t.label||t.slug,m=async f=>{try{i(!0),await nt(`/api/${t.slug}`,n),M.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(v){a(v instanceof Error?v.message:"Failed to create");}finally{i(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Dt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${Ge}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:l?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>m(),disabled:l}}),jsxRuntime.jsx("div",{className:"kyro-detail-body",children:jsxRuntime.jsx("div",{className:"kyro-card",children:jsxRuntime.jsx("div",{className:"kyro-card-content",children:jsxRuntime.jsx("form",{children:jsxRuntime.jsx(Wa,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function Jd({type:e,message:t,onClose:r}){let[o,a]=Ca__default.default.useState(false),n=Ca__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},l=()=>{n.current&&clearTimeout(n.current);};Ca__default.default.useEffect(()=>(o?l():s(),l),[o,r]);let i={success:lucideReact.CircleCheck,error:lucideReact.ShieldAlert,warning:lucideReact.TriangleAlert,info:lucideReact.Info}[e];return jsxRuntime.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:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(i,{className:"w-4 h-4"})}),jsxRuntime.jsx("div",{className:"kyro-toast-content",children:jsxRuntime.jsx("p",{className:"kyro-toast-message",children:t})}),jsxRuntime.jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsxRuntime.jsx(lucideReact.X,{className:"w-3.5 h-3.5"})})]})}function X3({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function Y3(){let e=Kt(o=>o.addToast),t=Kt(o=>o.removeToast);return {toasts:Kt(o=>o.toasts),addToast:e,removeToast:t}}function qn(){let e=Kt(r=>r.toasts),t=Kt(r=>r.removeToast);return jsxRuntime.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=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(Jd,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function mi({onAuth:e,theme:t="light"}){let[r,o]=Ca.useState("login"),[a,n]=Ca.useState(""),[s,l]=Ca.useState(""),[i,d]=Ca.useState(""),[c,m]=Ca.useState(false),[f,v]=Ca.useState(false),b=Kt(u=>u.addToast);Ca.useEffect(()=>{g();},[]);let g=async()=>{try{await Be("/api/users");}catch{v(true),o("register");}};return jsxRuntime.jsx(hr,{defaultMode:t,children:jsxRuntime.jsxs("div",{className:"kyro-login-page",children:[jsxRuntime.jsxs("div",{className:"kyro-login-container",children:[jsxRuntime.jsxs("div",{className:"kyro-login-header",children:[jsxRuntime.jsx("h1",{className:"kyro-login-title",children:f?"Create Admin Account":r==="login"?"Sign In":"Create Account"}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:f?"Set up your admin account to get started":r==="login"?"Enter your credentials to access the admin":"Create an account to access the admin"})]}),jsxRuntime.jsxs("form",{onSubmit:async u=>{u.preventDefault(),m(true);try{let y=r==="login"?"/api/auth/login":"/api/auth/register",h={email:a,password:s};r==="register"&&(h.confirmPassword=i);let R=await nt(y,h);R.isFirstUser&&v(!0),localStorage.setItem("kyro_user",JSON.stringify(R.user)),b("success",r==="login"?"Welcome back!":"Account created!"),e(R.token,R.user);}catch{b("error","Connection failed");}finally{m(false);}},className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:"Email"}),jsxRuntime.jsx("input",{id:"email",type:"email",value:a,onChange:u=>n(u.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:"Password"}),jsxRuntime.jsx("input",{id:"password",type:"password",value:s,onChange:u=>l(u.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:r==="login"?"current-password":"new-password"})]}),r==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:"Confirm Password"}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:i,onChange:u=>d(u.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:c,children:c?r==="login"?"Signing in...":"Creating account...":r==="login"?"Sign In":"Create Account"})]}),!f&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:r==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Don't have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("register"),children:"Sign up"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Already have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("login"),children:"Sign in"})]})})})]}),jsxRuntime.jsx(qn,{})]})})}function Yd({collections:e,onNavigate:t,user:r}){let{permissions:o}=Ur(),[a,n]=Ca.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=Ca.useState(true);Ca.useEffect(()=>{let d=setTimeout(()=>{n({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(d)},[]);let i=Object.entries(e).filter(([d])=>!Bs.includes(d)&&o?.collections?.[d]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx(Dt,{title:`Welcome back, ${r?.email?.split("@")[0]||"Admin"}`,description:"Everything looks great in your command center today.",action:i.length>0&&o?.collections?.[i[0]?.[0]]?.create!==false?{label:"New Document",onClick:()=>t("create",i[0]?.[0]),icon:lucideReact.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Content",value:a.totalDocs,icon:lucideReact.FileText,color:"text-blue-500"},{label:"Media Assets",value:a.totalMedia,icon:lucideReact.Image,color:"text-purple-500"},{label:"Active Users",value:a.totalUsers,icon:lucideReact.Users,color:"text-green-500"},{label:"System Health",value:"100%",icon:lucideReact.Activity,color:"text-amber-500"}].map((d,c)=>jsxRuntime.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:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:d.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsxRuntime.jsx(Et,{variant:"text",className:"w-16"}):d.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${d.color}`,children:jsxRuntime.jsx(d.icon,{className:"w-6 h-6"})})]},c))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),"Content Growth"]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:"Snapshot of document velocity over the last 7 days"}),jsxRuntime.jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsxRuntime.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]"}),jsxRuntime.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)]"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsxRuntime.jsx("span",{children:"Mon"}),jsxRuntime.jsx("span",{children:"Tue"}),jsxRuntime.jsx("span",{children:"Wed"}),jsxRuntime.jsx("span",{children:"Thu"}),jsxRuntime.jsx("span",{children:"Fri"}),jsxRuntime.jsx("span",{children:"Sat"}),jsxRuntime.jsx("span",{children:"Sun"})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:i.map(([d,c])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",d),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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:c.label||d}),jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:c.admin?.description||`Manage ${d} content.`})]},d))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-5 h-5"}),"Quick Links"]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[i.filter(([d])=>o?.collections?.[d]?.create!==false).map(([d])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",d),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:[jsxRuntime.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:["New ",e[d]?.singularLabel||e[d]?.label||d]}),jsxRuntime.jsx(lucideReact.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},d)),i.every(([d])=>o?.collections?.[d]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:"No collections available for creation."})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:"Media Library"}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:"Manage high-fidelity assets with our liquid masonry gallery."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:["Open Assets"," ",jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(lucideReact.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-5 h-5 opacity-40"}),"Recent Activity"]}),jsxRuntime.jsx("div",{className:"space-y-6",children:a.recentActivity.map(d=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:d.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:d.user})," ",d.type==="create"?"created":d.type==="edit"?"edited":d.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',d.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:d.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:d.time})]})]},d.id))}),jsxRuntime.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:"View Audit Logs"})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Activity,{className:"w-5 h-5 opacity-40"}),"System Status"]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:"Cloud API",status:"Optimal",pulse:"bg-green-500"},{label:"Database Node",status:"Healthy",pulse:"bg-green-500"},{label:"Media CDN",status:"Active",pulse:"bg-blue-500"},{label:"Auth Service",status:"Secure",pulse:"bg-green-500"}].map((d,c)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:d.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:d.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${d.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},c))})]})]})]})]})}function Zd(){let[e,t]=Ca.useState([]),[r,o]=Ca.useState(true),[a,n]=Ca.useState(""),[s,l]=Ca.useState(false),[i,d]=Ca.useState({name:"",email:"",password:"",role:"customer"}),[c,m]=Ca.useState(""),[f,v]=Ca.useState(false),{confirm:b,alert:g}=dt();Ca.useEffect(()=>{x();},[]);let x=async()=>{try{o(!0);let w=await Be("/api/users");t(w.docs||[]);}catch(w){console.error("Failed to load users:",w);}finally{o(false);}},u=w=>{let k=!w.locked;b({title:k?"Lock User Account?":"Unlock User Account?",message:k?`Are you sure you want to lock ${w.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${w.email}?`,variant:k?"danger":"success",onConfirm:async()=>{try{await Gt(`/api/users/${w.id}`,{locked:k}),t(p=>p.map(T=>T.id===w.id?{...T,locked:k}:T)),M.success(k?`Account locked: ${w.email}`:`Account restored: ${w.email}`);}catch(p){console.error("Failed to toggle user lock:",p),M.error("Failed to update account status");}}});},y=w=>{b({title:"Destroy User Account",message:`You are about to permanently delete ${w.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await xt(`/api/users/${w.id}`),t(k=>k.filter(p=>p.id!==w.id)),M.success(`Identity purged: ${w.email}`);}catch(k){console.error("Failed to delete user:",k),M.error("Failed to delete user");}}});},h=async()=>{if(!i.email.trim()||!i.password.trim()){m("Email and password are required");return}v(true),m("");try{await nt("/api/users",{name:i.name.trim()||void 0,email:i.email.trim(),password:i.password,role:i.role}),l(!1),d({name:"",email:"",password:"",role:"customer"}),M.success("User created successfully"),x();}catch(w){let k=w instanceof Error?w.message:"Failed to create user";m(k),M.error(k);}finally{v(false);}},R=["super_admin","admin","editor","author","customer","guest"],P=e.filter(w=>w.email.toLowerCase().includes(a.toLowerCase())||w.name?.toLowerCase().includes(a.toLowerCase()));return jsxRuntime.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:[jsxRuntime.jsx(Dt,{title:"Identity & Access",description:"Manage the core administrative team and security permissions.",icon:lucideReact.Users,action:{label:"New User",onClick:()=>{d({name:"",email:"",password:"",role:"customer"}),m(""),l(true);},icon:lucideReact.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(lucideReact.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"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search by identity or email...",value:a,onChange:w=>n(w.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.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:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsxRuntime.jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:r?Array.from({length:6}).map((w,k)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},k)):P.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsxRuntime.jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):P.map(w=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${w.locked?"opacity-50 grayscale":""}`,children:[jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Xu,{user:w}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:w.name||w.email.split("@")[0]}),w.tenantId&&jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:w.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:w.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:w.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(Pt,{variant:w.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:w.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3"}),w.lastLogin?new Date(w.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>u(w),className:`p-1.5 rounded-lg border transition-all ${w.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:w.locked?"Restore Access":"Restrict Access",children:w.locked?jsxRuntime.jsx(lucideReact.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(lucideReact.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>y(w),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:"Delete User",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-3.5 h-3.5"})})]})})]},w.id))})]})}),jsxRuntime.jsxs(Ot,{open:s,onClose:()=>l(false),title:"Create User",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsxRuntime.jsx("input",{type:"text",value:i.name,onChange:w=>d({...i,name:w.target.value}),placeholder:"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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsxRuntime.jsx("input",{type:"email",value:i.email,onChange:w=>d({...i,email:w.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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsxRuntime.jsx("input",{type:"password",value:i.password,onChange:w=>d({...i,password:w.target.value}),placeholder:"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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsxRuntime.jsx("select",{value:i.role,onChange:w=>d({...i,role:w.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:R.map(w=>jsxRuntime.jsx("option",{value:w,children:w},w))})]}),c&&jsxRuntime.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:[jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-4 h-4"}),c]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"button",onClick:h,disabled:f,className:"kyro-btn kyro-btn-primary px-6 py-2.5 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/10 disabled:opacity-50",children:f?"Creating...":"Create User"})]})]})]})}function Xu({user:e}){let[t,r]=Ca.useState(null);return Ca.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Be(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsxRuntime.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsxRuntime.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 ec(){let[e,t]=Ca.useState("Kyro CMS"),[r,o]=Ca.useState("Command Center"),[a,n]=Ca.useState("#6366f1"),[s,l]=Ca.useState("Welcome back to your Command Center."),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false);return Ca.useEffect(()=>{(async()=>{try{let g=await Be("/api/globals/site-settings"),x=g.data||g;x&&Object.keys(x).length>0&&(x.siteName&&t(x.siteName),x.adminTitle&&o(x.adminTitle),x.primaryColor&&n(x.primaryColor),x.dashboardGreeting&&l(x.dashboardGreeting));}catch(g){console.error("Failed to load branding:",g);}})();},[]),jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:jsxRuntime.jsxs("button",{type:"button",onClick:async()=>{d(true);try{await Gt("/api/globals/site-settings",{siteName:e,adminTitle:r,primaryColor:a,dashboardGreeting:s}),m(!0),M.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",a),setTimeout(()=>window.location.reload(),800);}catch(b){M.error("Failed to save branding"),console.error(b);}finally{d(false);}},disabled:i,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${c?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[i?jsxRuntime.jsx(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):c?jsxRuntime.jsx(lucideReact.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Save,{className:"w-4 h-4"}),i?"Saving...":c?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(lucideReact.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:e,onChange:b=>t(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"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:b=>o(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"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsxRuntime.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:"Greeting text for the dashboard..."})]})]})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(lucideReact.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}].map(b=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(b.hex),className:`aspect-square rounded-xl transition-all border-4 ${a===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))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.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:[jsxRuntime.jsx(lucideReact.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(lucideReact.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.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:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[r," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",e,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
99
+ \`\`\``})}),!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx("span",{children:"**bold**"}),jsxRuntime.jsx("span",{children:"*italic*"}),jsxRuntime.jsx("span",{children:"`code`"}),jsxRuntime.jsx("span",{children:"[link](url)"}),jsxRuntime.jsx("span",{children:"# heading"})]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"kyro-form-help",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:o})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[e.label||e.name,e.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx("div",{className:"h-[200px] bg-[var(--kyro-surface)] animate-pulse rounded-md border border-[var(--kyro-border)]"})]})};function jn({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),[l,i]=Ta.useState(false),d=t??"",c=d.length>8?d.slice(0,-8)+"*".repeat(8):d,p=async()=>{if(d)try{await navigator.clipboard.writeText(d),s(!0),setTimeout(()=>s(!1),1800);}catch{let g=document.createElement("textarea");g.value=d,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g),s(true),setTimeout(()=>s(false),1800);}},y=()=>{if(l||a)return;i(true);let g=new Uint8Array(32);crypto.getRandomValues(g);let b=Array.from(g).map(v=>v.toString(16).padStart(2,"0")).join("");r?.(b),setTimeout(()=>i(false),400);};return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("div",{className:"relative flex-1",children:jsxRuntime.jsx("input",{id:e.name,type:"text",value:c,readOnly:true,disabled:a,className:"kyro-form-input font-mono text-xs tracking-wider pr-10 opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed select-none",spellCheck:false})}),jsxRuntime.jsx("button",{type:"button",onClick:p,disabled:!d||a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-primary)] hover:bg-[var(--kyro-primary-alpha)] transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:n?"Copied!":"Copy full secret",children:n?jsxRuntime.jsx(Hl.Check,{className:"w-3.5 h-3.5 text-[var(--kyro-success)]"}):jsxRuntime.jsx(Hl.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:y,disabled:a,className:"p-2 rounded-lg border border-[var(--kyro-border)] bg-[var(--kyro-surface)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:border-[var(--kyro-warning)] hover:bg-[var(--kyro-warning)]/10 transition-all disabled:opacity-40 disabled:cursor-not-allowed active:scale-95",title:"Regenerate secret",children:jsxRuntime.jsx(Hl.RefreshCw,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})})}var _n=null,Zl=false,Ks=async()=>(_n&&Zl||(_n=unstorage.createStorage({driver:Km__default.default({dbName:"kyro-autosave",storeName:"autosave"})}),Zl=true),_n),Gm=()=>typeof window>"u"?{getItem:async()=>null,setItem:async()=>{},removeItem:async()=>{}}:{getItem:async e=>{try{return await(await Ks()).getItem(e)??null}catch(t){return console.error("Storage getItem error:",t),localStorage.getItem(e)}},setItem:async(e,t)=>{try{await(await Ks()).setItem(e,t);}catch(r){console.error("Storage setItem error:",r),localStorage.setItem(e,t);}},removeItem:async e=>{try{await(await Ks()).removeItem(e);}catch(t){console.error("Storage removeItem error:",t),localStorage.removeItem(e);}}},Fe=zustand.create()(middleware.persist((e,t)=>({formData:{},lastSavedData:{},sidebarCollapsed:false,draftCache:{},dirtyFields:new Set,activeTab:0,isSlugLocked:true,view:"edit",isDropdownOpen:false,versions:[],loadingVersions:false,showPreview:false,isMenuOpen:false,hasUnsavedChanges:false,loadingFields:{},compareMode:false,compareSelected:[],compareDiffs:[],loadingDiffs:false,isAutoSaving:false,autoSaveStatus:"idle",backgroundProcessing:false,lastAutoSaveTime:0,lastSavedAt:null,retryCount:0,autoSaveSkip:false,autoSaveTimer:null,setField:(r,o)=>{let a=t(),n=new Set(a.dirtyFields);JSON.stringify(o)!==JSON.stringify(a.lastSavedData[r])?n.add(r):n.delete(r),e({formData:{...a.formData,[r]:o},dirtyFields:n,hasUnsavedChanges:n.size>0});},setFormData:r=>{e({formData:r});},setNestedField:(r,o)=>{e(a=>{let n=r.split("."),s={...a.formData},l=s;for(let i=0;i<n.length-1;i++)l[n[i]]===void 0&&(l[n[i]]={}),l[n[i]]={...l[n[i]]},l=l[n[i]];return l[n[n.length-1]]=o,{formData:s}});},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})),setIsMenuOpen:r=>e(o=>({isMenuOpen:typeof r=="function"?r(o.isMenuOpen):r})),setHasUnsavedChanges:r=>e({hasUnsavedChanges:r}),setLoadingFields:r=>e(o=>({loadingFields:typeof r=="function"?r(o.loadingFields):r})),updateLoadingField:(r,o)=>e(a=>({loadingFields:{...a.loadingFields,[r]:o}})),setCompareMode:r=>e({compareMode:r}),setCompareSelected:r=>e(o=>({compareSelected:typeof r=="function"?r(o.compareSelected):r})),setCompareDiffs:r=>e({compareDiffs:r}),setLoadingDiffs:r=>e({loadingDiffs:r}),setIsAutoSaving:r=>e({isAutoSaving:r}),setAutoSaveStatus:r=>e({autoSaveStatus:r}),setBackgroundProcessing:r=>e({backgroundProcessing:r}),setSidebarCollapsed:r=>e({sidebarCollapsed:r}),setLastSavedAt:r=>e({lastSavedAt:r}),setRetryCount:r=>e({retryCount:r}),setAutoSaveSkip:r=>e({autoSaveSkip:r}),setLastAutoSaveTime:r=>e({lastAutoSaveTime:r}),startAutoSaveTimer:(r,o)=>{let{autoSaveTimer:a}=t();a&&clearTimeout(a);let n=setTimeout(r,o);e({autoSaveTimer:n});},clearAutoSaveTimer:()=>{let{autoSaveTimer:r}=t();r&&(clearTimeout(r),e({autoSaveTimer:null}));},markSaved:()=>{let{formData:r}=t();e({lastSavedData:r,hasUnsavedChanges:false,dirtyFields:new Set,lastSavedAt:Date.now()});},setLastSavedData:r=>{e({lastSavedData:r});},resetForm:()=>{e({formData:{},lastSavedData:{},hasUnsavedChanges:false,dirtyFields:new Set,activeTab:0});},loadDocument:(r,o)=>{let a=t();a.formData===r&&a.lastSavedData===(o||r)&&!a.hasUnsavedChanges||e({formData:r,lastSavedData:o||r,hasUnsavedChanges:false,dirtyFields:new Set});},getField:r=>t().formData[r],getNestedField:r=>{let o=r.split("."),a=t().formData;for(let n of o){if(a==null)return;a=a[n];}return a},getHasChanges:()=>t().dirtyFields.size>0,hasDirtyFields:()=>t().dirtyFields.size>0,getDirtyData:()=>{let{formData:r,dirtyFields:o}=t(),a={};for(let n of o)a[n]=r[n];return a},clearDirtyFields:()=>{e({dirtyFields:new Set,hasUnsavedChanges:false});},pruneExpiredDrafts:()=>{let o=Date.now(),{draftCache:a}=t(),n={};for(let[s,l]of Object.entries(a))o-new Date(l.draftUpdatedAt).getTime()<6048e5&&(n[s]=l);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:middleware.createJSONStorage(()=>Gm()),partialize:e=>({sidebarCollapsed:e.sidebarCollapsed,draftCache:e.draftCache}),onRehydrateStorage:()=>e=>{e&&e.pruneExpiredDrafts();}}));function Hn(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function Jo({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,s=e.variant==="textarea",l=e.name==="slug",{isSlugLocked:i,setIsSlugLocked:d,formData:c}=Fe(),p=e.variant==="email"?"email":e.variant==="password"?"password":e.variant==="url"?"url":"text",y=t==null?"":String(t),g={id:e.name,value:y,onChange:b=>r?.(b.target.value),placeholder:e.admin?.placeholder,disabled:a||n||l&&i,minLength:e.minLength,maxLength:e.maxLength,required:e.required,className:`kyro-form-input ${l?"pr-24":""} ${a||n||l&&i?"opacity-70 bg-[var(--kyro-bg-secondary)] cursor-not-allowed":""}`};return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"relative",children:[s?jsxRuntime.jsx("textarea",{...g,rows:e.rows||4}):jsxRuntime.jsx("input",{type:p,...g,pattern:e.pattern}),l&&jsxRuntime.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[!i&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r?.(Hn(c[e.admin?.autoGenerate||"title"]||"")),className:"p-1 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)]",title:"Regenerate slug",children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),jsxRuntime.jsx("path",{d:"M21 3v5h-5"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>d(!i),className:`p-1.5 rounded transition-colors ${i?"text-[var(--kyro-primary)] bg-[var(--kyro-primary-alpha)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)]"}`,title:i?"Unlock slug":"Lock slug",children:i?jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}):jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[jsxRuntime.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]})})]}),e.name?.toLowerCase().includes("metatitle")&&jsxRuntime.jsx("div",{className:"flex items-center justify-between mt-1 text-[10px] font-bold tracking-wider",children:jsxRuntime.jsxs("span",{className:y.length>60?"text-red-500":y.length>=40?"text-green-500":"text-amber-600",children:[y.length," / 60 \u2014 ",y.length>60?"Too Long":y.length>=40?"Ideal":"Short"]})})]})})}function Vn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsx("input",{type:"number",id:e.name,value:t??"",onChange:s=>r?.(parseFloat(s.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 Kn({field:e,value:t,onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(it,{field:e,error:o,hideLabel:true,children:jsxRuntime.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group py-0.5",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t??false,onChange:l=>r?.(l.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"}`}),jsxRuntime.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&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]})]})})}function Gn({field:e,value:t="",onChange:r,error:o,disabled:a}){let n=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly;return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsx("input",{type:e.time?"datetime-local":"date",id:e.name,value:t??"",onChange:s=>r?.(s.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 Ea(e){return e?Array.isArray(e)?e:Object.values(e):[]}function Jn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function qn(e){return e.reduce((t,r)=>(r.slug&&(t[r.slug]=r),t),{})}function Ma(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 Jm={pages:"FileText",posts:"Newspaper",categories:"Tags",menu:"Menu",products:"ShoppingBag",customers:"Users",orders:"ShoppingCart",coupons:"Ticket",forms:"FileInput","form-entries":"Inbox"};function ho(e,t,r){let o=t.split(".");if(o.length===0)return false;let a=o[0],n=o.slice(1).join(".");for(let s of e){if(s.name===a)if(n){if(s.fields&&Array.isArray(s.fields))return ho(s.fields,n,r);if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&ho(i.fields,n,r))return true;return false}if(s.type==="blocks"&&s.blocks&&Array.isArray(s.blocks)){let i=n.split(".")[0],d=n.split(".").slice(1).join(".");if(!d)return false;for(let c of s.blocks)if(c.slug===i&&c.fields&&Array.isArray(c.fields))return ho(c.fields,d,r);return false}return s.type==="array"&&s.fields&&Array.isArray(s.fields)?ho(s.fields,n,r):false}else return Object.assign(s,r),true;if(!s.name||s.type==="tabs"||s.type==="row"||s.type==="collapsible"){if(s.fields&&Array.isArray(s.fields)&&ho(s.fields,t,r))return true;if(s.type==="tabs"&&s.tabs&&Array.isArray(s.tabs)){for(let i of s.tabs)if(i.fields&&Array.isArray(i.fields)&&ho(i.fields,t,r))return true}}}return false}function qm(e,t){for(let[r,o]of Object.entries(e)){let a=Jm[r],n=t?.[r];if(a&&!o.admin?.icon&&(o.admin={...o.admin,icon:a}),n){let{fields:s,...l}=n;if(o.admin={...o.admin,...l},s&&o.fields&&Array.isArray(o.fields))for(let[i,d]of Object.entries(s))ho(o.fields,i,d);}}}function Xm(e="blog"){let t=[],r=[];switch(e){case "minimal":t.push(...Object.values(templates.minimalCollections)),r.push(...templates.coreSettingsGlobals);break;case "starter":t.push(...Object.values(templates.starterCollections)),r.push(...templates.coreSettingsGlobals);break;case "blog":t.push(...Object.values(templates.blogCollections)),r.push(...templates.coreSettingsGlobals);break;case "ecommerce":t.push(...Object.values(templates.ecommerceCollections)),r.push(...templates.allSettingsGlobals);break;case "kitchen-sink":t.push(...Object.values(templates.minimalCollections),...Object.values(templates.starterCollections),...Object.values(templates.blogCollections),...Object.values(templates.ecommerceCollections),...Object.values(templates.kitchenSinkCollections)),r.push(...templates.allSettingsGlobals);break}return Ma(t,Object.values(templates.mediaCollections)),Ma(t,Object.values(templates.authCollections)),{collections:Jn(t),globals:qn(r)}}function Ym(e){let t=Ea(e.collections),r=Ea(e.globals);if(t.length===0&&r.length===0)return Xm("kitchen-sink");let o=[];return Ma(o,Object.values(templates.mediaCollections)),Ma(o,Object.values(templates.authCollections)),Ma(o,t),{collections:Jn(o),globals:qn(r)}}var Wn=null;function Qm(){if(Wn)return Wn;try{if(typeof __KYRO_ADMIN_CONFIG_FILE__=="string"&&Bo__default.default.existsSync(__KYRO_ADMIN_CONFIG_FILE__))return Wn=JSON.parse(Bo__default.default.readFileSync(__KYRO_ADMIN_CONFIG_FILE__,"utf8")),Wn}catch{}return null}var pd=Qm()||{collections:[],globals:[]},md=Ym(pd);qm(md.collections,pd.collectionOverrides);var ud=md,qo=ud.collections,yd=ud.globals,Js=["users","audit_logs"];Object.values(qo).filter(e=>!Js.includes(e.slug)&&e.admin?.hidden!==true);function Xn({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i}){let d=typeof e.admin?.readOnly=="function"?false:!!e.admin?.readOnly,[c,p]=Ta.useState(null),y=JSON.stringify(n||{}),g=JSON.stringify(s||{});Ta.useEffect(()=>{if(e.options!=="__KYRO_DYNAMIC_OPTIONS__")return;let k=setTimeout(async()=>{try{let f="";if(l)f=`${xr}/${l}/dynamic-options/${e.name}`;else if(i)f=`${xr}/globals/${i}/dynamic-options/${e.name}`;else return;let u=await st(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:JSON.parse(y),siblingData:JSON.parse(g)})});if(u.ok){let x=await u.json();x.options&&p(x.options);}}catch(f){console.error("Failed to fetch dynamic options:",f);}},300);return ()=>clearTimeout(k)},[y,g,e.name,e.options,l,i]);let b=c||[];return e.options!=="__KYRO_DYNAMIC_OPTIONS__"&&(typeof e.options=="function"?b=e.options({data:n||{},siblingData:s||{}}):Array.isArray(e.options)&&(b=e.options)),e.dynamicOptions==="collections"&&(b=Object.keys(qo).filter(v=>v!=="media").map(v=>({label:qo[v]?.label||v,value:v}))),jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsxs("select",{id:e.name,value:e.hasMany?Array.isArray(t)?t:[]:t||"",onChange:v=>{if(e.hasMany){let k=Array.from(v.target.selectedOptions,f=>f.value);r?.(k);}else r?.(v.target.value||void 0);},multiple:e.hasMany,disabled:a||d,required:e.required,className:`kyro-form-input ${a||d?"opacity-50 cursor-not-allowed":""}`,children:[!e.required&&!e.hasMany&&jsxRuntime.jsx("option",{value:"",children:"Select..."}),b.map(v=>jsxRuntime.jsx("option",{value:v.value,children:v.label},v.value))]})})}function Yn({icon:e,title:t,description:r,action:o}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-3 justify-center py-16 px-8",children:[e&&jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[var(--kyro-surface-accent)] flex items-center justify-center mb-4",children:e}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text-primary)] text-base",children:t}),r&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] mt-1",children:r}),o]})}function ei(e){let t=e?.tabs;return e?.title||t?.title||e?.name||e?.label||e?.email||e?.filename||e?.slug||"Untitled"}function mu({id:e,label:t,relation:r,onRemove:o,disabled:a}){let{attributes:n,listeners:s,setNodeRef:l,transform:i,transition:d,isDragging:c}=sortable.useSortable({id:e}),p={transform:utilities.CSS.Transform.toString(i),transition:d,zIndex:c?10:1,opacity:c?.8:1};return jsxRuntime.jsxs("span",{ref:l,style:p,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&&jsxRuntime.jsx("div",{...n,...s,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:jsxRuntime.jsx(Hl.GripVertical,{className:"w-2.5 h-2.5"})}),r&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[r,":"]}),t,!a&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"hover:opacity-70 p-0.5 ml-0.5 flex items-center justify-center",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})}function uu({field:e,value:t,onChange:r,error:o,disabled:a}){let[n,s]=Ta.useState(false),[l,i]=Ta.useState(""),[d,c]=Ta.useState([]),[p,y]=Ta.useState(false),[g,b]=Ta.useState([]),v=Ta.useRef(new Set),k=Ta.useRef(null),f=Ta.useRef(()=>{});f.current=r||(()=>{});let u=e.hasMany,x=Array.isArray(e.relationTo)?e.relationTo:[e.relationTo],A=x.length>1,[F,h]=Ta.useState(x[0]||""),w=Ta.useCallback(()=>t?(u?Array.isArray(t)?t:[]:t?[t]:[]).map(O=>typeof O=="object"&&O!==null?O.value||O.id||"":String(O)).filter(Boolean):[],[t,u]),m=Ta.useCallback($=>{$.length!==0&&$.forEach(O=>{if(v.current.has(O))return;v.current.add(O);let ne=A?(()=>{if(!t)return F;let H=(u?Array.isArray(t)?t:[]:[t]).find(S=>typeof S=="object"&&S!==null?S.value===O||S.id===O:false);return H&&typeof H=="object"&&H.relationTo||F})():F;Ae(`/api/${ne}/${O}`).then(ie=>{let H=ie.data||ie;!H||typeof H!="object"||b(S=>S.some(J=>J.id===O)?S:[...S,{...H,id:String(H.id),relationTo:ne}]);}).catch(()=>{});});},[A,t,F,u]);Ta.useEffect(()=>{let $=w();m($);},[w,m]);let T=Ta.useCallback(($="")=>{y(true);let ne=`/api/${F}?${ln($,["title","name","label","email"])}`;Ae(ne).then(ie=>{c(H=>{let S=new Set(H.map(fe=>fe.id)),J=(ie.docs||[]).filter(fe=>!S.has(fe.id)).map(fe=>({...fe,id:fe.id}));return [...H,...J]}),y(false);}).catch(()=>{y(false);});},[F]);Ta.useEffect(()=>{n&&(c([]),T(l));},[n,F]),Ta.useEffect(()=>{let $=O=>{k.current&&!k.current.contains(O.target)&&s(false);};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);let B=$=>typeof $=="object"&&$!==null?$.value||$.id||"":String($),I=$=>{let O=$.id;return t?u&&Array.isArray(t)?t.some(ne=>B(ne)===O):B(t)===O:false},V=$=>{let O=$.id;if(u){let ne=Array.isArray(t)?t:[];if(I($))f.current?.(ne.filter(ie=>B(ie)!==O));else {let ie=A?{relationTo:F,value:O}:O;f.current?.([...ne,ie]);}}else if(I($))f.current?.(null);else {let ne=A?{relationTo:F,value:O}:O;f.current?.(ne),s(false),i("");}},C=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),K=$=>{let{active:O,over:ne}=$;if(!ne||O.id===ne.id)return;let ie=u?Array.isArray(t)?t:[]:[],H=ie.findIndex(J=>B(J)===O.id),S=ie.findIndex(J=>B(J)===ne.id);if(H!==-1&&S!==-1){let J=[...ie],[fe]=J.splice(H,1);J.splice(S,0,fe),f.current?.(J);}},E=()=>{if(!t)return null;let $=u?Array.isArray(t)?t:[]:t?[t]:[],O=$.map(ne=>B(ne));return u&&$.length>1?jsxRuntime.jsx(core.DndContext,{sensors:C,collisionDetection:core.closestCenter,onDragEnd:K,children:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:jsxRuntime.jsx(sortable.SortableContext,{items:O,strategy:sortable.horizontalListSortingStrategy,children:$.map(ne=>{let ie=B(ne),H=g.find(fe=>fe.id===ie),S=H?ei(H):ie.slice(0,12),J=A&&H?H.relationTo:null;return jsxRuntime.jsx(mu,{id:ie,label:S,relation:J,onRemove:()=>{let fe=$.filter(U=>B(U)!==ie);f.current?.(fe);},disabled:a},ie)})})})}):jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:$.map(ne=>{let ie=B(ne),H=g.find(fe=>fe.id===ie),S=H?ei(H):ie.slice(0,12),J=A&&H?H.relationTo:null;return jsxRuntime.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:[J&&jsxRuntime.jsxs("span",{className:"opacity-60 mr-0.5",children:[J,":"]}),S,!a&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{let fe=$.filter(U=>B(U)!==ie);f.current?.(u?fe:fe[0]??null);},className:"hover:opacity-70 flex items-center justify-center",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]},ie)})})};return jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[e.label&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium text-[var(--kyro-text-primary)]",children:[e.label,e.required&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-error)] ml-1",children:"*"})]}),jsxRuntime.jsxs("div",{ref:k,className:"relative",children:[A&&jsxRuntime.jsx("div",{className:"flex gap-1 mb-1.5",children:x.map($=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{h($),c([]),i("");},className:`px-2 py-0.5 text-[10px] font-bold rounded transition-colors ${F===$?"kyro-btn-primary":"bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-border)]"}`,children:$},$))}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Hl.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:$=>{i($.target.value),s(true),T($.target.value);},onFocus:()=>s(true),placeholder:e.admin?.placeholder||`Search ${F}...`,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"}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:p?jsxRuntime.jsx(Hl.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"}):jsxRuntime.jsx(Hl.ChevronDown,{className:`w-4 h-4 text-[var(--kyro-text-muted)] transition-transform ${n?"rotate-180":""}`})})]}),n&&jsxRuntime.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?jsxRuntime.jsx("div",{className:"p-4 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):d.length===0?jsxRuntime.jsx(Yn,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:d.map($=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>V($),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors ${I($)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:ei($)}),I($)&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-sidebar-active)]",children:"\u2713"})]}),"slug"in $&&typeof $.slug=="string"&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)]",children:$.slug})]},$.id))})}),E()]}),e.admin?.description&&!o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-muted)]",children:e.admin.description}),o&&jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-error)]",children:o})]})}var $a=uu;var wo=Ta.createContext(null);function vd(e=[],t=[]){return vanilla.createStore((r,o)=>({blocks:[],allowedBlocks:e,dynamicCategories:t,setBlocks:a=>{let n=ti(a||[]);r({blocks:n});},onBlocksChange:null,setOnBlocksChange:a=>r({onBlocksChange:a}),addBlock:(a,n)=>{let s=Yo(a),{blocks:l}=o(),i=[...l];n!==void 0?i.splice(n,0,s):i.push(s),r({blocks:i});let{onBlocksChange:d}=o();d&&d();},updateBlock:(a,n)=>{let{blocks:s}=o(),l=Oa(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=[...i];return c[d]={...c[d],...n},{newList:c,found:true}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}},removeBlock:a=>{if(!a)return;let{blocks:n}=o(),s=Oa(n,l=>{let i=l.filter(d=>d.id!==a);return i.length!==l.length?{newList:i,found:true}:{newList:l,found:false}});if(s!==n){r({blocks:s});let{onBlocksChange:l}=o();l&&l();}},moveBlock:(a,n)=>{let{blocks:s}=o(),l=Oa(s,i=>{let d=i.findIndex(c=>c.id===a);if(d!==-1){let c=n==="up"?d-1:d+1;if(c>=0&&c<i.length){let p=[...i];return [p[d],p[c]]=[p[c],p[d]],{newList:p,found:true}}}return {newList:i,found:false}});if(l!==s){r({blocks:l});let{onBlocksChange:i}=o();i&&i();}}}))}function ti(e){return Array.isArray(e)?e.map(t=>{let r={...t,id:t.id||Math.random().toString(36).substr(2,9)};return r.children&&Array.isArray(r.children)&&(r.children=ti(r.children)),r.data?.columnData&&Array.isArray(r.data.columnData)&&(r.data={...r.data,columnData:r.data.columnData.map(o=>({...o,children:o.children?ti(o.children):o.children}))}),r}):[]}function Yo(e){let t=gu(e),{options:r,children:o,...a}=t;return {id:Math.random().toString(36).substr(2,9),type:e,name:"",data:a,options:r,children:o,order:Date.now()}}function gu(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 ze(e){let t=Ta.useContext(wo);if(t)return zustand.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}if(n.data?.columnData){for(let s of n.data.columnData)if(s&&s.children&&s.children.length>0){let l=o(s.children);if(l)return l}}}};return o(r.blocks)})}function Be(){let e=Ta.useContext(wo);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 Oa(e,t){let{newList:r,found:o}=t(e);if(o)return r;let a=false,n=e.map(s=>{let l={...s},i=false;if(s.children&&s.children.length>0){let d=Oa(s.children,t);d!==s.children&&(l.children=d,i=true);}if(s.data?.columnData&&Array.isArray(s.data.columnData)){let d=s.data.columnData.map(c=>{if(c.children&&c.children.length>0){let p=Oa(c.children,t);if(p!==c.children)return {...c,children:p}}return c});d.some((c,p)=>c!==s.data.columnData[p])&&(l.data={...l.data,columnData:d},i=true);}return i&&(a=true),i?l:s});return a?n:e}function za({open:e,onClose:t,onSelect:r,onPasteBlock:o,children:a}){let[n,s]=Ta__default.default.useState(null),l=async()=>{try{s(null);let i=await navigator.clipboard.readText(),d=JSON.parse(i);d.__kyro_block?o&&o(d):s("Clipboard does not contain a valid Kyro block.");}catch(i){s("Failed to read block from clipboard."),console.error(i);}};return e?jsxRuntime.jsxs(dr,{open:e,onClose:t,title:"Insert Block",width:"md",children:[jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-muted)] mb-4",children:"Drag blocks into the editor or click to insert"}),o&&jsxRuntime.jsxs("div",{className:"mb-6 pb-6 border-b border-[var(--kyro-border)]",children:[jsxRuntime.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:[jsxRuntime.jsx(Hl.ClipboardPaste,{className:"w-4 h-4"}),"Paste Block from Clipboard"]}),n&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-2 text-center font-medium",children:n})]}),a]}):null}function gd({block:e,onSelect:t,children:r}){let{attributes:o,listeners:a,setNodeRef:n,isDragging:s}=core.useDraggable({id:`drawer-${e.type}`,data:{source:"drawer",blockType:e.type}});return jsxRuntime.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 ${s?"opacity-50 border-[var(--kyro-primary)]":""}`,style:{opacity:s?.5:1},children:[jsxRuntime.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||jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)] leading-tight",children:e.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 leading-tight",children:e.description})]})]})}var ri=({text:e="",onChange:t,compact:r=false})=>jsxRuntime.jsx("div",{className:r?"":"space-y-3",children:jsxRuntime.jsx("input",{type:"text",value:e,onChange:a=>t("text",a.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:"Enter heading text..."})});var Co=({id:e,type:t,label:r,children:o,className:a=""})=>{let{moveBlock:n,removeBlock:s}=Be();return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] tracking-wider",children:r||t}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-muted)] hover:text-[var(--kyro-primary)]",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>s(e),className:"p-1 hover:bg-[var(--kyro-error)]/10 rounded text-[var(--kyro-error)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"block-content",children:o})]})};var kd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o}=Be(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Co,{id:e.id,type:"heading",label:"Heading",children:jsxRuntime.jsx(ri,{text:a.text||"",onChange:n,compact:true})})};var wd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o}=Be(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Co,{id:e.id,type:"paragraph",label:"Paragraph",children:jsxRuntime.jsx("textarea",{value:a.text||"",onChange:s=>n("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:"Enter paragraph text..."})})};var Nd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data||e.data||{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-image border border-[var(--kyro-border)] rounded-lg p-4 mb-4 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Image"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Image Asset"}),jsxRuntime.jsx(lr,{field:{label:"Image Asset",name:"src",maxCount:1},value:s.src,onChange:i=>l("src",i)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Alt Text"}),jsxRuntime.jsx("input",{type:"text",value:s.alt||"",onChange:i=>l("alt",i.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:"Alternative text..."})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-xs font-medium text-[var(--kyro-text-muted)] mb-1 block",children:"Caption"}),jsxRuntime.jsx("input",{type:"text",value:s.caption||"",onChange:i=>l("caption",i.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:"Image caption..."})]})]})]})};var ai=({src:e="",title:t="",onChange:r,onUploadChange:o,compact:a=false})=>{e.includes("youtube.com")||e.includes("vimeo.com")||e.includes("youtu.be");return a?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.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:"Video title (optional)..."})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(lr,{field:{label:"Video Asset",name:"src",maxCount:1},value:e,onChange:o||(s=>r("src",s))}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--kyro-text-muted)]",children:"or paste a URL"}),jsxRuntime.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:"MP4 URL, YouTube, or Vimeo link..."}),jsxRuntime.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:"Video title (optional)..."})]})};var Sd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-video border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Video"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ai,{src:s.src||"",title:s.title||"",onChange:l,onUploadChange:i=>l("src",i),compact:true})]})};function Pu({id:e,text:t,onRemove:r}){let{attributes:o,listeners:a,setNodeRef:n,transform:s,transition:l,isDragging:i}=sortable.useSortable({id:e}),d={transform:utilities.CSS.Transform.toString(s),transition:l,zIndex:i?10:1,opacity:i?.8:1};return jsxRuntime.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 ${i?"bg-[var(--kyro-surface-accent)] shadow-sm":""}`,children:[jsxRuntime.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:jsxRuntime.jsx(Hl.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsxs("span",{className:"text-sm text-[var(--kyro-text-primary)] flex-1",children:["\u2022 ",t]}),jsxRuntime.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 ja=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ta__default.default.useState(""),[n,s]=Ta__default.default.useState([]);Ta__default.default.useEffect(()=>{let g=n.map(b=>b.text);JSON.stringify(g)!==JSON.stringify(e)&&s(e.map((b,v)=>({id:`${b}-${v}-${Math.random().toString(36).substr(2,4)}`,text:b})));},[e]);let l=()=>{o.trim()&&(t([...e,o.trim()]),a(""));},i=g=>{g.key==="Enter"&&(g.preventDefault(),l());},d=g=>{t(e.filter((b,v)=>v!==g));},c=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),p=g=>{let{active:b,over:v}=g;if(!v||b.id===v.id)return;let k=n.findIndex(u=>u.id===b.id),f=n.findIndex(u=>u.id===v.id);if(k!==-1&&f!==-1){let u=[...e],[x]=u.splice(k,1);u.splice(f,0,x),t(u);}},y=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 jsxRuntime.jsx(core.DndContext,{sensors:c,collisionDetection:core.closestCenter,onDragEnd:p,children:jsxRuntime.jsxs("div",{className:r?"space-y-1.5":"space-y-2",children:[e.length===0?jsxRuntime.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."}):jsxRuntime.jsx(sortable.SortableContext,{items:n.map(g=>g.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-1",children:n.map((g,b)=>jsxRuntime.jsx(Pu,{id:g.id,text:g.text,onRemove:()=>d(b)},g.id))})}),jsxRuntime.jsx("input",{type:"text",value:o,onChange:g=>a(g.target.value),onKeyDown:i,className:y,placeholder:"Type and press Enter to add..."})]})})};var Td=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data||e.data||{},l=Array.isArray(s.items)?s.items:[];return jsxRuntime.jsxs("div",{className:"block-list border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"List"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ja,{items:l,onChange:d=>{o(e.id,{data:{...s,items:d}});},compact:true})]})};var Rd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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:jsxRuntime.jsx(Hl.CodeXml,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-bold tracking-tight text-[var(--kyro-text-primary)]",children:"Code Snippet"}),jsxRuntime.jsxs("p",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] tracking-widest",children:["Block Editor \u2022 ",s.language||"javascript"]})]})]}),jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex bg-[var(--kyro-surface-accent)]/50 p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(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:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-4 h-4 rotate-[-90deg]"})}),jsxRuntime.jsx("div",{className:"w-px h-4 bg-[var(--kyro-border)] mx-1 self-center"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(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:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]})})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx(La,{field:{type:"code",name:"code",label:"Source Code",language:s.language||"javascript"},value:s.code||"",onChange:i=>l("code",i)}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2 block",children:"Syntax Highlighting"}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("select",{value:s.language||"javascript",onChange:i=>l("language",i.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:[jsxRuntime.jsx("option",{value:"plaintext",children:"Plain Text"}),jsxRuntime.jsx("option",{value:"javascript",children:"JavaScript"}),jsxRuntime.jsx("option",{value:"typescript",children:"TypeScript"}),jsxRuntime.jsx("option",{value:"python",children:"Python"}),jsxRuntime.jsx("option",{value:"json",children:"JSON"}),jsxRuntime.jsx("option",{value:"html",children:"HTML"}),jsxRuntime.jsx("option",{value:"css",children:"CSS"}),jsxRuntime.jsx("option",{value:"sql",children:"SQL"}),jsxRuntime.jsx("option",{value:"rust",children:"Rust"}),jsxRuntime.jsx("option",{value:"markdown",children:"Markdown"})]}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-4 h-4 rotate-90"})})]})]}),jsxRuntime.jsx("div",{className:"hidden sm:block w-px h-10 bg-[var(--kyro-border)]"}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col justify-center",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-[var(--kyro-text-muted)] mb-2",children:"Status"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-medium text-[var(--kyro-text-primary)] tracking-wide",children:"EDITING"})]})]})]})]})]})};var Ad=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-file border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"File"}),jsxRuntime.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(lr,{field:{label:"File",name:"file",maxCount:1},value:s.file,onChange:i=>l("file",i)})]})};var ci=({items:e=[],onChange:t,compact:r=false})=>{let[o,a]=Ta__default.default.useState(0),n=(p,y)=>{let g=[...e];g[p]={...g[p],title:y},t(g);},s=(p,y)=>{let g=[...e];g[p]={...g[p],content:y},t(g);},l=p=>{let y=e.filter((g,b)=>b!==p);t(y),o===p?a(null):o!==null&&o>p&&a(o-1);},i=()=>{t([...e,{title:`Item ${e.length+1}`,content:""}]),a(e.length);},d="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",c="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?jsxRuntime.jsxs("div",{className:"space-y-2",children:[e.length===0?jsxRuntime.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.'}):jsxRuntime.jsx("div",{className:"space-y-1.5",children:e.map((p,y)=>{let g=o===y;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:y),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:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${y+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(y);},className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3.5 h-3.5"})}),g?jsxRuntime.jsx(Hl.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Hl.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-2.5 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:p.title||"",onChange:b=>n(y,b.target.value),onClick:b=>b.stopPropagation(),className:c,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:p.content||"",onChange:b=>s(y,b.target.value),onClick:b=>b.stopPropagation(),className:`${c} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},y)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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:[jsxRuntime.jsx(Hl.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]}):jsxRuntime.jsxs("div",{className:"space-y-2",children:[e.length===0?jsxRuntime.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.'}):jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((p,y)=>{let g=o===y;return jsxRuntime.jsxs("div",{className:"border border-[var(--kyro-border)] rounded-lg overflow-hidden group",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(g?null:y),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:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] truncate",children:p.title||`Item ${y+1}`}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),l(y);},className:"opacity-0 group-hover:opacity-100 p-1.5 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-error)] transition-opacity",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})}),g?jsxRuntime.jsx(Hl.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Hl.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})]})]}),g&&jsxRuntime.jsxs("div",{className:"p-3 bg-[var(--kyro-surface)] space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:p.title||"",onChange:b=>n(y,b.target.value),className:d,placeholder:"Item title..."}),jsxRuntime.jsx("textarea",{value:p.content||"",onChange:b=>s(y,b.target.value),className:`${d} min-h-[60px] resize-none`,placeholder:"Item content..."})]})]},y)})}),jsxRuntime.jsxs("button",{type:"button",onClick:i,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:[jsxRuntime.jsx(Hl.Plus,{className:"w-3.5 h-3.5"}),"Add Item"]})]})};var Fd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=Array.isArray(s.items)?s.items:[],i=d=>{o(e.id,{data:{...s,items:d}});};return jsxRuntime.jsxs("div",{className:"block-accordion border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Accordion"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(ci,{items:l,onChange:i,compact:true})]})};var Pd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data||e.data||{},l=i=>{o(e.id,{data:{...s,content:i}});};return jsxRuntime.jsxs("div",{className:"block-richtext border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Hl.AlignLeft,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Rich Text"})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ho,{field:{name:"content",label:"Content",type:"richtext"},value:s.content,onChange:l})]})};var pi=({heading:e="",subheading:t="",ctaText:r="",ctaUrl:o="",onChange:a,compact:n=false})=>{let 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?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:i=>a("title",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subtitle",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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://..."})]})]}):jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:i=>a("title",i.target.value),className:`${s} font-bold text-base`,placeholder:"Hero heading..."}),jsxRuntime.jsx("textarea",{value:t,onChange:i=>a("subtitle",i.target.value),className:l,placeholder:"Hero subheading..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>a("ctaText",i.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:"CTA text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:i=>a("ctaUrl",i.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://..."})]})]})};function es({field:e,value:t,onChange:r,renderField:o}){let a=t||{};return jsxRuntime.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:[jsxRuntime.jsx("h3",{className:"text-sm font-bold tracking-widest text-[var(--kyro-text-primary)] mb-6 border-b border-[var(--kyro-border)] pb-2 inline-block",children:e.label||e.name}),jsxRuntime.jsx("div",{className:e.admin?.inline?"flex items-start gap-4":"space-y-6",children:e.fields.map(n=>o(n,a,r))})]})}var zu=new Set(["text","number","checkbox","select","radio","color","email","password"]);function ju(e){let t=e.fields||[];return t.length===0||t.length>4?false:t.every(r=>zu.has(r.type))}function Ld({id:e,index:t,isOpen:r,setOpenIndex:o,item:a,field:n,renderField:s,onChangeItem:l,onRemove:i,disabled:d,compact:c,getItemLabel:p}){let{attributes:y,listeners:g,setNodeRef:b,transform:v,transition:k,isDragging:f}=sortable.useSortable({id:e}),u={transform:utilities.CSS.Transform.toString(v),transition:k,zIndex:f?10:1,opacity:f?.8:1};return c?jsxRuntime.jsxs("div",{ref:b,style:u,className:`flex items-start gap-2 px-3 py-1.5 border-b border-[var(--kyro-border)] last:border-b-0 hover:bg-[var(--kyro-sidebar-active)]/5 transition-colors ${f?"bg-[var(--kyro-surface-accent)]/50":""}`,children:[jsxRuntime.jsx("div",{...y,...g,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:jsxRuntime.jsx(Hl.GripVertical,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] pt-2.5 min-w-[18px] text-center",children:t+1}),jsxRuntime.jsx("div",{className:`flex-1 min-w-0 ${(n.fields||[]).length>=3?"flex flex-col gap-1.5":"flex items-start gap-1.5"}`,children:(n.fields||[]).map(x=>jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:s(x,a,l)},x.name))}),jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:i,className:"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-error)] transition-colors disabled:opacity-30 p-0.5 mt-1.5 flex-shrink-0",title:"Remove",children:jsxRuntime.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsxRuntime.jsxs("div",{ref:b,style:u,className:`border border-[var(--kyro-border)] rounded-lg overflow-hidden group bg-[var(--kyro-surface)] ${f?"border-[var(--kyro-primary)] shadow-md":""}`,children:[jsxRuntime.jsxs("div",{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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[jsxRuntime.jsx("div",{...y,...g,className:"p-1 cursor-grab active:cursor-grabbing text-[var(--kyro-text-muted)] hover:bg-[var(--kyro-border)] rounded flex-shrink-0",children:jsxRuntime.jsx(Hl.GripVertical,{className:"w-4 h-4"})}),jsxRuntime.jsx("span",{role:"button",tabIndex:0,onClick:()=>o(r?null:t),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),o(r?null:t));},className:"text-xs font-bold tracking-widest text-[var(--kyro-text-muted)] truncate cursor-pointer flex-1 py-1 text-left",children:p(a)||`Item ${t+1}`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{type:"button",disabled:d,onClick:x=>{x.stopPropagation(),i();},className:"text-[11px] font-bold text-[var(--kyro-error)] opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-30 hover:bg-[var(--kyro-danger-bg)] rounded px-1.5 py-0.5",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(r?null:t),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",children:r?jsxRuntime.jsx(Hl.ChevronUp,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Hl.ChevronDown,{className:"w-4 h-4 text-[var(--kyro-text-muted)]"})})]})]}),r&&jsxRuntime.jsx("div",{className:"p-4 bg-[var(--kyro-surface)] space-y-4",children:(n.fields||[]).map(x=>s(x,a,l))})]})}function ts({field:e,value:t,onChange:r,renderField:o,disabled:a}){let n=Array.isArray(t)?t:[],s=e.fields||[],l=s[0],i=l?.name||"user",d=l?.type==="relationship",[c,p]=Ta__default.default.useState(0);Ta__default.default.useEffect(()=>{let f=false,u=n.filter(x=>typeof x!="object"||x===null?(f=true,false):true).map(x=>!x.id&&!x._key?(f=true,{...x,id:Math.random().toString(36).substr(2,9)}):x);f&&r(u);},[t,r]);function y(f){for(let u of ["label","title","name"]){let x=f[u];if(x&&typeof x=="string")return x}for(let u of s){if(u.type==="text"||u.type==="textarea"){let x=f[u.name];if(x&&typeof x=="string")return x}if(u.type==="group"&&u.fields){for(let x of u.fields)if(x.type==="text"||x.type==="textarea"){let F=f[u.name]?.[x.name];if(F&&typeof F=="string")return F}}}return ""}let g=ju(e),b=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}})),v=f=>{let{active:u,over:x}=f;if(!x||u.id===x.id)return;let A=n.findIndex(h=>(h.id||h._key)===u.id),F=n.findIndex(h=>(h.id||h._key)===x.id);if(A!==-1&&F!==-1){let h=[...n],[w]=h.splice(A,1);h.splice(F,0,w),r(h);}},k=Ta__default.default.useMemo(()=>n.map(f=>f?.id||f?._key||""),[n]);return d?jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx($a,{field:{name:i,relationTo:e.fields?.[0]?.relationTo||"",hasMany:true,label:e.fields?.[0]?.label},value:n.map(f=>f[i]).filter(Boolean),onChange:f=>{let u=(f||[]).map(x=>({[i]:x,id:Math.random().toString(36).substr(2,9)}));r(u);},disabled:a})]}):jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsx("label",{className:"kyro-form-label",children:e.label||e.name}),jsxRuntime.jsx(core.DndContext,{sensors:b,collisionDetection:core.closestCenter,onDragEnd:v,children:g?jsxRuntime.jsxs("div",{className:"kyro-form-array kyro-form-array--compact border border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30 rounded-md overflow-hidden",children:[jsxRuntime.jsx(sortable.SortableContext,{items:k,strategy:sortable.verticalListSortingStrategy,children:n.map((f,u)=>jsxRuntime.jsx(Ld,{id:f.id||f._key||`idx-${u}`,index:u,isOpen:false,setOpenIndex:()=>{},item:f,field:e,renderField:o,onChangeItem:x=>{let A=[...n];A[u]=x,r(A);},onRemove:()=>r(n.filter((x,A)=>A!==u)),disabled:a,compact:true,getItemLabel:y},f.id||f._key||u))}),jsxRuntime.jsx("button",{type:"button",className:"w-full py-2 border-2 border-dashed border-[var(--kyro-border)] rounded-none text-xs font-bold text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:border-[var(--kyro-primary)] transition-all disabled:opacity-50",disabled:a,onClick:()=>r([...n,{id:Math.random().toString(36).substr(2,9)}]),children:"+ Add Item"})]}):jsxRuntime.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:[jsxRuntime.jsx(sortable.SortableContext,{items:k,strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"space-y-2",children:n.map((f,u)=>{let x=c===u;return jsxRuntime.jsx(Ld,{id:f.id||f._key||`idx-${u}`,index:u,isOpen:x,setOpenIndex:p,item:f,field:e,renderField:o,onChangeItem:A=>{let F=[...n];F[u]=A,r(F);},onRemove:()=>r(n.filter((A,F)=>F!==u)),disabled:a,compact:false,getItemLabel:y},f.id||f._key||u)})})}),jsxRuntime.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 f=Math.random().toString(36).substr(2,9);r([...n,{id:f}]),p(n.length);},children:"+ Add Item"})]})})]})}var Md="other";function Ed(){return Md}function rs(e){Md=e;}var To=({field:e,value:t,onChange:r,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i})=>{if(e.hidden===true||e.admin?.hidden===true)return null;let d=c=>{rs("keystroke"),r(c);};switch(e.type){case "text":case "email":case "url":return jsxRuntime.jsx(Jo,{field:e,value:t,onChange:d,error:o,disabled:a});case "icon":return jsxRuntime.jsx($n,{field:e,value:t,onChange:d,error:o,disabled:a});case "textarea":return jsxRuntime.jsx(Jo,{field:{...e,variant:"textarea"},value:t,onChange:d,error:o,disabled:a});case "password":return jsxRuntime.jsx(Jo,{field:{...e,variant:"password"},value:t,onChange:d,error:o,disabled:a});case "secret":return jsxRuntime.jsx(jn,{field:e,value:t,onChange:r,error:o,disabled:a});case "number":return jsxRuntime.jsx(Vn,{field:e,value:t,onChange:r,disabled:a,error:o});case "checkbox":return jsxRuntime.jsx(Kn,{field:e,value:t,onChange:r,disabled:a,error:o});case "select":return jsxRuntime.jsx(Xn,{field:e,value:t,onChange:d,error:o,disabled:a,formData:n,siblingData:s,collectionSlug:l,globalSlug:i});case "date":return jsxRuntime.jsx(Gn,{field:e,value:t,onChange:r,disabled:a,error:o});case "richtext":return jsxRuntime.jsx(Ho,{field:e,value:t,onChange:d,disabled:a,error:o});case "markdown":return jsxRuntime.jsx(Vs,{field:e,value:t,onChange:d,disabled:a,error:o});case "code":return jsxRuntime.jsx(La,{field:e,value:t,onChange:d,disabled:a,error:o});case "image":case "upload":return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsx(lr,{field:e,value:t,onChange:r,disabled:a})});case "relationship":return jsxRuntime.jsx($a,{field:e,value:t,onChange:r,disabled:a,error:o});case "list":return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsx(ja,{items:Array.isArray(t)?t:[],onChange:r,compact:true})});case "array":return jsxRuntime.jsx(ts,{field:e,value:Array.isArray(t)?t:[],onChange:r,disabled:a,renderField:(c,p,y)=>{let g=p[c.name];return jsxRuntime.jsx(To,{field:c,value:g,onChange:b=>{y({...p,[c.name]:b});},disabled:a,error:o},c.name)}});case "blocks":return jsxRuntime.jsx(ui,{field:e,value:t,onChange:d,disabled:a,error:o});case "group":return jsxRuntime.jsx(es,{field:e,value:t,onChange:r,renderField:(c,p,y)=>{let g=p[c.name];return jsxRuntime.jsx(To,{field:c,value:g,onChange:b=>{y({...p,[c.name]:b});},disabled:a,error:o,collectionSlug:l,globalSlug:i},c.name)}});case "color":return jsxRuntime.jsx(it,{field:e,error:o,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.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"}),jsxRuntime.jsx("input",{type:"text",className:"kyro-form-input font-mono ",value:t||"",onChange:c=>r(c.target.value),disabled:a,placeholder:"#000000"})]})});default:return jsxRuntime.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 ea=({block:e,blockSchema:t,onClose:r})=>{let o=ze(e.id),{updateBlock:a}=Be(),n=o?.data||e.data||{},s=o?.children||e.children||[],l=(p,y)=>{a(e.id,{data:{...n,[p]:y}});},i=p=>{a(e.id,{children:p});},d=()=>t&&Array.isArray(t.fields)?jsxRuntime.jsx("div",{className:"space-y-4 pt-2",children:t.fields.map(p=>{if(p.admin?.condition){if(typeof p.admin.condition=="function")try{let g={values:n,...n};if(!p.admin.condition(g,g))return null}catch(g){console.warn(`Condition error for field ${p.name}:`,g);}else if(typeof p.admin.condition=="object")try{let g=p.admin.condition,b=g.field,v=n[b],k=!0;if("equals"in g?k=v===g.equals:"notEquals"in g?k=v!==g.notEquals:"in"in g&&Array.isArray(g.in)&&(k=g.in.includes(v)),!k)return null}catch(g){console.warn(`Declarative condition error for field ${p.name}:`,g);}}let y=n[p.name];return jsxRuntime.jsx("div",{className:"kyro-block-field-row border-b border-[var(--kyro-border)]/30 pb-3 last:border-b-0 last:pb-0",children:jsxRuntime.jsx(To,{field:p,value:y,onChange:g=>l(p.name,g)})},p.name)})}):jsxRuntime.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=De[e.type]||De.default;return jsxRuntime.jsxs(dr,{open:true,onClose:r,title:`Edit ${t?.label||e.type}`,width:"xl",showOverlay:false,accentClass:c.border,children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[d(),s.length>0&&jsxRuntime.jsxs("div",{className:"pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",s.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:s,onUpdateChildren:i})]})]}),jsxRuntime.jsx("div",{className:"mt-6 pt-4 border-t border-[var(--kyro-border)]",children:jsxRuntime.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 _u=6,to=({blockId:e,children:t,onUpdateChildren:r,depth:o=0,maxDepth:a=_u})=>{let[n,s]=Ta.useState(false),[l,i]=Ta.useState(new Set),[d,c]=Ta.useState(null),[p,y]=Ta.useState(null),g=Ta.useContext(wo);if(!g)throw new Error("ChildBlocksTree must be used within a BlocksContext");let b=zustand.useStore(g,m=>m.dynamicCategories),v=zustand.useStore(g,m=>m.allowedBlocks),k=o<a,f=16,u=m=>{let T=Yo(m);r([...t,T]),c(T.id);},x=m=>{let T=t.filter(B=>B.id!==m);r(T);},F=(m,T)=>{let B=t.map(I=>I.id===m?{...I,children:T}:I);r(B);},h=m=>{i(T=>{let B=new Set(T);return B.has(m)?B.delete(m):B.add(m),B});},w=m=>{let T=m.children&&m.children.length>0,B=l.has(m.id);yi(m.type);let V=T,C=d===m.id,K=v.find(E=>E.slug===m.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center group/column gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${C?"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"} ${k?"cursor-pointer":""}`,style:{marginLeft:o*f},onClick:()=>{k&&c(C?null:m.id);},children:[V?jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),h(m.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(Hl.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Kt[m.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Kt[m.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Va(m),m.data?.text?` - ${m.data.text.slice(0,30)}`:"",m.data?.heading?` - ${m.data.heading.slice(0,30)}`:""]}),K?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:K.admin.description})]}),T&&jsxRuntime.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"]}),p===m.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:E=>E.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(m.id),y(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>y(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"})]}):jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),y(m.id);},className:"p-1.5 rounded-md transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Hl.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)] invisible group-hover/column:visible"})})]}),C&&jsxRuntime.jsx(ea,{block:m,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Ud,{parentId:m.id,children:m.children,onUpdateChildren:E=>F(m.id,E),depth:o+1,maxDepth:a})})]},m.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(w)}),k&&jsxRuntime.jsxs("div",{style:{marginLeft:o*f},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(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:[jsxRuntime.jsx(Hl.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(za,{open:n,onClose:()=>s(false),onSelect:u,children:b.map(m=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:m.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:m.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(T.slug),s(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:[jsxRuntime.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:Kt[T.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},m.title))})]}),t.length===0&&k&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*f},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*f},children:["Maximum nesting level (",a,") reached"]})]})},Ud=({parentId:e,children:t,onUpdateChildren:r,depth:o,maxDepth:a})=>{let[n,s]=Ta.useState(false),[l,i]=Ta.useState(new Set),[d,c]=Ta.useState(null),[p,y]=Ta.useState(null),g=Ta.useContext(wo);if(!g)throw new Error("NestedChildBlocks must be used within a BlocksContext");let b=zustand.useStore(g,m=>m.dynamicCategories),v=zustand.useStore(g,m=>m.allowedBlocks),k=o<a,f=16,u=m=>{let T=Yo(m);r([...t,T]),c(T.id);},x=m=>{let T=t.filter(B=>B.id!==m);r(T);},F=(m,T)=>{let B=t.map(I=>I.id===m?{...I,children:T}:I);r(B);},h=m=>{i(T=>{let B=new Set(T);return B.has(m)?B.delete(m):B.add(m),B});},w=m=>{let T=m.children&&m.children.length>0,B=l.has(m.id);yi(m.type);let V=T,C=d===m.id,K=v.find(E=>E.slug===m.type);return jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsxs("div",{className:`flex items-center gap-2 p-2 bg-[var(--kyro-bg-secondary)] rounded border transition-colors ${C?"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"} ${k?"cursor-pointer":""}`,style:{marginLeft:o*f},onClick:()=>{k&&c(C?null:m.id);},children:[V?jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),h(m.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded",children:B?jsxRuntime.jsx(Hl.ChevronDown,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"}):jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 text-[var(--kyro-text-muted)]"})}):jsxRuntime.jsx("span",{className:"w-4"}),Kt[m.type]&&jsxRuntime.jsx("div",{className:"w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]",children:Kt[m.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] truncate",children:[Va(m),m.data?.text?` - ${m.data.text.slice(0,30)}`:"",m.data?.heading?` - ${m.data.heading.slice(0,30)}`:""]}),K?.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80",children:K.admin.description})]}),T&&jsxRuntime.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"]}),p===m.id?jsxRuntime.jsxs("div",{className:"flex items-center gap-1",onClick:E=>E.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{x(m.id),y(null);},className:"px-2 py-1 text-xs bg-[var(--kyro-danger)] text-white rounded",children:"Remove"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>y(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"})]}):jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),y(m.id);},className:"p-1.5 rounded-md invisible group-hover:visible transition-opacity cursor-pointer hover:bg-[var(--kyro-danger-bg)]",children:jsxRuntime.jsx(Hl.X,{className:"w-3.5 h-3.5 text-[var(--kyro-danger)]"})})]}),C&&jsxRuntime.jsx(ea,{block:m,onClose:()=>c(null)}),T&&B&&jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.jsx(Ud,{parentId:m.id,children:m.children,onUpdateChildren:E=>F(m.id,E),depth:o+1,maxDepth:a})})]},m.id)};return jsxRuntime.jsxs("div",{className:"space-y-2",children:[t.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:t.map(w)}),k&&jsxRuntime.jsxs("div",{style:{marginLeft:o*f},children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(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:[jsxRuntime.jsx(Hl.Plus,{className:"w-3 h-3"}),"Add Block"]}),jsxRuntime.jsx(za,{open:n,onClose:()=>s(false),onSelect:u,children:b.map(m=>jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] tracking-wide mb-2",children:m.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:m.blocks.map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{u(T.slug),s(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:[jsxRuntime.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:Kt[T.slug]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("div",{className:"text-xs font-medium tracking-tight text-[var(--kyro-text-primary)]",children:T.label}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] mt-0.5",children:T.admin?.description||""})]})]},T.slug))})]},m.title))})]}),t.length===0&&k&&jsxRuntime.jsx("div",{className:"text-xs text-[var(--kyro-text-muted)] italic py-2",style:{marginLeft:o*f},children:'No blocks added. Click "Add Block" to add elements.'}),o>=a&&t.length>0&&jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-muted)] italic",style:{marginLeft:o*f},children:["Maximum nesting level (",a,") reached"]})]})};var zd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=r?.children??e.children??[],i=(d,c)=>{o(e.id,{data:{...s,[d]:c}});};return jsxRuntime.jsxs("div",{className:"block-hero border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Hero Section"})}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(pi,{heading:s.title||"",subheading:s.subtitle||"",ctaText:s.ctaText||"",ctaUrl:s.ctaUrl||"",onChange:i,compact:true}),jsxRuntime.jsx(lr,{field:{label:"Background",name:"bgImage",maxCount:1},value:s.bgImage,onChange:d=>i("bgImage",d)}),jsxRuntime.jsxs("div",{className:"pt-3 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("label",{className:"text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block",children:["Children (",l.length,")"]}),jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:d=>o(e.id,{children:d})})]})]})]})};var fi=({title:e="",description:t="",icon:r="",link:o="",linkText:a="",onChange:n,compact:s=false})=>{let l=s?"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",i=s?"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 jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-3",children:[jsxRuntime.jsx("input",{type:"text",value:e,onChange:d=>n("title",d.target.value),className:`${l} font-bold text-base`,placeholder:"Card title..."}),jsxRuntime.jsx("textarea",{value:t,onChange:d=>n("description",d.target.value),className:i,placeholder:"Card description..."}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:d=>n("icon",d.target.value),className:l,placeholder:"Icon (emoji or name)..."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("input",{type:"text",value:a,onChange:d=>n("linkText",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:"Link text..."}),jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)] text-xs",children:"\u2192"}),jsxRuntime.jsx("input",{type:"url",value:o,onChange:d=>n("link",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://..."})]})]})};var Hd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o}=Be(),a=r?.data||e.data||{},n=(s,l)=>{o(e.id,{data:{...a,[s]:l}});};return jsxRuntime.jsx(Co,{id:e.id,type:"card",label:"Card",children:jsxRuntime.jsx(fi,{title:a.title||"",description:a.description||"",icon:a.icon||"",link:a.link||"",linkText:a.linkText||"",onChange:n,compact:true})})};var Vd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be();r?.data??e.data??{};let l=r?.children??e.children??[];return jsxRuntime.jsxs("div",{className:"block-array border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Repeater"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["(",l.length," items)"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx("div",{className:"space-y-3",children:jsxRuntime.jsx(to,{blockId:e.id,children:l,onUpdateChildren:i=>o(e.id,{children:i})})})]})};var Ga=({relationTo:e="pages",hasMany:t=false,selectedIds:r=[],selectedId:o,labelField:a="title",onChange:n,compact:s=false})=>{let[l,i]=Ta.useState(false),[d,c]=Ta.useState(""),[p,y]=Ta.useState([]),[g,b]=Ta.useState(false),[v,k]=Ta.useState([]),[f,u]=Ta.useState(true);Ta.useEffect(()=>{Ae("/api/collections").then(I=>{k((I.collections||[]).map(V=>V.slug||V.name||V)),u(false);}).catch(()=>u(false));},[]);let x=(I="")=>{b(true);let V=`/api/${e}?${ln(I,[a],20)}`;Ae(V).then(C=>{y(C.docs||[]),b(false);}).catch(()=>b(false));};Ta.useEffect(()=>{l&&x(d);},[l,d,e,a]);let A=I=>I?.[a]||I?.title||I?.name||I?.label||I?.filename||I?.slug||I?.id||"Untitled",F=t?r:o?[o]:[],h=I=>{t?F.includes(I.id)?n("selectedIds",F.filter(V=>V!==I.id)):n("selectedIds",[...F,I.id]):(n("selectedId",I.id),n("selectedIds",[I.id]),i(false));},w=I=>F.includes(I),m=s?"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",T=s?"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",B=e&&typeof e=="string"&&e.length>0;return jsxRuntime.jsxs("div",{className:s?"space-y-2":"space-y-4",children:[jsxRuntime.jsxs("div",{className:s?"flex items-center gap-2":"space-y-3",children:[!B&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f?jsxRuntime.jsx("div",{className:T+" text-[var(--kyro-text-muted)]",children:"Loading..."}):jsxRuntime.jsxs("select",{value:e,onChange:I=>n("relationTo",I.target.value),className:T,children:[jsxRuntime.jsx("option",{value:"",children:"Select collection..."}),v.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))]})}),!s&&jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t,onChange:I=>n("hasMany",I.target.checked),className:"w-4 h-4 rounded border-[var(--kyro-border)] focus:ring-[var(--kyro-sidebar-active)] focus:ring-offset-0"}),jsxRuntime.jsx("span",{className:"text-sm text-[var(--kyro-text-primary)]",children:"Allow multiple"})]})]}),jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Hl.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--kyro-text-muted)]"}),jsxRuntime.jsx("input",{type:"text",value:d,onChange:I=>{c(I.target.value),i(true);},onFocus:()=>i(true),onBlur:()=>setTimeout(()=>i(false),200),placeholder:`Search ${e}...`,className:`${m} pl-9`}),jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:g&&jsxRuntime.jsx(Hl.LoaderCircle,{className:"w-4 h-4 text-[var(--kyro-text-muted)] animate-spin"})})]}),l&&jsxRuntime.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:g?jsxRuntime.jsx("div",{className:"p-3 text-center text-sm text-[var(--kyro-text-muted)]",children:"Loading..."}):p.length===0?jsxRuntime.jsx(Yn,{title:"No results found"}):jsxRuntime.jsx("div",{className:"py-1",children:p.map(I=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:V=>V.preventDefault(),onClick:()=>h(I),className:`w-full px-3 py-2 text-left text-sm hover:bg-[var(--kyro-surface-accent)] transition-colors flex items-center justify-between ${w(I.id)?"bg-[var(--kyro-sidebar-active)]/10 text-[var(--kyro-sidebar-active)]":"text-[var(--kyro-text-primary)]"}`,children:[jsxRuntime.jsx("span",{children:A(I)}),w(I.id)&&jsxRuntime.jsx("span",{children:"\u2713"})]},I.id))})})]}),F.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:F.map(I=>{let V=p.find(C=>C.id===I)||{id:I};return jsxRuntime.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:[A(V),jsxRuntime.jsx("button",{type:"button",onMouseDown:C=>C.preventDefault(),onClick:()=>{t?n("selectedIds",F.filter(C=>C!==I)):(n("selectedId",null),n("selectedIds",[]));},className:"hover:opacity-70",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]},I)})})]})};var Gd=({block:e,index:t})=>{let r=ze(e.id),{updateBlock:o,removeBlock:a,moveBlock:n}=Be(),s=r?.data??e.data??{},l=(i,d)=>{o(e.id,{data:{...s,[i]:d}});};return jsxRuntime.jsxs("div",{className:"block-relationship border border-[var(--kyro-border)] rounded-md p-3 mb-2 relative group",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] ",children:"Relationship"}),jsxRuntime.jsxs("span",{className:"text-[10px] text-[var(--kyro-text-muted)]",children:["\u2192 ",s.relationTo||"pages"]})]}),jsxRuntime.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"up"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move up",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3 rotate-90"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>n(e.id,"down"),className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded",title:"Move down",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(e.id),className:"p-1 hover:bg-[var(--kyro-danger-bg)] rounded text-[var(--kyro-danger)]",title:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),jsxRuntime.jsx(Ga,{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 Vu={heading:kd,paragraph:wd,image:Nd,video:Sd,list:Td,code:Rd,file:Ad,accordion:Fd,richtext:Pd,hero:zd,card:Hd,array:Vd,relationship:Gd},De={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"}},Kt={heading:jsxRuntime.jsx(Hl.Heading1,{className:`w-4 h-4 ${De.default.text}`}),paragraph:jsxRuntime.jsx(Hl.AlignLeft,{className:`w-4 h-4 ${De.default.text}`}),image:jsxRuntime.jsx(Hl.Image,{className:`w-4 h-4 ${De.default.text}`}),video:jsxRuntime.jsx(Hl.Video,{className:`w-4 h-4 ${De.default.text}`}),list:jsxRuntime.jsx(Hl.List,{className:`w-4 h-4 ${De.default.text}`}),code:jsxRuntime.jsx(Hl.Code,{className:`w-4 h-4 ${De.default.text}`}),file:jsxRuntime.jsx(Hl.File,{className:`w-4 h-4 ${De.default.text}`}),accordion:jsxRuntime.jsx(Hl.ChevronDown,{className:`w-4 h-4 ${De.default.text}`}),richtext:jsxRuntime.jsx(Hl.AlignLeft,{className:`w-4 h-4 ${De.default.text}`}),hero:jsxRuntime.jsx(Hl.Star,{className:`w-4 h-4 ${De.hero.text}`}),card:jsxRuntime.jsx(Hl.Box,{className:`w-4 h-4 ${De.card.text}`}),array:jsxRuntime.jsx(Hl.ListOrdered,{className:`w-4 h-4 ${De.default.text}`}),relationship:jsxRuntime.jsx(Hl.Link2,{className:`w-4 h-4 ${De.default.text}`}),featureSplit:jsxRuntime.jsx(Hl.Columns3,{className:`w-4 h-4 ${De.featureSplit.text}`}),featureGrid:jsxRuntime.jsx(Hl.Blocks,{className:`w-4 h-4 ${De.featureGrid.text}`}),ctaBanner:jsxRuntime.jsx(Hl.Sparkles,{className:`w-4 h-4 ${De.ctaBanner.text}`}),testimonials:jsxRuntime.jsx(Hl.Users,{className:`w-4 h-4 ${De.testimonials.text}`}),faq:jsxRuntime.jsx(Hl.CircleHelp,{className:`w-4 h-4 ${De.faq.text}`}),stats:jsxRuntime.jsx(Hl.Activity,{className:`w-4 h-4 ${De.stats.text}`}),logoCloud:jsxRuntime.jsx(Hl.Image,{className:`w-4 h-4 ${De.logoCloud.text}`}),pricing:jsxRuntime.jsx(Hl.Tag,{className:`w-4 h-4 ${De.pricing.text}`}),team:jsxRuntime.jsx(Hl.Users,{className:`w-4 h-4 ${De.team.text}`}),recentFeed:jsxRuntime.jsx(Hl.Database,{className:`w-4 h-4 ${De.recentFeed.text}`}),processSteps:jsxRuntime.jsx(Hl.Clock,{className:`w-4 h-4 ${De.processSteps.text}`}),formEmbed:jsxRuntime.jsx(Hl.Mail,{className:`w-4 h-4 ${De.formEmbed.text}`}),videoShowcase:jsxRuntime.jsx(Hl.Video,{className:`w-4 h-4 ${De.videoShowcase.text}`})};function yi(e){return Vu[e]||null}function vi(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 Va(e){let t=e.name;return t&&t.trim()?t.trim():vi(e.type)}function ay(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 ny=({block:e,index:t,blockSchema:r,editingBlockId:o,setEditingBlockId:a,onDuplicate:n,compact:s})=>{let{attributes:l,listeners:i,setNodeRef:d,transform:c,transition:p,isDragging:y}=sortable.useSortable({id:e.id}),{removeBlock:g,updateBlock:b}=Be(),v=o===e.id,[k,f]=Ta.useState(false),[u,x]=Ta.useState(false),[A,F]=Ta.useState(e.name||""),h=Ta.useRef(null),[w,m]=Ta.useState(false),T=Ta.useCallback(async E=>{E.stopPropagation();try{let{id:$,...O}=e,ne=JSON.stringify({__kyro_block:!0,type:e.type,blockProps:O});await navigator.clipboard.writeText(ne),m(!0),setTimeout(()=>m(!1),2e3);}catch($){console.error("Failed to copy block",$);}},[e]);Ta.useEffect(()=>{u&&h.current&&(h.current.focus(),h.current.select());},[u]);let B=Ta.useCallback(()=>{x(false);let E=A.trim();E!==(e.name||"").trim()&&b(e.id,{name:E||""});},[A,e.name,e.id,b]),I={transform:utilities.CSS.Transform.toString(c),transition:p,zIndex:y?10:1,opacity:y?.8:1},V=Va(e),C=e.data||{},K=ay(C,r);return s?jsxRuntime.jsxs("div",{ref:d,style:I,className:"relative group w-full",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-2 pl-7 pr-2 py-2 w-full bg-[var(--kyro-bg-secondary)] rounded-md border transition-colors cursor-pointer text-sm ${v?`${(De[e.type]||De.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.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,...i,onClick:E=>E.stopPropagation(),children:jsxRuntime.jsx(Hl.GripVertical,{className:"w-2.5 h-2.5"})}),Kt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)] flex-shrink-0",children:Kt[e.type]}),u?jsxRuntime.jsx("input",{ref:h,value:A,onChange:E=>F(E.target.value),onBlur:B,onKeyDown:E=>{E.key==="Enter"&&B(),E.key==="Escape"&&(F(e.name||""),x(false));},onClick:E=>E.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"}):jsxRuntime.jsx("span",{className:"font-medium text-[var(--kyro-text-secondary)] flex-1 min-w-0 truncate transition-colors text-left",children:V}),k?jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",onClick:E=>E.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(e.id),f(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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-0.5",children:[jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),F(e.name||""),x(true);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Rename",children:jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),n(e.id);},className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate in place",children:jsxRuntime.jsx(Hl.Copy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"p-0.5 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Copy Block to Clipboard",children:w?jsxRuntime.jsx(Hl.Check,{className:"w-3 h-3 text-green-500"}):jsxRuntime.jsx(Hl.ClipboardCopy,{className:"w-3 h-3"})}),jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),f(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:"Remove",children:jsxRuntime.jsx(Hl.X,{className:"w-3 h-3"})})]})]}),v&&jsxRuntime.jsx(ea,{block:e,blockSchema:r,onClose:()=>a(null)})]}):jsxRuntime.jsxs("div",{ref:d,style:I,className:"relative group mb-2",children:[jsxRuntime.jsxs("div",{onClick:()=>a(e.id),className:`flex items-center gap-3 p-3 bg-[var(--kyro-bg-secondary)] rounded-lg border transition-colors cursor-pointer ${v?`${(De[e.type]||De.default).border} bg-[var(--kyro-primary)]/5`:"border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/50 hover:bg-[var(--kyro-primary)]/5"}`,children:[jsxRuntime.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,...i,onClick:E=>E.stopPropagation(),children:jsxRuntime.jsx(Hl.GripVertical,{className:"w-4 h-4"})}),Kt[e.type]&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-secondary)]",children:Kt[e.type]}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[u?jsxRuntime.jsx("input",{ref:h,value:A,onChange:E=>F(E.target.value),onBlur:B,onKeyDown:E=>{E.key==="Enter"&&B(),E.key==="Escape"&&(F(e.name||""),x(false));},onClick:E=>E.stopPropagation(),placeholder:vi(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"}):jsxRuntime.jsxs("div",{className:"text-xs font-semibold text-[var(--kyro-text-secondary)] truncate transition-colors",children:[V,K&&typeof K=="string"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] font-normal ml-1.5",children:["- ",K.length>40?`${K.slice(0,40)}...`:K]})]}),r?.admin?.description&&jsxRuntime.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&&jsxRuntime.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"]}),k?jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",onClick:E=>E.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{g(e.id),f(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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>f(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"})]}):jsxRuntime.jsxs("div",{className:"flex items-center gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),F(e.name||""),x(true);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Rename Block",children:jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsxRuntime.jsx("path",{d:"m15 5 4 4"})]})}),jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),n(e.id);},className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Duplicate Block",children:jsxRuntime.jsx(Hl.Copy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"p-1 hover:bg-[var(--kyro-surface-accent)] rounded text-[var(--kyro-text-secondary)] transition-colors",title:"Copy Block to Clipboard",children:w?jsxRuntime.jsx(Hl.Check,{className:"w-3.5 h-3.5 text-green-500"}):jsxRuntime.jsx(Hl.ClipboardCopy,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),f(true);},className:"p-1 hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] rounded text-[var(--kyro-text-muted)] transition-colors",title:"Remove Block",children:jsxRuntime.jsx(Hl.X,{className:"w-3.5 h-3.5"})})]})]}),v&&jsxRuntime.jsx(ea,{block:e,blockSchema:r,onClose:()=>a(null)})]})},sy=Ta__default.default.memo(ny),ui=({field:e,value:t,onChange:r,onBlocksChange:o,error:a,disabled:n,documentStatus:s,justSaved:l})=>{let[i,d]=Ta.useState(false),[c,p]=Ta.useState(false),y=Ta.useRef(null),g=e.admin?.pickerMode||"drawer",b=e.blocks||[],v=b.reduce((U,re)=>{let j=re.admin?.group||"Custom Blocks";return U[j]||(U[j]=[]),U[j].push(re),U},{}),k=["Structural Sections","Marketing Grids","Lead Capture & Interactive","Dynamic Content","Basic Content Elements","Custom Blocks"],f=Object.entries(v).sort(([U],[re])=>{let j=k.indexOf(U),ye=k.indexOf(re);return j!==-1&&ye!==-1?j-ye:j!==-1?-1:ye!==-1?1:U.localeCompare(re)}).map(([U,re])=>({title:U,blocks:re})),u=Ta.useRef(null);u.current||(u.current=vd(b,f));let x=u.current,A=zustand.useStore(x,U=>U.blocks),[F,h]=Ta.useState(null),[w,m]=Ta.useState(null),T=Ta.useRef(A.length),B=Ta.useRef(new Set(A.map(U=>U.id))),I=Ta.useRef(false);Ta.useEffect(()=>{if(I.current&&A.length>T.current){let U=A.find(re=>re.id&&!B.current.has(re.id));U&&m(U.id);}T.current=A.length,B.current=new Set(A.map(U=>U.id));},[A]),Ta.useEffect(()=>(o&&x.getState().setOnBlocksChange(o),()=>{x.getState().setOnBlocksChange(()=>{});}),[o,x]);let V=Ta.useRef(null);Ta.useEffect(()=>{let U=Array.isArray(t)?t:[],re=V.current||[];if(JSON.stringify(U)!==JSON.stringify(re)){let j=[...U];T.current=j.length,B.current=new Set(j.map(ye=>ye.id)),x.getState().setBlocks(j),V.current=j,I.current=true;}else U.length===0&&!I.current&&(I.current=true,V.current=[]);},[t,e.name,x]);let C=Ta.useRef(r);C.current=r,Ta.useEffect(()=>{if(!C.current)return;let U=V.current;U&&JSON.stringify(A)!==JSON.stringify(U)&&(V.current=[...A],C.current(A));},[A]);let E=Ta.useCallback(U=>{x.getState().addBlock(U);},[x]),$=Ta.useCallback(U=>{if(!(e.blocks||[]).some(z=>z.slug===U.type)){alert(`The block type "${U.type}" is not allowed in this collection.`);return}let ye=Math.random().toString(36).substring(2,11),Te={...U.blockProps||{},id:ye,type:U.type};x.getState().setBlocks([...A,Te]),d(false);},[e.blocks,A,x]),O=Ta.useCallback(U=>{let re=A.findIndex(G=>G.id===U);if(re===-1)return;let j=A[re],ye=G=>{let _e=Math.random().toString(36).substr(2,9);return {...G,id:_e,children:G.children?G.children.map(Me=>ye(Me)):G.children,data:G.data?JSON.parse(JSON.stringify(G.data)):G.data}},Te=ye(j),z=[...A];z.splice(re+1,0,Te),x.getState().setBlocks(z);},[A,x]),ne=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:3}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:250,tolerance:5}}),core.useSensor(core.KeyboardSensor)),ie=U=>{h(U.active);},H=U=>{let{active:re,over:j}=U;if(h(null),!!j){if(re.id.toString().startsWith("drawer-")){let ye=re.id.toString().replace("drawer-","");if(j.id.toString().startsWith("container-")){let Te=j.id.toString().replace("container-",""),z=A.find(G=>G.id===Te);if(z){let G=Yo(ye);x.getState().updateBlock(Te,{children:[...z.children||[],G]});}}else {let Te=A.findIndex(z=>z.id===j.id);Te!==-1?x.getState().addBlock(ye,Te):E(ye);}return}if(re.id!==j.id){let ye=A.findIndex(z=>z.id===re.id),Te=A.findIndex(z=>z.id===j.id);if(ye!==-1&&Te!==-1){let z=[...A],[G]=z.splice(ye,1);z.splice(Te,0,G),x.getState().setBlocks(z);}}}},S=F?f.flatMap(U=>U.blocks).find(U=>`drawer-${U.type}`===F.id)||A.find(U=>U.id===F.id):null;S?"label"in S?S.label:S.type:"Block";return Ta.useEffect(()=>{if(!c)return;let U=re=>{y.current&&!y.current.contains(re.target)&&p(false);};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[c]),jsxRuntime.jsx(wo.Provider,{value:u.current,children:jsxRuntime.jsxs("div",{className:"kyro-blocks-field",children:[jsxRuntime.jsxs(core.DndContext,{sensors:ne,collisionDetection:core.closestCenter,onDragStart:ie,onDragEnd:H,children:[jsxRuntime.jsxs("div",{className:g==="dropdown"?"mb-4":"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("label",{className:`kyro-form-label ${g==="dropdown"?"block mb-2":""}`,children:e.label||e.name}),g==="dropdown"?jsxRuntime.jsxs("div",{ref:y,className:"relative w-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>p(!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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("span",{className:"font-semibold",children:"Select an element to add..."})]}),jsxRuntime.jsx(Hl.ChevronDown,{className:`w-4 h-4 transition-transform ${c?"rotate-180 text-[var(--kyro-primary)]":"opacity-50"}`})]}),c&&jsxRuntime.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:f.map(U=>jsxRuntime.jsxs("div",{children:[f.length>1&&jsxRuntime.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(re=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{E(re.slug),p(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:[jsxRuntime.jsx("span",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center text-[var(--kyro-text-muted)]",children:Kt[re.slug]||jsxRuntime.jsx(Hl.Box,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"text-xs font-semibold truncate",children:re.label}),re.admin?.description&&jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-muted)] truncate",children:re.admin.description})]})]},re.slug))]},U.title))})]}):jsxRuntime.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:[jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4"}),"Add Block"]})]}),jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.jsx(za,{open:i,onClose:()=>d(false),onSelect:E,onPasteBlock:$,children:jsxRuntime.jsx("div",{className:"space-y-4",children:f.map(U=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-xs font-semibold text-[var(--kyro-text-muted)] mb-2 tracking-wider",children:U.title}),jsxRuntime.jsx("div",{className:"grid grid-cols-3 gap-2",children:U.blocks.map(re=>jsxRuntime.jsx(gd,{block:{type:re.slug,label:re.label,description:re.admin?.description||"",icon:null},onSelect:E,children:jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:Kt[re.slug]||jsxRuntime.jsx(Hl.Box,{className:"w-4 h-4"})})})},re.slug))})]},U.title))})})}),jsxRuntime.jsx(sortable.SortableContext,{items:A.map(U=>U.id),strategy:sortable.verticalListSortingStrategy,children:jsxRuntime.jsxs("div",{className:g==="dropdown"?"flex flex-col gap-2 mt-3":"space-y-4",children:[A.map((U,re)=>{let j=e.blocks?.find(ye=>ye.slug===U.type);return jsxRuntime.jsx(sy,{block:U,index:re,blockSchema:j,editingBlockId:w,setEditingBlockId:m,onDuplicate:O,compact:g==="dropdown"},U.id||re)}),A.length===0&&jsxRuntime.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"})]})}),jsxRuntime.jsx(core.DragOverlay,{children:F&&S&&jsxRuntime.jsx("div",{className:"bg-[var(--kyro-surface)] border border-[var(--kyro-primary)] rounded-md p-3 shadow-lg",children:S.label||S.type||"Block"})})]}),a&&jsxRuntime.jsx("p",{className:"kyro-form-error",children:a})]})})};function mr(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(mr);if(typeof e=="object"){let t=e,r=Object.keys(t),o="id"in t&&(typeof t.id=="string"||t.id===null),a="url"in t&&("filename"in t||"mimeType"in t);if(o&&a&&r.length<=25)return t.id;let n={};for(let s of r)n[s]=mr(t[s]);return n}return e}function Xd(){let e=Ta.useRef([]),t=Ta.useRef(false);return {queueTask:Ta.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 s=e.current.pop();e.current=[],t.current=true;try{await s();}catch(l){console.error("Error in queued function:",l);}finally{t.current=false,typeof a?.afterProcess=="function"&&a.afterProcess();}}}n();},[])}}function Yd({config:e,initialData:t,collectionSlug:r,globalSlug:o,documentId:a,onChange:n,onActionSuccess:s,onActionError:l}){let i=Fe(),{confirm:d}=ut(),{formData:c,setFormData:p,setField:y,lastSavedData:g,setLastSavedData:b,setHasUnsavedChanges:v,isSlugLocked:k,loadDocument:f,setIsAutoSaving:u,setAutoSaveStatus:x,setVersions:A,setLoadingVersions:F,sidebarCollapsed:h,setSidebarCollapsed:w,getDraftCache:m,setDraftCache:T,clearDraftCache:B,resetForm:I}=i,V=!!e.versions,C=o||t?.id||a||r,K=Ta.useRef(false);!o&&C&&c&&Object.keys(c).length>0&&c.id!==C&&(K.current=true),Ta.useEffect(()=>{K.current&&(K.current=false,I());},[I]);let E=Ta.useRef(null),$=Ta.useRef(null),O=Ta.useRef(null),ne=Ta.useRef(typeof navigator<"u"?navigator.onLine:true),ie=Ta.useRef(0),H=Ta.useRef(false),S=Ta.useRef(null),J=Ta.useRef(""),fe=Ta.useRef(""),{queueTask:U}=Xd(),re=Ta.useCallback(X=>o?`global:${o}`:r&&X?`${r}:${X}`:null,[r,o]),j=Ta.useCallback((X,le,ce)=>{T(X,{data:le,baseUpdatedAt:g.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:ce?.lastSyncedAt??null});},[g.updatedAt,T]),ye=Ta.useCallback(async()=>{let X=o?We(`/api/globals/${o}/versions`):r&&c.id?We(`/api/${r}/${c.id}/versions`):null;if(X){F(true);try{let ce=await(await st(X)).json();A(ce.docs||[]);}catch(le){console.error("Failed to fetch versions:",le);}finally{F(false);}}},[c.id,r,o,F,A]),Te=Ta.useCallback(()=>{let X=Fe.getState(),le=X.formData;if(H.current||!r||!le.id||!X.hasDirtyFields())return;let ce=re(le.id);ce&&j(ce,le);},[r,re,j]),z=Ta.useCallback(async X=>{let le=Fe.getState(),ce=le.formData,Se=le.lastSavedData;if(H.current||!o&&(!r||!ce.id)||!le.hasDirtyFields())return;let Ee=re(ce.id);if(Ee&&j(Ee,ce),!ne.current){x("offline");return}u(true),x("saving"),le.setBackgroundProcessing(true),o&&window.dispatchEvent(new Event("kyro:global-save-start"));try{let He=o?We(`/api/globals/${o}?autosave=true`):We(`/api/${r}/${ce.id}?autosave=true`),D=await st(He,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":"true"},keepalive:X?.keepalive,body:JSON.stringify({...mr(ce),baseUpdatedAt:Se.updatedAt??null})});if(D.ok)ie.current=Date.now(),le.setRetryCount(0),le.setLastSavedAt(Date.now()),O.current&&clearTimeout(O.current),Ee&&T(Ee,{data:ce,baseUpdatedAt:Se.updatedAt??null,draftUpdatedAt:new Date().toISOString(),lastSyncedAt:(await D.clone().json()).data?.updatedAt||new Date().toISOString()}),x("success"),setTimeout(()=>{Fe.getState().autoSaveStatus==="success"&&x("idle");},2e3);else if(D.status===409)x("conflict");else throw new Error(`Draft auto-save failed with status ${D.status}`)}catch(He){console.error("Auto-save failed:",He);let D=Fe.getState(),Q=D.retryCount;if(Q<5){D.setRetryCount(Q+1),x("retrying");let pe=Math.min(1e3*Math.pow(2,Q),6e4);O.current&&clearTimeout(O.current),O.current=setTimeout(()=>G(X),pe);}else x("offline");}finally{o&&window.dispatchEvent(new Event("kyro:global-save-end")),u(false),Fe.getState().setBackgroundProcessing(false);}},[r,re,o,j,x,T,u,V]),G=Ta.useCallback(X=>{U(()=>z(X),{beforeProcess:()=>true,afterProcess:()=>{}});},[z,U]),_e=Ta.useCallback(async(X,le=true)=>{let ce=Fe.getState(),Se=X||ce.formData,Ee=o?We(`/api/globals/${o}`):We(`/api/${r}/${Se.id}`),He=await st(Ee,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(le)},body:JSON.stringify({...mr(Se),baseUpdatedAt:ce.lastSavedData.updatedAt??null})});return He.status===409&&x("conflict"),He},[r,o,x]),Me=Ta.useCallback(async(X=true)=>{let le=Fe.getState(),ce=le.formData,Se=o?We(`/api/globals/${o}`):We(`/api/${r}/${ce.id}`),Ee=await st(Se,{method:"PATCH",headers:{"Content-Type":"application/json","X-Draft":String(X)},body:JSON.stringify({...mr(ce)})});if(Ee.ok){let D=(await Ee.json()).data||ce;le.setFormData({...ce,...D}),le.setLastSavedData({...ce,...D}),x("success"),setTimeout(()=>{Fe.getState().autoSaveStatus==="success"&&x("idle");},2e3);}return Ee},[r,o,x]);Ta.useEffect(()=>{let X=()=>{w(!h);};return window.addEventListener("toggle-sidebar",X),()=>window.removeEventListener("toggle-sidebar",X)},[h,w]);let Z=Ta.useRef(null),ge=Ta.useRef(""),Ge=Ta.useRef(false);Ta.useEffect(()=>{let X=o||t?.id,le=JSON.stringify(t);Ge.current&&Z.current===X&&ge.current===le||(f(t||{},t||{}),Ge.current=true,Z.current=X,ge.current=le);},[r,c.id,o,t,f]),Ta.useEffect(()=>{if(!r||!t?.id)return;let X=re(t.id);if(!X||S.current===X)return;let le=false;return (async()=>{if(!V)return;let Se=m(X);if(Se){if(JSON.stringify(Se.data)===JSON.stringify(t)){B(X);return}S.current=X,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(le)return;let He={...Fe.getState().formData,...Se.data};p(He),s?.("Recovered autosaved draft");},onCancel:async()=>{B(X);}});}})(),()=>{le=true;}},[B,r,d,re,m,t,s,p,V]);function ft(X,le){for(let ce of X){if(ce.name===le&&ce.admin?.autoGenerate==="title")return ce;if(ce.type==="tabs"&&"tabs"in ce)for(let Se of ce.tabs){let Ee=ft(Se.fields,le);if(Ee)return Ee}if((ce.type==="group"||ce.type==="collapsible")&&"fields"in ce){let Se=ft(ce.fields,le);if(Se)return Se}}}Ta.useEffect(()=>{let X=e.fields;if(!ft(X,"metaTitle"))return;let ce=ko(X,c,"title"),Se=ce?String(ce):"";Se&&(!c.metaTitle||c.metaTitle===c._lastMetaTitle)&&y("metaTitle",Se);},[c,e.fields,y]),Ta.useEffect(()=>{let X=e.fields,le=X.find(Ee=>Ee.name==="slug"&&Ee.admin?.autoGenerate);if(!le?.admin?.autoGenerate)return;let ce=le.admin.autoGenerate,Se=ko(X,c,ce);if(k&&Se){let Ee=Hn(Se);Ee!==c.slug&&y("slug",Ee);}},[c,k,e.fields,y]),Ta.useEffect(()=>{if(h||!o&&(!r||!c.id)||!Fe.getState().hasDirtyFields()||Ed()!=="keystroke")return;rs("other");let le=JSON.stringify(c);le!==J.current&&(E.current&&clearTimeout(E.current),E.current=setTimeout(Te,1500),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{J.current=le,G();},8e3));},[c,h,r,o,Te,G]),Ta.useEffect(()=>{if(!o&&(!r||!c.id))return;let X=()=>{H.current||!Fe.getState().hasDirtyFields()||G({keepalive:true});},le=()=>{document.hidden&&X();},ce=()=>{ne.current=true,X();},Se=()=>{ne.current=false;let Ee=Fe.getState();Ee.hasDirtyFields()&&Ee.setAutoSaveStatus("offline");};return window.addEventListener("blur",X),window.addEventListener("pagehide",X),window.addEventListener("online",ce),window.addEventListener("offline",Se),document.addEventListener("visibilitychange",le),()=>{window.removeEventListener("blur",X),window.removeEventListener("pagehide",X),window.removeEventListener("online",ce),window.removeEventListener("offline",Se),document.removeEventListener("visibilitychange",le);}},[r,o,c.id,G]),Ta.useEffect(()=>{let X=JSON.stringify(c);if(X===fe.current)return;fe.current=X;let le=document.getElementById("form-data");le&&(le.value=X),n?.(c);},[c,n]),Ta.useEffect(()=>{(o||c.id)&&ye();},[c.id,o,ye]);let lt=!c.id&&!o?"draft":V&&c.status||"published",sr=(!!c.id||!!o)&&lt==="draft";return {...i,fetchVersions:ye,performAutoSave:G,saveDocument:_e,forceSave:Me,autoSaveSkipRef:H,lastAutoSaveTimeRef:ie,documentStatus:lt,hasUnpublishedChanges:sr,versionsEnabled:V}}function Ro({trigger:e,children:t,align:r="right",direction:o="up"}){let[a,n]=Ta.useState(false),s=Ta.useRef(null);return Ta.useEffect(()=>{let l=i=>{s.current&&!s.current.contains(i.target)&&n(false);};return a&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[a]),jsxRuntime.jsxs("div",{className:"relative",ref:s,children:[jsxRuntime.jsx("div",{onClick:()=>n(!a),className:"cursor-pointer",children:e}),a&&jsxRuntime.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 Tt({children:e,onClick:t,icon:r,danger:o,disabled:a,className:n=""}){return jsxRuntime.jsx("div",{className:"px-1.5",children:jsxRuntime.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&&jsxRuntime.jsx("span",{className:"w-4 h-4 opacity-70",children:r}),jsxRuntime.jsx("span",{className:"flex-1",children:e})]})})}function qa(){return jsxRuntime.jsx("div",{className:"my-1 border-t border-[var(--kyro-border)] opacity-50"})}function Fo({status:e,saveStatus:t,hasChanges:r,onPublish:o,children:a,disabled:n,direction:s="down"}){let l=e==="published"&&!r&&t!=="saving"&&t!=="error",i=n||t==="saving"||l,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-success)] border-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)]`:t==="error"?`${d} bg-[var(--kyro-error)] border-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)]`:l?`${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)]`,p="kyro-btn kyro-btn-md px-2 rounded-l-none border-l-[1px] border-white/20 transition-all duration-300",y=()=>t==="saving"?`${p} bg-[var(--kyro-primary)]/70 text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-primary)]/70`:t==="saved"?`${p} bg-[var(--kyro-success)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-success)]`:t==="error"?`${p} bg-[var(--kyro-error)] text-[var(--kyro-sidebar-text-active)] border-[var(--kyro-error)]`:l?`${p} bg-[var(--kyro-gray-200)] text-[var(--kyro-text-muted)] border-[var(--kyro-gray-200)]`:`${p} 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 \u2713":t==="error"?"Retry":l?"Published":"Publish Changes";return jsxRuntime.jsxs("div",{className:"inline-flex items-center",children:[jsxRuntime.jsxs("button",{type:"button",onClick:o,disabled:i,className:`${c()} ${a?"":"rounded-r-lg border-r border-[var(--kyro-border)]"}`,children:[t==="saving"&&jsxRuntime.jsx(hr,{size:"sm",className:"inline mr-1.5"}),l&&jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"inline mr-1",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),g()]}),a&&jsxRuntime.jsx(Ro,{trigger:jsxRuntime.jsx("button",{type:"button",className:y(),disabled:t==="saving",children:jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}),direction:s,children:a})]})}var ec=({title:e,description:t,slug:r})=>jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-tight",children:"kyro-cms.com"}),jsxRuntime.jsxs("span",{className:"text-[12px] text-[var(--kyro-text-secondary)] leading-tight opacity-80",children:["https://kyro-cms.com \u203A posts \u203A ",r]})]})]}),jsxRuntime.jsx("h3",{className:"text-[20px] text-[#2563eb] dark:text-[#60a5fa] font-medium hover:underline cursor-pointer mb-1 leading-tight transition-colors",children:e}),jsxRuntime.jsx("p",{className:"text-[14px] text-[var(--kyro-text-secondary)] leading-relaxed line-clamp-2",children:t})]});function rc({field:e,formData:t,onTabDataChange:r,renderField:o}){let[a,n]=Ta.useState(0),s=e.tabs||[],l=s[a]||s[0],i=e.name?t[e.name]||{}:t;return jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--kyro-border)] mb-6 overflow-x-auto hide-scrollbar",children:s.map((d,c)=>jsxRuntime.jsx("button",{type:"button",className:`px-6 py-3 text-sm tracking-widest font-medium transition-all border-b-2 -mb-[1px] whitespace-nowrap ${a===c?"border-[var(--kyro-primary)] text-[var(--kyro-primary)]":"border-transparent text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] opacity-60 hover:opacity-100"}`,onClick:()=>n(c),children:d.label},c))}),jsxRuntime.jsx("div",{className:"space-y-6",children:l?.fields.map(d=>o(d,i,r))}),l?.label==="SEO Settings"&&jsxRuntime.jsxs("div",{className:"mt-12 pt-8 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold text-[var(--kyro-text-secondary)] tracking-[0.2em] mb-6 opacity-50",children:"Live Google Preview"}),jsxRuntime.jsx(ec,{title:String((typeof i.metaTitle=="object"?"":i.metaTitle)||(typeof i.title=="object"?"":i.title)||"Untitled"),description:String((typeof i.metaDescription=="object"?"":i.metaDescription)||"Please enter a description..."),slug:String((typeof t.slug=="object"?"":t.slug)||"your-slug")})]})]})}function nc({collectionSlug:e,globalSlug:t,documentStatus:r,hasUnpublishedChanges:o,localSaveStatus:a,isDuplicating:n,handleCreateNew:s,handleDuplicate:l,handleUnpublish:i,handleDelete:d,handlePublish:c,handleSaveDraft:p,handleSchedulePublish:y,handleConflictOverride:g}){let[b,v]=Ta.useState(Date.now()),[k,f]=Ta.useState(false),u=Ta.useRef(null),{formData:x,hasUnsavedChanges:A,autoSaveStatus:F,lastSavedAt:h,retryCount:w,view:m,setView:T,showPreview:B,setShowPreview:I,setFormData:V,markSaved:C,lastSavedData:K}=Fe(),E=!x.id;Ta.useEffect(()=>{let j=setInterval(()=>v(Date.now()),1e4);return ()=>clearInterval(j)},[]),Ta.useEffect(()=>{let j=ye=>{u.current&&!u.current.contains(ye.target)&&f(false);};if(k)return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[k]);let $=String(x.tabs?.title||(typeof x.title=="object"?"":x.title)||(typeof x.name=="object"?"":x.name)||"Untitled"),O=x.updatedAt?new Date(x.updatedAt).toLocaleString():"Just now",ne=x.createdAt?new Date(x.createdAt).toLocaleString():"Just now",ie=o?"Draft (unpublished changes)":r==="published"?"Published":"Draft",H=o?"Unpublished":r==="published"?"Published":"Draft",S=r==="published"&&!A?"bg-[var(--kyro-success)]":o?"bg-[var(--kyro-warning)]":"bg-[var(--kyro-text-muted)]",J=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",fe=(j=false)=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[F==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),j?"Saving\u2026":"Saving draft..."]}),F==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Hl.Check,{className:"w-3.5 h-3.5 shrink-0"}),j?"Saved":h?`Saved ${Math.floor((Date.now()-h)/6e4)}m ago`:"Draft saved"]}),F==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),j?`Retry ${w}/5`:`Retrying save (${w}/5)`]}),F==="offline"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-text-muted)] flex items-center gap-1.5",children:[jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M10.61 10.61a3 3 0 0 0 4.24 4.24"}),jsxRuntime.jsx("path",{d:"M13.36 13.36a3 3 0 0 0-4.24-4.24"}),jsxRuntime.jsx("path",{d:"m2 2 20 20"}),jsxRuntime.jsx("path",{d:"M18.36 5.64a9 9 0 0 0-12.72 0"}),jsxRuntime.jsx("path",{d:"M22.61 1.39a15 15 0 0 0-21.22 0"})]}),j?"Offline":"Offline \u2014 cached locally"]}),F==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:j?"Failed":"Draft save failed"}),F==="conflict"&&(j?jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict"}):jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)] font-semibold",children:"Conflict detected"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>g?.(),className:"text-[var(--kyro-primary)] hover:underline",children:"Keep my changes"}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-[var(--kyro-danger)] hover:underline",children:"Reload server version"})]}))]}),U=()=>!E&&jsxRuntime.jsxs(Ro,{trigger:jsxRuntime.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:"More actions",children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),jsxRuntime.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})}),direction:"down",children:[jsxRuntime.jsx(Tt,{onClick:p,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),jsxRuntime.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),jsxRuntime.jsx("polyline",{points:"7 3 7 8 15 8"})]}),children:"Save Draft"}),!t&&jsxRuntime.jsx(Tt,{onClick:s,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),children:"Create New"}),!t&&jsxRuntime.jsx(Tt,{onClick:l,disabled:n,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.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"}),jsxRuntime.jsx(Tt,{onClick:()=>f(true),icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),jsxRuntime.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),children:"Schedule Publish"}),r==="published"&&jsxRuntime.jsx(Tt,{onClick:i,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.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"}),jsxRuntime.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}),children:"Unpublish"}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(qa,{}),jsxRuntime.jsx(Tt,{onClick:d,danger:true,icon:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.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"})]})]}),re=()=>k&&jsxRuntime.jsx("div",{ref:u,className:"relative",children:jsxRuntime.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:[jsxRuntime.jsx("p",{className:"text-xs font-medium mb-2",children:"Schedule Publish"}),jsxRuntime.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)}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>f(false),className:"px-3 py-1.5 text-xs kyro-btn rounded-lg",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{let j=document.getElementById("schedule-datetime")?.value;j&&y(j);},className:"px-3 py-1.5 text-xs kyro-btn-success rounded-lg",children:"Schedule"})]})]})});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"md:hidden border-b border-[var(--kyro-border)] z-50 bg-[var(--kyro-surface)] backdrop-blur-md rounded-lg",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[jsxRuntime.jsx("a",{href:`${Oe}/${e}`,className:"p-1.5 rounded-lg hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h1",{className:"text-base font-bold tracking-tight truncate min-w-0",children:$}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-medium border ${J}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${S}`}),H]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[jsxRuntime.jsx(Fo,{status:r,saveStatus:a,hasChanges:A,onPublish:c,disabled:a==="saving"}),U(),re()]})]}),jsxRuntime.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:[jsxRuntime.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(j=>jsxRuntime.jsx("button",{type:"button",onClick:()=>T(j),className:`px-3 py-1 text-[10px] font-bold rounded-md transition-all ${m===j?"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:j==="edit"?"Edit":j==="version"?"History":"API"},j))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-medium",children:[fe(true),A&&F!=="saving"&&F!=="retrying"&&F!=="conflict"&&jsxRuntime.jsx("button",{type:"button",onClick:()=>{V(K),C();},className:"text-[var(--kyro-primary)] text-[10px] font-medium hover:underline",children:"Revert"}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>I(!B),className:`p-1.5 rounded-lg transition-all ${B?"bg-[var(--kyro-primary)]/10 text-[var(--kyro-primary)]":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,children:jsxRuntime.jsx(Hl.ExternalLink,{className:"w-3.5 h-3.5"})})]})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[jsxRuntime.jsx("a",{href:`${Oe}/${e}`,className:"p-2 border border-[var(--kyro-border)] rounded-xl hover:bg-[var(--kyro-bg-secondary)] transition-colors shrink-0",children:jsxRuntime.jsx(Hl.ChevronRight,{className:"w-4 h-4"})}),jsxRuntime.jsx("h1",{className:"text-xl font-bold tracking-tighter truncate min-w-0",children:$}),jsxRuntime.jsxs("span",{className:`shrink-0 inline-flex items-center gap-1.5 px-2 rounded-full text-[10px] font-regular border ${J}`,children:[jsxRuntime.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${S}`}),ie]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 text-[11px] font-medium tracking-wide opacity-60 ml-12",children:[fe(false),A&&F!=="saving"&&F!=="retrying"&&F!=="conflict"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"opacity-30",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{V(K),C();},className:"text-[var(--kyro-primary)] hover:underline",children:"Revert changes"})]}),h&&F!=="saving"&&F!=="retrying"&&F!=="success"&&jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Draft saved ",(()=>{let j=b-h,ye=Math.floor(j/6e4),Te=Math.floor(j/1e3);return ye>=1?`${ye}m ago`:Te>=5?`${Te}s ago`:"just now"})()]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Modified ",O]}),jsxRuntime.jsxs("span",{className:"border-l border-[var(--kyro-border)] pl-4",children:["Created ",ne]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.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(j=>jsxRuntime.jsx("button",{type:"button",onClick:()=>T(j),className:`px-5 py-2 text-xs font-bold rounded-lg transition-all ${m===j?"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:j.toUpperCase()},j))}),jsxRuntime.jsx("div",{className:"h-8 w-px bg-[var(--kyro-border)] mx-2"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>I(!B),className:`kyro-btn p-2.5 rounded-xl transition-all flex items-center gap-2 ${B?"shadow-lg":"text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-bg-secondary)]"}`,title:"Live Preview",children:[jsxRuntime.jsx(Hl.ExternalLink,{className:"w-4 h-4"}),B&&jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest pr-1",children:"Active"})]}),U(),re(),jsxRuntime.jsx(Fo,{status:r,saveStatus:a,hasChanges:A,onPublish:c,disabled:a==="saving"})]})]})]})]})}function sc({config:e,layout:t,collectionSlug:r,renderField:o}){let{showPreview:a,sidebarCollapsed:n,formData:s}=Fe();if(t==="single")return jsxRuntime.jsx("div",{className:"w-full space-y-6 md:space-y-8",children:jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.map(d=>o(d))})});let i=e.fields.some(d=>d.admin?.position==="sidebar")&&!a;return jsxRuntime.jsxs("div",{className:`w-full mx-auto grid gap-4 md:gap-8 pb-32 transition-all duration-700 ${a?"grid-cols-1 lg:grid-cols-2":n||!i?"grid-cols-1":"grid-cols-1 lg:grid-cols-[1fr_380px]"}`,children:[jsxRuntime.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}):jsxRuntime.jsx("div",{className:"surface-tile p-4 md:p-8 space-y-6 md:space-y-8",children:e.fields.filter(d=>!d.admin?.position||d.admin.position==="main").map(d=>o(d))})}),a?jsxRuntime.jsx("div",{className:"sticky top-36 h-[calc(100vh-280px)] animate-in fade-in slide-in-from-right-10 duration-700",children:jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest text-white/60",children:"Live Preview Mode"})]}),jsxRuntime.jsx("iframe",{src:`/${r}/${s.slug||s.id}?preview=true`,className:"w-full h-full border-none",title:"Live Preview"}),jsxRuntime.jsx("div",{className:"absolute inset-0 bg-transparent pointer-events-none border-[12px] border-[var(--kyro-surface)] rounded-3xl"})]})}):n?null:jsxRuntime.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(d=>d.admin?.position==="sidebar")&&jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-6 space-y-4 md:space-y-6",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Settings"}),e.fields.filter(d=>d.admin?.position==="sidebar").map(d=>o(d))]})})]})}function ic({handleRestoreVersion:e,handleCompareVersions:t,toggleCompareSelection:r}){let{compareMode:o,setCompareMode:a,compareSelected:n,setCompareSelected:s,compareDiffs:l,setCompareDiffs:i,loadingDiffs:d,loadingVersions:c,versions:p}=Fe();return jsxRuntime.jsx("div",{className:"w-full animate-in fade-in slide-in-from-bottom-4 pb-12",children:jsxRuntime.jsxs("div",{className:"surface-tile p-0 overflow-hidden",children:[jsxRuntime.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:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-base md:text-lg font-bold text-[var(--kyro-text-primary)]",children:"Version History"}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-muted)] mt-0.5",children:o?`Select 2 versions \xB7 ${n.length}/2 chosen`:`${p.length} snapshot${p.length!==1?"s":""} \xB7 Auto-saved`})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&n.length===2&&jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{a(!o),s([]),i([]);},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"})]})]}),l.length>0&&jsxRuntime.jsxs("div",{className:"border-b border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("div",{className:"px-6 py-3 flex items-center justify-between",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold text-[var(--kyro-text-primary)] tracking-wider",children:[l.length," change",l.length!==1?"s":""]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>i([]),className:"p-1 rounded hover:bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-muted)]",children:jsxRuntime.jsx(Hl.X,{className:"w-4 h-4"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:l.map((y,g)=>jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate font-semibold md:font-normal",children:y.field}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-muted)] truncate hidden md:block",children:typeof y.oldValue=="object"?JSON.stringify(y.oldValue):String(y.oldValue??"null")}),jsxRuntime.jsxs("div",{className:"md:col-span-2 text-[var(--kyro-text-primary)] truncate",children:[jsxRuntime.jsx("span",{className:"md:hidden text-[var(--kyro-text-muted)]",children:"\u2192 "}),typeof y.newValue=="object"?JSON.stringify(y.newValue):String(y.newValue??"null")]})]},g))})]}),c?jsxRuntime.jsx("div",{className:"flex justify-center py-16",children:jsxRuntime.jsx("span",{className:"animate-spin text-[var(--kyro-primary)]",children:"\u231B"})}):p.length===0?jsxRuntime.jsx("div",{className:"text-center py-16 text-[var(--kyro-text-muted)] text-sm italic",children:"No versions yet."}):jsxRuntime.jsx("div",{className:"divide-y divide-[var(--kyro-border)]",children:p.map((y,g)=>{let b=n.includes(y.id),v=(y.changeDescription||"").toLowerCase().includes("auto");return jsxRuntime.jsxs("div",{onClick:o?()=>r(y.id):void 0,className:`transition-all ${o?b?"bg-[var(--kyro-primary)]/5 cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)] cursor-pointer":"hover:bg-[var(--kyro-bg-secondary)]"}`,children:[jsxRuntime.jsxs("div",{className:"hidden md:grid grid-cols-12 gap-3 px-6 py-3 items-center",children:[jsxRuntime.jsx("div",{className:"col-span-1 flex items-center gap-2",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5",children:p.length-g})}),jsxRuntime.jsxs("div",{className:"col-span-4 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-2",children:[y.changeDescription||"Snapshot",v&&jsxRuntime.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"})]}),jsxRuntime.jsx("div",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(y.createdAt||y.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),jsxRuntime.jsx("div",{className:"col-span-3",children:y.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold capitalize tracking-wider ${y.status==="published"?" text-[var(--kyro-success)]":" text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${y.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),y.status]})}),jsxRuntime.jsx("div",{className:"col-span-2 text-[11px] text-[var(--kyro-text-muted)]",children:y.createdBy||"system"}),jsxRuntime.jsx("div",{className:"col-span-2 flex justify-end",children:!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(y.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"})})]}),jsxRuntime.jsxs("div",{className:"md:hidden flex items-start gap-3 px-4 py-3",children:[jsxRuntime.jsx("div",{className:"pt-0.5 shrink-0",children:o?jsxRuntime.jsx("div",{className:`w-4 h-4 rounded-full border ${b?"border-[var(--kyro-primary)] bg-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:b&&jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"})}):jsxRuntime.jsx("span",{className:"text-[10px] font-bold text-[var(--kyro-text-muted)] w-5 inline-block text-center",children:p.length-g})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"text-[13px] font-medium text-[var(--kyro-text-primary)] truncate flex items-center gap-1.5",children:[y.changeDescription||"Snapshot",v&&jsxRuntime.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)]",children:new Date(y.createdAt||y.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),y.status&&jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold capitalize tracking-wider ${y.status==="published"?"text-[var(--kyro-success)]":"text-[var(--kyro-warning)]"}`,children:[jsxRuntime.jsx("span",{className:`w-1 h-1 rounded-full ${y.status==="published"?"bg-[var(--kyro-success)]":"bg-[var(--kyro-warning)]"}`}),y.status]}),jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-muted)] opacity-60",children:y.createdBy||"system"})]})]}),!o&&jsxRuntime.jsx("button",{type:"button",onClick:()=>e(y.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"})]})]},y.id)})})]})})}function lc({collectionSlug:e,globalSlug:t}){let{formData:r}=Fe();return jsxRuntime.jsx("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_300px] gap-8",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-8 min-w-0",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"Response Payload"}),jsxRuntime.jsx("div",{className:"bg-[#0f172a] p-6 rounded-2xl border border-white/5 overflow-x-auto max-h-[800px]",children:jsxRuntime.jsx("pre",{className:"text-blue-300 text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(r,null,2)})})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsxs("div",{className:"surface-tile p-8 space-y-6",children:[jsxRuntime.jsx("h2",{className:"text-xl font-bold mb-6",children:"API Info"}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Reference Path"}),jsxRuntime.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()`:r.id?`kyro.collection('${e}').get('${r.id}')`:"Not saved yet"})]}),r.id&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Document ID"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.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(r.id)}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(String(r.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:"Copy ID",children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]}),t&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.1em] text-[var(--kyro-text-secondary)] opacity-50 block mb-2",children:"Global Slug"}),jsxRuntime.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 ds=class extends Ta.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=Fe.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(()=>{L.success("Crash details copied to clipboard");});};handleReload=()=>{window.location.reload();};render(){return this.state.hasError?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-500/10 flex items-center justify-center",children:jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-8 h-8 text-red-500"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--kyro-text-primary)]",children:this.props.fallbackTitle||"Something went wrong"}),jsxRuntime.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&&jsxRuntime.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}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[jsxRuntime.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:[jsxRuntime.jsx(Hl.RefreshCw,{className:"w-4 h-4"}),"Reload Page"]}),jsxRuntime.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:[jsxRuntime.jsx(Hl.Copy,{className:"w-4 h-4"}),"Copy Details"]})]})]}):this.props.children}};function dc(e,t){if(!(!e||typeof t!="string"))return t.split(".").reduce((r,o)=>r&&r[o]!==void 0?r[o]:void 0,e)}function xi(e,t,r){if(!e)return true;if(Array.isArray(e.and))return e.and.every(o=>xi(o,t,r));if(Array.isArray(e.or))return e.or.some(o=>xi(o,t,r));if(e.field){let o=e.field,a=dc(t,o);return a===void 0&&(a=dc(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?typeof a=="number"&&a>e.greaterThan:!!a}return true}var cc={};function Ya({config:e,data:t=cc,errors:r=cc,onChange:o,disabled:a,collectionSlug:n,globalSlug:s,documentId:l,documentName:i,layout:d="split",onActionSuccess:c,onActionError:p,justSaved:y}){let g=e||(s?yd[s]:n?qo[n]:null),[b,v]=Ta.useState(g);Ta.useEffect(()=>{s==="storage-settings"?Ae("/api/kyro/schema").then(P=>{P?.globals?.["storage-settings"]&&v(P.globals["storage-settings"]);}).catch(P=>console.error("[AutoForm] Failed to fetch dynamic schema",P)):v(g);},[s,g]);let k=b||g,{confirm:f}=ut(),{formData:u,hasUnsavedChanges:A,autoSaveStatus:w,lastSavedAt:m,view:$,setView:O,setShowPreview:fe,isMenuOpen:U,setIsMenuOpen:re,loadingFields:j,setLoadingFields:ye,compareSelected:G,setCompareSelected:_e,setCompareDiffs:Z,setLoadingDiffs:Ge,setField:ft,setFormData:lt,setLastSavedData:X,setAutoSaveStatus:le,fetchVersions:ce,saveDocument:Se,forceSave:Ee,autoSaveSkipRef:He,lastAutoSaveTimeRef:D,documentStatus:Q,hasUnpublishedChanges:pe,versionsEnabled:fr}=Yd({config:k,initialData:t,collectionSlug:n,globalSlug:s,documentId:l,onChange:o,onActionSuccess:c,onActionError:p}),fo=Ta.useRef(null),fa=Ta.useRef(null),[Za,en]=Ta.useState(false),[R,oe]=Ta.useState("idle"),[Ie,$t]=Ta.useState(false),[Ot,vr]=Ta.useState(Date.now()),gs=a,[bs,tn]=Ta.useState(false),[tp,xs]=Ta.useState(false),[rp,op]=Ta.useState(0),Ai=Ta.useRef(new Map),ap=3e4;Ta.useEffect(()=>{let P=s?`global:${s}`:`${n}:${l}`;if(!(s||n&&l&&l!=="new")||t&&Object.keys(t).length>0)return;let ke=Ai.current.get(P),$e=ke&&Date.now()-ke.ts<ap,ht=ke&&!$e;if($e){Fe.getState().loadDocument(ke.data,ke.data);return}ht&&Fe.getState().loadDocument(ke.data,ke.data);let It=new AbortController;xs(false),ke||tn(true);let Fr=s?`/api/globals/${s}`:`/api/${n}/${l}`;return Ae(Fr,{autoToast:false,signal:It.signal}).then(vt=>{let vo=vt.data||{};Ai.current.set(P,{data:vo,ts:Date.now()}),Fe.getState().loadDocument(vo,vo),tn(false);}).catch(vt=>{vt.name!=="AbortError"&&(tn(false),ke||xs(true));}),()=>It.abort()},[n,l,s,t,rp]),Ta.useEffect(()=>{let P=setInterval(()=>vr(Date.now()),1e4);return ()=>clearInterval(P)},[]);let Fi=(P,Y)=>{if(typeof P=="function")try{return P(u,Y)}catch(ke){return console.warn("Error evaluating admin runtime flag:",ke),false}return !!P},np=P=>{f({title:"Restore Version",message:"Are you sure you want to restore this version? This will overwrite your current changes.",onConfirm:async()=>{try{let Y=s?We(`/api/globals/${s}/versions/${P}/restore`):We(`/api/${n}/${u.id}/versions/${P}/restore`),ke=await st(Y,{method:"POST"});!ke.ok&&n&&(ke=await st(We(`/api/${n}/${u.id}/versions`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({versionId:P,action:"restore"})}));let $e=await ke.json();if($e.data){let{updatedAt:ht,createdAt:It,...Fr}=$e.data,vt={...u,...Fr};lt(vt),Fe.getState().loadDocument(vt,vt),c?.("Version restored successfully"),ce(),O("edit");}else L.error($e.error||"Failed to restore version");}catch(Y){console.error("Failed to restore version:",Y),L.error("Failed to restore version");}}});},sp=async()=>{if(G.length===2){Ge(true);try{let Y=await(await st(We(`/api/${n}/${u.id}/versions?compareA=${G[0]}&compareB=${G[1]}`))).json();Z(Y.diffs||[]);}catch(P){console.error("Compare failed:",P),Z([]);}finally{Ge(false);}}},ip=P=>{_e(Y=>Y.includes(P)?Y.filter(ke=>ke!==P):Y.length>=2?[Y[1],P]:[...Y,P]);};Ta.useEffect(()=>{let P=Y=>{(Y.metaKey||Y.ctrlKey)&&Y.key==="s"&&(Y.preventDefault(),rn()),(Y.metaKey||Y.ctrlKey)&&Y.shiftKey&&(Y.key==="P"||Y.key==="p")&&(Y.preventDefault(),document.getElementById("btn-publish")?.click()),(Y.metaKey||Y.ctrlKey)&&!Y.shiftKey&&Y.key==="p"&&(Y.preventDefault(),fe(ke=>!ke)),document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(Y.key==="1"&&O("edit"),Y.key==="2"&&O("version"),Y.key==="3"&&O("api"));};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]),Ta.useEffect(()=>{let P=()=>O("version");return window.addEventListener("kyro:show-version-history",P),()=>window.removeEventListener("kyro:show-version-history",P)},[]),Ta.useEffect(()=>{let P=Y=>{fo.current&&!fo.current.contains(Y.target)&&re(false);};if(U)return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[U]),Ta.useEffect(()=>{let P=Y=>{fa.current&&!fa.current.contains(Y.target)&&en(false);};if(Za)return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[Za]);let lp=()=>{A?f({title:"Unsaved Changes",message:"You have unsaved changes. Save before creating new?",onConfirm:async()=>{await rn(),await new Promise(P=>setTimeout(P,1e3)),window.location.href=`${Oe}/${n}/new`;}}):window.location.href=`${Oe}/${n}/new`;},dp=()=>{if(!u.id){L.error("Please save the document before duplicating.");return}let P=async()=>{try{$t(!0);let Y=await st(`/api/${n}/${u.id}/duplicate`,{method:"POST"});if(Y.ok){let ke=await Y.json();c?.("Document duplicated successfully"),ke.data?.id?window.location.href=`${Oe}/${n}/${ke.data.id}`:window.location.href=`${Oe}/${n}`;}else {let ke=await Y.json();L.error(ke.error||"Failed to duplicate");}}catch{L.error("Failed to duplicate document");}finally{$t(false);}};if(A){f({title:"Unsaved Changes",message:"You have unsaved changes. Please save the document before duplicating.",onConfirm:async()=>{await rn(),await P();}});return}f({title:"Duplicate Document",message:"Are you sure you want to duplicate this document?",onConfirm:async()=>{await P();}});},cp=()=>{f({title:"Delete Document",message:"Delete this document? This cannot be undone. Are you absolutely sure?",variant:"danger",onConfirm:async()=>{He.current=true;try{await wt(`/api/${n}/${u.id}`),window.location.href=`${Oe}/${n}`;}catch(P){L.error(P.message||"Failed to delete document");}finally{He.current=false;}}});},pp=()=>{f({title:"Unpublish Document",message:"Unpublish this document?",onConfirm:async()=>{He.current=true;try{let P=await Se({...u,status:"draft"},!1);if(P?.ok)c?.("Document unpublished successfully"),Fe.getState().loadDocument({...u,status:"draft"},{...u,status:"draft"});else {let Y=await P?.json().catch(()=>({}));L.error(Y?.error||"Failed to unpublish");}}catch{L.error("Failed to unpublish");}finally{He.current=false;}}});},rn=async()=>{let P=!u.id;He.current=true,oe("saving");try{let Y=mr({...u}),ke=P&&!s,$e=ke?await st(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}):await Se(Y);if($e.ok){let ht=await $e.json(),It=ht.data||Y;lt({...u,...It}),X({...u,...It}),D.current=Date.now(),le("success"),oe("saved"),fr&&ce(),setTimeout(()=>{le("idle"),oe("idle");},2e3),c?.(ke?"Document created successfully":"Changes saved"),ke&&setTimeout(()=>{window.location.href=`${Oe}/${n}/${ht.data.id}`;},800);}else {let ht=await $e.json();$e.status===409&&le("conflict"),oe("error"),L.error(ht.error||"Failed to save"),setTimeout(()=>oe("idle"),3e3);}}catch{oe("error"),L.error("Failed to save document"),setTimeout(()=>oe("idle"),3e3);}finally{window.dispatchEvent(new CustomEvent("kyro:global-save-end")),He.current=false;}},mp=async()=>{let P=!u.id;He.current=true,oe("saving");try{let Y={...u};if(P&&!s){let ht=mr({...u}),It=await st(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ht)});if(!It.ok){let vo=await It.json().catch(()=>({}));It.status===409&&le("conflict"),oe("error"),L.error(vo.error||"Failed to create document"),setTimeout(()=>oe("idle"),3e3);return}let vt=(await It.json()).data||ht;lt({...u,...vt}),X({...u,...vt}),Y={...u,...vt};}let ke=mr(Y),$e=await Se(ke,!1);if($e?.ok)oe("saved"),c?.("Published successfully"),P&&!s&&Y.id&&setTimeout(()=>{window.location.href=`${Oe}/${n}/${Y.id}`;},800);else {if(P&&!s&&Y.id){let It=await $e?.json().catch(()=>({}));L.warning("Document saved as draft. Publishing failed: "+(It?.error||"Unknown error")),setTimeout(()=>{window.location.href=`${Oe}/${n}/${Y.id}`;},1200);return}let ht=await $e?.json().catch(()=>({}));$e?.status===409&&le("conflict"),oe("error"),L.error(ht?.error||"Failed to publish"),setTimeout(()=>oe("idle"),3e3);}}catch{oe("error"),L.error("Failed to publish"),setTimeout(()=>oe("idle"),3e3);}finally{He.current=false;}},up=async P=>{let Y=!u.id;He.current=true;try{let ke={...mr({...u}),_schedulePublishAt:P};if(Y&&!s){let $e=await st(`/api/${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ke)});if(!$e.ok){let ht=await $e.json().catch(()=>({}));L.error(ht.error||"Failed to schedule publish");return}}else {let $e=await Se(ke);if(!$e.ok){let ht=await $e.json().catch(()=>({}));L.error(ht.error||"Failed to schedule publish");return}}c?.(`Scheduled publish for ${new Date(P).toLocaleString()}`),en(!1);}catch{L.error("Failed to schedule publish");}finally{He.current=false;}},yp=(P,Y)=>{ft(P,Y);},va=(P,Y,ke)=>{let $e=Y!==void 0?Y:u;if(Fi(P.hidden!==void 0?P.hidden:P.admin?.hidden,$e))return null;let It=Fi(P.readOnly!==void 0?P.readOnly:P.admin?.readOnly,$e),Fr=!!(gs||It);if(P.admin?.condition){if(typeof P.admin.condition=="function")try{let nt={values:u||{},...u||{}};if(!P.admin.condition(nt,$e))return null}catch(nt){console.warn(`Condition error for field ${P.name}:`,nt);}else if(typeof P.admin.condition=="object")try{if(!xi(P.admin.condition,$e,u))return null}catch(nt){console.warn(`Declarative condition error for field ${P.name}:`,nt);}}let vt=$e[P.name],vo=r[P.name],on=nt=>{ke?ke({...$e,[P.name]:nt}):yp(P.name,nt);};if(P.type==="row"&&"fields"in P){let nt=P.fields;return jsxRuntime.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:nt?.map(rt=>{let Pr=rt.admin||{},an=Pr?.action;if((rt.type==="button"||rt.type==="action")&&an){let gr=nt?.find(ga=>ga.type==="email");return jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx("button",{type:"button",onClick:async()=>{let ga=P.name,nn=gr?.name,sn=nn?u[nn]:void 0;if(!sn&&ga&&typeof ga=="string"&&nn&&(sn=u[ga]?.[nn]),!!sn){ye(br=>({...br,[rt.name]:true}));try{let br=await st(We(an),{method:Pr.method||"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:sn})}),ba={};try{ba=await br.json();}catch{ba={};}if(br.ok&&ba.success)c?.(ba.message||"Action completed successfully");else {let fp=ba.error||`Request failed (${br.status})`;p?.(fp);}}catch(br){p?.(br instanceof Error?br.message:"Error connecting to server");}finally{ye(br=>({...br,[rt.name]:false}));}}},disabled:j[rt.name]||Fr,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:j[rt.name]?"Sending...":rt.label||"Click"})},rt.name)}return jsxRuntime.jsx("div",{className:rt.type==="button"||rt.type==="action"?"flex-shrink-0":"flex-1",style:Pr?.width?{width:Pr.width,flex:"none"}:{},children:va(rt,Y,ke)},rt.name)})},P.name||`row-${Math.random()}`)}switch(P.type){case "tabs":return jsxRuntime.jsx(rc,{field:P,formData:u,onTabDataChange:nt=>{ft(P.name,nt);},renderField:(nt,rt,Pr)=>va(nt,rt,Pr)},P.name||`tabs-${Math.random()}`);case "group":return jsxRuntime.jsx(es,{field:P,value:vt,onChange:on,renderField:va},P.name);case "array":return jsxRuntime.jsx(ts,{field:P,value:vt,onChange:on,renderField:va,disabled:Fr},P.name);case "button":case "action":{let nt=P.name,rt=j[nt];return jsxRuntime.jsx("div",{className:"kyro-form-field",children:jsxRuntime.jsxs("button",{type:"button",disabled:rt||Fr,onClick:async()=>{let Pr=P.admin?.action||P.action,an=P.admin?.method||P.method||"POST";if(Pr){ye(gr=>({...gr,[nt]:true}));try{let gr=await st(Pr,{method:an,headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});await gr.json(),gr.ok;}catch(gr){console.error("Error executing action:",gr);}finally{ye(gr=>({...gr,[nt]:false}));}}},className:`kyro-btn kyro-btn-md kyro-btn-secondary transition-all active:scale-95 whitespace-nowrap flex items-center gap-2 ${rt?"opacity-70 cursor-not-allowed":""}`,children:[rt&&jsxRuntime.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:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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"})]}),rt?"Processing...":P.label||"Click"]})},nt)}case "relationship-block":return jsxRuntime.jsxs("div",{className:"kyro-form-field",children:[jsxRuntime.jsxs("label",{className:"kyro-form-label",children:[P.label||P.name,P.required&&jsxRuntime.jsx("span",{className:"kyro-form-label-required",children:"*"})]}),jsxRuntime.jsx(Ga,{relationTo:P.relationTo,hasMany:P.hasMany,selectedIds:Array.isArray(vt)?vt:vt?[vt]:[],onChange:(nt,rt)=>{on(rt);},compact:true}),P.admin?.description?jsxRuntime.jsx("p",{className:"kyro-form-help",children:String(P.admin?.description)}):null]},P.name);default:return jsxRuntime.jsx(To,{field:P,value:vt,onChange:on,error:vo,disabled:Fr,formData:u,siblingData:$e,collectionSlug:n,globalSlug:s},P.name||Math.random().toString())}};return bs?jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(_t,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(_t,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(_t,{variant:"rect",count:4})})]}):tp?jsxRuntime.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-16",children:[jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-8 h-8 text-[var(--kyro-danger)]"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)]",children:"Failed to load document. Check your connection."}),jsxRuntime.jsx("button",{type:"button",onClick:()=>{xs(false),tn(true),op(P=>P+1);},className:"kyro-btn kyro-btn-primary px-6 py-2 rounded-xl text-sm font-bold",children:"Retry"})]}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[d!=="single"&&jsxRuntime.jsx(nc,{collectionSlug:n,globalSlug:s,documentStatus:Q||"draft",hasUnpublishedChanges:pe,localSaveStatus:R,isDuplicating:Ie,handleCreateNew:lp,handleDuplicate:dp,handleUnpublish:pp,handleDelete:cp,handlePublish:mp,handleSaveDraft:rn,handleSchedulePublish:up,handleConflictOverride:()=>Ee()}),d==="single"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--kyro-border)] bg-[var(--kyro-surface)]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-[11px] font-medium",children:[w==="saving"&&jsxRuntime.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Saving..."]}),w==="success"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-success)] flex items-center gap-1",children:[jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"}),m?`Saved ${Math.floor((Date.now()-m)/6e4)}m ago`:"Saved"]}),w==="retrying"&&jsxRuntime.jsxs("span",{className:"text-[var(--kyro-warning)] flex items-center gap-1.5",children:[jsxRuntime.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Retrying..."]}),w==="offline"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-text-muted)]",children:"Offline \u2014 cached locally"}),w==="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Save failed"}),w==="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-danger)]",children:"Conflict detected"}),A&&w!=="saving"&&w!=="retrying"&&w!=="conflict"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-warning)]",children:"Unsaved changes"}),!A&&w!=="success"&&w!=="saving"&&w!=="error"&&jsxRuntime.jsx("span",{className:"text-[var(--kyro-success)]",children:"All changes saved"})]}),jsxRuntime.jsx("span",{className:"text-[11px] text-[var(--kyro-text-muted)] opacity-60",children:u.updatedAt?`Modified ${new Date(u.updatedAt).toLocaleString()}`:""})]}),jsxRuntime.jsx("button",{id:"btn-save",type:"button",style:{width:0,height:0,opacity:0,padding:0,margin:0,border:"none",position:"absolute"},onClick:async()=>{He.current=true;try{window.dispatchEvent(new Event("kyro:global-save-start"));let P=await Se(u);if(P.ok){let ke=(await P.json()).data||u;lt({...u,...ke}),X({...u,...ke}),c?.("Changes saved");}}catch(P){console.error("Save error exception:",P),p?.("Save failed: "+P.message);}finally{He.current=false,window.dispatchEvent(new Event("kyro:global-save-end"));}}})]}),jsxRuntime.jsx("main",{className:"w-full pt-6 md:pt-0",children:jsxRuntime.jsxs(ds,{children:[$==="edit"&&jsxRuntime.jsx(sc,{config:k,layout:d,collectionSlug:n,renderField:va}),$==="version"&&jsxRuntime.jsx(ic,{handleRestoreVersion:np,handleCompareVersions:sp,toggleCompareSelection:ip}),$==="api"&&jsxRuntime.jsx(lc,{collectionSlug:n,globalSlug:s})]})})]})}var pc={draft:"bg-[var(--kyro-warning)]",published:"bg-[var(--kyro-success)]",scheduled:"bg-[var(--kyro-primary)]",archived:"bg-[var(--kyro-text-muted)]"};function ki({status:e,saveStatus:t,hasChanges:r,onSave:o,onPublish:a,onUnpublish:n,onDuplicate:s,onViewHistory:l,onPreview:i,onDelete:d,onBack:c,onToggleSidebar:p,publishedAt:y,updatedAt:g,onCopyData:b,onPasteData:v}){let k=Fe(T=>T.view)||"edit",f=Fe(T=>T.setView),[u,x]=Ta.useState(false),A=Ta.useRef(null);Ta.useEffect(()=>{let T=B=>{A.current&&!A.current.contains(B.target)&&x(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);let F=()=>t==="saving"?"Saving...":t==="saved"?"Saved":t==="error"?"Error saving":r?"Unsaved":null,h=["edit","version","api"],w=F(),m="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 jsxRuntime.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&&jsxRuntime.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:jsxRuntime.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:jsxRuntime.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${pc[e]||"bg-[var(--kyro-text-muted)]"}`}),w&&jsxRuntime.jsxs("span",{className:`text-[10px] whitespace-nowrap max-md:hidden ${t==="error"?"text-[var(--kyro-error)]":"text-[var(--kyro-text-muted)]"}`,children:[t==="saving"&&jsxRuntime.jsx(hr,{size:"sm",className:"inline mr-0.5"}),w]}),jsxRuntime.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:h.map(T=>jsxRuntime.jsx("button",{type:"button",onClick:()=>f(T),className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all ${k===T?"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:T==="edit"?"Edit":T==="version"?"Ver":"API"},T))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[i&&jsxRuntime.jsx("button",{type:"button",onClick:i,className:`${m} max-md:hidden`,title:"Preview",children:jsxRuntime.jsx(Hl.Eye,{className:"w-3.5 h-3.5"})}),l&&jsxRuntime.jsx("button",{type:"button",onClick:l,className:`${m} max-md:hidden`,title:"View History",children:jsxRuntime.jsx(Hl.Clock,{className:"w-3.5 h-3.5"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:s,className:`${m} max-md:hidden`,title:"Duplicate",children:jsxRuntime.jsx(Hl.Copy,{className:"w-3.5 h-3.5"})}),b&&jsxRuntime.jsx("button",{type:"button",onClick:b,className:`${m} max-md:hidden`,title:"Copy Data",children:jsxRuntime.jsx(Hl.ClipboardCopy,{className:"w-3.5 h-3.5"})}),v&&jsxRuntime.jsx("button",{type:"button",onClick:v,className:`${m} max-md:hidden`,title:"Paste Data",children:jsxRuntime.jsx(Hl.ClipboardPaste,{className:"w-3.5 h-3.5"})}),d&&jsxRuntime.jsx("button",{type:"button",onClick:d,className:`${m} hover:bg-[var(--kyro-danger-bg)] hover:text-[var(--kyro-danger)] max-md:hidden`,title:"Delete",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5"})}),p&&jsxRuntime.jsx("button",{type:"button",onClick:p,className:`${m} max-md:hidden`,title:"Toggle Sidebar",children:jsxRuntime.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),jsxRuntime.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),jsxRuntime.jsxs("div",{ref:A,className:"relative md:hidden",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(!u),className:m,title:"More",children:jsxRuntime.jsx(Hl.EllipsisVertical,{className:"w-3.5 h-3.5"})}),u&&jsxRuntime.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:[w&&jsxRuntime.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:[jsxRuntime.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${pc[e]}`}),jsxRuntime.jsx("span",{className:"capitalize",children:e}),jsxRuntime.jsx("span",{children:"\xB7"}),t==="saving"&&jsxRuntime.jsx(hr,{size:"sm",className:"inline"}),jsxRuntime.jsx("span",{children:w})]}),jsxRuntime.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-[var(--kyro-border)]",children:h.map(T=>jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(T),x(false);},className:`px-2.5 py-1 text-[11px] font-semibold rounded-md transition-all flex-1 ${k===T?"bg-[var(--kyro-primary)] text-[var(--kyro-sidebar-text-active)]":"text-[var(--kyro-text-muted)] hover:text-[var(--kyro-text-primary)]"}`,children:T==="edit"?"Edit":T==="version"?"Ver":"API"},T))}),l&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{l(),x(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:[jsxRuntime.jsx(Hl.Clock,{className:"w-3.5 h-3.5"})," View History"]}),s&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{s(),x(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:[jsxRuntime.jsx(Hl.Copy,{className:"w-3.5 h-3.5"})," Duplicate"]}),b&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{b(),x(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:[jsxRuntime.jsx(Hl.ClipboardCopy,{className:"w-3.5 h-3.5"})," Copy Data"]}),v&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{v(),x(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:[jsxRuntime.jsx(Hl.ClipboardPaste,{className:"w-3.5 h-3.5"})," Paste Data"]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{i(),x(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:[jsxRuntime.jsx(Hl.Eye,{className:"w-3.5 h-3.5"})," Preview"]}),d&&jsxRuntime.jsx("div",{className:"border-t border-[var(--kyro-border)] mt-1 pt-1",children:jsxRuntime.jsxs("button",{type:"button",onClick:()=>{d(),x(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:[jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5"})," Delete"]})})]})]}),jsxRuntime.jsx("div",{className:"h-4 w-px bg-[var(--kyro-border)] mx-0.5"}),e==="draft"&&a&&jsxRuntime.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:[jsxRuntime.jsx(Hl.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Publish"})]}),e==="published"&&n&&jsxRuntime.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:[jsxRuntime.jsx(Hl.Undo,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"max-md:hidden",children:"Unpublish"})]}),jsxRuntime.jsxs(Fo,{status:e,saveStatus:t,hasChanges:r,onPublish:o,children:[s&&jsxRuntime.jsx(Tt,{icon:jsxRuntime.jsx(Hl.Copy,{className:"w-4 h-4"}),onClick:s,children:"Duplicate"}),b&&jsxRuntime.jsx(Tt,{icon:jsxRuntime.jsx(Hl.ClipboardCopy,{className:"w-4 h-4"}),onClick:b,children:"Copy Data"}),v&&jsxRuntime.jsx(Tt,{icon:jsxRuntime.jsx(Hl.ClipboardPaste,{className:"w-4 h-4"}),onClick:v,children:"Paste Data"}),l&&jsxRuntime.jsx(Tt,{icon:jsxRuntime.jsx(Hl.Clock,{className:"w-4 h-4"}),onClick:l,children:"View History"}),i&&jsxRuntime.jsx(Tt,{icon:jsxRuntime.jsx(Hl.Eye,{className:"w-4 h-4"}),onClick:i,children:"Preview"}),(s||b||v||l||i)&&jsxRuntime.jsx(qa,{}),d&&jsxRuntime.jsx(Tt,{onClick:d,danger:true,icon:jsxRuntime.jsx(Hl.Trash2,{className:"w-4 h-4"}),children:"Delete"})]})]})]})}function wi({config:e,collection:t,global:r,documentId:o,onBack:a,onSave:n,onDelete:s,onError:l,mode:i="collection"}){let{confirm:d,alert:c}=ut(),[p,y]=Ta.useState({}),[g,b]=Ta.useState({}),[v,k]=Ta.useState(true),[f,u]=Ta.useState(false),[x,A]=Ta.useState(false),[F,h]=Ta.useState(false),[w,m]=Ta.useState("idle"),[T,B]=Ta.useState("draft"),[I,V]=Ta.useState(null),[C,K]=Ta.useState(null),[E,$]=Ta.useState(null),[O,ne]=Ta.useState(false),ie=r?.fields||t?.fields||[],H=r?.label||t?.label||"Document",S=r?.slug||t?.slug||"",J=JSON.stringify(p)!==JSON.stringify(g);Ta.useEffect(()=>{J&&T==="published"&&B("draft");},[J,T]),Ta.useEffect(()=>{J&&w==="saved"&&m("idle");},[J,w]),Ta.useEffect(()=>{i==="global"?U():o&&fe();},[o,i,S]);let fe=async()=>{try{k(!0);let Z=await Ae(`/api/${S}/${o}`,{autoToast:!1}),ge=Z.data||{};y(ge),b(ge),B(ge?.status||Z.status||"draft"),V(Z.createdAt||ge.createdAt||null),K(Z.updatedAt||ge.updatedAt||null),$(Z.publishedAt||ge.publishedAt||null);}catch{l("Failed to load document");}finally{k(false);}},U=async()=>{try{k(!0);let Z=await Ae(`/api/globals/${S}`,{autoToast:!1}),ge=Z.data||{};y(ge),b(ge),V(Z.createdAt||null),K(Z.updatedAt||null);}catch{l("Failed to load global");}finally{k(false);}},re=Ta.useCallback(async(Z=false)=>{try{m("saving");let ge=i==="global"?`/api/globals/${S}`:`/api/${S}/${o}`,Ge=T==="draft"||p?.status==="draft",ft=await Wt(ge,p,{autoToast:!1,headers:{"X-Draft":String(Ge)}}),lt=ft&&(ft.data||ft)||p;Z||(b(lt),n()),y(lt),B(lt?.status||T),m("saved"),K(new Date().toISOString()),ne(!0),setTimeout(()=>ne(!1),3e3),Z||(T==="draft"||lt?.status==="draft"?L.warning("Draft saved"):L.success("Updated")),setTimeout(()=>{m("idle");},2e3);}catch{m("error"),Z||(l("Failed to save changes"),L.error("Failed to save changes"));}finally{u(false);}},[p,i,S,o,T,n,l]),j=async()=>{try{u(!0),await Wt(`/api/${S}/${o}`,p,{autoToast:!1,headers:{"X-Draft":"false"}}),B("published"),$(new Date().toISOString()),L.success("Published successfully"),n();}catch{l("Failed to publish"),L.error("Failed to publish");}finally{u(false);}},ye=async()=>{try{u(!0),await Wt(`/api/${S}/${o}`,{status:"draft"},{autoToast:!1,headers:{"X-Draft":"false"}}),B("draft"),L.warning("Document unpublished"),n();}catch{l("Failed to unpublish"),L.error("Failed to unpublish");}finally{u(false);}},Te=async()=>{try{A(!0);let Z=await dt(`/api/${S}/${o}/duplicate`,void 0,{autoToast:!1});L.success("Document duplicated"),Z?.data?.id?window.location.href=`${Oe}/${S}/${Z.data.id}`:window.location.href=`${Oe}/${S}`;}catch(Z){L.error(Z.message||"Failed to duplicate document");}finally{A(false);}},z=async()=>{try{let Z={...p};delete Z.id,delete Z.createdAt,delete Z.updatedAt,delete Z.status,await navigator.clipboard.writeText(JSON.stringify(Z)),L.success("Document data copied to clipboard");}catch{L.error("Failed to copy document data");}},G=async()=>{try{let Z=await navigator.clipboard.readText(),ge=JSON.parse(Z);if(typeof ge!="object"||ge===null)throw new Error("Invalid format");y(Ge=>({...Ge,...ge,id:Ge.id,createdAt:Ge.createdAt,updatedAt:Ge.updatedAt,status:Ge.status})),L.success("Document data pasted");}catch{L.error("Clipboard does not contain valid document JSON");}},_e=()=>{d({title:`Delete ${H}?`,message:"This action cannot be undone.",variant:"danger",onConfirm:async()=>{try{h(!0),await wt(`/api/${S}/${o}`),window.location.href=`${Oe}/${S}`;}catch{h(false);}}});};if(v)return jsxRuntime.jsx("div",{className:"kyro-detail",children:jsxRuntime.jsxs("div",{className:"space-y-6 p-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(_t,{variant:"text",className:"w-1/3"}),jsxRuntime.jsx(_t,{variant:"text",className:"w-2/3"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:jsxRuntime.jsx(_t,{variant:"rect",count:4})})]})});let Me=i==="global"||t?.admin?.layout==="single";return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:a},breadcrumbs:[{label:i==="global"?"Globals":"Collections"},{label:H,href:i==="collection"?`${Oe}/${S}`:void 0},{label:i==="global"||o?"Edit":"New"}],title:i==="global"?H:ko(t?.fields,p,t?.admin?.useAsTitle||"title")||p.name||o||`New ${t?.singularLabel||H}`,metadata:[jsxRuntime.jsx(At,{variant:T==="published"?"success":"warning",dot:true,className:"text-[10px] font-bold ",children:T},"status")]}),jsxRuntime.jsx(ki,{status:T,saveStatus:w,hasChanges:J,onSave:()=>re(false),onPublish:j,onUnpublish:T==="published"?ye:void 0,onDuplicate:Te,onCopyData:z,onPasteData:G,onViewHistory:()=>{window.dispatchEvent(new CustomEvent("kyro:show-version-history"));},onPreview:()=>window.open(`/preview/${S}/${o}`,"_blank"),onDelete:_e,onBack:a,onToggleSidebar:()=>window.dispatchEvent(new CustomEvent("toggle-sidebar")),publishedAt:E,updatedAt:C}),jsxRuntime.jsxs("div",{className:Me?"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:[jsxRuntime.jsx("div",{className:"space-y-4 md:space-y-8 min-w-0",children:jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-8 px-1",children:[jsxRuntime.jsx("h2",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Core Configuration"}),jsxRuntime.jsx("div",{className:"h-px flex-1 bg-[var(--kyro-border)] ml-6 opacity-30"})]}),jsxRuntime.jsx(Ya,{config:t?{...t,fields:ie}:{slug:"unknown",fields:ie},data:p,onChange:y,layout:Me?"single":"split",globalSlug:i==="global"?S:void 0,collectionSlug:i==="collection"?S:void 0,onActionSuccess:Z=>L.success(Z),onActionError:Z=>L.error(Z),documentStatus:T,justSaved:O}),Me&&jsxRuntime.jsxs("div",{className:"mt-8 pt-8 border-t border-[var(--kyro-border)] flex justify-end gap-3",children:[i==="collection"&&o&&jsxRuntime.jsx("button",{type:"button",onClick:_e,disabled:F||f,className:"kyro-btn kyro-btn-sm text-[var(--kyro-danger)] hover:bg-[var(--kyro-danger)]/10 w-full justify-start mt-2",children:F?"Deleting...":"Delete Document"}),jsxRuntime.jsx(Fo,{status:T,saveStatus:f?"saving":"idle",hasChanges:J,onPublish:()=>re(false),disabled:f})]})]})}),!Me&&jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6 animate-in fade-in slide-in-from-right-4 duration-500",children:[jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4 md:mb-6",children:"Metadata"}),jsxRuntime.jsxs("div",{className:"space-y-4 md:space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Dynamic Status"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-[9px] font-bold tracking-widest ${T==="published"?"bg-green-500/10 text-green-500":"bg-amber-500/10 text-amber-500"}`,children:T||"draft"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Date Created"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:I?new Date(I).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Last Modified"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:C?new Date(C).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"}):"Just now"})]}),E&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-40",children:"Public At"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-text-secondary)]",children:new Date(E).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})})]})]})]}),jsxRuntime.jsxs("div",{className:"surface-tile p-4 md:p-8 bg-[var(--kyro-bg-secondary)]",children:[jsxRuntime.jsx("h3",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-3 md:mb-4",children:"Quick Links"}),jsxRuntime.jsxs("div",{className:"space-y-2 md:space-y-3",children:[jsxRuntime.jsx("button",{type:"button",onClick:Te,disabled:x||f,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:x?"Duplicating...":"Duplicate Document"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>window.open(`/preview/${S}/${o}`,"_blank"),className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start",children:"View Public Page"}),jsxRuntime.jsx("button",{type:"button",onClick:_e,className:"kyro-btn kyro-btn-sm kyro-btn-ghost w-full justify-start text-[var(--kyro-error)] hover:bg-[var(--kyro-danger-bg)]",children:"Delete Entry"})]})]})]})]})]})}function Ni({config:e,collection:t,onCancel:r,onSuccess:o,onError:a}){let[n,s]=Ta.useState({}),[l,i]=Ta.useState(false),d=t.fields||[],c=t.label||t.slug,p=async y=>{try{i(!0),await dt(`/api/${t.slug}`,n),L.success(`${t.singularLabel||t.label||"Document"} created`),o();}catch(g){a(g instanceof Error?g.message:"Failed to create");}finally{i(false);}};return jsxRuntime.jsxs("div",{className:"kyro-detail",children:[jsxRuntime.jsx(Lt,{back:{onClick:r},breadcrumbs:[{label:"Collections"},{label:c,href:`${Oe}/${t.slug}`},{label:"New"}],title:`Create ${t.singularLabel||c}`,action:{label:l?"Creating...":`Create ${t.singularLabel||c}`,onClick:()=>p(),disabled:l}}),jsxRuntime.jsx("div",{className:"kyro-detail-body",children:jsxRuntime.jsx("div",{className:"kyro-card",children:jsxRuntime.jsx("div",{className:"kyro-card-content",children:jsxRuntime.jsx("form",{children:jsxRuntime.jsx(Ya,{config:{...t,fields:d},data:n,onChange:s})})})})})]})}function uc({type:e,message:t,onClose:r}){let[o,a]=Ta__default.default.useState(false),n=Ta__default.default.useRef(null),s=()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(r,5e3);},l=()=>{n.current&&clearTimeout(n.current);};Ta__default.default.useEffect(()=>(o?l():s(),l),[o,r]);let i={success:Hl.CircleCheck,error:Hl.ShieldAlert,warning:Hl.TriangleAlert,info:Hl.Info}[e];return jsxRuntime.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:[jsxRuntime.jsx("div",{className:"kyro-toast-accent"}),jsxRuntime.jsx("div",{className:"kyro-toast-icon-container",children:jsxRuntime.jsx(i,{className:"w-4 h-4"})}),jsxRuntime.jsx("div",{className:"kyro-toast-content",children:jsxRuntime.jsx("p",{className:"kyro-toast-message",children:t})}),jsxRuntime.jsx("button",{type:"button",className:"kyro-toast-close group-hover:opacity-100 opacity-40 transition-opacity",onClick:r,children:jsxRuntime.jsx(Hl.X,{className:"w-3.5 h-3.5"})})]})}function qT({children:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e})}function XT(){let e=Gt(o=>o.addToast),t=Gt(o=>o.removeToast);return {toasts:Gt(o=>o.toasts),addToast:e,removeToast:t}}function cs(){let e=Gt(r=>r.toasts),t=Gt(r=>r.removeToast);return jsxRuntime.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=>jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:jsxRuntime.jsx(uc,{type:r.type,message:r.message,onClose:()=>t(r.id)})},r.id))})}function Ti({onAuth:e,theme:t="light"}){let[r,o]=Ta.useState("login"),[a,n]=Ta.useState(""),[s,l]=Ta.useState(""),[i,d]=Ta.useState(""),[c,p]=Ta.useState(false),[y,g]=Ta.useState(false),b=Gt(f=>f.addToast);Ta.useEffect(()=>{v();},[]);let v=async()=>{try{await Ae("/api/users");}catch{g(true),o("register");}};return jsxRuntime.jsx(wr,{defaultMode:t,children:jsxRuntime.jsxs("div",{className:"kyro-login-page",children:[jsxRuntime.jsxs("div",{className:"kyro-login-container",children:[jsxRuntime.jsxs("div",{className:"kyro-login-header",children:[jsxRuntime.jsx("h1",{className:"kyro-login-title",children:y?"Create Admin Account":r==="login"?"Sign In":"Create Account"}),jsxRuntime.jsx("p",{className:"kyro-login-subtitle",children:y?"Set up your admin account to get started":r==="login"?"Enter your credentials to access the admin":"Create an account to access the admin"})]}),jsxRuntime.jsxs("form",{onSubmit:async f=>{f.preventDefault(),p(true);try{let u=r==="login"?"/api/auth/login":"/api/auth/register",x={email:a,password:s};r==="register"&&(x.confirmPassword=i);let A=await dt(u,x);A.isFirstUser&&g(!0),localStorage.setItem("kyro_user",JSON.stringify(A.user)),b("success",r==="login"?"Welcome back!":"Account created!"),e(A.token,A.user);}catch{b("error","Connection failed");}finally{p(false);}},className:"kyro-login-form",children:[jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"email",children:"Email"}),jsxRuntime.jsx("input",{id:"email",type:"email",value:a,onChange:f=>n(f.target.value),placeholder:"admin@example.com",required:true,autoComplete:"email"})]}),jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"password",children:"Password"}),jsxRuntime.jsx("input",{id:"password",type:"password",value:s,onChange:f=>l(f.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:r==="login"?"current-password":"new-password"})]}),r==="register"&&jsxRuntime.jsxs("div",{className:"kyro-form-group",children:[jsxRuntime.jsx("label",{htmlFor:"confirmPassword",children:"Confirm Password"}),jsxRuntime.jsx("input",{id:"confirmPassword",type:"password",value:i,onChange:f=>d(f.target.value),placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",required:true,minLength:8,autoComplete:"new-password"})]}),jsxRuntime.jsx("button",{type:"submit",className:"kyro-btn kyro-btn-primary kyro-btn-lg",disabled:c,children:c?r==="login"?"Signing in...":"Creating account...":r==="login"?"Sign In":"Create Account"})]}),!y&&jsxRuntime.jsx("div",{className:"kyro-login-footer",children:jsxRuntime.jsx("p",{children:r==="login"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Don't have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("register"),children:"Sign up"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Already have an account?"," ",jsxRuntime.jsx("button",{type:"button",className:"kyro-login-link",onClick:()=>o("login"),children:"Sign in"})]})})})]}),jsxRuntime.jsx(cs,{})]})})}function vc({collections:e,onNavigate:t,user:r}){let{permissions:o}=_r(),[a,n]=Ta.useState({totalDocs:0,totalMedia:0,totalUsers:0,recentActivity:[]}),[s,l]=Ta.useState(true);Ta.useEffect(()=>{let d=setTimeout(()=>{n({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(d)},[]);let i=Object.entries(e).filter(([d])=>!Js.includes(d)&&o?.collections?.[d]?.read!==false);return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 px-8 pb-12",children:[jsxRuntime.jsx(Lt,{title:`Welcome back, ${r?.email?.split("@")[0]||"Admin"}`,description:"Everything looks great in your command center today.",action:i.length>0&&o?.collections?.[i[0]?.[0]]?.create!==false?{label:"New Document",onClick:()=>t("create",i[0]?.[0]),icon:Hl.Plus}:void 0}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[{label:"Total Content",value:a.totalDocs,icon:Hl.FileText,color:"text-blue-500"},{label:"Media Assets",value:a.totalMedia,icon:Hl.Image,color:"text-purple-500"},{label:"Active Users",value:a.totalUsers,icon:Hl.Users,color:"text-green-500"},{label:"System Health",value:"100%",icon:Hl.Activity,color:"text-amber-500"}].map((d,c)=>jsxRuntime.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:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40 mb-1",children:d.label}),jsxRuntime.jsx("h3",{className:"text-3xl font-bold tracking-tighter",children:s?jsxRuntime.jsx(_t,{variant:"text",className:"w-16"}):d.value})]}),jsxRuntime.jsx("div",{className:`p-3 rounded-2xl bg-[var(--kyro-bg-secondary)] group-hover:scale-110 transition-transform duration-500 ${d.color}`,children:jsxRuntime.jsx(d.icon,{className:"w-6 h-6"})})]},c))}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8",children:[jsxRuntime.jsxs("div",{className:"space-y-8 min-w-0",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-1 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Hl.LayoutDashboard,{className:"w-5 h-5 opacity-40"}),"Content Growth"]}),jsxRuntime.jsx("p",{className:"text-[10px] font-bold tracking-widest opacity-40 mb-8",children:"Snapshot of document velocity over the last 7 days"}),jsxRuntime.jsxs("div",{className:"h-48 w-full relative mb-12",children:[jsxRuntime.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 1000 200",preserveAspectRatio:"none",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"chartGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:"var(--kyro-primary)",stopOpacity:"0.3"}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:"var(--kyro-primary)",stopOpacity:"0"})]})}),jsxRuntime.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]"}),jsxRuntime.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)]"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-4 text-[10px] font-bold opacity-30 tracking-widest ",children:[jsxRuntime.jsx("span",{children:"Mon"}),jsxRuntime.jsx("span",{children:"Tue"}),jsxRuntime.jsx("span",{children:"Wed"}),jsxRuntime.jsx("span",{children:"Thu"}),jsxRuntime.jsx("span",{children:"Fri"}),jsxRuntime.jsx("span",{children:"Sat"}),jsxRuntime.jsx("span",{children:"Sun"})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:i.map(([d,c])=>jsxRuntime.jsxs("div",{onClick:()=>t("list",d),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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2",children:[jsxRuntime.jsx("h3",{className:"font-bold text-lg tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors",children:c.label||d}),jsxRuntime.jsx(Hl.ArrowUpRight,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-all"})]}),jsxRuntime.jsx("div",{className:"w-full h-1 bg-[var(--kyro-bg-secondary)] rounded-full mb-3 overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-[var(--kyro-primary)]",style:{width:`${Math.random()*60+20}%`}})}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] line-clamp-1",children:c.admin?.description||`Manage ${d} content.`})]},d))})]}),jsxRuntime.jsxs("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-6 border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-all cursor-pointer group",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-between mb-4",children:jsxRuntime.jsxs("h3",{className:"text-xl font-bold tracking-tight group-hover:text-[var(--kyro-primary)] transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Plus,{className:"w-5 h-5"}),"Quick Links"]})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[i.filter(([d])=>o?.collections?.[d]?.create!==false).map(([d])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>t("new",d),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:[jsxRuntime.jsxs("span",{className:"text-sm font-medium text-[var(--kyro-text-primary)]",children:["New ",e[d]?.singularLabel||e[d]?.label||d]}),jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4 text-[var(--kyro-text-secondary)] group-hover/btn:text-[var(--kyro-primary)]"})]},d)),i.every(([d])=>o?.collections?.[d]?.create===false)&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] py-2",children:"No collections available for creation."})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("h3",{className:"text-2xl font-bold tracking-tighter mb-2",children:"Media Library"}),jsxRuntime.jsx("p",{className:"opacity-80 text-sm font-medium mb-6",children:"Manage high-fidelity assets with our liquid masonry gallery."}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-xs tracking-widest text-blue-400",children:["Open Assets"," ",jsxRuntime.jsx(Hl.ArrowRight,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]}),jsxRuntime.jsx(Hl.Image,{className:"absolute bottom-[-20px] right-[-20px] w-48 h-48 opacity-10 rotate-12 group-hover:scale-110 transition-transform duration-1000"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Clock,{className:"w-5 h-5 opacity-40"}),"Recent Activity"]}),jsxRuntime.jsx("div",{className:"space-y-6",children:a.recentActivity.map(d=>jsxRuntime.jsxs("div",{className:"flex gap-4 group",children:[jsxRuntime.jsx("div",{className:"mt-1",children:jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[10px] font-bold",children:d.user[0]})})}),jsxRuntime.jsxs("div",{className:"flex-1 border-b border-[var(--kyro-border)] pb-4 group-last:border-none",children:[jsxRuntime.jsxs("p",{className:"text-sm font-medium text-[var(--kyro-text-primary)] leading-snug",children:[jsxRuntime.jsx("span",{className:"font-bold",children:d.user})," ",d.type==="create"?"created":d.type==="edit"?"edited":d.type==="publish"?"published":"uploaded"," ",jsxRuntime.jsxs("span",{className:"text-[var(--kyro-primary)] italic",children:['"',d.doc,'"']})," ","in ",jsxRuntime.jsx("span",{className:"opacity-60",children:d.collection})]}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 mt-1 block",children:d.time})]})]},d.id))}),jsxRuntime.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:"View Audit Logs"})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8",children:[jsxRuntime.jsxs("h2",{className:"text-xl font-bold mb-6 tracking-tight flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Activity,{className:"w-5 h-5 opacity-40"}),"System Status"]}),jsxRuntime.jsx("div",{className:"space-y-4",children:[{label:"Cloud API",status:"Optimal",pulse:"bg-green-500"},{label:"Database Node",status:"Healthy",pulse:"bg-green-500"},{label:"Media CDN",status:"Active",pulse:"bg-blue-500"},{label:"Auth Service",status:"Secure",pulse:"bg-green-500"}].map((d,c)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--kyro-bg-secondary)] rounded-2xl border border-[var(--kyro-border)]",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold text-[var(--kyro-text-secondary)]",children:d.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:d.status}),jsxRuntime.jsx("div",{className:`w-2 h-2 rounded-full ${d.pulse} animate-pulse shadow-[0_0_8px] shadow-current`})]})]},c))})]})]})]})]})}function bc(){let[e,t]=Ta.useState([]),[r,o]=Ta.useState(true),[a,n]=Ta.useState(""),[s,l]=Ta.useState(false),[i,d]=Ta.useState({name:"",email:"",password:"",role:"customer"}),[c,p]=Ta.useState(""),[y,g]=Ta.useState(false),{confirm:b,alert:v}=ut();Ta.useEffect(()=>{k();},[]);let k=async()=>{try{o(!0);let h=await Ae("/api/users");t(h.docs||[]);}catch(h){console.error("Failed to load users:",h);}finally{o(false);}},f=h=>{let w=!h.locked;b({title:w?"Lock User Account?":"Unlock User Account?",message:w?`Are you sure you want to lock ${h.email}? They will be immediately logged out and unable to return.`:`Restore system access for ${h.email}?`,variant:w?"danger":"success",onConfirm:async()=>{try{await Wt(`/api/users/${h.id}`,{locked:w}),t(m=>m.map(T=>T.id===h.id?{...T,locked:w}:T)),L.success(w?`Account locked: ${h.email}`:`Account restored: ${h.email}`);}catch(m){console.error("Failed to toggle user lock:",m),L.error("Failed to update account status");}}});},u=h=>{b({title:"Destroy User Account",message:`You are about to permanently delete ${h.email}. This will remove all their data and cannot be undone.`,variant:"danger",confirmLabel:"Destroy Account",onConfirm:async()=>{try{await wt(`/api/users/${h.id}`),t(w=>w.filter(m=>m.id!==h.id)),L.success(`Identity purged: ${h.email}`);}catch(w){console.error("Failed to delete user:",w),L.error("Failed to delete user");}}});},x=async()=>{if(!i.email.trim()||!i.password.trim()){p("Email and password are required");return}g(true),p("");try{await dt("/api/users",{name:i.name.trim()||void 0,email:i.email.trim(),password:i.password,role:i.role}),l(!1),d({name:"",email:"",password:"",role:"customer"}),L.success("User created successfully"),k();}catch(h){let w=h instanceof Error?h.message:"Failed to create user";p(w),L.error(w);}finally{g(false);}},A=["super_admin","admin","editor","author","customer","guest"],F=e.filter(h=>h.email.toLowerCase().includes(a.toLowerCase())||h.name?.toLowerCase().includes(a.toLowerCase()));return jsxRuntime.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:[jsxRuntime.jsx(Lt,{title:"Identity & Access",description:"Manage the core administrative team and security permissions.",icon:Hl.Users,action:{label:"New User",onClick:()=>{d({name:"",email:"",password:"",role:"customer"}),p(""),l(true);},icon:Hl.UserPlus}}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[jsxRuntime.jsxs("div",{className:"relative flex-1 group",children:[jsxRuntime.jsx(Hl.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"}),jsxRuntime.jsx("input",{type:"text",placeholder:"Search by identity or email...",value:a,onChange:h=>n(h.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"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 bg-[var(--kyro-surface-accent)] p-1 rounded-xl border border-[var(--kyro-border)]",children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"ADMINS"}),jsxRuntime.jsx("button",{className:"px-4 py-1.5 text-[10px] font-bold tracking-widest opacity-40 hover:opacity-100 transition-all",children:"LOCKED"})]})]}),jsxRuntime.jsx("div",{className:"surface-tile overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-left",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.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:[jsxRuntime.jsx("th",{className:"px-6 py-4 w-64",children:"Member Identity"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Administrative Role"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Security Status"}),jsxRuntime.jsx("th",{className:"px-6 py-4",children:"Last Activity"}),jsxRuntime.jsx("th",{className:"px-6 py-4 w-32 text-right",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{className:"divide-y divide-[var(--kyro-border)]",children:r?Array.from({length:6}).map((h,w)=>jsxRuntime.jsx("tr",{className:"animate-pulse",children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-5 bg-[var(--kyro-surface-accent)]/30"})},w)):F.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:5,className:"px-6 py-20 text-center",children:jsxRuntime.jsx("p",{className:"text-xs font-bold opacity-30 tracking-widest uppercase italic",children:"No identity matches found"})})}):F.map(h=>jsxRuntime.jsxs("tr",{className:`hover:bg-[var(--kyro-surface-accent)]/50 transition-colors group ${h.locked?"opacity-50 grayscale":""}`,children:[jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Cy,{user:h}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs font-bold text-[var(--kyro-text-primary)] truncate",children:h.name||h.email.split("@")[0]}),h.tenantId&&jsxRuntime.jsx(At,{variant:"outline",className:"text-[7px] px-1 py-0 border-none bg-[var(--kyro-surface-accent)] opacity-50",children:h.tenantId})]}),jsxRuntime.jsx("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50 truncate",children:h.email})]})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Shield,{className:"w-3.5 h-3.5 opacity-30"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest uppercase opacity-70",children:h.role})]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsx(At,{variant:h.locked?"danger":"success",dot:true,className:"text-[8px] font-bold uppercase tracking-widest",children:h.locked?"Restricted":"Authorized"})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-[var(--kyro-text-secondary)] opacity-50 uppercase tabular-nums",children:[jsxRuntime.jsx(Hl.Clock,{className:"w-3 h-3"}),h.lastLogin?new Date(h.lastLogin).toLocaleDateString():"Never"]})}),jsxRuntime.jsx("td",{className:"px-6 py-3.5 text-right",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[jsxRuntime.jsx("button",{onClick:()=>f(h),className:`p-1.5 rounded-lg border transition-all ${h.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:h.locked?"Restore Access":"Restrict Access",children:h.locked?jsxRuntime.jsx(Hl.LockOpen,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Hl.Lock,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{onClick:()=>u(h),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:"Delete User",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5"})})]})})]},h.id))})]})}),jsxRuntime.jsxs(Nt,{open:s,onClose:()=>l(false),title:"Create User",size:"lg",children:[jsxRuntime.jsx(Br,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Name (optional)"}),jsxRuntime.jsx("input",{type:"text",value:i.name,onChange:h=>d({...i,name:h.target.value}),placeholder:"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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Email Address"}),jsxRuntime.jsx("input",{type:"email",value:i.email,onChange:h=>d({...i,email:h.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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Password"}),jsxRuntime.jsx("input",{type:"password",value:i.password,onChange:h=>d({...i,password:h.target.value}),placeholder:"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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Role"}),jsxRuntime.jsx("select",{value:i.role,onChange:h=>d({...i,role:h.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:A.map(h=>jsxRuntime.jsx("option",{value:h,children:h},h))})]}),c&&jsxRuntime.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:[jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-4 h-4"}),c]})]})}),jsxRuntime.jsxs(Gr,{children:[jsxRuntime.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"}),jsxRuntime.jsx("button",{type:"button",onClick:x,disabled:y,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:y?"Creating...":"Create User"})]})]})]})}function Cy({user:e}){let[t,r]=Ta.useState(null);return Ta.useEffect(()=>{let o=e.avatar;typeof o=="string"&&/^[0-9a-f-]+$/i.test(o)&&Ae(`/api/media/${o}`).then(a=>r(a?.thumbnailUrl||a?.url||null)).catch(()=>r(null));},[e.avatar]),t?jsxRuntime.jsx("div",{className:"w-8 h-8 rounded-lg overflow-hidden border border-[var(--kyro-border)] flex-shrink-0",children:jsxRuntime.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"})}):jsxRuntime.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 xc(){let[e,t]=Ta.useState("Kyro CMS"),[r,o]=Ta.useState("Command Center"),[a,n]=Ta.useState("#6366f1"),[s,l]=Ta.useState("Welcome back to your Command Center."),[i,d]=Ta.useState(false),[c,p]=Ta.useState(false);return Ta.useEffect(()=>{(async()=>{try{let v=await Ae("/api/globals/site-settings"),k=v.data||v;k&&Object.keys(k).length>0&&(k.siteName&&t(k.siteName),k.adminTitle&&o(k.adminTitle),k.primaryColor&&n(k.primaryColor),k.dashboardGreeting&&l(k.dashboardGreeting));}catch(v){console.error("Failed to load branding:",v);}})();},[]),jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 pt-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h1",{className:"text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]",children:["Branding ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Hub"})]}),jsxRuntime.jsx("p",{className:"text-[var(--kyro-text-secondary)] mt-1 font-medium opacity-60",children:"Customize the identity and aesthetic of your administrative ecosystem."})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:jsxRuntime.jsxs("button",{type:"button",onClick:async()=>{d(true);try{await Wt("/api/globals/site-settings",{siteName:e,adminTitle:r,primaryColor:a,dashboardGreeting:s}),p(!0),L.success("Branding updated"),document.documentElement.style.setProperty("--kyro-primary",a),setTimeout(()=>window.location.reload(),800);}catch(b){L.error("Failed to save branding"),console.error(b);}finally{d(false);}},disabled:i,className:`flex items-center gap-2 px-8 py-3 rounded-2xl font-bold text-sm shadow-xl transition-all active:scale-95 ${c?"bg-green-500 text-white":"kyro-btn-primary hover:shadow-[var(--kyro-primary)]"}`,children:[i?jsxRuntime.jsx(Hl.RefreshCcw,{className:"w-4 h-4 animate-spin"}):c?jsxRuntime.jsx(Hl.Check,{className:"w-4 h-4"}):jsxRuntime.jsx(Hl.Save,{className:"w-4 h-4"}),i?"Saving...":c?"Identity Updated":"Publish Branding"]})})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Hl.Tag,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Core Identity"})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Site Public Name"}),jsxRuntime.jsx("input",{type:"text",value:e,onChange:b=>t(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"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Admin Dashboard Title"}),jsxRuntime.jsx("input",{type:"text",value:r,onChange:b=>o(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"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"System Greeting"}),jsxRuntime.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:"Greeting text for the dashboard..."})]})]})]}),jsxRuntime.jsxs("section",{className:"surface-tile p-8 space-y-8",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[jsxRuntime.jsx(Hl.Palette,{className:"w-5 h-5 text-[var(--kyro-primary)]"}),jsxRuntime.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Visual Aesthetic"})]}),jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Primary Brand Color"}),jsxRuntime.jsx("div",{className:"grid grid-cols-6 gap-3",children:[{name:"Indigo",hex:"#6366f1"},{name:"Emerald",hex:"#10b981"},{name:"Rose",hex:"#f43f5e"},{name:"Amber",hex:"#f59e0b"},{name:"Sky",hex:"#0ea5e9"},{name:"Violet",hex:"#8b5cf6"}].map(b=>jsxRuntime.jsx("button",{type:"button",onClick:()=>n(b.hex),className:`aspect-square rounded-xl transition-all border-4 ${a===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))})]}),jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 border-t border-[var(--kyro-border)]",children:[jsxRuntime.jsx("label",{className:"text-[10px] font-bold tracking-[0.2em] opacity-40",children:"Project Logo (SVG/PNG)"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6",children:[jsxRuntime.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:[jsxRuntime.jsx(Hl.Image,{className:"w-6 h-6 mb-1 opacity-40"}),jsxRuntime.jsx("span",{className:"text-[8px] font-bold ",children:"Upload"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-bold mb-1",children:"Upload global CMS logo"}),jsxRuntime.jsx("p",{className:"text-[10px] opacity-40 leading-relaxed",children:"This will replace the Kyro brand in the sidebar and login screens."})]})]})]})]})]}),jsxRuntime.jsxs("section",{className:"lg:col-span-2 surface-tile p-8 overflow-hidden relative group",children:[jsxRuntime.jsxs("div",{className:"absolute top-0 right-0 p-8 flex items-center gap-2 text-[var(--kyro-primary)]",children:[jsxRuntime.jsx(Hl.Sparkles,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold tracking-widest",children:"Live Preview"})]}),jsxRuntime.jsxs("div",{className:"max-w-2xl mx-auto py-12 text-center space-y-6",children:[jsxRuntime.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:[jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),jsxRuntime.jsxs("span",{className:"text-[10px] font-bold tracking-widest opacity-60",children:[r," Online"]})]}),jsxRuntime.jsxs("h2",{className:"text-5xl font-bold tracking-tighter leading-none italic",children:["Welcome to ",e,"."]}),jsxRuntime.jsx("p",{className:"text-xl font-medium text-[var(--kyro-text-secondary)] opacity-60",children:s})]}),jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:`
100
100
  :root {
101
101
  --kyro-primary-temp: ${a};
102
102
  }
103
103
  .preview-btn {
104
104
  background-color: var(--kyro-primary-temp);
105
105
  }
106
- `}})]})]})]})}var ry=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function tc({collections:e}){let[t,r]=Ca.useState([]),[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),[l,i]=Ca.useState(""),[d,c]=Ca.useState(null),[m,f]=Ca.useState(false),{confirm:v,alert:b}=dt(),[g,x]=Ca.useState(false),[u,y]=Ca.useState(""),h=async()=>{try{let p=await Be("/api/keys");r(p);}catch(p){console.error(p);}};Ca.useEffect(()=>{h();},[]);let R=async()=>{y(""),x(true);},P=async()=>{if(u.trim())try{await nt("/api/keys",{name:u}),h(),x(!1),y(""),M.success("API key generated");}catch(p){console.error(p),M.error("Failed to generate API key");}},w=p=>{v({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 xt(`/api/keys/${p}`),h(),M.success("API key revoked");}catch(T){console.error(T),M.error("Failed to revoke API key");}}});},k=async()=>{if(l){f(true);try{let T=await(await fetch(tt(`/api/${l}`))).json();c(T);}catch{c({error:"Failed to fetch. Ensure the endpoint exists."});}finally{f(false);}}};return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Dt,{title:"Developer Center",description:"Provision access keys and explore the headless API ecosystem.",icon:lucideReact.CodeXml,actions:[{label:"Generate Key",onClick:R,icon:lucideReact.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:t.length===0?jsxRuntime.jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx(lucideReact.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):t.map(p=>jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(lucideReact.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:p.name})]}),jsxRuntime.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:[jsxRuntime.jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:n===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"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(n===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:n===p.id?jsxRuntime.jsx(lucideReact.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"})}),jsxRuntime.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),M.success("API key copied to clipboard");},children:jsxRuntime.jsx(lucideReact.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(p.createdAt).toLocaleDateString()})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Status:"}),jsxRuntime.jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>w(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:"Revoke Key",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-5 h-5"})})]})},p.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(lucideReact.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.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."}),jsxRuntime.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",jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(lucideReact.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")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(lucideReact.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")})]})]})]})]})]})]}),jsxRuntime.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:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(lucideReact.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.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."})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",ry,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:p=>i(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)]"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:k,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?jsxRuntime.jsx(lucideReact.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),d?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsxRuntime.jsx(Zu__default.default,{value:JSON.stringify(d,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx(lucideReact.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(Ot,{open:g,onClose:()=>x(false),title:"Generate Access Token",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.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."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:u,onChange:p=>y(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"&&P()})]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>x(false),className:"px-6 py-3 rounded-xl font-bold text-sm border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:bg-[var(--kyro-surface-accent)] transition-all",children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",onClick:P,className:"kyro-btn kyro-btn-primary px-8 py-3 rounded-xl font-bold text-sm hover:opacity-90 shadow-lg shadow-[var(--kyro-primary)]/20 transition-all",children:"Generate Token"})]})]})]})}function rc(e){let[t,r]=Ca.useState([]),[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),[l,i]=Ca.useState(false),{confirm:d}=dt(),c=Ca.useCallback(async()=>{a(true),s(null);try{let b=await Be(e.endpoint),g=Array.isArray(b)?b:b.docs||[],x=e.transformLoad?e.transformLoad(g):g;r(x),e.onSuccess?.("load",x);}catch(b){let g=b instanceof Error?b.message:"Failed to load resources";s(g),e.onError?.("load",b);}finally{a(false);}},[e.endpoint,e.transformLoad]);Ca.useEffect(()=>{c();},[c]);let m=Ca.useCallback((b,g="item")=>{d({title:`Delete ${g}`,message:`Are you sure you want to delete this ${g.toLowerCase()}? This action cannot be undone.`,variant:"danger",onConfirm:async()=>{try{await xt(`${e.endpoint}/${b}`),r(x=>x.filter(u=>u.id!==b)),e.onSuccess?.("delete",b),M.success(`${g} deleted`);}catch(x){let u=x instanceof Error?x.message:`Failed to delete ${g}`;M.error(u),e.onError?.("delete",x);}}});},[e.endpoint,d]),f=Ca.useCallback(async b=>{s(null);try{let g=await nt(e.endpoint,b);return r(x=>[g,...x]),i(!1),e.onSuccess?.("create",g),g}catch(g){let x=g instanceof Error?g.message:"Failed to create resource";throw s(x),e.onError?.("create",g),g}},[e.endpoint]),v=Ca.useCallback(async(b,g)=>{s(null);try{let x=await Gt(`${e.endpoint}/${b}`,g);return r(u=>u.map(y=>y.id===b?x:y)),e.onSuccess?.("update",x),x}catch(x){let u=x instanceof Error?x.message:"Failed to update resource";throw s(u),e.onError?.("update",x),x}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:m,create:f,update:v,isCreateModalOpen:l,setIsCreateModalOpen:i}}function oc(){let{items:e,loading:t,create:r,remove:o,update:a,isCreateModalOpen:n,setIsCreateModalOpen:s}=rc({endpoint:"/api/webhooks"}),{confirm:l}=dt(),[i,d]=Ca.useState(false),[c,m]=Ca.useState(false),[f,v]=Ca.useState(null),[b,g]=Ca.useState(null),[x,u]=Ca.useState({name:"",url:"",events:[],secret:""}),[y,h]=Ca.useState(""),R=async()=>{if(!x.name.trim()||!x.url.trim()){h("Name and URL are required");return}try{await r(x),u({name:"",url:"",events:[],secret:""}),M.success(`Webhook established: ${x.name}`);}catch{h("Failed to create webhook"),M.error("Failed to create webhook");}},P=async p=>{g(p),v(null),d(true);try{let T=await nt(`/api/webhooks/${p}/test`);v({success:!0,message:T.message||"Webhook triggered successfully"}),M.success("Dispatch verified: Remote endpoint responded");}catch{v({success:false,message:"Failed to trigger webhook"});}},w=async(p,T)=>{try{let B=T==="active"?"paused":"active";await a(p,{status:B}),M.success(B==="active"?"Signals resumed":"Dispatcher paused");}catch(B){console.error(B),M.error("Failed to toggle webhook status");}},k=[{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"}];return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Dt,{title:"Webhooks",description:"Receive real-time notifications when your content changes.",icon:lucideReact.Webhook,actions:[{label:"Create Webhook",onClick:()=>{u({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:""}),h(""),s(true);},icon:lucideReact.Plus},{label:"Guide",onClick:()=>m(true),icon:lucideReact.Info,variant:"outline"}]}),jsxRuntime.jsxs("div",{className:"relative overflow-hidden rounded-[2rem] border border-[var(--kyro-border)] bg-gradient-to-br from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] p-8",children:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-[0.03] pointer-events-none",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-64 h-64 rotate-12"})}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-8 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-5 bg-gradient-to-br from-[var(--kyro-primary)] to-[var(--kyro-primary)]/50 rounded-[1.5rem] shadow-xl shadow-[var(--kyro-primary)]/20",children:jsxRuntime.jsx(lucideReact.Zap,{className:"w-8 h-8 text-white"})}),jsxRuntime.jsxs("div",{className:"flex-1 text-center md:text-left",children:[jsxRuntime.jsx("h3",{className:"text-xl font-bold mb-2",children:"Real-time Event Synchronization"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70 max-w-2xl leading-relaxed",children:"Webhooks allow your application to receive instant HTTP notifications when events happen in your CMS. Eliminate polling and build responsive, event-driven architectures with ease."})]}),jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Collections"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"Triggered"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center px-4 py-2 bg-[var(--kyro-surface)]/50 border border-[var(--kyro-border)] rounded-2xl",children:[jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 uppercase tracking-tighter",children:"Latency"}),jsxRuntime.jsx("span",{className:"text-sm font-bold text-[var(--kyro-primary)]",children:"<200ms"})]})]})]})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40",children:"ACTIVE ENDPOINTS"})]}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-40 uppercase",children:[e.length," Hook",e.length!==1&&"s"]})]}),t?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 surface-tile rounded-3xl opacity-50 italic",children:"Connecting to dispatcher..."}):e.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-[3rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx("div",{className:"w-20 h-20 mx-auto mb-6 bg-gradient-to-tr from-[var(--kyro-surface)] to-[var(--kyro-surface-accent)] rounded-3xl flex items-center justify-center shadow-xl border border-[var(--kyro-border)]",children:jsxRuntime.jsx(lucideReact.Webhook,{className:"w-10 h-10 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-2xl font-bold mb-3",children:"No Webhooks Found"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-60 mb-8 max-w-sm mx-auto",children:"Your CMS is currently silent. Create a webhook to start broadcasting events to your external services."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(true),className:"kyro-btn kyro-btn-primary inline-flex items-center gap-3 px-8 py-4 rounded-2xl font-bold hover:scale-[1.05] transition-all shadow-xl shadow-[var(--kyro-primary)]/10",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"w-5 h-5"}),"Configure Webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:e.map(p=>jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(lucideReact.Webhook,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors",children:p.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-2 h-2 rounded-full ${p.status==="active"?"bg-green-500 animate-pulse":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-bold uppercase tracking-wider ${p.status==="active"?"text-green-500":"text-amber-500"}`,children:p.status})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6 pt-2",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs opacity-60 truncate max-w-[200px]",title:p.url,children:p.url})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[p.events.slice(0,2).map(T=>jsxRuntime.jsx(Pt,{variant:"outline",className:"text-[8px] font-bold px-1.5 opacity-60",children:T},T)),p.events.length>2&&jsxRuntime.jsxs("span",{className:"text-[8px] font-bold opacity-30",children:["+",p.events.length-2," more"]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 sm:border-l border-t sm:border-t-0 border-[var(--kyro-border)] pt-4 sm:pt-0 sm:pl-6 mt-4 sm:mt-0",children:[jsxRuntime.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest opacity-30",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] font-bold opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3"}),p.lastTriggered?`Last triggered: ${new Date(p.lastTriggered).toLocaleDateString()}`:"Never triggered"]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 lg:bg-[var(--kyro-surface-accent)]/50 lg:p-2 lg:rounded-2xl lg:opacity-0 group-hover:opacity-100 transition-all duration-300 lg:translate-x-4 group-hover:translate-x-0",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>P(p.id),className:"flex-1 lg:flex-none p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all flex items-center justify-center gap-2",title:"Send test request",children:[jsxRuntime.jsx(lucideReact.Send,{className:"w-4 h-4"}),jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Test"})]}),jsxRuntime.jsx("div",{className:"w-px h-6 bg-[var(--kyro-border)] mx-1 hidden lg:block"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>w(p.id,p.status),className:`p-3 bg-[var(--kyro-surface)] border border-[var(--kyro-border)] rounded-xl hover:border-[var(--kyro-primary)] transition-all group/toggle ${p.status==="active"?"text-amber-500/50 hover:text-amber-500":"text-green-500/50 hover:text-green-500"}`,title:p.status==="active"?"Pause webhook":"Activate webhook",children:p.status==="active"?jsxRuntime.jsx(lucideReact.Pause,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.Play,{className:"w-4 h-4"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(p.id,"Webhook"),className:"p-3 bg-red-500/5 border border-red-500/10 rounded-xl hover:bg-red-500/10 hover:border-red-500/30 transition-all group/delete",title:"Delete webhook",children:jsxRuntime.jsx(lucideReact.Trash2,{className:"w-4 h-4 text-red-500/50 group-hover/delete:text-red-500"})})]})]})},p.id))})]}),jsxRuntime.jsxs(Ot,{open:n,onClose:()=>s(false),title:"Register Webhook",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Webhook Name"}),jsxRuntime.jsx("input",{type:"text",value:x.name,onChange:p=>u({...x,name:p.target.value}),placeholder:"e.g., Slack Notifications",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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Payload URL"}),jsxRuntime.jsx("input",{type:"url",value:x.url,onChange:p=>u({...x,url:p.target.value}),placeholder:"https://your-server.com/webhook",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)]"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Signing Secret"}),jsxRuntime.jsx("input",{type:"text",value:x.secret,onChange:p=>u({...x,secret:p.target.value}),placeholder:"Optional secret for verification",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)]"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("label",{className:"block text-xs font-bold mb-1.5 text-[var(--kyro-text-secondary)] uppercase tracking-wider",children:"Subscribed Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:k.map(p=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let T=x.events.includes(p.value)?x.events.filter(B=>B!==p.value):[...x.events,p.value];u({...x,events:T});},className:`flex items-center gap-3 p-3 rounded-lg border transition-all text-left ${x.events.includes(p.value)?"bg-[var(--kyro-primary)]/5 border-[var(--kyro-primary)]/30 text-[var(--kyro-primary)]":"bg-[var(--kyro-surface-accent)]/50 border-[var(--kyro-border)] hover:border-[var(--kyro-primary)]/30"}`,children:[jsxRuntime.jsx("div",{className:`w-4 h-4 rounded flex items-center justify-center border transition-all ${x.events.includes(p.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:x.events.includes(p.value)&&jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-3 h-3 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-bold",children:p.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-50",children:p.description})]})]},p.value))})]})]}),y&&jsxRuntime.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:[jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-4 h-4"}),y]})]})}),jsxRuntime.jsxs(Vr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(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"}),jsxRuntime.jsx("button",{type:"button",onClick:R,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",children:"Create Webhook"})]})]}),jsxRuntime.jsxs(Ot,{open:i,onClose:()=>d(false),title:"Webhook Test Dispatcher",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsx("div",{className:"p-8 rounded-[2rem] bg-[var(--kyro-surface-accent)]/30 border border-[var(--kyro-border)] text-center",children:f?jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsx("div",{className:`w-16 h-16 mx-auto rounded-2xl flex items-center justify-center shadow-xl ${f.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:f.success?jsxRuntime.jsx(lucideReact.CircleCheck,{className:"w-8 h-8"}):jsxRuntime.jsx(lucideReact.TriangleAlert,{className:"w-8 h-8"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-2",children:f.success?"Dispatch Successful":"Dispatch Failed"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-70",children:f.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-6 py-4",children:[jsxRuntime.jsx(lucideReact.RefreshCw,{className:"w-12 h-12 text-[var(--kyro-primary)] animate-spin mx-auto opacity-50"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-xl font-bold mb-1",children:"Synthesizing Payload"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50 italic",children:"Dispatching to remote endpoint..."})]})]})})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>d(false),className:"w-full py-3 rounded-xl font-bold text-sm bg-[var(--kyro-surface-accent)] border border-[var(--kyro-border)] hover:bg-[var(--kyro-surface)] transition-all",children:"Acknowledge"})})]}),jsxRuntime.jsxs(Ot,{open:c,onClose:()=>m(false),title:"Webhook Integration Guide",size:"lg",children:[jsxRuntime.jsx(Hr,{children:jsxRuntime.jsxs("div",{className:"space-y-8",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.ExternalLink,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Request Context"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["When an event triggers, Kyro sends a standard ",jsxRuntime.jsx("span",{className:"font-bold text-[var(--kyro-text-primary)]",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-6 rounded-3xl bg-[var(--kyro-surface-accent)]/50 border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"font-bold mb-3 flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Shield,{className:"w-4 h-4 text-[var(--kyro-primary)]"}),"Security Verification"]}),jsxRuntime.jsxs("p",{className:"text-sm text-[var(--kyro-text-secondary)] leading-relaxed",children:["If a secret is provided, each request includes an ",jsxRuntime.jsx("span",{className:"font-mono text-[var(--kyro-primary)]",children:"X-Kyro-Signature"})," header. Always verify this signature in production environments."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h4",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Payload Architecture"}),jsxRuntime.jsxs("div",{className:"relative group",children:[jsxRuntime.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-[var(--kyro-primary)]/20 to-transparent rounded-2xl blur opacity-25 group-hover:opacity-50 transition-all"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] rounded-2xl border border-[var(--kyro-border)] p-6 font-mono text-sm overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-4 border-b border-[var(--kyro-border)] pb-4 opacity-30",children:[jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500/50"}),jsxRuntime.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500/50"}),jsxRuntime.jsx("span",{className:"text-[10px] ml-2 tracking-tighter",children:"payload.json"})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"{"}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"products"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"id"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"prod_8273"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-4",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-05-14T02:53:22Z"'})]}),jsxRuntime.jsx("div",{className:"text-[var(--kyro-text-secondary)]",children:"}"})]})]})]})]})]})}),jsxRuntime.jsx(Vr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>m(false),className:"kyro-btn kyro-btn-primary w-full py-3 rounded-xl font-bold text-sm hover:opacity-90 transition-all shadow-lg shadow-[var(--kyro-primary)]/20",children:"I Understand"})})]})]})}function sc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{user:n,permissions:s}=Ur(),[l,i]=Ca.useState(""),[d,c]=Ca.useState(0),[m,f]=Ca.useState(false),[v,b]=Ca.useState([]),g=Ca.useRef(null),x=Ca.useRef(null);Ca.useEffect(()=>{e&&(i(""),c(0),b([]),f(false),setTimeout(()=>g.current?.focus(),100));},[e]);let u=Ca.useCallback(async A=>{if(!A||A.length<2){b([]);return}f(true);try{let K=await(await fetch(tt(`/api/search?q=${encodeURIComponent(A)}&limit=15`))).json();K.results&&b(K.results);}catch(X){console.error("Search error:",X),b([]);}finally{f(false);}},[]);if(Ca.useEffect(()=>(x.current&&clearTimeout(x.current),l.length>=2?x.current=setTimeout(()=>u(l),300):b([]),()=>{x.current&&clearTimeout(x.current);}),[l,u]),!e)return null;let y=Object.entries(r).filter(([A])=>s?.collections?.[A]?.read!==false).map(([A,X])=>({id:`col-${A}`,label:X.label||A,type:"collection",slug:A,icon:lucideReact.FileText})),h=Object.entries(o).filter(([A])=>s?.globals?.[A]?.read!==false).map(([A,X])=>({id:`global-${A}`,label:X.label||A,type:"global",slug:A,icon:lucideReact.Settings})),R=typeof document<"u"&&document.documentElement.classList.contains("dark"),P=n?.role==="admin",w=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:lucideReact.Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:lucideReact.Clock,visible:P},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:lucideReact.File,visible:P},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:lucideReact.Shield,visible:P},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:lucideReact.Database,visible:P},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:lucideReact.Hexagon,visible:P},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:lucideReact.Network,visible:P},{id:"action-theme",label:R?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:R?lucideReact.Sun:lucideReact.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:lucideReact.LogOut,visible:true}].filter(A=>A.visible),k=v.map((A,X)=>({id:`doc-${A.collection}-${A.id}`,label:A.title,type:"document",collection:A.collection,label2:A.label,docId:A.id,icon:lucideReact.File,doc:A.doc})),p=l.length>=2?[...w,...y,...h,...k]:[...w,...y,...h],T=l===""?p:p.filter(A=>A.label.toLowerCase().includes(l.toLowerCase())),B=A=>{if(A.key==="ArrowDown")A.preventDefault(),c(X=>(X+1)%T.length);else if(A.key==="ArrowUp")A.preventDefault(),c(X=>(X-1+T.length)%T.length);else if(A.key==="Enter"){let X=T[d];X&&S(X);}else A.key==="Escape"&&t();},S=A=>{A.type==="collection"?A.slug==="users"?a(A.slug,A.slug):a("list",A.slug):A.type==="global"?a("settings",A.slug):A.type==="document"?A.collection==="users"?a("users","users",A.docId):a("edit",A.collection,A.docId):A.type==="action"&&(A.view==="users"?a("users","users"):A.view==="media"?a("media","media"):a(A.view,A.view)),t();},F=()=>l===""?"Quick Actions & Collections":v.length>0?"Documents":m?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[m?jsxRuntime.jsx(lucideReact.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(lucideReact.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:g,placeholder:"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:A=>i(A.target.value),onKeyDown:B}),jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:T.length>0?jsxRuntime.jsxs("div",{className:"space-y-1 px-4",children:[jsxRuntime.jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:F()}),T.map((A,X)=>jsxRuntime.jsxs("div",{onClick:()=>S(A),onMouseEnter:()=>c(X),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${X===d?"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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${X===d?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(A.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:A.label}),A.type==="document"&&A.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${X===d?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:A.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${X===d?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:A.type}),X===d&&jsxRuntime.jsx(lucideReact.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},A.id))]}):jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.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..."})})}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsxRuntime.jsx("div",{children:"Kyro Universal Search"})]})]})]})}function ic(){let{modal:e,closeModal:t}=dt(),[r,o]=Ca.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(l){console.error("Modal confirm action failed:",l);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Ns,{open:e.open,onClose:s,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function iy({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Ca.useState(false),[n,s]=Ca.useState(null),l=Ca.useMemo(()=>Mn(Ba(e.collections)),[e.collections]),i=Ca.useMemo(()=>En(Ba(e.globals)),[e.globals]),[d,c]=Ca.useState(null),[m,f]=Ca.useState(null),[v,b]=Ca.useState("list"),[g,x]=Ca.useState(null),[u,y]=Ca.useState(false);Ca.useEffect(()=>{(async()=>{try{let k=await fetch("/api/users/me");if(k.ok){let p=await k.json();s(p),a(!0);}}catch(k){console.error("Auth check failed",k);}})();},[]),Ca.useEffect(()=>{if(o&&!d){let w=Object.keys(l)[0];w&&c(w);}},[o,l,d]);let h=(w,k=null,p=null)=>{b(w),k&&c(k),p&&x(p),y(false);};Ca.useEffect(()=>{let w=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),y(p=>!p));};return window.addEventListener("keydown",w),window.openCommandPalette=()=>y(true),()=>{window.removeEventListener("keydown",w),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(hr,{mode:t,onChange:r,children:jsxRuntime.jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("div",{className:"flex h-screen overflow-hidden",children:jsxRuntime.jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxRuntime.jsx(sc,{isOpen:u,onClose:()=>y(false),collections:l,globals:i,onNavigate:h}),(()=>{let w=d?l[d]:null;switch(v){case "create":return w?jsxRuntime.jsx(di,{config:e,collection:w,onSuccess:()=>b("list"),onCancel:()=>b("list"),onError:k=>M.error(k)}):null;case "detail":return w&&g?jsxRuntime.jsx(li,{config:e,collection:w,documentId:g,onBack:()=>b("list"),onSave:()=>{},onError:k=>M.error(k)}):null;case "users":return jsxRuntime.jsx(Zd,{});case "media":return jsxRuntime.jsx(Nn,{});case "branding":return jsxRuntime.jsx(ec,{});case "developer":return jsxRuntime.jsx(tc,{collections:l});case "webhooks":return jsxRuntime.jsx(oc,{});default:return w?jsxRuntime.jsx(ks,{config:e,collection:w,onCreate:()=>b("create"),onEdit:k=>h("detail",d,k)}):jsxRuntime.jsx(Yd,{onNavigate:h,collections:l,user:n})}})()]})})}),jsxRuntime.jsx(ic,{}),jsxRuntime.jsx(qn,{})]})}):jsxRuntime.jsx(mi,{onAuth:(w,k)=>{s(k),a(true);},theme:t})}function ly({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxRuntime.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(vs,{count:e}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsxRuntime.jsx(So,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(jt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function vy({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:l=false}){let i=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime())){let f=Date.parse(c);return isNaN(f)?"Invalid date":new Date(f).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"})},d=c=>{if(!c)return "Unknown date";let m=new Date(c);if(isNaN(m.getTime()))return i(c);let v=new Date().getTime()-m.getTime();if(v<0)return "Just now";let b=Math.floor(v/6e4),g=Math.floor(v/36e5),x=Math.floor(v/864e5);return b<1?"Just now":b<60?`${b}m ago`:g<24?`${g}h ago`:x<7?`${x}d ago`:i(c)};return jsxRuntime.jsx(dr,{open:e,onClose:t,title:"Version History",width:"md",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(kr,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(lucideReact.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(c=>{let m=c.id===o;return jsxRuntime.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&&jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${c.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:[c.status==="published"&&jsxRuntime.jsx(lucideReact.CheckCircle2,{className:"w-3 h-3"}),c.status==="published"?"Published":"Draft"]}),jsxRuntime.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",c.version]}),m&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),d(c.createdAt)]}),c.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(lucideReact.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:c.createdBy.name||c.createdBy.email})]}),c.changelog&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',c.changelog,'"']})]}),jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Preview this version",children:jsxRuntime.jsx(lucideReact.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(c,r.find(f=>f.id===o)||c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Compare with current",children:jsxRuntime.jsx(lucideReact.GitCompare,{className:"w-4 h-4"})}),!m&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(c),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:"Restore this version",children:jsxRuntime.jsx(lucideReact.Undo2,{className:"w-4 h-4"})})]})]})]},c.id)})})})}function gA({title:e,onMenuClick:t,actions:r}){return jsxRuntime.jsxs("header",{className:"kyro-header",children:[jsxRuntime.jsxs("div",{className:"kyro-header-left",children:[jsxRuntime.jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsxRuntime.jsx("h1",{className:"kyro-header-title",children:e})]}),jsxRuntime.jsxs("div",{className:"kyro-header-right",children:[r,jsxRuntime.jsx("div",{className:"kyro-header-user",children:jsxRuntime.jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"8",r:"4"}),jsxRuntime.jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var nr={ready:[],beforeDeploy:[],afterDeploy:[]};function ts(e){return nr.ready.push(e),()=>{nr.ready=nr.ready.filter(t=>t!==e);}}function cc(e){return nr.beforeDeploy.push(e),()=>{nr.beforeDeploy=nr.beforeDeploy.filter(t=>t!==e);}}function pc(e){return nr.afterDeploy.push(e),()=>{nr.afterDeploy=nr.afterDeploy.filter(t=>t!==e);}}async function mc(e){let t=[];for(let r of nr.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 uc(e){let t=[];for(let r of nr.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 yc(e,t){for(let r of nr.afterDeploy)try{await r(e,t);}catch{}}function vc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function gc(e,t={}){let[r,o]=Ca.useState(null),[a,n]=Ca.useState(true),[s,l]=Ca.useState(null),i=Ca.useCallback(async()=>{n(true),l(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=`${vc(`/api/${e}`)}?${d.toString()}`,m=await fetch(c,{credentials:"include"});if(!m.ok)throw new Error(`HTTP ${m.status}: ${m.statusText}`);let f=await m.json();o(f.data??f);}catch(d){l(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Ca.useEffect(()=>{i();},[i]),{data:r,loading:a,error:s,refetch:i}}function bc(e,t="POST"){let[r,o]=Ca.useState(false),[a,n]=Ca.useState(null);return {mutate:Ca.useCallback(async l=>{o(true),n(null);try{let i=vc(`/api/${e}`),d=await fetch(i,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(i){return n(i instanceof Error?i.message:String(i)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var la=new Map;function da(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 xc(e){la.delete(e);}function kc(e){return la.get(e)}function hc(){return Array.from(la.values())}function wc(e){return Array.from(la.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var by={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};da(by);var xy={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};da(xy);var ca=new Map;function pa(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");ca.set(e.id,e);}function Nc(e){ca.delete(e);}function Cc(e){return ca.get(e)}function Sc(){return Array.from(ca.values())}function Tc(e){return Array.from(ca.values()).filter(t=>t.category===e)}function Rc(e){let t=ca.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var ky=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsxRuntime.jsx("strong",{children:"Sample Block"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},hy={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:ky};pa(hy);var Ny=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsxRuntime.jsx("strong",{children:"Sample Block 2"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},Cy={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Ny};pa(Cy);var ma=new Map;function ua(e){if(!e.id||typeof e.id!="string")throw new Error("Field must have a valid id");if(!e.type||typeof e.type!="string")throw new Error("Field must have a valid type");ma.set(e.id,e);}function Dc(e){ma.delete(e);}function Pc(e){return ma.get(e)}function Ic(){return Array.from(ma.values())}function Bc(e){return Array.from(ma.values()).find(t=>t.type===e)}function Lc(e,t){let r=ma.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var Ry=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample text"}),Ay={id:"sample-text",type:"text",label:"Sample Text",editor:Ry};ua(Ay);var Dy=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample textarea"}),Py={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:Dy};ua(Py);var Mc=yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/shim");yr__default.default.join(Mc,"use-sync-external-store.js");yr__default.default.join(Mc,"use-sync-external-store-with-selector.js");function $y(e={}){let{basePath:t="/admin",apiPath:r="/api",configPath:o="kyro.config.ts"}=e;return {name:"@kyro-cms/admin",hooks:{"astro:config:setup":async({config:a,updateConfig:n,injectRoute:s,logger:l})=>{l.info(`Kyro Admin mounted at ${t} (API: ${r})`);let i=yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/default-kyro-config.ts"),d=yr__default.default.resolve(a.root.pathname,"..",o),c=yr__default.default.resolve(a.root.pathname,o),m=Do__default.default.existsSync(d)?d:Do__default.default.existsSync(c)?c:i;m!==i?l.info(`Loaded config from ${m}`):l.warn("Config file not found. Using defaults.");let f=yr__default.default.join(yr__default.default.dirname(m),".kyro-admin-config.json"),v="";try{let g=yr__default.default.join(yr__default.default.dirname(m),".env");Do__default.default.existsSync(g)&&dotenv.config({path:g});let x=await esbuild.build({entryPoints:[m],bundle:!0,format:"esm",platform:"node",target:"es2022",write:!1,sourcemap:!1,loader:{".ts":"ts",".tsx":"tsx"},resolveExtensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"],external:["@kyro-cms/*"]});v=m.replace(/\.ts$/,".admin.mjs"),Do__default.default.writeFileSync(v,x.outputFiles[0].text,"utf8");let u=`
106
+ `}})]})]})]})}var Py=typeof __KYRO_API_PATH__<"u"?__KYRO_API_PATH__:"/api";function kc({collections:e}){let[t,r]=Ta.useState([]),[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),[l,i]=Ta.useState(""),[d,c]=Ta.useState(null),[p,y]=Ta.useState(false),{confirm:g,alert:b}=ut(),[v,k]=Ta.useState(false),[f,u]=Ta.useState(""),x=async()=>{try{let m=await Ae("/api/keys");r(m);}catch(m){console.error(m);}};Ta.useEffect(()=>{x();},[]);let A=async()=>{u(""),k(true);},F=async()=>{if(f.trim())try{await dt("/api/keys",{name:f}),x(),k(!1),u(""),L.success("API key generated");}catch(m){console.error(m),L.error("Failed to generate API key");}},h=m=>{g({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 wt(`/api/keys/${m}`),x(),L.success("API key revoked");}catch(T){console.error(T),L.error("Failed to revoke API key");}}});},w=async()=>{if(l){y(true);try{let T=await(await fetch(We(`/api/${l}`))).json();c(T);}catch{c({error:"Failed to fetch. Ensure the endpoint exists."});}finally{y(false);}}};return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:"Developer Center",description:"Provision access keys and explore the headless API ecosystem.",icon:Hl.CodeXml,actions:[{label:"Generate Key",onClick:A,icon:Hl.Key}]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[jsxRuntime.jsxs("section",{className:"xl:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium tracking-[0.2em] opacity-40 uppercase",children:"Access Credentials"})]}),jsxRuntime.jsx("div",{className:"space-y-4",children:t.length===0?jsxRuntime.jsxs("div",{className:"p-12 text-center rounded-[2rem] border-2 border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface-accent)]/30",children:[jsxRuntime.jsx(Hl.Lock,{className:"w-10 h-10 mx-auto mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"text-sm text-[var(--kyro-text-secondary)] opacity-50",children:"No API keys found. Generate one to get started."})]}):t.map(m=>jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[jsxRuntime.jsx("div",{className:"p-2.5 bg-[var(--kyro-surface-accent)] rounded-xl group-hover:bg-[var(--kyro-primary)]/10 transition-colors",children:jsxRuntime.jsx(Hl.Key,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] group-hover:text-[var(--kyro-primary)] transition-colors"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold group-hover:text-[var(--kyro-primary)] transition-colors truncate",children:m.name})]}),jsxRuntime.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:[jsxRuntime.jsx("code",{className:"text-xs font-mono opacity-80 truncate mr-4",children:n===m.id?m.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"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>s(n===m.id?null:m.id),className:"p-1.5 hover:bg-[var(--kyro-surface-accent)] rounded-lg transition-all text-[var(--kyro-text-secondary)]",children:n===m.id?jsxRuntime.jsx(Hl.EyeOff,{className:"w-4 h-4"}):jsxRuntime.jsx(Hl.Eye,{className:"w-4 h-4"})}),jsxRuntime.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(m.key),L.success("API key copied to clipboard");},children:jsxRuntime.jsx(Hl.Copy,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-6 mt-4 text-[10px] font-bold opacity-30 uppercase tracking-widest",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Issued:"}),jsxRuntime.jsx("span",{children:new Date(m.createdAt).toLocaleDateString()})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{children:"Status:"}),jsxRuntime.jsx("span",{className:"text-green-500",children:"Active"})]})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>h(m.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:"Revoke Key",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-5 h-5"})})]})},m.id))})]}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx(Hl.Terminal,{className:"w-48 h-48 rotate-12"})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center mb-6",children:jsxRuntime.jsx(Hl.Terminal,{className:"w-6 h-6 text-white"})}),jsxRuntime.jsx("h3",{className:"text-white text-2xl font-bold tracking-tight mb-3",children:"Endpoint Hub"}),jsxRuntime.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."}),jsxRuntime.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",jsxRuntime.jsx(Hl.ExternalLink,{className:"w-3.5 h-3.5"})]})]})]}),jsxRuntime.jsxs("div",{className:"rounded-[2.5rem] border border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50 p-8 space-y-6",children:[jsxRuntime.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Environment Matrix"}),jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Content API"}),jsxRuntime.jsx(At,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Production"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://api.kyro.io/v1"}),jsxRuntime.jsx(Hl.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")})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-xs font-bold",children:"Draft Explorer"}),jsxRuntime.jsx(At,{variant:"outline",className:"text-[8px] font-bold uppercase py-0.5",children:"Staging"})]}),jsxRuntime.jsxs("div",{className:"group relative",children:[jsxRuntime.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"}),jsxRuntime.jsxs("div",{className:"relative bg-[var(--kyro-bg)] p-3.5 rounded-xl border border-[var(--kyro-border)] flex items-center justify-between",children:[jsxRuntime.jsx("code",{className:"text-[10px] font-mono opacity-60",children:"https://preview.kyro.io/v1"}),jsxRuntime.jsx(Hl.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")})]})]})]})]})]})]}),jsxRuntime.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:[jsxRuntime.jsx("div",{className:"absolute top-0 right-0 p-20 opacity-[0.02] pointer-events-none",children:jsxRuntime.jsx(Hl.CirclePlay,{className:"w-96 h-96"})}),jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-10 relative z-10",children:[jsxRuntime.jsxs("div",{className:"max-w-xl",children:[jsxRuntime.jsxs("h2",{className:"text-3xl font-bold tracking-tighter flex items-center gap-4 mb-3",children:[jsxRuntime.jsx("div",{className:"w-12 h-12 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Hl.CirclePlay,{className:"w-7 h-7 text-[var(--kyro-primary)]"})}),"API ",jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:"Explorer"})]}),jsxRuntime.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."})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex-1 relative flex items-center pl-6",children:[jsxRuntime.jsxs("span",{className:"text-[11px] font-bold opacity-30 uppercase tracking-widest mr-2 whitespace-nowrap",children:["GET ",Py,"/"]}),jsxRuntime.jsx("input",{type:"text",value:l,onChange:m=>i(m.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)]"})]}),jsxRuntime.jsxs("button",{type:"button",onClick:w,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?jsxRuntime.jsx(Hl.RefreshCcw,{className:"w-4 h-4 animate-spin"}):jsxRuntime.jsx(Hl.ChevronRight,{className:"w-5 h-5"}),"Run Query"]})]})]}),d?jsxRuntime.jsxs("div",{className:"animate-in fade-in zoom-in-95 duration-500 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-1 h-3 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] opacity-40",children:"Response Payload"})]}),jsxRuntime.jsx(At,{variant:"outline",className:"text-[9px] font-mono px-3",children:"200 OK"})]}),jsxRuntime.jsxs("div",{className:"rounded-[2rem] overflow-hidden border border-[var(--kyro-border)] shadow-2xl bg-[#090b10]",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-6 py-4 bg-[#11141d] border-b border-[var(--kyro-border)]/50",children:[jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-amber-500/20"}),jsxRuntime.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/20"})]}),jsxRuntime.jsx(Ry__default.default,{value:JSON.stringify(d,null,2),height:"450px",theme:codemirrorThemeAura.aura,extensions:[langJson.json()],editable:false,className:"text-sm"})]})]}):jsxRuntime.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:[jsxRuntime.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:jsxRuntime.jsx(Hl.CodeXml,{className:"w-10 h-10"})}),jsxRuntime.jsx("p",{className:"font-bold text-sm opacity-30 uppercase tracking-[0.2em]",children:"Awaiting request dispatch..."})]})]})]}),jsxRuntime.jsxs(Nt,{open:v,onClose:()=>k(false),title:"Generate Access Token",size:"lg",children:[jsxRuntime.jsx(Br,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.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."}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-bold uppercase tracking-widest opacity-40 px-1",children:"Token Name"}),jsxRuntime.jsx("input",{type:"text",value:f,onChange:m=>u(m.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:m=>m.key==="Enter"&&F()})]})]})}),jsxRuntime.jsxs(Gr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>k(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"}),jsxRuntime.jsx("button",{type:"button",onClick:F,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 hc(e){let[t,r]=Ta.useState([]),[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),[l,i]=Ta.useState(false),{confirm:d}=ut(),c=Ta.useCallback(async()=>{a(true),s(null);try{let b=await Ae(e.endpoint),v=Array.isArray(b)?b:b.docs||[],k=e.transformLoad?e.transformLoad(v):v;r(k),e.onSuccess?.("load",k);}catch(b){let v=b instanceof Error?b.message:"Failed to load resources";s(v),e.onError?.("load",b);}finally{a(false);}},[e.endpoint,e.transformLoad]);Ta.useEffect(()=>{c();},[c]);let p=Ta.useCallback((b,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 wt(`${e.endpoint}/${b}`),r(k=>k.filter(f=>f.id!==b)),e.onSuccess?.("delete",b),L.success(`${v} deleted`);}catch(k){let f=k instanceof Error?k.message:`Failed to delete ${v}`;L.error(f),e.onError?.("delete",k);}}});},[e.endpoint,d]),y=Ta.useCallback(async b=>{s(null);try{let v=await dt(e.endpoint,b);return r(k=>[v,...k]),i(!1),e.onSuccess?.("create",v),v}catch(v){let k=v instanceof Error?v.message:"Failed to create resource";throw s(k),e.onError?.("create",v),v}},[e.endpoint]),g=Ta.useCallback(async(b,v)=>{s(null);try{let k=await Wt(`${e.endpoint}/${b}`,v);return r(f=>f.map(u=>u.id===b?k:u)),e.onSuccess?.("update",k),k}catch(k){let f=k instanceof Error?k.message:"Failed to update resource";throw s(f),e.onError?.("update",k),k}},[e.endpoint]);return {items:t,setItems:r,loading:o,error:n,load:c,remove:p,create:y,update:g,isCreateModalOpen:l,setIsCreateModalOpen:i}}var By={generic:"\u{1F517}","github-dispatch":"\u2699\uFE0F","dokploy-deploy":"\u{1F680}","coolify-deploy":"\u{1F3AF}"};function wc(){let{items:e,loading:t,create:r,remove:o,update:a,isCreateModalOpen:n,setIsCreateModalOpen:s}=hc({endpoint:"/api/webhooks"}),{confirm:l}=ut(),[i,d]=Ta.useState(false),[c,p]=Ta.useState(false),[y,g]=Ta.useState(null),[b,v]=Ta.useState(null),[k,f]=Ta.useState({}),[u,x]=Ta.useState(true),[A,F]=Ta.useState("action"),[h,w]=Ta.useState("generic"),[m,T]=Ta.useState({name:"",url:"",events:[],secret:"",action:"generic",config:{}}),[B,I]=Ta.useState("");Ta.useEffect(()=>{V();},[]);let V=async()=>{try{let S=await Ae("/api/webhooks/actions");f(S.actions);}catch(S){console.error("Failed to load webhook actions:",S);}finally{x(false);}},C=()=>{F("action"),w("generic"),T({name:"",url:"",events:["collection.create","collection.update","collection.delete"],secret:"",action:"generic",config:{}}),I("");},K=S=>{w(S),T(J=>({...J,action:S,config:{}})),F("config");},E=(S,J)=>{T(fe=>({...fe,config:{...fe.config,[S]:J}}));},$=async()=>{if(!m.name.trim()){I("Name is required");return}if(h==="generic"&&!m.url.trim()){I("URL is required for custom webhooks");return}let S=k[h];if(S){for(let J of S.configFields)if(J.required&&!m.config[J.name]?.trim()){I(`${J.label} is required`);return}}try{await r(m),C(),L.success(`Webhook created: ${m.name}`);}catch{I("Failed to create webhook"),L.error("Failed to create webhook");}},O=async S=>{v(S),g(null),d(true);try{let J=await dt(`/api/webhooks/${S}/test`);g({success:!0,message:J.message||"Webhook triggered successfully"}),L.success("Test delivered successfully");}catch{g({success:false,message:"Failed to trigger webhook"});}},ne=async(S,J)=>{try{let fe=J==="active"?"paused":"active";await a(S,{status:fe}),L.success(fe==="active"?"Webhook activated":"Webhook paused");}catch(fe){console.error(fe),L.error("Failed to toggle webhook status");}},ie=[{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"}],H=S=>k[S||"generic"]?.label||"Custom URL";return jsxRuntime.jsxs("div",{className:"w-full space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 pb-32",children:[jsxRuntime.jsx(Lt,{title:"Webhooks",description:"Get notified when your content changes.",icon:Hl.Webhook,actions:[{label:"New webhook",onClick:()=>{C(),s(true);},icon:Hl.Plus},{label:"Guide",onClick:()=>p(true),icon:Hl.Info,variant:"outline"}]}),jsxRuntime.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6 relative z-10",children:[jsxRuntime.jsx("div",{className:"p-3 bg-[var(--kyro-primary)]/10 rounded-xl",children:jsxRuntime.jsx(Hl.Zap,{className:"w-6 h-6 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("div",{className:"flex-1 text-center md:text-left",children:jsxRuntime.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."})})]})}),jsxRuntime.jsxs("section",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-1 h-4 bg-[var(--kyro-primary)] rounded-full"}),jsxRuntime.jsx("h2",{className:"text-sm font-medium text-[var(--kyro-text-secondary)]",children:"Endpoints"})]}),jsxRuntime.jsxs("div",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:[e.length," hook",e.length!==1&&"s"]})]}),t?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-20 opacity-50 text-sm text-[var(--kyro-text-secondary)]",children:"Loading webhooks..."}):e.length===0?jsxRuntime.jsxs("div",{className:"p-16 text-center rounded-2xl border border-dashed border-[var(--kyro-border)] bg-[var(--kyro-surface)]/50",children:[jsxRuntime.jsx("div",{className:"w-16 h-16 mx-auto mb-5 bg-[var(--kyro-primary)]/10 rounded-2xl flex items-center justify-center",children:jsxRuntime.jsx(Hl.Webhook,{className:"w-8 h-8 text-[var(--kyro-primary)]"})}),jsxRuntime.jsx("h3",{className:"text-lg font-bold mb-2",children:"No webhooks yet"}),jsxRuntime.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."}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>{C(),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:[jsxRuntime.jsx(Hl.Plus,{className:"w-4 h-4"}),"Create webhook"]})]}):jsxRuntime.jsx("div",{className:"grid gap-4",children:e.map(S=>jsxRuntime.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:jsxRuntime.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-5 relative z-10",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[jsxRuntime.jsx("div",{className:"p-2 bg-[var(--kyro-surface-accent)] rounded-lg",children:jsxRuntime.jsx(Hl.Webhook,{className:"w-4 h-4 text-[var(--kyro-text-secondary)]"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:S.name}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[jsxRuntime.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S.status==="active"?"bg-green-500":"bg-amber-500"}`}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium ${S.status==="active"?"text-green-500":"text-amber-500"}`,children:S.status}),jsxRuntime.jsx(At,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:H(S.action)})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 pt-1",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Destination"}),jsxRuntime.jsx("div",{className:"font-mono text-xs text-[var(--kyro-text-secondary)] opacity-60 truncate max-w-[200px]",title:S.url,children:S.url||`${H(S.action)} webhook`})]}),jsxRuntime.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:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Events"}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1",children:[S.events.slice(0,3).map(J=>jsxRuntime.jsx(At,{variant:"outline",className:"text-[9px] px-1.5 opacity-50",children:J},J)),S.events.length>3&&jsxRuntime.jsxs("span",{className:"text-[9px] text-[var(--kyro-text-secondary)] opacity-30",children:["+",S.events.length-3]})]})]}),jsxRuntime.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:[jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-50",children:"Activity"}),jsxRuntime.jsxs("div",{className:"text-[10px] text-[var(--kyro-text-secondary)] opacity-60 flex items-center gap-1.5",children:[jsxRuntime.jsx(Hl.Clock,{className:"w-3 h-3"}),S.lastTriggered?`Last triggered ${new Date(S.lastTriggered).toLocaleDateString()}`:"Never triggered"]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 lg:opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>O(S.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:"Send test request",children:[jsxRuntime.jsx(Hl.Send,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium",children:"Test"})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>ne(S.id,S.status),className:`p-2 rounded-lg border border-[var(--kyro-border)] hover:border-[var(--kyro-primary)] transition-colors ${S.status==="active"?"text-amber-500/60 hover:text-amber-500":"text-green-500/60 hover:text-green-500"}`,title:S.status==="active"?"Pause":"Activate",children:S.status==="active"?jsxRuntime.jsx(Hl.Pause,{className:"w-3.5 h-3.5"}):jsxRuntime.jsx(Hl.Play,{className:"w-3.5 h-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(S.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:"Delete",children:jsxRuntime.jsx(Hl.Trash2,{className:"w-3.5 h-3.5 text-red-500/50 hover:text-red-500"})})]})]})},S.id))})]}),jsxRuntime.jsx(Nt,{open:n&&A==="action",onClose:()=>s(false),title:"New webhook",children:jsxRuntime.jsx(Br,{children:jsxRuntime.jsx("div",{className:"space-y-4",children:u?jsxRuntime.jsx("div",{className:"flex items-center justify-center p-12 opacity-50",children:jsxRuntime.jsx(Hl.RefreshCw,{className:"w-5 h-5 animate-spin text-[var(--kyro-primary)]"})}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(k).map(([S,J])=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>K(S),className:"flex flex-col items-start p-4 rounded-xl border border-[var(--kyro-border)] bg-[var(--kyro-surface)] hover:border-[var(--kyro-primary)]/40 transition-all text-left group",children:[jsxRuntime.jsx("div",{className:"text-lg mb-2",children:By[S]||"\u{1F517}"}),jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-0.5 group-hover:text-[var(--kyro-primary)] transition-colors",children:J.label}),jsxRuntime.jsx("p",{className:"text-[11px] text-[var(--kyro-text-secondary)] opacity-50 leading-relaxed",children:J.description}),J.envVars.length>0&&jsxRuntime.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:J.envVars.map(fe=>jsxRuntime.jsx("span",{className:"text-[9px] font-mono bg-[var(--kyro-surface-accent)] px-1.5 py-0.5 rounded opacity-40",children:fe},fe))})]},S))})})})}),jsxRuntime.jsxs(Nt,{open:n&&A==="config",onClose:()=>s(false),title:k[h]?.label||"Webhook",children:[jsxRuntime.jsx(Br,{children:jsxRuntime.jsxs("div",{className:"space-y-5",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Name"}),jsxRuntime.jsx("input",{type:"text",value:m.name,onChange:S=>T({...m,name:S.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)]"})]}),h==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"URL"}),jsxRuntime.jsx("input",{type:"url",value:m.url,onChange:S=>T({...m,url:S.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)]"})]}),h!=="generic"&&k[h]?.configFields.map(S=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:[S.label," ",S.required&&jsxRuntime.jsx("span",{className:"text-red-500",children:"*"})]}),jsxRuntime.jsx("input",{type:"text",value:m.config[S.name]||"",onChange:J=>E(S.name,J.target.value),placeholder:S.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)]"})]},S.name)),h==="generic"&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium mb-1.5 text-[var(--kyro-text-secondary)]",children:"Signing secret"}),jsxRuntime.jsx("input",{type:"text",value:m.secret,onChange:S=>T({...m,secret:S.target.value}),placeholder:"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)]"})]})]}),h!=="generic"&&k[h]?.envVars.length>0&&jsxRuntime.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/5 border border-amber-500/15",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-3.5 h-3.5 text-amber-500"}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium text-amber-600",children:"Environment variables required"})]}),jsxRuntime.jsxs("p",{className:"text-[11px] text-amber-600/60 mb-2",children:["Add these to your ",jsxRuntime.jsx("code",{className:"font-mono bg-amber-500/10 px-1 py-0.5 rounded text-[10px]",children:".env"})," file:"]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1.5",children:k[h].envVars.map(S=>jsxRuntime.jsxs("code",{className:"text-[10px] font-mono bg-amber-500/10 text-amber-600 px-1.5 py-0.5 rounded",children:[S,"=..."]},S))})]}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("label",{className:"block text-xs font-medium text-[var(--kyro-text-secondary)]",children:"Events"}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ie.map(S=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let J=m.events.includes(S.value)?m.events.filter(fe=>fe!==S.value):[...m.events,S.value];T({...m,events:J});},className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all text-left text-sm ${m.events.includes(S.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:[jsxRuntime.jsx("div",{className:`w-3.5 h-3.5 rounded flex items-center justify-center border transition-all ${m.events.includes(S.value)?"bg-[var(--kyro-primary)] border-[var(--kyro-primary)]":"border-[var(--kyro-border)]"}`,children:m.events.includes(S.value)&&jsxRuntime.jsx(Hl.CircleCheck,{className:"w-2.5 h-2.5 text-white"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-xs font-medium",children:S.label}),jsxRuntime.jsx("div",{className:"text-[10px] opacity-40",children:S.description})]})]},S.value))})]})]}),B&&jsxRuntime.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:[jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-3.5 h-3.5"}),B]})]})}),jsxRuntime.jsxs(Gr,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>F("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"}),jsxRuntime.jsx("button",{type:"button",onClick:$,className:"kyro-btn kyro-btn-primary px-4 py-2 rounded-lg text-sm font-medium",children:"Create webhook"})]})]}),jsxRuntime.jsxs(Nt,{open:i,onClose:()=>d(false),title:"Test webhook",children:[jsxRuntime.jsx(Br,{children:jsxRuntime.jsx("div",{className:"p-6 rounded-xl bg-[var(--kyro-surface)] border border-[var(--kyro-border)] text-center",children:y?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`w-12 h-12 mx-auto rounded-xl flex items-center justify-center ${y.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:y.success?jsxRuntime.jsx(Hl.CircleCheck,{className:"w-6 h-6"}):jsxRuntime.jsx(Hl.TriangleAlert,{className:"w-6 h-6"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:y.success?"Delivered":"Failed"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-60",children:y.message})]})]}):jsxRuntime.jsxs("div",{className:"space-y-4 py-4",children:[jsxRuntime.jsx(Hl.RefreshCw,{className:"w-8 h-8 text-[var(--kyro-primary)] animate-spin mx-auto opacity-40"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold mb-1",children:"Sending test payload"}),jsxRuntime.jsx("p",{className:"text-xs text-[var(--kyro-text-secondary)] opacity-50",children:"Dispatching..."})]})]})})}),jsxRuntime.jsx(Gr,{children:jsxRuntime.jsx("button",{type:"button",onClick:()=>d(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"})})]}),jsxRuntime.jsxs(Nt,{open:c,onClose:()=>p(false),title:"How webhooks work",children:[jsxRuntime.jsx(Br,{children:jsxRuntime.jsxs("div",{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Hl.ExternalLink,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Request format"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["When an event triggers, Kyro sends a ",jsxRuntime.jsx("span",{className:"font-medium",children:"POST"})," request to your endpoint with a JSON payload containing document metadata and operation details."]})]}),jsxRuntime.jsxs("div",{className:"p-4 rounded-md bg-[var(--kyro-surface)] border border-[var(--kyro-border)]",children:[jsxRuntime.jsxs("h4",{className:"text-sm font-medium mb-1.5 flex items-center gap-2",children:[jsxRuntime.jsx(Hl.Shield,{className:"w-3.5 h-3.5 text-[var(--kyro-primary)]"}),"Signature verification"]}),jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] leading-relaxed opacity-70",children:["If a secret is set, each request includes an ",jsxRuntime.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."]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("h4",{className:"text-xs font-medium text-[var(--kyro-text-secondary)] opacity-50",children:"Example payload"}),jsxRuntime.jsx("div",{className:"bg-[var(--kyro-bg)] rounded-md border border-[var(--kyro-border)] p-4 font-mono text-xs overflow-hidden",children:jsxRuntime.jsxs("div",{className:"space-y-0.5 text-[var(--kyro-text-secondary)]",children:[jsxRuntime.jsx("div",{children:"{"}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"event"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"collection.create"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"collection"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"posts"'}),","]}),jsxRuntime.jsxs("div",{className:"pl-3",children:[jsxRuntime.jsx("span",{className:"text-[var(--kyro-primary)]",children:'"timestamp"'}),": ",jsxRuntime.jsx("span",{className:"text-green-500",children:'"2026-06-28T12:00:00Z"'})]}),jsxRuntime.jsx("div",{children:"}"})]})})]})]})}),jsxRuntime.jsx(Gr,{children:jsxRuntime.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"})})]})]})}function Sc({isOpen:e,onClose:t,collections:r,globals:o,onNavigate:a}){let{user:n,permissions:s}=_r(),[l,i]=Ta.useState(""),[d,c]=Ta.useState(0),[p,y]=Ta.useState(false),[g,b]=Ta.useState([]),v=Ta.useRef(null),k=Ta.useRef(null);Ta.useEffect(()=>{e&&(i(""),c(0),b([]),y(false),setTimeout(()=>v.current?.focus(),100));},[e]);let f=Ta.useCallback(async C=>{if(!C||C.length<2){b([]);return}y(true);try{let E=await(await fetch(We(`/api/search?q=${encodeURIComponent(C)}&limit=15`))).json();E.results&&b(E.results);}catch(K){console.error("Search error:",K),b([]);}finally{y(false);}},[]);if(Ta.useEffect(()=>(k.current&&clearTimeout(k.current),l.length>=2?k.current=setTimeout(()=>f(l),300):b([]),()=>{k.current&&clearTimeout(k.current);}),[l,f]),!e)return null;let u=Object.entries(r).filter(([C])=>s?.collections?.[C]?.read!==false).map(([C,K])=>({id:`col-${C}`,label:K.label||C,type:"collection",slug:C,icon:Hl.FileText})),x=Object.entries(o).filter(([C])=>s?.globals?.[C]?.read!==false).map(([C,K])=>({id:`global-${C}`,label:K.label||C,type:"global",slug:C,icon:Hl.Settings})),A=typeof document<"u"&&document.documentElement.classList.contains("dark"),F=n?.role==="admin",h=[{id:"action-media",label:"Media Gallery",type:"action",view:"media",icon:Hl.Image,visible:s?.collections?.media?.read!==false},{id:"action-users",label:"Team Management",type:"action",view:"users",icon:Hl.Clock,visible:F},{id:"action-audit",label:"Audit Logs",type:"action",view:"audit",icon:Hl.File,visible:F},{id:"action-roles",label:"Roles & Permissions",type:"action",view:"roles",icon:Hl.Shield,visible:F},{id:"action-api",label:"REST API Explorer",type:"action",view:"api-explorer",icon:Hl.Database,visible:F},{id:"action-graphql",label:"GraphQL Playground",type:"action",view:"graphql",icon:Hl.Hexagon,visible:F},{id:"action-rest",label:"REST Playground",type:"action",view:"rest",icon:Hl.Network,visible:F},{id:"action-theme",label:A?"Switch to Light Mode":"Switch to Dark Mode",type:"action",view:"theme",icon:A?Hl.Sun:Hl.Moon,visible:true},{id:"action-logout",label:"Sign Out",type:"action",view:"logout",icon:Hl.LogOut,visible:true}].filter(C=>C.visible),w=g.map((C,K)=>({id:`doc-${C.collection}-${C.id}`,label:C.title,type:"document",collection:C.collection,label2:C.label,docId:C.id,icon:Hl.File,doc:C.doc})),m=l.length>=2?[...h,...u,...x,...w]:[...h,...u,...x],T=l===""?m:m.filter(C=>C.label.toLowerCase().includes(l.toLowerCase())),B=C=>{if(C.key==="ArrowDown")C.preventDefault(),c(K=>(K+1)%T.length);else if(C.key==="ArrowUp")C.preventDefault(),c(K=>(K-1+T.length)%T.length);else if(C.key==="Enter"){let K=T[d];K&&I(K);}else C.key==="Escape"&&t();},I=C=>{C.type==="collection"?C.slug==="users"?a(C.slug,C.slug):a("list",C.slug):C.type==="global"?a("settings",C.slug):C.type==="document"?C.collection==="users"?a("users","users",C.docId):a("edit",C.collection,C.docId):C.type==="action"&&(C.view==="users"?a("users","users"):C.view==="media"?a("media","media"):a(C.view,C.view)),t();},V=()=>l===""?"Quick Actions & Collections":g.length>0?"Documents":p?"Searching...":"Search Results";return jsxRuntime.jsxs("div",{className:"fixed inset-0 z-[1000] flex items-start justify-center pt-[15vh] px-4",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center px-6 py-5 border-b border-[var(--kyro-border)]",children:[p?jsxRuntime.jsx(Hl.LoaderCircle,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4 animate-spin"}):jsxRuntime.jsx(Hl.Search,{className:"w-5 h-5 text-[var(--kyro-text-secondary)] opacity-50 mr-4"}),jsxRuntime.jsx("input",{ref:v,placeholder:"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:C=>i(C.target.value),onKeyDown:B}),jsxRuntime.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:jsxRuntime.jsx("span",{className:"text-[10px] font-bold opacity-40 tracking-widest",children:"ESC"})})]}),jsxRuntime.jsx("div",{className:"max-h-[400px] overflow-y-auto py-4",children:T.length>0?jsxRuntime.jsxs("div",{className:"space-y-1 px-4",children:[jsxRuntime.jsx("p",{className:"px-4 text-[10px] font-bold tracking-[0.2em] opacity-40 mb-4",children:V()}),T.map((C,K)=>jsxRuntime.jsxs("div",{onClick:()=>I(C),onMouseEnter:()=>c(K),className:`flex items-center justify-between px-4 py-4 rounded-2xl cursor-pointer ${K===d?"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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:`p-2 rounded-xl ${K===d?"bg-white/20":"bg-[var(--kyro-bg-secondary)] border border-[var(--kyro-border)]"}`,children:jsxRuntime.jsx(C.icon,{className:"w-4 h-4"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-bold text-sm",children:C.label}),C.type==="document"&&C.label2&&jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest ${K===d?"text-[var(--kyro-sidebar-text-active)]/60":"opacity-40"}`,children:C.label2})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:`text-[10px] font-bold tracking-widest opacity-40 ${K===d?"text-[var(--kyro-sidebar-text-active)] p-1":""}`,children:C.type}),K===d&&jsxRuntime.jsx(Hl.ArrowRight,{className:"w-4 h-4 mr-2"})]})]},C.id))]}):jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.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..."})})}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u2191\u2193 Navigate"}),jsxRuntime.jsx("span",{className:"flex items-center gap-2 underline underline-offset-4 decoration-2 decoration-[var(--kyro-primary)]",children:"\u23CE Select"})]}),jsxRuntime.jsx("div",{children:"Kyro Universal Search"})]})]})]})}function Tc(){let{modal:e,closeModal:t}=ut(),[r,o]=Ta.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(l){console.error("Modal confirm action failed:",l);}finally{o(false),t();}else t();},s=()=>{a.onCancel&&a.onCancel(),t();};return jsxRuntime.jsx(Es,{open:e.open,onClose:s,onConfirm:n,title:a.title,message:a.message,confirmLabel:a.confirmLabel,cancelLabel:a.cancelLabel,variant:a.variant==="danger"?"danger":"default",loading:r})}function $y({config:e,theme:t="light",onThemeChange:r}){let[o,a]=Ta.useState(false),[n,s]=Ta.useState(null),l=Ta.useMemo(()=>Jn(Ea(e.collections)),[e.collections]),i=Ta.useMemo(()=>qn(Ea(e.globals)),[e.globals]),[d,c]=Ta.useState(null),[p,y]=Ta.useState(null),[g,b]=Ta.useState("list"),[v,k]=Ta.useState(null),[f,u]=Ta.useState(false);Ta.useEffect(()=>{(async()=>{try{let w=await fetch("/api/users/me");if(w.ok){let m=await w.json();s(m),a(!0);}}catch(w){console.error("Auth check failed",w);}})();},[]),Ta.useEffect(()=>{if(o&&!d){let h=Object.keys(l)[0];h&&c(h);}},[o,l,d]);let x=(h,w=null,m=null)=>{b(h),w&&c(w),m&&k(m),u(false);};Ta.useEffect(()=>{let h=w=>{(w.metaKey||w.ctrlKey)&&w.key==="k"&&(w.preventDefault(),u(m=>!m));};return window.addEventListener("keydown",h),window.openCommandPalette=()=>u(true),()=>{window.removeEventListener("keydown",h),delete window.openCommandPalette;}},[]);return o?jsxRuntime.jsx(wr,{mode:t,onChange:r,children:jsxRuntime.jsxs("div",{className:"kyro-admin min-h-screen bg-[var(--kyro-bg)] text-[var(--kyro-text-primary)]",children:[jsxRuntime.jsx("div",{className:"flex h-screen overflow-hidden",children:jsxRuntime.jsx("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto",children:[jsxRuntime.jsx(Sc,{isOpen:f,onClose:()=>u(false),collections:l,globals:i,onNavigate:x}),(()=>{let h=d?l[d]:null;switch(g){case "create":return h?jsxRuntime.jsx(Ni,{config:e,collection:h,onSuccess:()=>b("list"),onCancel:()=>b("list"),onError:w=>L.error(w)}):null;case "detail":return h&&v?jsxRuntime.jsx(wi,{config:e,collection:h,documentId:v,onBack:()=>b("list"),onSave:()=>{},onError:w=>L.error(w)}):null;case "users":return jsxRuntime.jsx(bc,{});case "media":return jsxRuntime.jsx(Mn,{});case "branding":return jsxRuntime.jsx(xc,{});case "developer":return jsxRuntime.jsx(kc,{collections:l});case "webhooks":return jsxRuntime.jsx(wc,{});default:return h?jsxRuntime.jsx(Bs,{config:e,collection:h,onCreate:()=>b("create"),onEdit:w=>x("detail",d,w)}):jsxRuntime.jsx(vc,{onNavigate:x,collections:l,user:n})}})()]})})}),jsxRuntime.jsx(Tc,{}),jsxRuntime.jsx(cs,{})]})}):jsxRuntime.jsx(Ti,{onAuth:(h,w)=>{s(w),a(true);},theme:t})}function Oy({selectedCount:e,onClearSelection:t,actions:r,onSelectAll:o}){return e===0?null:jsxRuntime.jsxs("div",{className:"flex items-center justify-between py-2 px-4 bg-gray-50 border-b border-gray-200",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Fs,{count:e}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600",children:"selected"})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,className:"text-sm text-gray-500 hover:text-gray-700",children:"Clear selection"}),o&&jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Select all"})]}),jsxRuntime.jsx(Ro,{trigger:jsxRuntime.jsxs("button",{type:"button",className:"kyro-btn kyro-btn-secondary kyro-btn-sm",children:["Actions",jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),children:r.map((a,n)=>jsxRuntime.jsx(Tt,{onClick:a.onClick,icon:a.icon,danger:a.danger,children:a.label},n))})]})}function Gy({open:e,onClose:t,versions:r,currentVersionId:o,onPreview:a,onRestore:n,onCompare:s,loading:l=false}){let i=c=>{if(!c)return "Unknown date";let p=new Date(c);if(isNaN(p.getTime())){let y=Date.parse(c);return isNaN(y)?"Invalid date":new Date(y).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"})},d=c=>{if(!c)return "Unknown date";let p=new Date(c);if(isNaN(p.getTime()))return i(c);let g=new Date().getTime()-p.getTime();if(g<0)return "Just now";let b=Math.floor(g/6e4),v=Math.floor(g/36e5),k=Math.floor(g/864e5);return b<1?"Just now":b<60?`${b}m ago`:v<24?`${v}h ago`:k<7?`${k}d ago`:i(c)};return jsxRuntime.jsx(dr,{open:e,onClose:t,title:"Version History",width:"md",children:l?jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12",children:jsxRuntime.jsx(hr,{})}):r.length===0?jsxRuntime.jsxs("div",{className:"text-center flex flex-col items-center justify-center py-16 text-[var(--kyro-text-muted)]",children:[jsxRuntime.jsx(Hl.History,{className:"w-12 h-12 mb-4 opacity-20"}),jsxRuntime.jsx("p",{className:"font-medium text-[var(--kyro-text)]",children:"No version history yet"}),jsxRuntime.jsx("p",{className:"text-sm mt-1",children:"Versions are automatically saved as you work."})]}):jsxRuntime.jsx("div",{className:"space-y-3 px-1 pb-4 pt-1",children:r.map(c=>{let p=c.id===o;return jsxRuntime.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&&jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-1 h-full bg-[var(--kyro-primary)] shadow-[0_0_8px_var(--kyro-primary)]"}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[jsxRuntime.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tracking-wide uppercase ${c.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:[c.status==="published"&&jsxRuntime.jsx(Hl.CheckCircle2,{className:"w-3 h-3"}),c.status==="published"?"Published":"Draft"]}),jsxRuntime.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",c.version]}),p&&jsxRuntime.jsxs("span",{className:"text-[10px] font-medium text-[var(--kyro-primary)] flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--kyro-primary)] animate-pulse"}),"Current"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--kyro-text)] truncate mb-1",children:[jsxRuntime.jsx(Hl.Clock,{className:"w-3.5 h-3.5 text-[var(--kyro-text-muted)]"}),d(c.createdAt)]}),c.createdBy&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--kyro-text-muted)] mt-1.5",children:[jsxRuntime.jsx(Hl.User,{className:"w-3.5 h-3.5"}),jsxRuntime.jsx("span",{children:c.createdBy.name||c.createdBy.email})]}),c.changelog&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--kyro-text-secondary)] mt-2 italic border-l-2 border-[var(--kyro-border)] pl-2",children:['"',c.changelog,'"']})]}),jsxRuntime.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:[jsxRuntime.jsx("button",{type:"button",onClick:()=>a(c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Preview this version",children:jsxRuntime.jsx(Hl.Eye,{className:"w-4 h-4"})}),s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>s(c,r.find(y=>y.id===o)||c),className:"p-2 text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-primary)] hover:bg-[var(--kyro-primary)]/10 rounded-md transition-colors",title:"Compare with current",children:jsxRuntime.jsx(Hl.GitCompare,{className:"w-4 h-4"})}),!p&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(c),className:"p-2 text-amber-600 hover:bg-amber-500/10 rounded-md transition-colors",title:"Restore this version",children:jsxRuntime.jsx(Hl.Undo2,{className:"w-4 h-4"})})]})]})]},c.id)})})})}function yF({title:e,onMenuClick:t,actions:r}){return jsxRuntime.jsxs("header",{className:"kyro-header",children:[jsxRuntime.jsxs("div",{className:"kyro-header-left",children:[jsxRuntime.jsx("button",{type:"button",className:"kyro-header-menu",onClick:t,"aria-label":"Toggle menu",children:jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:jsxRuntime.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"})})}),jsxRuntime.jsx("h1",{className:"kyro-header-title",children:e})]}),jsxRuntime.jsxs("div",{className:"kyro-header-right",children:[r,jsxRuntime.jsx("div",{className:"kyro-header-user",children:jsxRuntime.jsx("button",{type:"button",className:"kyro-header-user-btn",children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"8",r:"4"}),jsxRuntime.jsx("path",{d:"M4 20c0-4 4-6 8-6s8 2 8 6"})]})})})]})]})}var nr={ready:[],beforeDeploy:[],afterDeploy:[]};function vs(e){return nr.ready.push(e),()=>{nr.ready=nr.ready.filter(t=>t!==e);}}function Fc(e){return nr.beforeDeploy.push(e),()=>{nr.beforeDeploy=nr.beforeDeploy.filter(t=>t!==e);}}function Pc(e){return nr.afterDeploy.push(e),()=>{nr.afterDeploy=nr.afterDeploy.filter(t=>t!==e);}}async function Dc(e){let t=[];for(let r of nr.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 Ic(e){let t=[];for(let r of nr.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 Bc(e,t){for(let r of nr.afterDeploy)try{await r(e,t);}catch{}}function Mc(e){return `${typeof window<"u"?window.location.origin:""}${e}`}function Ec(e,t={}){let[r,o]=Ta.useState(null),[a,n]=Ta.useState(true),[s,l]=Ta.useState(null),i=Ta.useCallback(async()=>{n(true),l(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=`${Mc(`/api/${e}`)}?${d.toString()}`,p=await fetch(c,{credentials:"include"});if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);let y=await p.json();o(y.data??y);}catch(d){l(d instanceof Error?d.message:String(d));}finally{n(false);}},[e,t.page,t.limit,t.sort,t.order]);return Ta.useEffect(()=>{i();},[i]),{data:r,loading:a,error:s,refetch:i}}function $c(e,t="POST"){let[r,o]=Ta.useState(false),[a,n]=Ta.useState(null);return {mutate:Ta.useCallback(async l=>{o(true),n(null);try{let i=Mc(`/api/${e}`),d=await fetch(i,{method:t,credentials:"include",headers:{"Content-Type":"application/json"},body:l?JSON.stringify(l):void 0});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);let c=await d.json();return c.data??c}catch(i){return n(i instanceof Error?i.message:String(i)),null}finally{o(false);}},[e,t]),loading:r,error:a}}var da=new Map;function ca(e){if(!e.name||typeof e.name!="string")throw new Error("Plugin must have a valid name");da.has(e.name)&&console.warn(`Plugin "${e.name}" is already registered. Overwriting.`),da.set(e.name,e),e.apply&&e.apply({});}function Oc(e){da.delete(e);}function Uc(e){return da.get(e)}function zc(){return Array.from(da.values())}function jc(e){return Array.from(da.values()).filter(t=>t.hooks&&typeof t.hooks[e]=="function")}var Jy={name:"sample-plugin",version:"0.1.0",description:"A tiny sample plugin to demonstrate the extensibility surface",hooks:{onAdminReady:()=>{}}};ca(Jy);var qy={name:"sample-plugin-2",version:"0.1.0",description:"Second MVP plugin demonstrating beforeDeploy hook",hooks:{beforeDeploy:e=>({success:true})}};ca(qy);var pa=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");pa.set(e.id,e);}function _c(e){pa.delete(e);}function Hc(e){return pa.get(e)}function Vc(){return Array.from(pa.values())}function Kc(e){return Array.from(pa.values()).filter(t=>t.category===e)}function Gc(e){let t=pa.get(e);return t?t.render:(console.warn(`Block "${e}" not found in registry`),null)}var Xy=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"1px solid #ccc",padding:8,borderRadius:6},children:[jsxRuntime.jsx("strong",{children:"Sample Block"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},Yy={id:"sample-block",label:"Sample Block",category:"demo",schema:[{name:"title",label:"Title",type:"text",required:true}],render:Xy};ma(Yy);var Zy=e=>{let{data:t}=e;return jsxRuntime.jsxs("div",{style:{border:"2px dashed #888",padding:10,borderRadius:8},children:[jsxRuntime.jsx("strong",{children:"Sample Block 2"}),jsxRuntime.jsx("pre",{style:{marginTop:6},children:JSON.stringify(t??{},null,2)})]})},ef={id:"sample-block-2",label:"Sample Block 2",category:"demo",schema:[{name:"subtitle",label:"Subtitle",type:"text",required:false}],render:Zy};ma(ef);var ua=new Map;function ya(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");ua.set(e.id,e);}function qc(e){ua.delete(e);}function Xc(e){return ua.get(e)}function Yc(){return Array.from(ua.values())}function Qc(e){return Array.from(ua.values()).find(t=>t.type===e)}function Zc(e,t){let r=ua.get(e);if(!r)return console.warn(`Field "${e}" not found in registry`),null;let o=r.editor;return jsxRuntime.jsx(o,{...t})}var of=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("input",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample text"}),af={id:"sample-text",type:"text",label:"Sample Text",editor:of};ya(af);var sf=({name:e,value:t,onChange:r})=>jsxRuntime.jsx("textarea",{name:e,value:typeof t=="string"?t:"",onChange:o=>r?.(o.target.value),placeholder:"Sample textarea"}),lf={id:"sample-textarea",type:"textarea",label:"Sample Textarea",editor:sf};ya(lf);var ep=yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/shim");yr__default.default.join(ep,"use-sync-external-store.js");yr__default.default.join(ep,"use-sync-external-store-with-selector.js");function yf(e={}){let{basePath:t="/admin",apiPath:r="/api",configPath:o="kyro.config.ts"}=e;return {name:"@kyro-cms/admin",hooks:{"astro:config:setup":async({config:a,updateConfig:n,injectRoute:s,logger:l})=>{l.info(`Kyro Admin mounted at ${t} (API: ${r})`);let i=yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,"lib/default-kyro-config.ts"),d=yr__default.default.resolve(a.root.pathname,"..",o),c=yr__default.default.resolve(a.root.pathname,o),p=Bo__default.default.existsSync(d)?d:Bo__default.default.existsSync(c)?c:i;p!==i?l.info(`Loaded config from ${p}`):l.warn("Config file not found. Using defaults.");let y=yr__default.default.join(yr__default.default.dirname(p),".kyro-admin-config.json"),g="";try{let v=yr__default.default.join(yr__default.default.dirname(p),".env");Bo__default.default.existsSync(v)&&dotenv.config({path:v});let k=await esbuild.build({entryPoints:[p],bundle:!0,format:"esm",platform:"node",target:"es2022",write:!1,sourcemap:!1,loader:{".ts":"ts",".tsx":"tsx"},resolveExtensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".json"],external:["@kyro-cms/*"]});g=p.replace(/\.ts$/,".admin.mjs"),Bo__default.default.writeFileSync(g,k.outputFiles[0].text,"utf8");let f=`
107
107
  import { parentPort } from 'worker_threads';
108
- import('${url.pathToFileURL(v).href}').then(mod => {
108
+ import('${url.pathToFileURL(g).href}').then(mod => {
109
109
  const cfg = mod.default || mod;
110
110
  const serialize = (obj, key) => {
111
111
  if (obj === null || obj === undefined) return obj;
@@ -132,7 +132,7 @@ code block
132
132
  }).catch(err => {
133
133
  parentPort.postMessage({ error: err.message });
134
134
  });
135
- `,y=new worker_threads.Worker(u,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),h=await new Promise((P,w)=>{y.on("message",P),y.on("error",w);let k=setTimeout(()=>{y.terminate(),w(new Error("Config loading timed out"));},3e4);});if(y.terminate(),h.error)throw new Error(h.error);let R=[{name:"metaTitle",type:"text",label:"Meta Title",admin:{description:"The title used for search engines (recommended < 60 chars).",autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{description:"A brief summary for search engines (recommended < 160 chars).",autoGenerate:"content"}},{name:"keywords",type:"text",label:"Keywords",admin:{description:"Comma-separated list of keywords for this page."}},{name:"ogImage",type:"upload",label:"OpenGraph Image",relationTo:"media",admin:{description:"The image shown when shared on social media."}},{name:"twitter",type:"group",label:"Twitter Card",fields:[{name:"title",type:"text",label:"Twitter Title"},{name:"description",type:"textarea",label:"Twitter Description"},{name:"image",type:"upload",label:"Twitter Image",relationTo:"media"}]},{name:"advanced",type:"group",label:"Advanced Search Settings",fields:[{name:"noindex",type:"checkbox",label:"Hide from search engines (noindex)",defaultValue:!1},{name:"nofollow",type:"checkbox",label:"Do not follow links (nofollow)",defaultValue:!1},{name:"canonicalUrl",type:"text",label:"Canonical URL Override",admin:{description:"Leave empty to use the default canonical URL."}},{name:"structuredData",type:"code",label:"JSON-LD Structured Data",admin:{description:"Custom JSON-LD schema for this specific page."}}]}];for(let P of h.collections||[])if(P.seo){let w=P.fields?.find(k=>k.type==="tabs"&&k.name==="mainTabs");w?.tabs&&(w.tabs.find(k=>k.label==="SEO Settings")||w.tabs.push({label:"SEO Settings",fields:R}));}Do__default.default.writeFileSync(f,JSON.stringify(h,null,2),"utf8"),l.info("Project config loaded for admin");}catch(g){l.error(`Could not load project config: ${g.message}`);}finally{if(v&&Do__default.default.existsSync(v))try{Do__default.default.unlinkSync(v);}catch{}}n({vite:{plugins:[{name:"kyro-admin-tsx-loader",enforce:"pre",config(g){let x=g.esbuild,u=x?.exclude,y=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...x||{},exclude:u?Array.isArray(u)?[...u,y]:[u,y]:y}}}},{name:"kyro-cjs-shim",enforce:"pre",resolveId(g){if(g.includes("react/compiler-runtime"))return "\0react-compiler-runtime";if(g==="debug"||g.includes("debug/src/browser.js"))return "\0debug-browser"},load(g){if(g==="\0react-compiler-runtime")return `
135
+ `,u=new worker_threads.Worker(f,{eval:!0,env:{...process.env,NODE_OPTIONS:""}}),x=await new Promise((F,h)=>{u.on("message",F),u.on("error",h);let w=setTimeout(()=>{u.terminate(),h(new Error("Config loading timed out"));},3e4);});if(u.terminate(),x.error)throw new Error(x.error);let A=[{name:"metaTitle",type:"text",label:"Meta Title",admin:{description:"The title used for search engines (recommended < 60 chars).",autoGenerate:"title"}},{name:"metaDescription",type:"textarea",label:"Meta Description",admin:{description:"A brief summary for search engines (recommended < 160 chars).",autoGenerate:"content"}},{name:"keywords",type:"text",label:"Keywords",admin:{description:"Comma-separated list of keywords for this page."}},{name:"ogImage",type:"upload",label:"OpenGraph Image",relationTo:"media",admin:{description:"The image shown when shared on social media."}},{name:"twitter",type:"group",label:"Twitter Card",fields:[{name:"title",type:"text",label:"Twitter Title"},{name:"description",type:"textarea",label:"Twitter Description"},{name:"image",type:"upload",label:"Twitter Image",relationTo:"media"}]},{name:"advanced",type:"group",label:"Advanced Search Settings",fields:[{name:"noindex",type:"checkbox",label:"Hide from search engines (noindex)",defaultValue:!1},{name:"nofollow",type:"checkbox",label:"Do not follow links (nofollow)",defaultValue:!1},{name:"canonicalUrl",type:"text",label:"Canonical URL Override",admin:{description:"Leave empty to use the default canonical URL."}},{name:"structuredData",type:"code",label:"JSON-LD Structured Data",admin:{description:"Custom JSON-LD schema for this specific page."}}]}];for(let F of x.collections||[])if(F.seo){let h=F.fields?.find(w=>w.type==="tabs"&&w.name==="tabs");h?.tabs&&(h.tabs.find(w=>w.label==="SEO Settings")||h.tabs.push({label:"SEO Settings",fields:A}));}Bo__default.default.writeFileSync(y,JSON.stringify(x,null,2),"utf8"),l.info("Project config loaded for admin");}catch(v){l.error(`Could not load project config: ${v.message}`);}finally{if(g&&Bo__default.default.existsSync(g))try{Bo__default.default.unlinkSync(g);}catch{}}n({vite:{plugins:[{name:"kyro-admin-tsx-loader",enforce:"pre",config(v){let k=v.esbuild,f=k?.exclude,u=/\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;return {esbuild:{...k||{},exclude:f?Array.isArray(f)?[...f,u]:[f,u]:u}}}},{name:"kyro-cjs-shim",enforce:"pre",resolveId(v){if(v.includes("react/compiler-runtime"))return "\0react-compiler-runtime";if(v==="debug"||v.includes("debug/src/browser.js"))return "\0debug-browser"},load(v){if(v==="\0react-compiler-runtime")return `
136
136
  import React from "react";
137
137
  export function c(size) {
138
138
  const internals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
@@ -141,7 +141,7 @@ export function c(size) {
141
141
  }
142
142
  return internals.H.useMemoCache(size);
143
143
  }
144
- `;if(g==="\0debug-browser")return `
144
+ `;if(v==="\0debug-browser")return `
145
145
  function debug(namespace) {
146
146
  function d(...args) {
147
147
  if (typeof localStorage !== "undefined" && localStorage.getItem("DEBUG")) {
@@ -154,4 +154,4 @@ debug.enable = function() {};
154
154
  debug.disable = function() {};
155
155
  debug.enabled = function() { return false; };
156
156
  export default debug;
157
- `}}],resolve:{alias:{"kyro:config":m}},optimizeDeps:{include:["@kyro-cms/admin"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(f)},ssr:{noExternal:["@kyro-cms/admin","@kyro-cms/core","@tiptap/core","@tiptap/react","@tiptap/pm","@tiptap/starter-kit","@tiptap/extension-link","@tiptap/extension-image","@tiptap/extension-text-align","@tiptap/extension-underline","@tiptap/extension-highlight","@tiptap/extension-task-list","@tiptap/extension-task-item","@tiptap/extension-text-style","@tiptap/extension-color","prosemirror-model","prosemirror-state","prosemirror-view","prosemirror-schema-list","prosemirror-commands","prosemirror-keymap","prosemirror-transform","prosemirror-inputrules"]}}}),globalThis.__KYRO_ADMIN_PROJECT_CONFIG__={collections:[],globals:[],adapter:null};let b=[{pattern:"",entrypoint:"./pages/index.astro"},{pattern:"/login",entrypoint:"./pages/auth/login.astro"},{pattern:"/register",entrypoint:"./pages/auth/register.astro"},{pattern:"/media",entrypoint:"./pages/media.astro"},{pattern:"/users",entrypoint:"./pages/users/index.astro"},{pattern:"/users/new",entrypoint:"./pages/users/new.astro"},{pattern:"/users/[id]",entrypoint:"./pages/users/[id].astro"},{pattern:"/roles",entrypoint:"./pages/roles/index.astro"},{pattern:"/settings",entrypoint:"./pages/settings/index.astro"},{pattern:"/settings/[slug]",entrypoint:"./pages/settings/[slug].astro"},{pattern:"/audit",entrypoint:"./pages/audit/index.astro"},{pattern:"/sessions",entrypoint:"./pages/sessions.astro"},{pattern:"/keys",entrypoint:"./pages/keys.astro"},{pattern:"/webhooks",entrypoint:"./pages/webhooks.astro"},{pattern:"/plugins",entrypoint:"./pages/plugins.astro"},{pattern:"/marketplace",entrypoint:"./pages/marketplace.astro"},{pattern:"/graphql",entrypoint:"./pages/graphql.astro"},{pattern:"/rest-playground",entrypoint:"./pages/rest-playground.astro"},{pattern:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let g of b){let x=`${t}${g.pattern}`.replace(/\/$/,"");s({pattern:x||"/",entrypoint:yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,g.entrypoint)});}},"astro:build:done":({logger:a})=>{a.info("Kyro Admin build complete");}}}}exports.ActionBar=si;exports.Admin=iy;exports.AutoForm=Wa;exports.Badge=Pt;exports.BulkActionsBar=ly;exports.Button=gs;exports.ConfirmModal=Ns;exports.CountBadge=vs;exports.CreateView=di;exports.DARK_THEME=Fa;exports.DarkThemeProvider=Rn;exports.DetailView=li;exports.Dropdown=So;exports.DropdownItem=jt;exports.DropdownSeparator=Ka;exports.ExtDarkThemeProvider=Rn;exports.ExtLightThemeProvider=Tn;exports.ExtThemeProvider=hr;exports.Header=gA;exports.LIGHT_THEME=_o;exports.LightThemeProvider=Tn;exports.ListView=ks;exports.LoginPage=mi;exports.Modal=Ot;exports.PageHeader=Dt;exports.SlidePanel=dr;exports.Spinner=kr;exports.ThemeProvider=hr;exports.Toast=Jd;exports.ToastProvider=X3;exports.VersionHistoryPanel=vy;exports.adminPath=Ge;exports.afterDeploy=pc;exports.apiPath=br;exports.beforeDeploy=cc;exports.emitAdminReady=mc;exports.emitAfterDeploy=yc;exports.emitBeforeDeploy=uc;exports.getBlock=Cc;exports.getBlocks=Sc;exports.getBlocksByCategory=Tc;exports.getField=Pc;exports.getFieldByType=Bc;exports.getFields=Ic;exports.getPlugin=kc;exports.getPlugins=hc;exports.getPluginsWithHook=wc;exports.kyroAdmin=$y;exports.mergeThemes=Da;exports.onAdminReady=ts;exports.paths=Yc;exports.registerBlock=pa;exports.registerField=ua;exports.registerPlugin=da;exports.resolveAdmin=ss;exports.resolveApi=tt;exports.unregisterBlock=Nc;exports.unregisterField=Dc;exports.unregisterPlugin=xc;exports.useBlockRenderer=Rc;exports.useExtTheme=Ho;exports.useFieldRenderer=Lc;exports.useKyroMutation=bc;exports.useKyroQuery=gc;exports.useTheme=Ho;exports.useToast=Y3;
157
+ `}}],resolve:{alias:{"kyro:config":p}},optimizeDeps:{include:["@kyro-cms/admin"],exclude:["debug","react/compiler-runtime"]},define:{__KYRO_ADMIN_PATH__:JSON.stringify(t),__KYRO_API_PATH__:JSON.stringify(r),__KYRO_ADMIN_CONFIG_FILE__:JSON.stringify(y)},ssr:{noExternal:["@kyro-cms/admin","@kyro-cms/core","@tiptap/core","@tiptap/react","@tiptap/pm","@tiptap/starter-kit","@tiptap/extension-link","@tiptap/extension-image","@tiptap/extension-text-align","@tiptap/extension-underline","@tiptap/extension-highlight","@tiptap/extension-task-list","@tiptap/extension-task-item","@tiptap/extension-text-style","@tiptap/extension-color","prosemirror-model","prosemirror-state","prosemirror-view","prosemirror-schema-list","prosemirror-commands","prosemirror-keymap","prosemirror-transform","prosemirror-inputrules"]}}}),globalThis.__KYRO_ADMIN_PROJECT_CONFIG__={collections:[],globals:[],adapter:null};let b=[{pattern:"",entrypoint:"./pages/index.astro"},{pattern:"/login",entrypoint:"./pages/auth/login.astro"},{pattern:"/register",entrypoint:"./pages/auth/register.astro"},{pattern:"/media",entrypoint:"./pages/media.astro"},{pattern:"/users",entrypoint:"./pages/users/index.astro"},{pattern:"/users/new",entrypoint:"./pages/users/new.astro"},{pattern:"/users/[id]",entrypoint:"./pages/users/[id].astro"},{pattern:"/roles",entrypoint:"./pages/roles/index.astro"},{pattern:"/settings",entrypoint:"./pages/settings/index.astro"},{pattern:"/settings/[slug]",entrypoint:"./pages/settings/[slug].astro"},{pattern:"/audit",entrypoint:"./pages/audit/index.astro"},{pattern:"/sessions",entrypoint:"./pages/sessions.astro"},{pattern:"/keys",entrypoint:"./pages/keys.astro"},{pattern:"/webhooks",entrypoint:"./pages/webhooks.astro"},{pattern:"/plugins",entrypoint:"./pages/plugins.astro"},{pattern:"/marketplace",entrypoint:"./pages/marketplace.astro"},{pattern:"/graphql",entrypoint:"./pages/graphql.astro"},{pattern:"/rest-playground",entrypoint:"./pages/rest-playground.astro"},{pattern:"/[collection]",entrypoint:"./pages/[collection]/index.astro"},{pattern:"/[collection]/[id]",entrypoint:"./pages/[collection]/[id].astro"}];for(let v of b){let k=`${t}${v.pattern}`.replace(/\/$/,"");s({pattern:k||"/",entrypoint:yr__default.default.resolve(new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))).pathname,v.entrypoint)});}},"astro:build:done":({logger:a})=>{a.info("Kyro Admin build complete");}}}}exports.ActionBar=ki;exports.Admin=$y;exports.AutoForm=Ya;exports.Badge=At;exports.BulkActionsBar=Oy;exports.Button=Ps;exports.ConfirmModal=Es;exports.CountBadge=Fs;exports.CreateView=Ni;exports.DARK_THEME=Ia;exports.DarkThemeProvider=zn;exports.DetailView=wi;exports.Dropdown=Ro;exports.DropdownItem=Tt;exports.DropdownSeparator=qa;exports.ExtDarkThemeProvider=zn;exports.ExtLightThemeProvider=Un;exports.ExtThemeProvider=wr;exports.Header=yF;exports.LIGHT_THEME=Vo;exports.LightThemeProvider=Un;exports.ListView=Bs;exports.LoginPage=Ti;exports.Modal=Nt;exports.PageHeader=Lt;exports.SlidePanel=dr;exports.Spinner=hr;exports.ThemeProvider=wr;exports.Toast=uc;exports.ToastProvider=qT;exports.VersionHistoryPanel=Gy;exports.adminPath=Oe;exports.afterDeploy=Pc;exports.apiPath=xr;exports.beforeDeploy=Fc;exports.emitAdminReady=Dc;exports.emitAfterDeploy=Bc;exports.emitBeforeDeploy=Ic;exports.getBlock=Hc;exports.getBlocks=Vc;exports.getBlocksByCategory=Kc;exports.getField=Xc;exports.getFieldByType=Qc;exports.getFields=Yc;exports.getPlugin=Uc;exports.getPlugins=zc;exports.getPluginsWithHook=jc;exports.kyroAdmin=yf;exports.mergeThemes=Ba;exports.onAdminReady=vs;exports.paths=vp;exports.registerBlock=ma;exports.registerField=ya;exports.registerPlugin=ca;exports.resolveAdmin=ks;exports.resolveApi=We;exports.unregisterBlock=_c;exports.unregisterField=qc;exports.unregisterPlugin=Oc;exports.useBlockRenderer=Gc;exports.useExtTheme=Ko;exports.useFieldRenderer=Zc;exports.useKyroMutation=$c;exports.useKyroQuery=Ec;exports.useTheme=Ko;exports.useToast=XT;