@object-ui/console 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AppManagementPage-C3hg63SY.js → AppManagementPage-C5q5QBar.js} +1 -1
- package/dist/assets/{AuditLogPage-BQ8vLOcD.js → AuditLogPage-BpLFTD-b.js} +1 -1
- package/dist/assets/{CreateAppPage-Do3sVvxx.js → CreateAppPage-A-VfItcx.js} +1 -1
- package/dist/assets/{DashboardDesignPage-B2PH_3Ly.js → DashboardDesignPage-N8NL-jkM.js} +1 -1
- package/dist/assets/{DashboardView-DxTi63mN.js → DashboardView-Dy0d2kFj.js} +1 -1
- package/dist/assets/{EditAppPage-j0L1x2UT.js → EditAppPage-B6HL4COW.js} +1 -1
- package/dist/assets/{OrgManagementPage-BTNWvRHI.js → OrgManagementPage-BqtqRi_6.js} +1 -1
- package/dist/assets/{PageDesignPage-B62v76Qo.js → PageDesignPage-BzIL8o0u.js} +1 -1
- package/dist/assets/{PageView-CzF68bdQ.js → PageView-eCi7zkJr.js} +1 -1
- package/dist/assets/{PermissionManagementPage-PWrxdXgQ.js → PermissionManagementPage-BmI-0QXt.js} +1 -1
- package/dist/assets/{RecordDetailView-FkYkjMEZ.js → RecordDetailView-CFVPmfrM.js} +1 -1
- package/dist/assets/{ReportView-pQJYBCo1.js → ReportView-DNOPIpWM.js} +1 -1
- package/dist/assets/{RoleManagementPage-cNU9Z5K1.js → RoleManagementPage-DwtqyfDW.js} +1 -1
- package/dist/assets/{SearchResultsPage-DJU7W1Zx.js → SearchResultsPage-BxzOkRnL.js} +1 -1
- package/dist/assets/{SystemHubPage-BxKsLijB.js → SystemHubPage-RFiJSMgW.js} +1 -1
- package/dist/assets/{UserManagementPage-D2qUebpD.js → UserManagementPage-BBS1vYGa.js} +1 -1
- package/dist/assets/index-DDpLaQOV.js +8 -0
- package/dist/index.html +1 -1
- package/package.json +35 -35
- package/dist/assets/index-RiB5-8aY.js +0 -8
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChartImpl-Cwo6IWnY.js","assets/infrastructure-C6Ph6Ug0.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/framework-DJlDX9E6.js","assets/plugins-core-PiAAytWV.js","assets/data-adapter-wZ81OFjZ.js","assets/plugins-core-Cfhp_BXE.css","assets/vendor-charts-Bl5l0H2K.js","assets/AdvancedChartImpl-Dvg6YIfN.js","assets/KanbanImpl-D9BbG_RT.js","assets/KanbanEnhanced-Dj7Qccu2.js","assets/RecordDetailView-FkYkjMEZ.js","assets/skeletons-DcGqw3b1.js","assets/plugins-views-CE0VP3vl.js","assets/plugins-views-DnNKJB60.css","assets/ui-layout-DdDX0gzI.js","assets/DashboardView-DxTi63mN.js","assets/PageView-CzF68bdQ.js","assets/ReportView-pQJYBCo1.js","assets/SearchResultsPage-DJU7W1Zx.js","assets/CreateAppPage-Do3sVvxx.js","assets/src-oeWLmiqa.js","assets/EditAppPage-j0L1x2UT.js","assets/PageDesignPage-B62v76Qo.js","assets/DashboardDesignPage-B2PH_3Ly.js","assets/LoginPage-D2CqpSi0.js","assets/AuthPageLayout-DDjJTsQ6.js","assets/RegisterPage-D7PJIabW.js","assets/ForgotPasswordPage-Slo6CHvD.js","assets/SystemHubPage-BxKsLijB.js","assets/AppManagementPage-C3hg63SY.js","assets/UserManagementPage-D2qUebpD.js","assets/systemObjects-5--4zaiX.js","assets/OrgManagementPage-BTNWvRHI.js","assets/RoleManagementPage-cNU9Z5K1.js","assets/PermissionManagementPage-PWrxdXgQ.js","assets/AuditLogPage-BQ8vLOcD.js","assets/ProfilePage-CUo-xIgl.js","assets/maplibre-gl-DsUGuDud.js","assets/MarkdownImpl-B0Iew7iJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,E as n,M as r,N as i,O as a,S as o,T as s,b as c,d as l,f as u,g as d,h as f,k as p,l as m,v as h,w as g,x as _}from"./framework-DJlDX9E6.js";import{t as v}from"./vendor-react-BwtAzZZ3.js";import{$c as y,$o as b,$s as x,$t as S,Ao as C,As as w,At as T,Bo as E,Bs as D,Cl as O,Cn as k,Ct as A,Dc as j,Dn as M,Do as N,Dt as P,En as F,Et as ee,Fc as te,Fo as ne,Fs as re,Ft as ie,Gc as ae,Go as oe,Gs as se,Gt as ce,Hc as le,Ho as ue,Ic as de,Io as fe,Is as pe,Jo as I,Jt as me,Ko as he,Lo as ge,Lt as _e,Mo as ve,Ms as ye,Mt as be,No as xe,Nt as Se,Oo as L,Ot as Ce,Pc as we,Po as Te,Pt as Ee,Qo as De,Qt as Oe,Rt as ke,Sn as Ae,Ss as je,St as R,Tn as Me,Tt as Ne,Uo as Pe,Ut as Fe,Vc as Ie,Vo as Le,Wc as Re,Wo as ze,Wt as Be,Xo as Ve,Xt as He,Yc as Ue,Yo as We,Yt as Ge,Zc as Ke,Zt as qe,_ as Je,_c as Ye,_n as Xe,_s as Ze,a as Qe,an as $e,at as et,b as tt,bc as nt,bl as rt,bn as it,bt as at,c as ot,cn as st,ct,dc as lt,dn as z,ds as ut,dt,el as ft,en as pt,f as mt,fn as ht,ft as gt,gc as _t,gn as vt,h as yt,hc as bt,hn as xt,hs as St,ht as Ct,i as wt,ic as Tt,il as Et,in as Dt,it as Ot,jc as kt,jn as At,jo as jt,kc as Mt,ko as Nt,ks as Pt,kt as Ft,l as It,lc as Lt,ln as Rt,ls as zt,lt as Bt,ml as Vt,mn as Ht,n as Ut,nc as Wt,nl as Gt,ns as Kt,o as qt,ol as Jt,on as B,ot as Yt,p as Xt,pn as Zt,pt as V,qc as Qt,qo as $t,qt as en,rn as tn,rs as nn,s as rn,sc as an,sl as on,sn,st as cn,t as ln,tc as un,tl as dn,tn as fn,u as pn,ul as mn,un as hn,ut as gn,v as _n,vl as vn,vn as yn,vs as bn,wc as xn,wn as Sn,wt as Cn,xn as wn,xt as Tn,y as En,yl as H,yn as U,ys as Dn}from"./plugins-core-PiAAytWV.js";import{S as W,g as On,h as kn,i as An,t as jn,v as G,y as Mn}from"./data-adapter-wZ81OFjZ.js";import{a as Nn,c as Pn,d as Fn,i as In,l as Ln,n as Rn,o as K,r as zn,s as Bn,t as Vn,u as Hn}from"./ui-layout-DdDX0gzI.js";import{c as Un,f as Wn,l as Gn,n as Kn,p as q,r as qn,s as Jn,t as Yn,u as Xn}from"./infrastructure-C6Ph6Ug0.js";import{c as Zn,o as Qn,s as $n}from"./plugins-views-CE0VP3vl.js";import{t as er}from"./vendor-objectstack-BtztJIHv.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var tr=e(v(),1),J=e(i(),1),Y=g(),nr=(0,J.createContext)(null);function rr(e){return e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}async function ir(e){let t=e.getClient(),[n,r,i,a,o]=await Promise.all([t.meta.getItems(`app`).catch(()=>({items:[]})),t.meta.getItems(`object`).catch(()=>({items:[]})),t.meta.getItems(`dashboard`).catch(()=>({items:[]})),t.meta.getItems(`report`).catch(()=>({items:[]})),t.meta.getItems(`page`).catch(()=>({items:[]}))]);return{apps:rr(n),objects:rr(r),dashboards:rr(i),reports:rr(a),pages:rr(o)}}function ar({children:e,adapter:t}){let[n,r]=(0,J.useState)({apps:[],objects:[],dashboards:[],reports:[],pages:[],loading:!0,error:null}),i=(0,J.useRef)(t);i.current=t;let a=(0,J.useCallback)(async()=>{r(e=>({...e,loading:!0,error:null}));try{r({...await ir(i.current),loading:!1,error:null})}catch(e){r(t=>({...t,loading:!1,error:e instanceof Error?e:Error(String(e))}))}},[]);(0,J.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await ir(t);e||r({...n,loading:!1,error:null})}catch(t){e||r(e=>({...e,loading:!1,error:t instanceof Error?t:Error(String(t))}))}})(),()=>{e=!0}},[t]);let o={...n,refresh:a};return(0,Y.jsx)(nr.Provider,{value:o,children:e})}function or(){let e=(0,J.useContext)(nr);if(!e)throw Error(`useMetadata must be used within a <MetadataProvider>`);return e}var sr=(0,J.createContext)(null);function cr(){return(0,J.useContext)(sr)}function lr({children:e,adapter:t}){let[n,r]=(0,J.useState)(t??null);return(0,J.useEffect)(()=>{if(t){r(t);return}let e=!1;async function n(){try{let t=new jn({baseUrl:``,autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});await t.connect(),e||r(t)}catch(t){e||console.error(`[Console] Failed to initialize:`,t)}}return n(),()=>{e=!0}},[t]),(0,Y.jsx)(sr.Provider,{value:n,children:e})}var ur=(0,J.createContext)(null);function dr({children:e,user:t={},app:r={},data:i={}}){let a=(0,J.useMemo)(()=>({user:t,app:r,data:i,evaluator:new n({user:t,app:r,data:i})}),[t,r,i]);return(0,Y.jsx)(ur.Provider,{value:a,children:e})}function fr(){let e=(0,J.useContext)(ur);if(!e){let e={user:{},app:{},data:{}};return{...e,evaluator:new n(e)}}return e}function pr(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}var mr=`objectui-recent-items`,hr=8;function gr(){try{let e=localStorage.getItem(mr);return e?JSON.parse(e):[]}catch{return[]}}function _r(e){try{localStorage.setItem(mr,JSON.stringify(e))}catch{}}function vr(){let[e,t]=(0,J.useState)(gr);return(0,J.useEffect)(()=>{t(gr())},[]),{recentItems:e,addRecentItem:(0,J.useCallback)(e=>{t(t=>{let n=t.filter(t=>t.id!==e.id),r=[{...e,visitedAt:new Date().toISOString()},...n].slice(0,hr);return _r(r),r})},[]),clearRecentItems:(0,J.useCallback)(()=>{t([]),_r([])},[])}}var yr=`objectui-favorites`,br=20;function xr(){try{let e=localStorage.getItem(yr);return e?JSON.parse(e):[]}catch{return[]}}function Sr(e){try{localStorage.setItem(yr,JSON.stringify(e))}catch{}}function Cr(){let[e,t]=(0,J.useState)(xr);return(0,J.useEffect)(()=>{t(xr())},[]),{favorites:e,addFavorite:(0,J.useCallback)(e=>{t(t=>{if(t.some(t=>t.id===e.id))return t;let n=[{...e,favoritedAt:new Date().toISOString()},...t].slice(0,br);return Sr(n),n})},[]),removeFavorite:(0,J.useCallback)(e=>{t(t=>{let n=t.filter(t=>t.id!==e);return Sr(n),n})},[]),toggleFavorite:(0,J.useCallback)(e=>{t(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[{...e,favoritedAt:new Date().toISOString()},...t].slice(0,br);return Sr(n),n})},[]),isFavorite:(0,J.useCallback)(t=>e.some(e=>e.id===t),[e]),clearFavorites:(0,J.useCallback)(()=>{t([]),Sr([])},[])}}var wr=`objectui-nav-pins`,Tr=20;function Er(){try{let e=localStorage.getItem(wr);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Dr(e){try{localStorage.setItem(wr,JSON.stringify(e))}catch{}}function Or(){let[e,t]=(0,J.useState)(Er);(0,J.useEffect)(()=>{t(Er())},[]);let n=(0,J.useCallback)((e,n)=>{t(t=>{let r=t.filter(t=>t!==e),i=n?[...r,e].slice(0,Tr):r;return Dr(i),i})},[]),r=(0,J.useCallback)(t=>e.includes(t),[e]),i=(0,J.useCallback)(t=>t.map(t=>{let n=e.includes(t.id),r=t.children?.length?i(t.children):t.children;return n!==(t.pinned??!1)||r!==t.children?{...t,pinned:n,children:r}:t}),[e]);return{pinnedIds:e,togglePin:n,isPinned:r,applyPins:i,clearPins:(0,J.useCallback)(()=>{t([]),Dr([])},[])}}function X(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}function kr(e){let t=`objectui-nav-order-${e}`,[n,r]=J.useState(()=>{try{let e=localStorage.getItem(t);if(!e)return{};let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))Array.isArray(t)&&t.every(e=>typeof e==`string`)&&(r[e]=t);return r}catch{return{}}}),i=J.useCallback(e=>{r(e);try{localStorage.setItem(t,JSON.stringify(e))}catch{}},[t]);return{applyOrder:J.useCallback(e=>{let t=n.__root__;if(!t)return e;let r=new Map(e.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return r.forEach(e=>i.push(e)),i},[n]),handleReorder:J.useCallback(e=>{let t=e.map(e=>e.id);i({...n,__root__:t})},[n,i])}}function Ar(e){if(!e)return Ie;if(Ve[e])return Ve[e];let t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return Ve[t]?Ve[t]:Ie}function jr({activeAppName:e,onAppChange:t}){let{isMobile:n}=ke(),{user:r,signOut:i}=Un(),a=Ln(),{t:o}=q(),{objectLabel:s}=Xn();J.useEffect(()=>{let e=0,t=t=>{e=t.touches[0].clientX},r=t=>{let r=t.changedTouches[0].clientX-e;e<30&&r>50&&n&&document.querySelector(`[data-sidebar="trigger"]`)?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0}))};return document.addEventListener(`touchstart`,t,{passive:!0}),document.addEventListener(`touchend`,r,{passive:!0}),()=>{document.removeEventListener(`touchstart`,t),document.removeEventListener(`touchend`,r)}},[n]);let{recentItems:c}=vr(),{favorites:l,removeFavorite:u}=Cr(),{apps:d}=or(),f=(d||[]).filter(e=>e.active!==!1),p=f.find(t=>t.name===e)||f[0],m=p?.branding?.logo,h=p?.branding?.primaryColor,{applyOrder:g,handleReorder:_}=kr(e),{togglePin:v,applyPins:b}=Or(),x=p?.areas||[],[S,C]=J.useState(()=>x.length>0?x[0].id:null);J.useEffect(()=>{x.length>0?C(e=>x.some(t=>t.id===e)?e:x[0].id):C(null)},[e,x.length]);let w=x.find(e=>e.id===S)?.navigation||p?.navigation||[],E=J.useMemo(()=>b(g(w)),[w,g,b]),[O,k]=J.useState(``),[j,M]=J.useState(!1),{evaluator:N}=fr(),F=J.useCallback(e=>pr(e,N),[N]),{can:te}=Yn(),re=J.useCallback(e=>e.every(e=>{let t=e.split(`:`),[n,r]=t.length>=2?[t[0],t[1]]:[e,`read`];return te(n,r)}),[te]),oe=p?`/apps/${e}`:``,ce=J.useMemo(()=>[{id:`sys-settings`,label:`System Settings`,type:`url`,url:`/system`,icon:`settings`},{id:`sys-apps`,label:`Applications`,type:`url`,url:`/system/apps`,icon:`layout-grid`},{id:`sys-users`,label:`Users`,type:`url`,url:`/system/users`,icon:`users`},{id:`sys-orgs`,label:`Organizations`,type:`url`,url:`/system/organizations`,icon:`building-2`},{id:`sys-roles`,label:`Roles`,type:`url`,url:`/system/roles`,icon:`shield`},{id:`sys-create-app`,label:`Create App`,type:`url`,url:`/create-app`,icon:`plus`}],[]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(A,{collapsible:`icon`,children:[(0,Y.jsx)(Ft,{children:(0,Y.jsx)(be,{children:(0,Y.jsx)(ie,{children:p?(0,Y.jsxs)(st,{children:[(0,Y.jsx)(Ht,{asChild:!0,children:(0,Y.jsxs)(Ee,{size:`lg`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,Y.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,style:h?{backgroundColor:h}:void 0,children:m?(0,Y.jsx)(`img`,{src:m,alt:X(p.label,o),className:`size-6 object-contain`}):J.createElement(Ar(p.icon),{className:`size-4`})}),(0,Y.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:X(p.label,o)}),(0,Y.jsx)(`span`,{className:`truncate text-xs`,children:X(p.description,o)||`${f.length} Apps Available`})]}),(0,Y.jsx)(Ke,{className:`ml-auto`})]})}),(0,Y.jsxs)(Rt,{className:`w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg`,align:`start`,side:n?`bottom`:`right`,sideOffset:4,children:[(0,Y.jsx)(ht,{className:`text-xs text-muted-foreground`,children:`Switch Application`}),f.map(e=>(0,Y.jsxs)(z,{onClick:()=>t(e.name),className:`gap-2 p-2`,children:[(0,Y.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-sm border`,children:e.icon?J.createElement(Ar(e.icon),{className:`size-3`}):(0,Y.jsx)(Ie,{className:`size-3`})}),X(e.label,o),p.name===e.name&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]},e.name)),(0,Y.jsx)(Zt,{}),(0,Y.jsxs)(z,{className:`gap-2 p-2`,onClick:()=>a(`/apps/${e}/create-app`),"data-testid":`add-app-btn`,children:[(0,Y.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md border bg-background`,children:(0,Y.jsx)(D,{className:`size-4`})}),(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Add App`})]}),(0,Y.jsxs)(z,{className:`gap-2 p-2`,onClick:()=>a(`/apps/${e}/edit-app/${e}`),"data-testid":`edit-app-btn`,children:[(0,Y.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md border bg-background`,children:(0,Y.jsx)(se,{className:`size-4`})}),(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Edit App`})]}),(0,Y.jsxs)(z,{className:`gap-2 p-2`,onClick:()=>a(`/apps/${e}/system/apps`),"data-testid":`manage-all-apps-btn`,children:[(0,Y.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md border bg-background`,children:(0,Y.jsx)(Pt,{className:`size-4`})}),(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Manage All Apps`})]})]})]}):(0,Y.jsxs)(Ee,{size:`lg`,onClick:()=>a(`/system`),"data-testid":`system-sidebar-header`,children:[(0,Y.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:(0,Y.jsx)(Pt,{className:`size-4`})}),(0,Y.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:`System Console`}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:`No apps configured`})]})]})})})}),(0,Y.jsx)(Cn,{children:p?(0,Y.jsxs)(Y.Fragment,{children:[x.length>1&&(0,Y.jsxs)(ee,{children:[(0,Y.jsxs)(Ce,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ye,{className:`h-3.5 w-3.5`}),`Area`]}),(0,Y.jsx)(P,{children:(0,Y.jsx)(be,{children:x.map(e=>{let t=Ar(e.icon);return(0,Y.jsx)(ie,{children:(0,Y.jsxs)(Ee,{isActive:e.id===S,tooltip:e.label,onClick:()=>C(e.id),children:[(0,Y.jsx)(t,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e.label})]})},e.id)})})})]}),(0,Y.jsx)(ee,{className:`py-0`,children:(0,Y.jsxs)(P,{className:`relative`,children:[(0,Y.jsx)(ye,{className:`pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 select-none opacity-70`}),(0,Y.jsx)(T,{placeholder:`Search navigation...`,value:O,onChange:e=>k(e.target.value),className:`pl-8`})]})}),(0,Y.jsx)(Vn,{items:E,basePath:oe,evaluateVisibility:F,checkPermission:re,searchQuery:O,enablePinning:!0,onPinToggle:v,enableReorder:!0,onReorder:_,resolveObjectLabel:(e,t)=>s({name:e,label:t}),t:o}),c.length>0&&(0,Y.jsxs)(ee,{children:[(0,Y.jsxs)(Ce,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>M(e=>!e),children:[(0,Y.jsx)(y,{className:`h-3 w-3 transition-transform duration-150 ${j?`rotate-90`:``}`}),(0,Y.jsx)(ae,{className:`h-3.5 w-3.5`}),`Recent`]}),j&&(0,Y.jsx)(P,{children:(0,Y.jsx)(be,{children:c.slice(0,5).map(e=>(0,Y.jsx)(ie,{children:(0,Y.jsx)(Ee,{asChild:!0,tooltip:e.label,children:(0,Y.jsxs)(In,{to:e.href,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:`📄`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]})})},e.id))})})]}),l.length>0&&(0,Y.jsxs)(ee,{children:[(0,Y.jsxs)(Ce,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(bn,{className:`h-3.5 w-3.5`}),`Favorites`]}),(0,Y.jsx)(P,{children:(0,Y.jsx)(be,{children:l.slice(0,8).map(e=>(0,Y.jsxs)(ie,{children:[(0,Y.jsx)(Ee,{asChild:!0,tooltip:e.label,children:(0,Y.jsxs)(In,{to:e.href,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:e.type===`page`?`📄`:`📋`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]})}),(0,Y.jsx)(Se,{showOnHover:!0,onClick:t=>{t.stopPropagation(),u(e.id)},"aria-label":`Remove ${e.label} from favorites`,children:(0,Y.jsx)(Dn,{className:`h-3 w-3`})})]},e.id))})})]})]}):(0,Y.jsxs)(ee,{"data-testid":`system-fallback-nav`,children:[(0,Y.jsxs)(Ce,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Pt,{className:`h-3.5 w-3.5`}),`System`]}),(0,Y.jsx)(P,{children:(0,Y.jsx)(be,{children:ce.map(e=>{let t=Ar(e.icon);return(0,Y.jsx)(ie,{children:(0,Y.jsx)(Ee,{asChild:!0,tooltip:e.label,children:(0,Y.jsxs)(In,{to:e.url||`/system`,children:[(0,Y.jsx)(t,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{children:e.label})]})})},e.id)})})})]})}),(0,Y.jsx)(Ne,{children:(0,Y.jsx)(be,{children:(0,Y.jsx)(ie,{children:(0,Y.jsxs)(st,{children:[(0,Y.jsx)(Ht,{asChild:!0,children:(0,Y.jsxs)(Ee,{size:`lg`,className:`data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground`,children:[(0,Y.jsxs)(ne,{className:`h-8 w-8 rounded-lg`,children:[(0,Y.jsx)(ge,{src:r?.image??`/avatars/user.jpg`,alt:r?.name??`User`}),(0,Y.jsx)(fe,{className:`rounded-lg bg-primary text-primary-foreground`,children:qn(r)})]}),(0,Y.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:r?.name??`User`}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r?.email??``})]}),(0,Y.jsx)(Ke,{className:`ml-auto size-4`})]})}),(0,Y.jsxs)(Rt,{className:`w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg`,side:n?`bottom`:`right`,align:`end`,sideOffset:4,children:[(0,Y.jsx)(ht,{className:`p-0 font-normal`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5 text-left text-sm`,children:[(0,Y.jsxs)(ne,{className:`h-8 w-8 rounded-lg`,children:[(0,Y.jsx)(ge,{src:r?.image??`/avatars/user.jpg`,alt:r?.name??`User`}),(0,Y.jsx)(fe,{className:`rounded-lg bg-primary text-primary-foreground`,children:qn(r)})]}),(0,Y.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:r?.name??`User`}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r?.email??``})]})]})}),(0,Y.jsx)(Zt,{}),(0,Y.jsx)(hn,{children:(0,Y.jsxs)(z,{onClick:()=>a(p?`/apps/${e}/system`:`/system`),children:[(0,Y.jsx)(Pt,{className:`mr-2 h-4 w-4`}),`Settings`]})}),(0,Y.jsx)(Zt,{}),(0,Y.jsxs)(z,{className:`text-destructive focus:text-destructive`,onClick:()=>i(),children:[(0,Y.jsx)(Lt,{className:`mr-2 h-4 w-4`}),`Log out`]})]})]})})})})]}),n&&(0,Y.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,children:(p?w:ce).filter(e=>e.type!==`group`).slice(0,5).map(t=>{let n=Ar(t.icon),r=p?`/apps/${e}`:``,i=t.url||`#`;return t.type===`object`?(i=`${r}/${t.objectName}`,t.viewName&&(i+=`/view/${t.viewName}`)):t.type===`dashboard`?i=t.dashboardName?`${r}/dashboard/${t.dashboardName}`:`#`:t.type===`page`&&(i=t.pageName?`${r}/page/${t.pageName}`:`#`),(0,Y.jsxs)(In,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] justify-center`,children:[(0,Y.jsx)(n,{className:`h-5 w-5`}),(0,Y.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:X(t.label,o)})]},t.id)})})]})}function Mr(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,J.useState)(`disconnected`),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)([]),[p,m]=(0,J.useState)(null),h=(0,J.useRef)(null),g=(0,J.useRef)(0),_=(0,J.useRef)(null),v=(0,J.useRef)(new Map),y=(0,J.useRef)([]),b=(0,J.useRef)(!0),x=(0,J.useRef)(!1),S=(0,J.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,J.useCallback)(e=>{for(;y.current.length>0;){let t=y.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),w=(0,J.useCallback)(()=>{if(typeof WebSocket>`u`){m(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){m(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){m(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{m(Error(`Invalid WebSocket URL`)),c(`error`);return}h.current&&=(x.current=!0,h.current.close(),null),x.current=!1,c(`connecting`),m(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!b.current)return;m(e instanceof Error?e:Error(`Failed to create WebSocket connection`)),c(`error`);return}h.current=s,s.onopen=()=>{b.current&&(c(`connected`),m(null),g.current=0,C(s))},s.onmessage=e=>{if(b.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=v.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{b.current&&(m(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(b.current){if(h.current=null,x.current){c(`disconnected`);return}if(r&&g.current<a){c(`reconnecting`);let e=Math.min(i*2**g.current,3e4);g.current+=1,_.current=setTimeout(()=>{b.current&&w()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,C]),T=(0,J.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),E=(0,J.useCallback)(()=>{S(),g.current=0,w()},[w,S]),D=(0,J.useCallback)((e,t)=>{let r=h.current;if(r&&r.readyState===WebSocket.OPEN){let i={type:e,channel:n,data:t,timestamp:new Date().toISOString()};r.send(JSON.stringify(i))}else y.current.push({type:e,data:t})},[n]),O=(0,J.useCallback)((e,t)=>(v.current.has(e)||v.current.set(e,new Set),v.current.get(e).add(t),()=>{let n=v.current.get(e);n&&(n.delete(t),n.size===0&&v.current.delete(e))}),[]);return(0,J.useEffect)(()=>(b.current=!0,t&&w(),()=>{b.current=!1,S(),x.current=!0,h.current&&=(h.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:D,subscribe:O,disconnect:T,reconnect:E,error:p}}var Nr=0;function Pr(){return Nr+=1,`conflict-${Date.now()}-${Nr}`}var Fr=0;function Ir(){return Fr+=1,`ver-${Date.now()}-${Fr}`}function Lr(e,t,n){let[r,i]=(0,J.useState)([]),[a,o]=(0,J.useState)([]);return{versions:r,currentVersion:(0,J.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,J.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:Ir(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,J.useCallback)((n,r,a)=>{o(o=>{let s=o.find(e=>e.id===n);if(!s)return o;let c;switch(r){case`local`:c=s.localValue;break;case`remote`:c=s.remoteValue;break;case`merge`:c=a??s.localValue;break}return i(n=>{let i=n.length===0?1:n[n.length-1].version+1,a={id:Ir(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:{[s.field]:{before:s.baseValue,after:c}},message:`Resolved conflict on "${s.field}" using ${r} strategy`};return[...n,a]}),o.filter(e=>e.id!==n)})},[e,t]),resolveAllConflicts:(0,J.useCallback)(n=>{o(r=>{if(r.length===0)return r;let a={};for(let e of r)a[e.field]={before:e.baseValue,after:n===`local`?e.localValue:e.remoteValue};return i(r=>{let i=r.length===0?1:r[r.length-1].version+1,o={id:Ir(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:a,message:`Resolved all conflicts using ${n} strategy`};return[...r,o]}),[]})},[e,t]),revertToVersion:(0,J.useCallback)(n=>{let a=r.findIndex(e=>e.id===n);if(a===-1)return null;let o={};for(let e=0;e<=a;e++){let t=r[e];for(let[e,n]of Object.entries(t.changes))o[e]=n.after}let s={},c={};for(let e of r)for(let[t,n]of Object.entries(e.changes))c[t]=n.after;for(let[e,t]of Object.entries(o))c[e]!==t&&(s[e]={before:c[e],after:t});return Object.keys(s).length>0&&i(n=>{let i=n.length===0?1:n[n.length-1].version+1,o={id:Ir(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:s,message:`Reverted to version ${r[a].version}`};return[...n,o]}),o},[r,e,t]),compareVersions:(0,J.useCallback)((e,t)=>{let n=r.findIndex(t=>t.id===e),i=r.findIndex(e=>e.id===t);if(n===-1||i===-1)return null;let[a,o]=n<i?[n,i]:[i,n],s=e=>{let t={};for(let n=0;n<=e;n++)for(let[e,i]of Object.entries(r[n].changes))t[e]=i.after;return t},c=s(a),l=s(o),u=new Set([...Object.keys(c),...Object.keys(l)]),d={};for(let e of u){let t=c[e],n=l[e];t!==n&&(d[e]={before:t,after:n})}return d},[r]),addConflict:(0,J.useCallback)(e=>{let t={...e,id:Pr()};o(e=>[...e,t])},[]),clearHistory:(0,J.useCallback)(()=>{i([]),o([])},[])}}var Rr={sm:24,md:32,lg:40},zr={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function Br(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function Vr({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=Rr[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,J.useMemo)(()=>e.slice(0,t),[e,t]),u=Math.max(0,e.length-t),d={display:`inline-flex`,alignItems:`center`,flexDirection:`row-reverse`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`},f={width:`${a}px`,height:`${a}px`,borderRadius:`50%`,border:`2px solid #fff`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`${s}px`,fontWeight:600,color:`#fff`,position:`relative`,flexShrink:0,overflow:`hidden`,boxSizing:`border-box`},p={...f,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${o}px`},m={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${c}px`,height:`${c}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},h=(0,J.useMemo)(()=>[...l].reverse(),[l]);return J.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&J.createElement(`div`,{key:`overflow`,style:p,title:`${u} more user${u===1?``:`s`}`},`+${u}`),h.map((e,t)=>J.createElement(`div`,{key:e.userId,style:{...f,backgroundColor:e.color,marginLeft:t>0||u>0?`-${o}px`:`0`},title:`${e.userName} (${e.status})`},e.avatar?J.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):Br(e.userName),r&&J.createElement(`span`,{style:{...m,backgroundColor:zr[e.status]}}))))}var Hr=(0,J.createContext)({theme:`system`,setTheme:()=>null});function Ur({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=(0,J.useState)(()=>localStorage.getItem(n)||t);(0,J.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(i)},[i]);let o={theme:i,setTheme:e=>{localStorage.setItem(n,e),a(e)}};return(0,Y.jsx)(Hr.Provider,{...r,value:o,children:e})}var Wr=()=>{let e=(0,J.useContext)(Hr);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function Gr(){let{theme:e,setTheme:t}=Wr(),{t:n}=q();return(0,Y.jsxs)(st,{children:[(0,Y.jsx)(Ht,{asChild:!0,children:(0,Y.jsxs)(I,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,Y.jsx)(Ze,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),(0,Y.jsx)(un,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:n(`console.theme.toggle`)})]})}),(0,Y.jsxs)(Rt,{align:`end`,children:[(0,Y.jsxs)(z,{onClick:()=>t(`light`),className:`gap-2`,children:[(0,Y.jsx)(Ze,{className:`h-4 w-4`}),n(`console.theme.light`),e===`light`&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,Y.jsxs)(z,{onClick:()=>t(`dark`),className:`gap-2`,children:[(0,Y.jsx)(un,{className:`h-4 w-4`}),n(`console.theme.dark`),e===`dark`&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,Y.jsxs)(z,{onClick:()=>t(`system`),className:`gap-2`,children:[(0,Y.jsx)(Wt,{className:`h-4 w-4`}),n(`console.theme.system`),e===`system`&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]})]})]})}var Kr=[{code:`en`,label:`English`},{code:`zh`,label:`中文`},{code:`ja`,label:`日本語`},{code:`ko`,label:`한국어`},{code:`de`,label:`Deutsch`},{code:`fr`,label:`Français`},{code:`es`,label:`Español`},{code:`pt`,label:`Português`},{code:`ru`,label:`Русский`},{code:`ar`,label:`العربية`}];function qr(){let{t:e,language:t,changeLanguage:n}=q();return(0,Y.jsxs)(st,{children:[(0,Y.jsx)(Ht,{asChild:!0,children:(0,Y.jsxs)(I,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,Y.jsx)(Mt,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e(`console.localeSwitcher.label`)})]})}),(0,Y.jsx)(Rt,{align:`end`,className:`max-h-72 overflow-y-auto`,children:Kr.map(e=>(0,Y.jsxs)(z,{onClick:()=>n(e.code),className:`gap-2`,children:[e.label,t===e.code&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]},e.code))})]})}var Jr={connected:{label:`Connected`,color:`text-green-500`,icon:Ue},connecting:{label:`Connecting...`,color:`text-yellow-500`,icon:lt},reconnecting:{label:`Reconnecting...`,color:`text-yellow-500`,icon:lt},disconnected:{label:`Disconnected`,color:`text-muted-foreground`,icon:nn},error:{label:`Connection Error`,color:`text-destructive`,icon:nn}};function Yr({state:e,className:t}){let n=Jr[e],r=n.icon,[i,a]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{if(e===`connected`){a(!0);let e=setTimeout(()=>a(!1),2e3);return()=>clearTimeout(e)}a(!1)},[e]),e===`connected`&&!i?null:(0,Y.jsxs)(`div`,{className:H(`flex items-center gap-1.5 text-xs font-medium px-2 py-1 rounded-md transition-opacity duration-300`,n.color,e===`connected`&&`bg-green-500/10`,e===`error`&&`bg-destructive/10`,e===`reconnecting`&&`bg-yellow-500/10`,t),title:n.label,children:[(0,Y.jsx)(r,{className:H(`h-3.5 w-3.5`,(e===`connecting`||e===`reconnecting`)&&`animate-spin`)}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})}var Xr={create:{icon:D,color:`text-green-500`},update:{icon:se,color:`text-blue-500`},delete:{icon:ut,color:`text-red-500`},comment:{icon:Tt,color:`text-amber-500`}};function Zr(e){let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.floor((Date.now()-t)/1e3);if(n<60)return`${Math.max(n,0)}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Qr({activities:e=[],className:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)({create:!0,update:!0,delete:!0,comment:!0}),c=e=>{s(t=>({...t,[e]:!t[e]}))},l=e.filter(e=>o[e.type]);return(0,Y.jsxs)(Be,{open:n,onOpenChange:r,children:[(0,Y.jsx)(Ge,{asChild:!0,children:(0,Y.jsxs)(I,{variant:`ghost`,size:`icon`,className:t??`h-8 w-8`,"aria-label":`Activity feed`,children:[(0,Y.jsx)(mn,{className:`h-4 w-4`}),e.length>0&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-primary text-[9px] font-bold text-primary-foreground flex items-center justify-center`,children:e.length>9?`9+`:e.length})]})}),(0,Y.jsxs)(ce,{side:`right`,className:`w-80 sm:w-96`,children:[(0,Y.jsx)(en,{children:(0,Y.jsxs)(me,{className:`flex items-center justify-between`,children:[`Recent Activity`,(0,Y.jsxs)(I,{variant:i?`secondary`:`ghost`,size:`sm`,className:`h-7 px-2`,onClick:()=>a(!i),children:[(0,Y.jsx)(kt,{className:`h-3.5 w-3.5 mr-1`}),`Filter`]})]})}),i&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-3 px-1`,children:Object.keys(Xr).map(e=>{let{icon:t,color:n}=Xr[e],r=o[e];return(0,Y.jsxs)(Te,{variant:r?`default`:`outline`,className:`cursor-pointer select-none gap-1 capitalize`,onClick:()=>c(e),children:[(0,Y.jsx)(t,{className:`h-3 w-3 ${r?``:n}`}),e]},e)})}),l.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-16 text-muted-foreground`,children:[(0,Y.jsx)(mn,{className:`h-8 w-8 opacity-40`}),(0,Y.jsx)(`p`,{className:`text-sm`,children:`No recent activity`})]}):(0,Y.jsx)(`ul`,{className:`mt-4 space-y-1 overflow-y-auto max-h-[calc(100vh-8rem)]`,children:l.map(e=>{let{icon:t,color:n}=Xr[e.type];return(0,Y.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md px-2 py-2 hover:bg-muted/50 transition-colors`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 shrink-0 ${n}`,children:(0,Y.jsx)(t,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-snug`,children:e.description}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[e.user,` · `,Zr(e.timestamp)]})]})]},e.id)})})]})]})}function $r(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var ei=[{userId:`u1`,userName:`Alice Chen`,color:`#3498db`,status:`active`,lastActivity:new Date().toISOString()},{userId:`u2`,userName:`Bob Smith`,color:`#2ecc71`,status:`idle`,lastActivity:new Date().toISOString()},{userId:`u3`,userName:`Carol Li`,color:`#e74c3c`,status:`active`,lastActivity:new Date().toISOString()}];function ti({appName:e,objects:t,connectionState:n,presenceUsers:r,activities:i}){let a=Pn(),o=Hn(),{isOnline:s}=u(),c=cr(),{t:l}=q(),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),h=(0,J.useCallback)(async()=>{if(c)try{let[e,t]=await Promise.all([c.find(`sys_presence`).catch(()=>({data:[]})),c.find(`sys_activity`,{$orderby:{timestamp:`desc`},$top:20}).catch(()=>({data:[]}))]);if(e.data?.length){let t=e.data.filter(e=>typeof e.userId==`string`);t.length&&f(t)}if(t.data?.length){let e=t.data.filter(e=>typeof e.type==`string`);e.length&&m(e)}}catch{}},[c]);(0,J.useEffect)(()=>{h()},[h]);let g=r??d??ei,_=i??p??[],v=a.pathname.split(`/`).filter(Boolean),y=o.appName||v[1],b=v[2],x=`/apps/${y}`,S=t.map(e=>({label:e.label||e.name,href:`${x}/${e.name}`})),w=[{label:e,href:x}];if(b===`dashboard`)w.push({label:l(`console.breadcrumb.dashboards`),href:`${w[0].href}`}),v[3]&&w.push({label:$r(v[3])});else if(b===`page`)w.push({label:l(`console.breadcrumb.pages`),href:`${w[0].href}`}),v[3]&&w.push({label:$r(v[3])});else if(b===`report`)w.push({label:l(`console.breadcrumb.reports`),href:`${w[0].href}`}),v[3]&&w.push({label:$r(v[3])});else if(b===`system`)w.push({label:l(`console.breadcrumb.system`)}),v[3]&&w.push({label:$r(v[3])});else if(b){let e=t.find(e=>e.name===b);if(e)if(w.push({label:e.label||b,href:`/apps/${y}/${b}`,siblings:S}),v[3]===`record`&&v[4]){let e=v[4].length>12?`${v[4].slice(0,8)}…`:v[4];w.push({label:`#${e}`})}else v[3]===`view`&&v[4]&&w.push({label:$r(v[4])})}return(0,Y.jsxs)(`div`,{className:`flex items-center justify-between w-full h-full px-2 sm:px-3 md:px-4 gap-1.5 sm:gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 min-w-0 flex-1`,children:[(0,Y.jsx)(_e,{className:`md:hidden shrink-0`}),(0,Y.jsx)(He,{orientation:`vertical`,className:`h-4 md:hidden shrink-0`}),(0,Y.jsx)(L,{className:`hidden sm:flex min-w-0`,children:(0,Y.jsx)(jt,{children:w.map((e,t)=>(0,Y.jsxs)(J.Fragment,{children:[t>0&&(0,Y.jsx)(xe,{}),(0,Y.jsx)(Nt,{children:t===w.length-1||!e.href?e.siblings&&e.siblings.length>1?(0,Y.jsxs)(st,{children:[(0,Y.jsxs)(Ht,{className:`flex items-center gap-1 text-sm font-medium`,children:[e.label,(0,Y.jsx)(dn,{className:`h-3 w-3`})]}),(0,Y.jsx)(Rt,{align:`start`,className:`max-h-64 overflow-y-auto`,children:e.siblings.map(e=>(0,Y.jsx)(z,{asChild:!0,children:(0,Y.jsx)(In,{to:e.href,className:`w-full`,children:e.label})},e.href))})]}):(0,Y.jsx)(ve,{className:`truncate max-w-[200px]`,children:e.label}):e.siblings&&e.siblings.length>1?(0,Y.jsxs)(st,{children:[(0,Y.jsxs)(Ht,{className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[e.label,(0,Y.jsx)(dn,{className:`h-3 w-3`})]}),(0,Y.jsx)(Rt,{align:`start`,className:`max-h-64 overflow-y-auto`,children:e.siblings.map(e=>(0,Y.jsx)(z,{asChild:!0,children:(0,Y.jsx)(In,{to:e.href,className:`w-full`,children:e.label})},e.href))})]}):(0,Y.jsx)(C,{asChild:!0,children:(0,Y.jsx)(In,{to:e.href,className:`truncate max-w-[150px]`,children:e.label})})})]},t))})}),(0,Y.jsx)(`span`,{className:`text-sm font-medium sm:hidden truncate min-w-0`,children:w[w.length-1]?.label||e})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1 md:gap-2 shrink-0`,children:[!s&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 rounded-full bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 text-xs font-medium`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-yellow-500 animate-pulse`}),`Offline`]}),n&&(0,Y.jsx)(Yr,{state:n}),g.length>0&&(0,Y.jsx)(`div`,{className:`hidden md:flex items-center shrink-0`,title:`Users currently online`,children:(0,Y.jsx)(Vr,{users:g,size:`sm`,maxVisible:3,showStatus:!0})}),(0,Y.jsxs)(`button`,{onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),className:`hidden lg:flex relative items-center gap-2 w-50 xl:w-70 h-8 px-3 text-sm rounded-md border bg-muted/50 text-muted-foreground hover:bg-muted transition-colors`,children:[(0,Y.jsx)(ye,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:`Search...`}),(0,Y.jsxs)(`kbd`,{className:`pointer-events-none inline-flex h-5 items-center gap-0.5 rounded border bg-muted px-1.5 text-[10px] font-medium text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`text-xs`,children:`⌘`}),`K`]})]}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`lg:hidden h-8 w-8 shrink-0`,onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),children:(0,Y.jsx)(ye,{className:`h-4 w-4`})}),(0,Y.jsx)(`div`,{className:`hidden sm:flex shrink-0 relative`,children:(0,Y.jsx)(Qr,{activities:_})}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`h-8 w-8 hidden md:flex shrink-0`,children:(0,Y.jsx)(Qt,{className:`h-4 w-4`})}),(0,Y.jsx)(`div`,{className:`hidden sm:flex shrink-0`,children:(0,Y.jsx)(Gr,{})}),(0,Y.jsx)(`div`,{className:`hidden sm:flex shrink-0`,children:(0,Y.jsx)(qr,{})})]})]})}var ni=768,ri=1024;function ii(){let{setOpen:e,isMobile:t}=ke();(0,J.useEffect)(()=>{function t(){let t=window.innerWidth;t>=ni&&t<ri&&e(!1)}return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,t])}function ai({children:e}){return ii(),(0,Y.jsx)(Y.Fragment,{children:e})}function oi({children:e,activeAppName:t,activeApp:n,onAppChange:r,objects:i,connectionState:a}){return(0,Y.jsx)(Rn,{sidebar:(0,Y.jsx)(jr,{activeAppName:t,onAppChange:r}),navbar:(0,Y.jsx)(ti,{appName:X(n?.label)||t,objects:i,connectionState:a}),className:`p-0 overflow-hidden bg-muted/5`,branding:n?.branding?{primaryColor:n.branding.primaryColor,accentColor:n.branding.accentColor,favicon:n.branding.favicon,logo:n.branding.logo,title:n.label?`${X(n.label)} — ObjectStack Console`:void 0}:void 0,children:(0,Y.jsx)(ai,{children:e})})}function si(e){if(!e)return Ie;if(Ve[e])return Ve[e];let t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return Ve[t]?Ve[t]:Ie}function ci({apps:e,activeApp:t,objects:n,onAppChange:r}){let[i,a]=(0,J.useState)(!1),o=Ln(),{appName:s}=Hn(),{setTheme:c}=Wr(),{evaluator:l}=fr(),{t:u}=q();(0,J.useEffect)(()=>{let e=e=>{e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let d=`/apps/${s||t?.name}`,f=(0,J.useCallback)(e=>{a(!1),e()},[]),p=li(t?.navigation||[]).filter(e=>pr(e.visible??e.visibleOn,l));return(0,Y.jsxs)(xt,{open:i,onOpenChange:a,children:[(0,Y.jsx)(yn,{placeholder:u(`console.commandPalette.placeholder`)}),(0,Y.jsxs)(it,{children:[(0,Y.jsx)(vt,{children:u(`console.commandPalette.noResults`)}),p.filter(e=>e.type===`object`).length>0&&(0,Y.jsx)(Xe,{heading:u(`console.commandPalette.objects`),children:p.filter(e=>e.type===`object`).map(e=>{let t=si(e.icon);return(0,Y.jsxs)(U,{value:`object ${X(e.label,u)} ${e.objectName}`,onSelect:()=>f(()=>o(`${d}/${e.objectName}`)),children:[(0,Y.jsx)(t,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:X(e.label,u)})]},e.id)})}),p.filter(e=>e.type===`dashboard`).length>0&&(0,Y.jsx)(Xe,{heading:u(`console.commandPalette.dashboards`),children:p.filter(e=>e.type===`dashboard`).map(e=>(0,Y.jsxs)(U,{value:`dashboard ${X(e.label,u)} ${e.dashboardName}`,onSelect:()=>f(()=>o(`${d}/dashboard/${e.dashboardName}`)),children:[(0,Y.jsx)(bt,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:X(e.label,u)})]},e.id))}),p.filter(e=>e.type===`page`).length>0&&(0,Y.jsx)(Xe,{heading:u(`console.commandPalette.pages`),children:p.filter(e=>e.type===`page`).map(e=>(0,Y.jsxs)(U,{value:`page ${X(e.label,u)} ${e.pageName}`,onSelect:()=>f(()=>o(`${d}/page/${e.pageName}`)),children:[(0,Y.jsx)(we,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:X(e.label,u)})]},e.id))}),p.filter(e=>e.type===`report`).length>0&&(0,Y.jsx)(Xe,{heading:u(`console.commandPalette.reports`),children:p.filter(e=>e.type===`report`).map(e=>(0,Y.jsxs)(U,{value:`report ${X(e.label,u)} ${e.reportName}`,onSelect:()=>f(()=>o(`${d}/report/${e.reportName}`)),children:[(0,Y.jsx)(Jt,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:X(e.label,u)})]},e.id))}),e.filter(e=>e.active!==!1).length>1&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wn,{}),(0,Y.jsx)(Xe,{heading:u(`console.commandPalette.switchApp`),children:e.filter(e=>e.active!==!1).map(e=>{let n=si(e.icon);return(0,Y.jsxs)(U,{value:`app ${X(e.label,u)} ${e.name}`,onSelect:()=>f(()=>r(e.name)),children:[(0,Y.jsx)(n,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:X(e.label,u)}),e.name===t?.name&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:u(`console.commandPalette.current`)})]},e.name)})})]}),(0,Y.jsx)(wn,{}),(0,Y.jsxs)(Xe,{heading:u(`console.commandPalette.preferences`),children:[(0,Y.jsxs)(U,{value:`theme light`,onSelect:()=>f(()=>c(`light`)),children:[(0,Y.jsx)(Ze,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`console.commandPalette.lightTheme`)})]}),(0,Y.jsxs)(U,{value:`theme dark`,onSelect:()=>f(()=>c(`dark`)),children:[(0,Y.jsx)(un,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`console.commandPalette.darkTheme`)})]}),(0,Y.jsxs)(U,{value:`theme system`,onSelect:()=>f(()=>c(`system`)),children:[(0,Y.jsx)(Wt,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`console.commandPalette.systemTheme`)})]})]}),(0,Y.jsx)(wn,{}),(0,Y.jsxs)(Xe,{heading:u(`console.commandPalette.actions`),children:[(0,Y.jsxs)(U,{value:`create new app application`,onSelect:()=>f(()=>o(`${d}/create-app`)),children:[(0,Y.jsx)(D,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`console.commandPalette.createApp`)})]}),(0,Y.jsxs)(U,{value:`search all results full page`,onSelect:()=>f(()=>o(`${d}/search`)),children:[(0,Y.jsx)(ye,{className:`mr-2 h-4 w-4`}),(0,Y.jsx)(`span`,{children:u(`console.commandPalette.openFullSearch`)})]})]})]})]})}function li(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...li(n.children)):t.push(n);return t}function ui({error:e,onReset:t}){let{t:n}=q();return(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center p-8`,children:(0,Y.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10`,children:(0,Y.jsx)(zt,{className:`h-6 w-6 text-destructive`})}),(0,Y.jsx)(Bt,{children:n(`console.errors.somethingWentWrong`)}),(0,Y.jsx)(ct,{className:`mb-4`,children:e.message||n(`console.errors.unexpectedError`)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,Y.jsxs)(I,{variant:`outline`,size:`sm`,onClick:t,className:`gap-2`,children:[(0,Y.jsx)(re,{className:`h-4 w-4`}),n(`console.errors.tryAgain`)]}),(0,Y.jsxs)(I,{variant:`ghost`,size:`sm`,onClick:()=>{window.location.href=`/`},className:`gap-2`,children:[(0,Y.jsx)(xn,{className:`h-4 w-4`}),n(`console.errors.goHome`)]})]})]}),!1]})})}var di=class extends J.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary] Caught error:`,e,t),this.props.onError?.(e,t)}resetErrorBoundary=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?typeof this.props.fallback==`function`?this.props.fallback({error:this.state.error,reset:this.resetErrorBoundary}):this.props.fallback:(0,Y.jsx)(ui,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}};function Z({message:e}){let{t}=q(),[n,r]=(0,J.useState)(0),i=(0,J.useMemo)(()=>[t(`console.loadingSteps.connecting`),t(`console.loadingSteps.loadingConfig`),t(`console.loadingSteps.preparingWorkspace`)],[t]);return(0,J.useEffect)(()=>{if(e)return;let t=setInterval(()=>{r(e=>Math.min(e+1,i.length-1))},1200);return()=>clearInterval(t)},[e,i.length]),(0,Y.jsx)(`div`,{className:`flex flex-col items-center justify-center h-screen bg-background`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-6`,children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-primary/20 rounded-2xl blur-xl animate-pulse`}),(0,Y.jsx)(`div`,{className:`relative bg-linear-to-br from-primary to-primary/80 p-4 rounded-2xl shadow-lg`,children:(0,Y.jsx)(Ie,{className:`h-10 w-10 text-primary-foreground`})})]}),(0,Y.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Y.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:t(`console.title`)}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`console.initializing`)})]}),e?(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full`,children:[(0,Y.jsx)(et,{className:`h-4 w-4 text-primary`}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 w-64`,children:i.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 text-sm transition-opacity duration-300`,style:{opacity:t<=n?1:.3},children:[t<n?(0,Y.jsx)(Ue,{className:`h-4 w-4 text-primary shrink-0`}):t===n?(0,Y.jsx)(lt,{className:`h-4 w-4 text-primary shrink-0 animate-spin`}):(0,Y.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0`}),(0,Y.jsx)(`span`,{className:t<=n?`text-foreground`:`text-muted-foreground`,children:e})]},e))})]})})}var fi=J.lazy(()=>W(()=>import(`./ChartImpl-Cwo6IWnY.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))),pi=J.lazy(()=>W(()=>import(`./AdvancedChartImpl-Dvg6YIfN.js`),__vite__mapDeps([8,2,1,3,4,5,6,7]))),mi=({schema:e})=>(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fe,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,Y.jsx)(fi,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),hi=({schema:e})=>{let t=J.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fe,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,Y.jsx)(pi,{chartType:t.chartType,data:t.data,config:t.config,xAxisKey:t.xAxisKey,series:t.series,className:t.className})})};function gi(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}var _i=e=>{let{schema:t}=e,n=(0,J.useContext)(c),r=e.dataSource||n?.dataSource,i=o(t.bind),[a,s]=(0,J.useState)([]),[l,u]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let e=!0;return t.objectName&&!i&&!t.data&&(async()=>{if(!(!r||!t.objectName)){e&&u(!0);try{let n;if(t.aggregate&&typeof r.aggregate==`function`){let e=await r.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:t.aggregate.groupBy,filter:t.filter});n=Array.isArray(e)?e:[]}else if(typeof r.find==`function`)n=p(await r.find(t.objectName,{$filter:t.filter})),t.aggregate&&n.length>0&&(n=gi(n,t.aggregate));else return;e&&s(n)}catch(e){console.error(`[ObjectChart] Fetch error:`,e)}finally{e&&u(!1)}}})(),()=>{e=!1}},[t.objectName,r,i,t.data,t.filter,t.aggregate]);let d=i||t.data||a,f=Array.isArray(d)?d:[],m={...t,data:f};return l&&f.length===0?(0,Y.jsx)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),children:`Loading chart data…`}):!r&&t.objectName&&f.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),children:[`No data source available for "`,t.objectName,`"`]}):(0,Y.jsx)(hi,{...e,schema:m})};r.register(`object-chart`,_i,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]}),r.register(`bar-chart`,mi,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),r.register(`chart`,_i,{namespace:`view`,category:`view`,label:`Chart`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),r.register(`chart`,hi,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),r.register(`chart:bar`,hi,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),r.register(`pie-chart`,hi,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),r.register(`donut-chart`,hi,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),r.register(`radar-chart`,hi,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),r.register(`scatter-chart`,hi,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});var vi=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:s,onCardClick:c,...l})=>{let u=Array.isArray(r),[d,m]=(0,J.useState)([]),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(u?i??!1:!1),[y,b]=(0,J.useState)(null),x=o(e.bind);(0,J.useEffect)(()=>{u&&i!==void 0&&v(i)},[i,u]),(0,J.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&g(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,J.useEffect)(()=>{if(u)return;let n=!0;return e.objectName&&!x&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&v(!0);try{let r=a(h?.fields),i=p(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&m(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&b(e)}finally{n&&v(!1)}}})(),()=>{n=!1}},[e.objectName,t,x,e.data,e.filter,u,h]);let S=(u?r:void 0)||x||e.data||d,C=(0,J.useMemo)(()=>{if(!Array.isArray(S))return[];let t=e.cardTitle||e.titleField;if(!t&&h){if(h.titleFormat){let e=/\{(.+?)\}/.exec(h.titleFormat);e&&(t=e[1])}!t&&h.NAME_FIELD_KEY&&(t=h.NAME_FIELD_KEY)}let n=[`name`,`title`,`subject`,`label`,`display_name`];return S.map(e=>{let r=t?e[t]:void 0;if(!r){for(let t of n)if(e[t]){r=e[t];break}}return{...e,id:e.id||e._id,title:r||`Untitled`}})},[S,e,h]),w=(0,J.useMemo)(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns;if(e.groupBy&&h?.fields?.[e.groupBy]?.options)return h.fields[e.groupBy].options.map(e=>({id:e.value,title:e.label}));if(e.groupBy&&C.length>0){let t=new Set(C.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,C,h]),T=e.swimlaneField||e.grouping?.fields?.[0]?.field,E={...e,data:C,columns:w,className:n||e.className,...T?{swimlaneField:T}:{}},D=f({navigation:e.navigation,objectName:e.objectName,onRowClick:s??c});if(y)return(0,Y.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,y.message]});let O=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xi,{schema:{...E,onCardClick:e=>{D.handleClick(e),c?.(e)}}}),D.isOverlay&&(0,Y.jsx)(Yt,{...D,title:O,children:e=>(0,Y.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Y.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},yi=J.lazy(()=>W(()=>import(`./KanbanImpl-D9BbG_RT.js`),__vite__mapDeps([9,2,1,3,4,5,6]))),bi=J.lazy(()=>W(()=>import(`./KanbanEnhanced-Dj7Qccu2.js`),__vite__mapDeps([10,2,1,3,4,5,6]))),xi=({schema:e})=>{let t=J.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fe,{className:`w-full h-[600px]`}),children:(0,Y.jsx)(yi,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};r.register(`kanban-ui`,xi,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}}),r.register(`kanban-enhanced`,({schema:e})=>{let t=J.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fe,{className:`w-full h-[600px]`}),children:(0,Y.jsx)(bi,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var Si=({schema:e,...n})=>{let{dataSource:r}=t()||{};return(0,Y.jsx)(vi,{schema:e,dataSource:r,...n})};r.register(`object-kanban`,Si,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),r.register(`kanban`,Si,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});var Ci=`bg-blue-500 text-white`,wi=new Date,Ti={"calendar.today":`Today`,"calendar.month":`Month`,"calendar.week":`Week`,"calendar.day":`Day`,"calendar.newEvent":`New event`,"calendar.moreEvents":`+{{count}} more`};function Ei(){try{let e=q();return e.t(`calendar.today`)===`calendar.today`?{t:(e,t)=>{let n=Ti[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}:{t:e.t,language:e.language}}catch{return{t:(e,t)=>{let n=Ti[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n},language:`en`}}}function Di({events:e=[],view:t=`month`,currentDate:n=wi,locale:r=`default`,onEventClick:i,onDateClick:a,onViewChange:o,onNavigate:s,onAddClick:c,onEventDrop:l,className:u}){let[d,f]=J.useState(t),[p,m]=J.useState(n),{t:h,language:g}=Ei(),_=r===`default`?g:r;J.useEffect(()=>{m(n)},[n]),J.useEffect(()=>{f(t)},[t]);let v=J.useRef(o);v.current=o,J.useEffect(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=e=>{e.matches&&(f(`day`),v.current?.(`day`))};return t(e),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let b=()=>{let e=new Date(p);d===`month`?e.setMonth(e.getMonth()-1):d===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),m(e),s?.(e)},x=()=>{let e=new Date(p);d===`month`?e.setMonth(e.getMonth()+1):d===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),m(e),s?.(e)},C=()=>{let e=new Date;m(e),s?.(e)},w=e=>{f(e),o?.(e)},T=()=>{if(d===`month`)return p.toLocaleDateString(_,{month:`long`,year:`numeric`});if(d===`week`){let e=Oi(p),t=new Date(e);return t.setDate(t.getDate()+6),`${e.toLocaleDateString(_,{month:`short`,day:`numeric`})} - ${t.toLocaleDateString(_,{month:`short`,day:`numeric`,year:`numeric`})}`}else return p.toLocaleDateString(_,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})},E=J.useRef(0),O=e=>{E.current=e.touches[0].clientX},k=e=>{let t=E.current-e.changedTouches[0].clientX;if(Math.abs(t)>50){let e=new Date(p);d===`day`?e.setDate(e.getDate()+(t>0?1:-1)):d===`week`?e.setDate(e.getDate()+(t>0?7:-7)):e.setMonth(e.getMonth()+(t>0?1:-1)),m(e),s?.(e)}},A=e=>{e&&(m(e),s?.(e))};return(0,Y.jsxs)(`div`,{role:`region`,"aria-label":`Calendar`,className:H(`flex flex-col h-full bg-background min-w-0 overflow-hidden`,u),children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center bg-muted/50 rounded-lg p-1 gap-1`,children:[(0,Y.jsx)(I,{variant:`ghost`,size:`sm`,onClick:C,className:`h-8`,"aria-label":`Go to today`,children:h(`calendar.today`)}),(0,Y.jsx)(`div`,{className:`h-4 w-px bg-border mx-1`}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,"aria-label":`Previous period`,onClick:b,className:`h-8 w-8`,children:(0,Y.jsx)(ft,{className:`h-4 w-4`})}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,"aria-label":`Next period`,onClick:x,className:`h-8 w-8`,children:(0,Y.jsx)(y,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(tn,{children:[(0,Y.jsx)($e,{asChild:!0,children:(0,Y.jsxs)(I,{variant:`ghost`,"aria-label":`Current date: ${T()}`,className:H(`text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors`,`flex items-center gap-2`),children:[(0,Y.jsx)(on,{className:`h-5 w-5 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:T()})]})}),(0,Y.jsx)(Dt,{className:`w-auto p-0`,align:`start`,children:(0,Y.jsx)(N,{mode:`single`,selected:p,onSelect:A,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(qe,{value:d,onValueChange:w,children:[(0,Y.jsx)(pt,{className:`w-32 bg-background`,children:(0,Y.jsx)(fn,{})}),(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(S,{value:`day`,children:h(`calendar.day`)}),(0,Y.jsx)(S,{value:`week`,children:h(`calendar.week`)}),(0,Y.jsx)(S,{value:`month`,children:h(`calendar.month`)})]})]}),c&&(0,Y.jsxs)(I,{onClick:c,size:`sm`,className:`gap-1`,children:[(0,Y.jsx)(D,{className:`h-4 w-4`}),h(`calendar.newEvent`)]})]})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-auto`,onTouchStart:O,onTouchEnd:k,children:[d===`month`&&(0,Y.jsx)(Mi,{date:p,events:e,locale:_,onEventClick:i,onDateClick:a,onEventDrop:l}),d===`week`&&(0,Y.jsx)(Ni,{date:p,events:e,locale:_,onEventClick:i,onDateClick:a}),d===`day`&&(0,Y.jsx)(Pi,{date:p,events:e,onEventClick:i,onDateClick:a})]})]})}function Oi(e){let t=new Date(e),n=t.getDay(),r=t.getDate()-n;return t.setDate(r),t}function ki(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0),a=r.getDay(),o=[];for(let e=a-1;e>=0;e--){let t=new Date(r.getTime());t.setDate(t.getDate()-(e+1)),o.push(t)}for(let e=1;e<=i.getDate();e++)o.push(new Date(t,n,e));let s=42-o.length;for(let e=1;e<=s;e++){let t=new Date(i.getTime());t.setDate(t.getDate()+e),o.push(t)}return o}function Ai(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ji(e,t){return t.filter(t=>{let n=new Date(t.start),r=t.end?new Date(t.end):new Date(n),i=new Date(e);i.setHours(0,0,0,0);let a=new Date(e);a.setHours(23,59,59,999);let o=new Date(n);o.setHours(0,0,0,0);let s=new Date(r);return s.setHours(23,59,59,999),i<=s&&a>=o})}function Mi({date:e,events:t,locale:n=`default`,onEventClick:r,onDateClick:i,onEventDrop:a}){let o=J.useMemo(()=>ki(e),[e.getFullYear(),e.getMonth()]),s=J.useMemo(()=>new Date,[]),{t:c}=Ei(),l=J.useMemo(()=>{let e=new Date(2024,0,7);return Array.from({length:7},(t,r)=>{let i=new Date(e);return i.setDate(i.getDate()+r),i.toLocaleDateString(n,{weekday:`short`})})},[n]),[u,d]=J.useState(null),[f,p]=J.useState(null),m=J.useMemo(()=>{let e=new Map;for(let n of t){let t=new Date(n.start),r=n.end?new Date(n.end):new Date(t);t.setHours(0,0,0,0),r.setHours(0,0,0,0);let i=new Date(t);for(;i<=r;){let t=`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`,r=e.get(t);r?r.push(n):e.set(t,[n]),i.setDate(i.getDate()+1)}}return e},[t]),h=(e,t)=>{d(t.id),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t.id))},g=()=>{d(null),p(null)},_=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,p(t)},v=e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},y=(e,n)=>{if(e.preventDefault(),p(null),d(null),!a)return;let r=e.dataTransfer.getData(`text/plain`),i=t.find(e=>String(e.id)===r);if(!i)return;let o=new Date(i.start),s=new Date(o);s.setHours(0,0,0,0);let c=new Date(n);c.setHours(0,0,0,0);let l=c.getTime()-s.getTime();if(l===0)return;let u=new Date(o.getTime()+l),f;i.end&&(f=new Date(new Date(i.end).getTime()+l)),a(i,u,f)};return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b`,children:l.map(e=>(0,Y.jsx)(`div`,{role:`columnheader`,className:`p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0`,children:e},e))}),(0,Y.jsx)(`div`,{role:`grid`,"aria-label":`Calendar grid`,className:`grid grid-cols-7 flex-1 auto-rows-fr`,children:o.map((t,n)=>{let o=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,l=m.get(o)||[],d=t.getMonth()===e.getMonth(),p=Ai(t,s);return(0,Y.jsxs)(`div`,{role:`gridcell`,"aria-label":`${t.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${l.length>0?`, ${l.length} event${l.length>1?`s`:``}`:``}`,className:H(`border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50`,!d&&`bg-muted/50 text-muted-foreground opacity-50`,f===n&&`ring-2 ring-primary`),onClick:()=>i?.(t),onDragOver:e=>_(e,n),onDragLeave:v,onDrop:e=>y(e,t),children:[(0,Y.jsx)(`div`,{className:H(`text-sm font-medium mb-2`,p&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6`),...p?{"aria-current":`date`}:{},children:t.getDate()}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[l.slice(0,3).map(e=>(0,Y.jsx)(`div`,{role:`button`,title:e.title,"aria-label":e.title,draggable:!!a,onDragStart:t=>h(t,e),onDragEnd:g,className:H(`text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||Ci,u===e.id&&`opacity-50`),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),r?.(e)},children:e.title},e.id)),l.length>3&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground px-2`,children:c(`calendar.moreEvents`,{count:l.length-3})})]})]},n)})})]})}function Ni({date:e,events:t,locale:n=`default`,onEventClick:r,onDateClick:i}){let a=J.useRef(null),o=e=>{i&&(a.current=setTimeout(()=>{i(e)},500))},s=()=>{a.current&&=(clearTimeout(a.current),null)},c=Oi(e),l=Array.from({length:7},(e,t)=>{let n=new Date(c);return n.setDate(n.getDate()+t),n}),u=new Date;return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-7 border-b`,children:l.map(e=>{let t=Ai(e,u);return(0,Y.jsxs)(`div`,{className:`p-3 text-center border-r last:border-r-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:e.toLocaleDateString(n,{weekday:`short`})}),(0,Y.jsx)(`div`,{className:H(`text-lg font-semibold mt-1`,t&&`inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8`),children:e.getDate()})]},e.toISOString())})}),(0,Y.jsx)(`div`,{role:`grid`,className:`grid grid-cols-7 flex-1`,children:l.map(e=>{let n=ji(e,t);return(0,Y.jsx)(`div`,{role:`gridcell`,"aria-label":`${e.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}${n.length>0?`, ${n.length} event${n.length>1?`s`:``}`:``}`,className:`border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50`,onClick:()=>i?.(e),onTouchStart:()=>o(e),onTouchEnd:s,children:(0,Y.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>(0,Y.jsxs)(`div`,{role:`button`,title:e.title,"aria-label":e.title,className:H(`text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||Ci),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:t=>{t.stopPropagation(),r?.(e)},children:[(0,Y.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,Y.jsx)(`div`,{className:`text-xs opacity-90 mt-1`,children:e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})})]},e.id))})},e.toISOString())})})]})}function Pi({date:e,events:t,onEventClick:n,onDateClick:r}){let i=ji(e,t),a=Array.from({length:24},(e,t)=>t),o=J.useRef(null),s=t=>{r&&(o.current=setTimeout(()=>{let n=new Date(e);n.setHours(t,0,0,0),r(n)},500))},c=()=>{o.current&&=(clearTimeout(o.current),null)};return(0,Y.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,Y.jsx)(`div`,{role:`list`,className:`flex-1 overflow-auto`,children:a.map(e=>{let t=i.filter(t=>t.allDay?e===0:t.start.getHours()===e);return(0,Y.jsxs)(`div`,{role:`listitem`,className:`flex border-b min-h-[60px]`,children:[(0,Y.jsx)(`div`,{className:`w-20 p-2 text-sm text-muted-foreground border-r`,children:e===0?`12 AM`:e<12?`${e} AM`:e===12?`12 PM`:`${e-12} PM`}),(0,Y.jsx)(`div`,{className:`flex-1 p-2 space-y-2`,onTouchStart:()=>s(e),onTouchEnd:c,children:t.map(e=>(0,Y.jsxs)(`div`,{title:e.title,"aria-label":e.title,className:H(`px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80`,e.color?.startsWith(`#`)?`text-white`:e.color||Ci),style:e.color&&e.color.startsWith(`#`)?{backgroundColor:e.color}:void 0,onClick:()=>n?.(e),children:[(0,Y.jsx)(`div`,{className:`font-medium truncate`,children:e.title}),!e.allDay&&(0,Y.jsxs)(`div`,{className:`text-xs opacity-90 mt-1`,children:[e.start.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`}),e.end&&` - ${e.end.toLocaleTimeString(`default`,{hour:`numeric`,minute:`2-digit`})}`]})]},e.id))})]},e)})})})}function Fi(e){return`data`in e&&e.data?e.data:`staticData`in e&&e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Ii(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Li(e){return`filter`in e&&e.filter&&typeof e.filter==`object`&&`calendar`in e.filter?e.filter.calendar:e.calendar?e.calendar:e.startDateField||e.dateField?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField||`name`,colorField:e.colorField,allDayField:e.allDayField}:null}var Ri=({schema:e,dataSource:t,className:n,data:r,loading:i,onEventClick:o,onRowClick:s,onDateClick:c,onNavigate:l,onViewChange:u,onEventDrop:d,locale:m})=>{let h=Array.isArray(r),[g,_]=(0,J.useState)(h?r:[]),[v,y]=(0,J.useState)(h?i??!1:!0),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(new Date),[E,D]=(0,J.useState)(`month`),[O,k]=(0,J.useState)(0),{ref:A,isRefreshing:j,pullDistance:M}=Qe({onRefresh:(0,J.useCallback)(async()=>{k(e=>e+1)},[]),enabled:!!t&&!!e.objectName}),N=(0,J.useMemo)(()=>Fi(e),[e.data,e.staticData,e.objectName]),P=(0,J.useMemo)(()=>Li(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),F=N?.provider===`value`,ee=(0,J.useRef)(null);ee.current=S,(0,J.useEffect)(()=>{h&&_(r)},[r,h]),(0,J.useEffect)(()=>{h&&i!==void 0&&y(i)},[i,h]),(0,J.useEffect)(()=>{if(h)return;let n=!0;return(async()=>{try{if(!n)return;if(y(!0),F&&N?.provider===`value`){n&&(_(N.items),y(!1));return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(N?.provider===`object`){let r=N.object,i=a(ee.current?.fields),o=p(await t.find(r,{$filter:e.filter,$orderby:Ii(e.sort),...i.length>0?{$expand:i}:{}}));n&&_(o)}else N?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectCalendar`),n&&_([]));n&&y(!1)}catch(e){console.error(`[ObjectCalendar] Error fetching data:`,e),n&&(x(e),y(!1))}})(),()=>{n=!1}},[h,N,t,F,e.filter,e.sort,O]),(0,J.useEffect)(()=>{!F&&t&&(async()=>{try{if(!t)return;let n=N?.provider===`object`?N.object:e.objectName;if(!n)return;C(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,F,N]);let te=(0,J.useMemo)(()=>{if(!P||!g.length)return[];let{startDateField:e,endDateField:t,titleField:n,colorField:r}=P;return g.map((i,a)=>{let o=i[e],s=t?i[t]:null,c=i[n]||`Untitled`,l=r?i[r]:void 0;return{id:i.id||i._id||`event-${a}`,title:c,start:o?new Date(o):new Date,end:s?new Date(s):void 0,color:l,allDay:!s,data:i}}).filter(e=>!isNaN(e.start.getTime()))},[g,P]);(0,J.useCallback)(()=>{c?.(new Date)},[c]);let ne=f({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return v?(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading calendar...`})})}):b?(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,b.message]})})}):P?(0,Y.jsxs)(`div`,{ref:A,className:n,children:[M>0&&(0,Y.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:M},children:j?`Refreshing…`:`Pull to refresh`}),(0,Y.jsx)(`div`,{className:`border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]`,children:(0,Y.jsx)(Di,{events:te,currentDate:w,view:e.defaultView||`month`,locale:m,onEventClick:e=>{ne.handleClick(e.data),o?.(e.data)},onDateClick:c,onNavigate:e=>{T(e),l?.(e)},onViewChange:e=>{D(e),u?.(e)},onAddClick:void 0,onEventDrop:d?(e,t,n)=>{d(e.data,t,n)}:void 0})}),ne.isOverlay&&(0,Y.jsx)(Yt,{...ne,title:`Event Details`,children:e=>(0,Y.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Y.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:`Calendar configuration required. Please specify startDateField and titleField.`})})})};r.register(`calendar-view`,({schema:e,className:t,onAction:n,...r})=>{let i=J.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((t,n)=>{let r=e.titleField||`title`,i=e.startDateField||`start`,a=e.endDateField||`end`,o=e.colorField||`color`,s=e.allDayField||`allDay`;return{id:t.id||t._id||n,title:t[r]||`Untitled Event`,start:new Date(t[i]),end:t[a]?new Date(t[a]):void 0,allDay:t[s],color:t[o],data:t}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]);return(0,Y.jsx)(Di,{className:t,events:i,onEventClick:e=>{n?.({type:`event-click`,payload:e})},...r})},{namespace:`plugin-calendar`,label:`Calendar View`,inputs:[{name:`data`,type:`array`,label:`Data`,description:`Array of record objects to display as events`},{name:`titleField`,type:`string`,label:`Title Field`,defaultValue:`title`,description:`Field name to use for event title`},{name:`startDateField`,type:`string`,label:`Start Date Field`,defaultValue:`start`,description:`Field name for event start date`},{name:`endDateField`,type:`string`,label:`End Date Field`,defaultValue:`end`,description:`Field name for event end date (optional)`},{name:`allDayField`,type:`string`,label:`All Day Field`,defaultValue:`allDay`,description:`Field name for all-day flag`},{name:`colorField`,type:`string`,label:`Color Field`,defaultValue:`color`,description:`Field name for event color`},{name:`colorMapping`,type:`object`,label:`Color Mapping`,description:`Map field values to colors (e.g., {meeting: "blue", deadline: "red"})`},{name:`view`,type:`enum`,enum:[`month`,`week`,`day`],defaultValue:`month`,label:`View Mode`,description:`Calendar view mode (month, week, or day)`},{name:`currentDate`,type:`string`,label:`Current Date`,description:`ISO date string for initial calendar date`},{name:`allowCreate`,type:`boolean`,label:`Allow Create`,defaultValue:!1,description:`Allow creating events by clicking on dates`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{view:`month`,titleField:`title`,startDateField:`start`,endDateField:`end`,allDayField:`allDay`,colorField:`color`,allowCreate:!1,data:[{id:1,title:`Team Meeting`,start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:`#3b82f6`,allDay:!1},{id:2,title:`Project Deadline`,start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:`#ef4444`,allDay:!0},{id:3,title:`Conference`,start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:`#10b981`,allDay:!0}],className:`h-[600px] border rounded-lg`}});var zi=({schema:e,...n})=>{let{dataSource:r}=t()||{};return(0,Y.jsx)(Ri,{schema:e,dataSource:r,...n})};r.register(`object-calendar`,zi,{namespace:`plugin-calendar`,label:`Object Calendar`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]}),r.register(`calendar`,zi,{namespace:`view`,label:`Calendar View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`calendar`,type:`object`,label:`Calendar Config`,description:`startDateField, endDateField, titleField, colorField`}]});function Bi({open:e,onToggle:t,className:n}){return(0,Y.jsxs)(I,{size:`sm`,variant:e?`secondary`:`outline`,onClick:t,className:`shadow-none gap-2 ${n||``}`,title:`Toggle Metadata Inspector`,children:[(0,Y.jsx)(Re,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`hidden lg:inline`,children:`Metadata`})]})}function Vi({sections:e,open:t}){if(!t)return null;let[n,r]=(0,J.useState)([`0`]),[i,a]=(0,J.useState)(null),o=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),a(t),setTimeout(()=>a(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},s=e=>{r(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,Y.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Metadata Inspector`}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:`JSON`})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let r=String(t),a=n.includes(r),c=i===t;return(0,Y.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,Y.jsxs)(`button`,{onClick:()=>s(r),className:`flex-1 flex items-center justify-between text-left`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),a?(0,Y.jsx)(dn,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,Y.jsx)(y,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,Y.jsx)(`button`,{onClick:()=>o(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:`Copy JSON`,children:c?(0,Y.jsx)(Gt,{className:`h-3 w-3 text-green-600`}):(0,Y.jsx)(le,{className:`h-3 w-3 text-muted-foreground`})})]}),a&&(0,Y.jsx)(`div`,{className:`px-4 pb-4`,children:(0,Y.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,Y.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function Hi(){let[e,t]=(0,J.useState)((0,J.useMemo)(()=>{try{return typeof window<`u`?s(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}var Ui={"=":`equals`,"==":`equals`,"!=":`notEquals`,"<>":`notEquals`,">":`greaterThan`,"<":`lessThan`,">=":`greaterOrEqual`,"<=":`lessOrEqual`,contains:`contains`,not_contains:`notContains`,is_empty:`isEmpty`,is_not_empty:`isNotEmpty`,in:`in`,not_in:`notIn`,"not in":`notIn`,before:`before`,after:`after`,between:`between`,equals:`equals`,notEquals:`notEquals`,greaterThan:`greaterThan`,lessThan:`lessThan`,greaterOrEqual:`greaterOrEqual`,lessOrEqual:`lessOrEqual`,notContains:`notContains`,isEmpty:`isEmpty`,isNotEmpty:`isNotEmpty`,notIn:`notIn`},Wi={equals:`=`,notEquals:`!=`,greaterThan:`>`,lessThan:`<`,greaterOrEqual:`>=`,lessOrEqual:`<=`,contains:`contains`,notContains:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`,in:`in`,notIn:`not in`,before:`before`,after:`after`,between:`between`};function Gi(e){let t=(e||``).toLowerCase();return[`integer`,`int`,`float`,`double`,`number`,`currency`,`money`,`percent`,`rating`].includes(t)?`number`:[`date`,`datetime`,`datetime_tz`,`timestamp`,`time`].includes(t)?`date`:[`boolean`,`bool`,`checkbox`,`switch`].includes(t)?`boolean`:[`select`,`picklist`,`single_select`,`multi_select`,`enum`,`status`,`lookup`,`master_detail`,`user`,`owner`].includes(t)?`select`:`text`}function Ki(e){if(!Array.isArray(e)||e.length<2)return null;let[t,n,r]=e;return typeof t!=`string`||typeof n!=`string`?null:{id:crypto.randomUUID(),field:t,operator:Ui[n]||n,value:r??``}}function qi(e){if(Array.isArray(e)){let t=Ki(e);return t?[t]:[]}return typeof e==`object`&&e&&e.field?[{id:e.id||crypto.randomUUID(),field:e.field,operator:Ui[e.operator]||e.operator||`equals`,value:e.value??``}]:[]}function Ji(e){if(!Array.isArray(e)||e.length===0)return{logic:`and`,conditions:[]};if(typeof e[0]==`string`&&(e[0]===`and`||e[0]===`or`))return{logic:e[0],conditions:e.slice(1).flatMap(e=>qi(e))};if(e.length>=2&&e.length<=3&&typeof e[0]==`string`&&typeof e[1]==`string`&&!Array.isArray(e[0])&&!Array.isArray(e[2])){let t=Ki(e);return{logic:`and`,conditions:t?[t]:[]}}if(Array.isArray(e[0])||typeof e[0]==`object`&&e[0]!==null&&!Array.isArray(e[0]))return{logic:`and`,conditions:e.flatMap(e=>qi(e))};let t=Ki(e);return{logic:`and`,conditions:t?[t]:[]}}function Yi(e,t){let n=t.filter(e=>e.field).map(e=>[e.field,Wi[e.operator]||e.operator,e.value]);return n.length===0?[]:n.length===1&&e===`and`?n[0]:e===`or`?[`or`,...n]:n}function Xi(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function Zi(e){return e.split(`,`).map(e=>Number(e.trim())).filter(e=>!isNaN(e)&&e>0)}var Qi={grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,gallery:`Gallery`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`},$i=Object.keys(Qi),ea=[{value:`compact`,gapClass:`gap-0`},{value:`short`,gapClass:`gap-px`},{value:`medium`,gapClass:`gap-0.5`},{value:`tall`,gapClass:`gap-1`},{value:`extra_tall`,gapClass:`gap-1.5`}];function ta(e){return e.fields?Object.entries(e.fields).map(([e,t])=>({value:e,label:t.label||e,type:Gi(t.type),options:t.options})):[]}function na(e){let t=Ji(e);return{id:`root`,logic:t.logic,conditions:t.conditions}}function ra(e){return(Array.isArray(e)?e:[]).map(e=>({id:e.id||crypto.randomUUID(),field:e.field||``,order:e.order||e.direction||`asc`}))}function ia({renderSummary:e,children:t}){let[n,r]=J.useState(!1);return(0,Y.jsxs)(Y.Fragment,{children:[e(()=>r(e=>!e)),n&&t]})}var aa=5;function oa({colName:e,label:t,idx:n,total:r,onToggle:i,onMove:a}){let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=ot({id:e});return(0,Y.jsxs)(`div`,{ref:c,style:{transform:En.Transform.toString(l),transition:u,zIndex:d?10:void 0,opacity:d?.5:void 0},"data-field-name":e,"data-field-label":t,className:`flex items-center gap-1 text-xs hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1 group`,children:[(0,Y.jsx)(`span`,{...o,...s,className:`shrink-0 cursor-grab touch-none`,"data-testid":`col-drag-handle-${e}`,children:(0,Y.jsx)(j,{className:`h-3 w-3 text-muted-foreground/50`})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`col-eye-${e}`,className:`h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0`,onClick:()=>i(e,!1),"aria-label":`Hide ${t}`,children:(0,Y.jsx)(te,{className:`h-3.5 w-3.5 text-primary`})}),(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:t}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`col-move-up-${e}`,className:`h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,disabled:n===0,onClick:()=>a(e,`up`),"aria-label":`Move ${t} up`,children:(0,Y.jsx)(j,{className:`h-3 w-3 rotate-90`})}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`col-move-down-${e}`,className:`h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,disabled:n===r-1,onClick:()=>a(e,`down`),"aria-label":`Move ${t} down`,children:(0,Y.jsx)(j,{className:`h-3 w-3 -rotate-90`})})]})}function sa({columns:e,fieldOptions:t,onToggle:n,onMove:r,onReorder:i}){return(0,Y.jsx)(pn,{sensors:_n(Je(Xt,{activationConstraint:{distance:aa}}),Je(mt)),collisionDetection:yt,onDragEnd:J.useCallback(t=>{let{active:n,over:r}=t;if(!r||n.id===r.id)return;let a=e.indexOf(String(n.id)),o=e.indexOf(String(r.id));a===-1||o===-1||i(rn(e,a,o))},[e,i]),children:(0,Y.jsx)(qt,{items:e,strategy:It,children:e.map((i,a)=>(0,Y.jsx)(oa,{colName:i,label:t.find(e=>e.value===i)?.label||i,idx:a,total:e.length,onToggle:n,onMove:r},i))})})}var Q=e=>e.type==null||e.type===`grid`,ca=e=>e.type==null||[`grid`,`kanban`,`gallery`].includes(e.type),la=e=>e.type==null||[`grid`,`calendar`,`timeline`,`gantt`].includes(e.type),ua=e=>e.type==null||[`grid`,`kanban`].includes(e.type),da=e=>e.type==null||[`grid`,`kanban`].includes(e.type),fa=e=>e.type==null||[`grid`,`gallery`].includes(e.type);function pa(e){let{t,fieldOptions:n,objectDef:r,updateField:i,filterGroupValue:a,sortItemsValue:o}=e,s=n.map(e=>({value:e.value,label:e.label})),c=[{value:``,label:t(`console.objectView.none`)},...s];return{breadcrumb:[t(`console.objectView.page`)],sections:[ma(t,r),ha(t),ga(t,i),_a(t,i),va(t,i),ya(t,n,c,r,i,a,o),ba(t,n,c,i),xa(t,i),Sa(t,i),Ca(t,i)]}}function ma(e,t){return{key:`general`,title:e(`console.objectView.general`),hint:e(`console.objectView.generalHint`),fields:[{key:`label`,label:e(`console.objectView.title`),type:`custom`,render:(t,n)=>(0,Y.jsx)(V,{label:e(`console.objectView.title`),children:(0,Y.jsx)(B,{"data-testid":`view-title-input`,className:`h-7 text-xs w-32 text-right`,value:t||``,onChange:e=>n(e.target.value)})})},{key:`description`,label:e(`console.objectView.description`),type:`custom`,render:(n,r)=>(0,Y.jsx)(V,{label:e(`console.objectView.description`),children:(0,Y.jsx)(B,{"data-testid":`view-description-input`,className:`h-7 text-xs w-32 text-right`,value:n??``,placeholder:t.description||e(`console.objectView.noDescription`),onChange:e=>r(e.target.value)})})},{key:`type`,label:e(`console.objectView.viewType`),type:`custom`,render:(t,n)=>(0,Y.jsx)(V,{label:e(`console.objectView.viewType`),children:(0,Y.jsx)(`select`,{"data-testid":`view-type-select`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground`,value:t||`grid`,onChange:e=>n(e.target.value),children:$i.map(e=>(0,Y.jsx)(`option`,{value:e,children:Qi[e]},e))})})}]}}function ha(e){let t=[`showSearch`,`showSort`,`showFilters`,`showHideFields`,`showGroup`,`showColor`,`showDensity`];return{key:`toolbar`,title:e(`console.objectView.toolbar`),hint:e(`console.objectView.toolbarHint`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_toolbarSummary`,label:e(`console.objectView.toolbar`),type:`custom`,render:(n,r,i)=>{let a=t.length,o=t.filter(e=>i[e]!==!1).length;return(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 py-1`,"data-testid":`toolbar-summary-chip`,children:(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:e(`console.objectView.toolbarEnabledCount`,{count:o,total:a})})})}},$(`showSearch`,e(`console.objectView.enableSearch`),`toggle-showSearch`,!0),$(`showSort`,e(`console.objectView.enableSort`),`toggle-showSort`,!0),$(`showFilters`,e(`console.objectView.enableFilter`),`toggle-showFilters`,!0),$(`showHideFields`,e(`console.objectView.enableHideFields`),`toggle-showHideFields`,!0),$(`showGroup`,e(`console.objectView.enableGroup`),`toggle-showGroup`,!0,!1,void 0,ca),$(`showColor`,e(`console.objectView.enableColor`),`toggle-showColor`,!0,!1,void 0,la),$(`showDensity`,e(`console.objectView.enableDensity`),`toggle-showDensity`,!0,!1,void 0,Q)]}}function ga(e,t){return{key:`navigation`,title:e(`console.objectView.navigationSection`),hint:e(`console.objectView.navigationHint`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_navigationMode`,label:e(`console.objectView.navigationMode`),type:`custom`,render:(n,r,i)=>{let a=i.navigation?.mode||`page`;return(0,Y.jsx)(V,{label:e(`console.objectView.navigationMode`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-navigation-mode`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]`,value:a,onChange:e=>{let n=e.target.value;t(`navigation`,{...i.navigation||{},mode:n}),t(`clickIntoRecordDetails`,n!==`none`)},children:[(0,Y.jsx)(`option`,{value:`page`,children:`Page`}),(0,Y.jsx)(`option`,{value:`drawer`,children:`Drawer`}),(0,Y.jsx)(`option`,{value:`modal`,children:`Modal`}),(0,Y.jsx)(`option`,{value:`split`,children:`Split`}),(0,Y.jsx)(`option`,{value:`popover`,children:`Popover`}),(0,Y.jsx)(`option`,{value:`new_window`,children:`New Window`}),(0,Y.jsx)(`option`,{value:`none`,children:`None`})]})})}},{key:`_navigationWidth`,label:e(`console.objectView.navigationWidth`),type:`custom`,helpText:e(`console.objectView.navigationWidthHint`),visibleWhen:e=>[`drawer`,`modal`,`split`].includes(e.navigation?.mode||`page`),render:(n,r,i)=>{let a=i.navigation?.mode||`page`;return(0,Y.jsx)(V,{label:e(`console.objectView.navigationWidth`),children:(0,Y.jsx)(B,{"data-testid":`input-navigation-width`,className:`h-7 text-xs w-24 text-right`,value:i.navigation?.width??``,placeholder:`600px`,onChange:e=>t(`navigation`,{...i.navigation||{},mode:a,width:e.target.value})})})}},{key:`_navigationOpenNewTab`,label:e(`console.objectView.openNewTab`),type:`custom`,helpText:e(`console.objectView.openNewTabHint`),visibleWhen:e=>[`page`,`new_window`].includes(e.navigation?.mode||`page`),render:(n,r,i)=>{let a=i.navigation?.mode||`page`;return(0,Y.jsx)(V,{label:e(`console.objectView.openNewTab`),children:(0,Y.jsx)(at,{"data-testid":`toggle-navigation-openNewTab`,checked:i.navigation?.openNewTab===!0,onCheckedChange:e=>t(`navigation`,{...i.navigation||{},mode:a,openNewTab:e}),className:`scale-75`})})}}]}}function _a(e,t){return{key:`records`,title:e(`console.objectView.records`),hint:e(`console.objectView.recordsHint`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_selectionType`,label:e(`console.objectView.selectionMode`),type:`custom`,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.selectionMode`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-selection-type`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]`,value:i.selection?.type||`multiple`,onChange:e=>t(`selection`,{type:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`none`,children:e(`console.objectView.selectionNone`)}),(0,Y.jsx)(`option`,{value:`single`,children:e(`console.objectView.selectionSingle`)}),(0,Y.jsx)(`option`,{value:`multiple`,children:e(`console.objectView.selectionMultiple`)})]})})},{key:`_addRecord`,label:e(`console.objectView.addRecordEnabled`),type:`custom`,render:(n,r,i)=>{let a=i.addRecordViaForm===!0||i.addRecord?.enabled===!0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{label:e(`console.objectView.addRecordEnabled`),children:(0,Y.jsx)(at,{"data-testid":`toggle-addRecord-enabled`,checked:a,onCheckedChange:e=>{t(`addRecordViaForm`,e),t(`addRecord`,{...i.addRecord||{},enabled:e})},className:`scale-75`})}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{label:e(`console.objectView.addRecordPosition`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-addRecord-position`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]`,value:i.addRecord?.position||`top`,onChange:e=>t(`addRecord`,{...i.addRecord||{},enabled:!0,position:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`top`,children:`Top`}),(0,Y.jsx)(`option`,{value:`bottom`,children:`Bottom`})]})}),(0,Y.jsx)(V,{label:e(`console.objectView.addRecordMode`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-addRecord-mode`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]`,value:i.addRecord?.mode||`form`,onChange:e=>t(`addRecord`,{...i.addRecord||{},enabled:!0,mode:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`inline`,children:`Inline`}),(0,Y.jsx)(`option`,{value:`form`,children:`Form`}),(0,Y.jsx)(`option`,{value:`modal`,children:`Modal`})]})}),(0,Y.jsx)(V,{label:e(`console.objectView.addRecordFormView`),children:(0,Y.jsx)(B,{"data-testid":`input-addRecord-formView`,className:`h-7 text-xs w-24 text-right`,value:i.addRecord?.formView??``,onChange:e=>t(`addRecord`,{...i.addRecord||{},enabled:!0,formView:e.target.value})})})]})]})}}]}}function va(e,t){return{key:`exportPrint`,title:e(`console.objectView.exportPrint`),hint:e(`console.objectView.exportPrintHint`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_export`,label:e(`console.objectView.allowExport`),type:`custom`,render:(n,r,i)=>{let a=i.exportOptions!=null||i.allowExport===!0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{label:e(`console.objectView.allowExport`),children:(0,Y.jsx)(at,{"data-testid":`toggle-allowExport`,checked:a,onCheckedChange:e=>t(`allowExport`,e),className:`scale-75`})}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{label:e(`console.objectView.exportFormats`),children:(0,Y.jsx)(`div`,{"data-testid":`export-formats`,className:`flex flex-wrap gap-1`,children:[`csv`,`xlsx`,`json`,`pdf`].map(e=>(0,Y.jsxs)(`label`,{className:`flex items-center gap-1 text-xs cursor-pointer`,children:[(0,Y.jsx)(At,{"data-testid":`export-format-${e}`,checked:(i.exportOptions?.formats||[]).includes(e),onCheckedChange:n=>{let r=i.exportOptions?.formats||[],a=n?[...r,e]:r.filter(t=>t!==e);t(`exportOptions`,{...i.exportOptions||{},formats:a})},className:`h-3.5 w-3.5`}),e]},e))})}),(0,Y.jsx)(V,{label:e(`console.objectView.exportMaxRecords`),children:(0,Y.jsx)(B,{"data-testid":`input-export-maxRecords`,className:`h-7 text-xs w-20 text-right`,type:`number`,value:i.exportOptions?.maxRecords??``,placeholder:`0`,onChange:e=>t(`exportOptions`,{...i.exportOptions||{},maxRecords:Number(e.target.value)||void 0})})}),(0,Y.jsx)(V,{label:e(`console.objectView.exportIncludeHeaders`),children:(0,Y.jsx)(at,{"data-testid":`toggle-export-includeHeaders`,checked:i.exportOptions?.includeHeaders!==!1,onCheckedChange:e=>t(`exportOptions`,{...i.exportOptions||{},includeHeaders:e}),className:`scale-75`})}),(0,Y.jsx)(V,{label:e(`console.objectView.exportFileNamePrefix`),children:(0,Y.jsx)(B,{"data-testid":`input-export-fileNamePrefix`,className:`h-7 text-xs w-24 text-right`,value:i.exportOptions?.fileNamePrefix??``,placeholder:`export`,onChange:e=>t(`exportOptions`,{...i.exportOptions||{},fileNamePrefix:e.target.value})})})]})]})}},$(`showRecordCount`,e(`console.objectView.showRecordCount`),`toggle-showRecordCount`,!1,!0,void 0,Q),$(`allowPrinting`,e(`console.objectView.allowPrinting`),`toggle-allowPrinting`,!1,!0,void 0,Q)]}}function ya(e,t,n,r,i,a,o){return{key:`data`,title:e(`console.objectView.data`),hint:e(`console.objectView.listConfigHint`),collapsible:!0,fields:[{key:`_source`,label:e(`console.objectView.source`),type:`custom`,render:()=>(0,Y.jsx)(V,{label:e(`console.objectView.source`),value:r.label||r.name})},{key:`_columns`,label:e(`console.objectView.fields`),type:`custom`,render:(n,r,a)=>{let o=Array.isArray(a.columns)?a.columns.length:0,s=o>0?e(`console.objectView.fieldsVisible`,{count:o}):e(`console.objectView.none`),c=(e,t)=>{let n=Array.isArray(a.columns)?[...a.columns]:[];if(t&&!n.includes(e))n.push(e);else if(!t){let t=n.indexOf(e);t>=0&&n.splice(t,1)}i(`columns`,n)},l=(e,t)=>{let n=Array.isArray(a.columns)?[...a.columns]:[],r=n.indexOf(e);if(r<0)return;let o=t===`up`?r-1:r+1;o<0||o>=n.length||([n[r],n[o]]=[n[o],n[r]],i(`columns`,n))},u=()=>{i(`columns`,t.map(e=>e.value))},d=()=>{i(`columns`,[])};return(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.fields`),value:s,onClick:t}),children:(0,Y.jsxs)(`div`,{"data-testid":`column-selector`,className:`pb-2 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 pb-1`,children:[(0,Y.jsx)(B,{"data-testid":`column-search-input`,className:`h-6 text-xs flex-1`,placeholder:e(`console.objectView.searchFields`),onChange:e=>{let t=e.target,n=t.closest(`[data-testid="column-selector"]`);if(!n)return;let r=t.value.toLowerCase();n.querySelectorAll(`[data-field-name]`).forEach(e=>{let t=e.getAttribute(`data-field-name`)||``,n=e.getAttribute(`data-field-label`)||``;e.style.display=!r||t.toLowerCase().includes(r)||n.toLowerCase().includes(r)?``:`none`})}}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`column-show-all`,className:`text-xs text-primary hover:underline whitespace-nowrap`,onClick:u,children:e(`console.objectView.showAllFields`)}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`column-hide-all`,className:`text-xs text-primary hover:underline whitespace-nowrap`,onClick:d,children:e(`console.objectView.hideAllFields`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-0.5 max-h-48 overflow-auto`,children:[Array.isArray(a.columns)&&a.columns.length>0&&(0,Y.jsx)(`div`,{"data-testid":`selected-columns`,className:`space-y-0.5 pb-1 mb-1 border-b border-border/50`,children:(0,Y.jsx)(sa,{columns:a.columns,fieldOptions:t,onToggle:c,onMove:l,onReorder:e=>i(`columns`,e)})}),t.filter(e=>!Array.isArray(a.columns)||!a.columns.includes(e.value)).map(e=>(0,Y.jsxs)(`div`,{"data-field-name":e.value,"data-field-label":e.label,className:`flex items-center gap-1 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1`,children:[(0,Y.jsx)(j,{className:`h-3 w-3 text-muted-foreground/20 shrink-0`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`col-eye-${e.value}`,className:`h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0`,onClick:()=>c(e.value,!0),"aria-label":`Show ${e.label}`,children:(0,Y.jsx)(de,{className:`h-3.5 w-3.5 text-muted-foreground`})}),(0,Y.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.label})]},e.value))]})]})})}},{key:`_filterBy`,label:e(`console.objectView.filterBy`),type:`custom`,render:(n,r,o)=>{let s=a.conditions.length,c=s>0?e(`console.objectView.filtersCount`,{count:s}):e(`console.objectView.none`);return(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.filterBy`),value:c,onClick:t}),children:(0,Y.jsx)(`div`,{"data-testid":`inline-filter-builder`,className:`pb-2`,children:(0,Y.jsx)(gt,{fields:t,value:a,onChange:e=>{i(`filter`,Yi(e.logic,e.conditions.map(e=>({field:e.field,operator:e.operator,value:e.value}))))},className:`[&_button]:h-7 [&_button]:text-xs [&_input]:h-7 [&_input]:text-xs`,showClearAll:!0})})})}},{key:`_sortBy`,label:e(`console.objectView.sortBy`),type:`custom`,render:(n,r,a)=>{let s=Array.isArray(a.sort)?a.sort.filter(e=>e.field).length:0,c=s>0?e(`console.objectView.sortsCount`,{count:s}):e(`console.objectView.none`);return(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.sortBy`),value:c,onClick:t}),children:(0,Y.jsx)(`div`,{"data-testid":`inline-sort-builder`,className:`pb-2`,children:(0,Y.jsx)(dt,{fields:t.map(e=>({value:e.value,label:e.label})),value:o,onChange:e=>{i(`sort`,e.map(e=>({id:e.id,field:e.field,order:e.order})))},className:`[&_button]:h-7 [&_button]:text-xs`})})})}},{key:`_groupBy`,label:e(`console.objectView.groupBy`),type:`custom`,visibleWhen:fa,render:(n,r,a)=>{let o=a.type||`grid`,s=a.kanban?.groupByField||a.kanban?.groupField||a.groupBy||``;return(0,Y.jsx)(V,{label:e(`console.objectView.groupBy`),children:(0,Y.jsxs)(`select`,{"data-testid":`data-groupBy`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]`,value:s,onChange:e=>{i(`groupBy`,e.target.value),o===`kanban`&&i(`kanban`,{...a.kanban||{},groupByField:e.target.value})},children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.none`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})}},{key:`_pageSize`,label:e(`console.objectView.pageSize`),type:`custom`,render:(t,n,r)=>(0,Y.jsx)(V,{label:e(`console.objectView.pageSize`),children:(0,Y.jsx)(B,{"data-testid":`input-pagination-pageSize`,className:`h-7 text-xs w-20 text-right`,type:`number`,value:r.pagination?.pageSize??``,placeholder:`25`,onChange:e=>{let t=Number(e.target.value)||void 0;i(`pagination`,{...r.pagination||{},pageSize:t})}})})},{key:`_pageSizeOptions`,label:e(`console.objectView.pageSizeOptions`),type:`custom`,render:(t,n,r)=>(0,Y.jsx)(V,{label:e(`console.objectView.pageSizeOptions`),children:(0,Y.jsx)(B,{"data-testid":`input-pagination-pageSizeOptions`,className:`h-7 text-xs w-28 text-right`,value:(r.pagination?.pageSizeOptions||[]).join(`, `),placeholder:`10, 25, 50, 100`,onChange:e=>{let t=Zi(e.target.value);i(`pagination`,{...r.pagination||{},pageSizeOptions:t.length?t:void 0})}})})},wa(`searchableFields`,e(`console.objectView.searchableFields`),`searchable-fields-selector`,`searchable-field`,t,i,`selected`),wa(`filterableFields`,e(`console.objectView.filterableFields`),`filterable-fields-selector`,`filterable-field`,t,i,`selected`),wa(`hiddenFields`,e(`console.objectView.hiddenFields`),`hidden-fields-selector`,`hidden-field`,t,i,`hidden`),{key:`_quickFilters`,label:e(`console.objectView.quickFilters`),type:`custom`,render:(t,n,r)=>(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.quickFilters`),value:`${(r.quickFilters||[]).length} filters`,onClick:t}),children:(0,Y.jsxs)(`div`,{"data-testid":`quick-filters-editor`,className:`pb-2 space-y-1`,children:[(r.quickFilters||[]).map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(B,{"data-testid":`quick-filter-label-${t}`,className:`h-6 text-xs flex-1`,value:e.label||``,placeholder:`Label`,onChange:e=>{let n=[...r.quickFilters||[]];n[t]={...n[t],label:e.target.value},i(`quickFilters`,n)}}),(0,Y.jsx)(At,{"data-testid":`quick-filter-default-${t}`,checked:e.defaultActive===!0,onCheckedChange:e=>{let n=[...r.quickFilters||[]];n[t]={...n[t],defaultActive:e},i(`quickFilters`,n)},className:`h-3.5 w-3.5`}),(0,Y.jsx)(`button`,{type:`button`,className:`text-destructive hover:text-destructive/80 text-xs`,onClick:()=>{i(`quickFilters`,(r.quickFilters||[]).filter((e,n)=>n!==t))},children:`✕`})]},e.id||t)),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`add-quick-filter`,className:`text-xs text-primary hover:underline`,onClick:()=>{let e={id:crypto.randomUUID(),label:``,filters:[],defaultActive:!1};i(`quickFilters`,[...r.quickFilters||[],e])},children:[`+ `,e(`console.objectView.addQuickFilter`)]})]})})},{key:`_userFilters`,label:e(`console.objectView.userFilters`),type:`custom`,render:(n,r,a)=>{let o=a.userFilters||{element:`dropdown`,fields:[]},s=o.element||`dropdown`,c=o.fields||[],l=o.tabs||[],u=t.filter(e=>{let t=Array.isArray(e.options)&&e.options.length>0,n=e.type===`select`||e.type===`boolean`;return t||n}).map(e=>e.value),d=[{value:`dropdown`,label:e(`console.objectView.ufDropdown`)},{value:`tabs`,label:e(`console.objectView.ufTabs`)},{value:`toggle`,label:e(`console.objectView.ufToggle`)}],f=s===`tabs`?l.length>0?l.map(e=>e.label||e.id).join(`, `):e(`console.objectView.none`):c.length>0?c.map(e=>t.find(t=>t.value===e.field)?.label||e.field).join(`, `):e(`console.objectView.none`);return(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.userFilters`),value:f,onClick:t}),children:(0,Y.jsxs)(`div`,{"data-testid":`user-filters-editor`,className:`pb-2 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.ufElements`)}),(0,Y.jsx)(`div`,{className:`flex gap-1`,children:d.map(e=>(0,Y.jsx)(`button`,{type:`button`,"data-testid":`uf-element-${e.value}`,className:`text-xs px-2 py-0.5 rounded border ${s===e.value?`bg-primary text-primary-foreground border-primary`:`border-border hover:bg-accent`}`,onClick:()=>{i(`userFilters`,{...o,element:e.value})},children:e.label},e.value))})]}),(s===`dropdown`||s===`toggle`)&&(0,Y.jsxs)(`div`,{"data-testid":`uf-fields-section`,className:`space-y-1`,children:[c.map((e,n)=>(0,Y.jsxs)(`div`,{"data-testid":`uf-field-${n}`,className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:t.find(t=>t.value===e.field)?.label||e.field}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`uf-remove-field-${n}`,className:`text-destructive hover:text-destructive/80 text-xs`,onClick:()=>{let e=c.filter((e,t)=>t!==n);i(`userFilters`,{...o,fields:e})},children:`✕`})]},e.field||n)),u.length>0?(0,Y.jsxs)(`select`,{"data-testid":`uf-add-field`,className:`text-xs h-6 w-full border rounded px-1`,value:``,onChange:e=>{if(!e.target.value)return;let t={field:e.target.value};i(`userFilters`,{...o,fields:[...c,t]}),e.target.value=``},children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.ufAddField`)}),u.filter(e=>!c.some(t=>t.field===e)).map(e=>(0,Y.jsx)(`option`,{value:e,children:t.find(t=>t.value===e)?.label||e},e))]}):(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.ufNoFields`)})]}),s===`tabs`&&(0,Y.jsxs)(`div`,{"data-testid":`uf-tabs-section`,className:`space-y-1`,children:[l.map((t,n)=>(0,Y.jsxs)(`div`,{"data-testid":`uf-tab-${n}`,className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(B,{"data-testid":`uf-tab-label-${n}`,className:`h-6 text-xs flex-1`,value:t.label||``,placeholder:e(`console.objectView.ufTabLabel`),onChange:e=>{let t=[...l];t[n]={...t[n],label:e.target.value},i(`userFilters`,{...o,tabs:t})}}),(0,Y.jsx)(At,{"data-testid":`uf-tab-default-${n}`,checked:t.default===!0,onCheckedChange:e=>{let t=l.map((t,r)=>({...t,default:r===n?e:!1}));i(`userFilters`,{...o,tabs:t})},className:`h-3.5 w-3.5`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`uf-remove-tab-${n}`,className:`text-destructive hover:text-destructive/80 text-xs`,onClick:()=>{let e=l.filter((e,t)=>t!==n);i(`userFilters`,{...o,tabs:e})},children:`✕`})]},t.id||n)),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`uf-add-tab`,className:`text-xs text-primary hover:underline`,onClick:()=>{let e={id:crypto.randomUUID(),label:``,filters:[],default:!1};i(`userFilters`,{...o,tabs:[...l,e]})},children:e(`console.objectView.ufAddTab`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Y.jsx)(At,{"data-testid":`uf-show-all-records`,checked:o.showAllRecords!==!1,onCheckedChange:e=>{i(`userFilters`,{...o,showAllRecords:e?void 0:!1})},className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`text-xs`,children:e(`console.objectView.ufShowAllRecords`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(At,{"data-testid":`uf-allow-add-tab`,checked:o.allowAddTab===!0,onCheckedChange:e=>{i(`userFilters`,{...o,allowAddTab:e})},className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`text-xs`,children:e(`console.objectView.ufAllowAddTab`)})]})]})]})})}},$(`virtualScroll`,e(`console.objectView.virtualScroll`),`toggle-virtualScroll`,!1,!0,void 0,Q),{key:`_typeOptions`,label:`Type-specific options`,type:`custom`,render:(n,r,a)=>{let o=a.type||`grid`,s=(e,t,n)=>{i(e,{...a[e]||{},[t]:n})};return o===`grid`?(0,Y.jsx)(`div`,{"data-testid":`type-options-section`,className:`hidden`}):(0,Y.jsxs)(`div`,{"data-testid":`type-options-section`,className:`pt-1 space-y-2`,children:[o===`kanban`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.groupByField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-kanban-groupByField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.kanban?.groupByField||a.kanban?.groupField||``,onChange:e=>s(`kanban`,`groupByField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),o===`calendar`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.startDateField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-calendar-startDateField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.calendar?.startDateField||``,onChange:e=>s(`calendar`,`startDateField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.endDateField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-calendar-endDateField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.calendar?.endDateField||``,onChange:e=>s(`calendar`,`endDateField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.titleField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-calendar-titleField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.calendar?.titleField||``,onChange:e=>s(`calendar`,`titleField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})]}),o===`map`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.latitudeField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-map-latitudeField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.map?.latitudeField||``,onChange:e=>s(`map`,`latitudeField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.longitudeField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-map-longitudeField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.map?.longitudeField||``,onChange:e=>s(`map`,`longitudeField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})]}),o===`gallery`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.imageField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-gallery-imageField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a.gallery?.imageField||``,onChange:e=>s(`gallery`,`imageField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(o===`timeline`||o===`gantt`)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.dateField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-${o}-dateField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a[o]?.dateField||a[o]?.startDateField||``,onChange:e=>s(o,`dateField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`console.objectView.titleField`)}),(0,Y.jsxs)(`select`,{"data-testid":`type-opt-${o}-titleField`,className:`w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1`,value:a[o]?.titleField||``,onChange:e=>s(o,`titleField`,e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.selectField`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})]})]})}}]}}function ba(e,t,n,r){return{key:`appearance`,title:e(`console.objectView.appearance`),collapsible:!0,defaultCollapsed:!0,fields:[$(`striped`,e(`console.objectView.striped`),`toggle-striped`,!1,!0,void 0,Q),$(`bordered`,e(`console.objectView.bordered`),`toggle-bordered`,!1,!0,void 0,Q),{key:`color`,label:e(`console.objectView.color`),type:`custom`,visibleWhen:la,render:(n,r)=>(0,Y.jsx)(V,{label:e(`console.objectView.color`),children:(0,Y.jsxs)(`select`,{"data-testid":`appearance-color`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]`,value:n||``,onChange:e=>r(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:e(`console.objectView.none`)}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})},$(`wrapHeaders`,e(`console.objectView.wrapHeaders`),`toggle-wrapHeaders`,!1,!0,void 0,Q),$(`showDescription`,e(`console.objectView.showFieldDescriptions`),`toggle-showDescription`,!0),$(`resizable`,e(`console.objectView.resizableColumns`),`toggle-resizable`,!1,!0,void 0,Q),{key:`rowHeight`,label:e(`console.objectView.rowHeight`),type:`custom`,visibleWhen:Q,render:(t,n)=>(0,Y.jsx)(V,{label:e(`console.objectView.rowHeight`),children:(0,Y.jsx)(`div`,{className:`flex gap-0.5`,"data-testid":`appearance-rowHeight`,role:`radiogroup`,"aria-label":e(`console.objectView.rowHeight`),children:ea.map(e=>(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":(t||`compact`)===e.value,"aria-label":e.value,"data-testid":`row-height-${e.value}`,className:`h-7 w-7 rounded border flex items-center justify-center ${(t||`compact`)===e.value?`border-primary bg-primary/10 text-primary`:`border-input text-muted-foreground hover:bg-accent/50`}`,onClick:()=>n(e.value),title:e.value,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center w-4 h-4 ${e.gapClass}`,children:[(0,Y.jsx)(`div`,{className:`w-3.5 h-px bg-current rounded-full`}),(0,Y.jsx)(`div`,{className:`w-3.5 h-px bg-current rounded-full`}),(0,Y.jsx)(`div`,{className:`w-3.5 h-px bg-current rounded-full`})]})},e.value))})})},{key:`_conditionalFormatting`,label:e(`console.objectView.conditionalFormatting`),type:`custom`,visibleWhen:ua,render:(n,i,a)=>(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.conditionalFormatting`),value:`${(a.conditionalFormatting||[]).length} rules`,onClick:t}),children:(0,Y.jsxs)(`div`,{"data-testid":`conditional-formatting-editor`,className:`pb-2 space-y-1`,children:[(a.conditionalFormatting||[]).map((e,n)=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs border rounded p-1`,children:[(0,Y.jsxs)(`select`,{"data-testid":`cf-field-${n}`,className:`text-xs h-6 rounded border border-input bg-background px-1 flex-1`,value:e.field||``,onChange:e=>{let t=[...a.conditionalFormatting||[]];t[n]={...t[n],field:e.target.value},r(`conditionalFormatting`,t)},children:[(0,Y.jsx)(`option`,{value:``,children:`Field`}),t.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,Y.jsxs)(`select`,{"data-testid":`cf-operator-${n}`,className:`text-xs h-6 rounded border border-input bg-background px-1`,value:e.operator||`equals`,onChange:e=>{let t=[...a.conditionalFormatting||[]];t[n]={...t[n],operator:e.target.value},r(`conditionalFormatting`,t)},children:[(0,Y.jsx)(`option`,{value:`equals`,children:`=`}),(0,Y.jsx)(`option`,{value:`not_equals`,children:`≠`}),(0,Y.jsx)(`option`,{value:`contains`,children:`contains`}),(0,Y.jsx)(`option`,{value:`greater_than`,children:`>`}),(0,Y.jsx)(`option`,{value:`less_than`,children:`<`}),(0,Y.jsx)(`option`,{value:`in`,children:`in`})]}),(0,Y.jsx)(B,{"data-testid":`cf-value-${n}`,className:`h-6 text-xs w-16`,value:String(e.value??``),placeholder:`Value`,onChange:e=>{let t=[...a.conditionalFormatting||[]];t[n]={...t[n],value:e.target.value},r(`conditionalFormatting`,t)}}),(0,Y.jsx)(`button`,{type:`button`,className:`text-destructive hover:text-destructive/80 text-xs`,onClick:()=>{r(`conditionalFormatting`,(a.conditionalFormatting||[]).filter((e,t)=>t!==n))},children:`✕`})]},n)),(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`add-conditional-rule`,className:`text-xs text-primary hover:underline`,onClick:()=>{let e={field:``,operator:`equals`,value:``};r(`conditionalFormatting`,[...a.conditionalFormatting||[],e])},children:[`+ `,e(`console.objectView.addRule`)]})]})})},{key:`_emptyState`,label:`Empty state`,type:`custom`,render:(t,n,i)=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V,{label:e(`console.objectView.emptyStateTitle`),children:(0,Y.jsx)(B,{"data-testid":`input-emptyState-title`,className:`h-7 text-xs w-28 text-right`,value:i.emptyState?.title??``,onChange:e=>r(`emptyState`,{...i.emptyState||{},title:e.target.value})})}),(0,Y.jsx)(V,{label:e(`console.objectView.emptyStateMessage`),children:(0,Y.jsx)(B,{"data-testid":`input-emptyState-message`,className:`h-7 text-xs w-28 text-right`,value:i.emptyState?.message??``,onChange:e=>r(`emptyState`,{...i.emptyState||{},message:e.target.value})})}),(0,Y.jsx)(V,{label:e(`console.objectView.emptyStateIcon`),children:(0,Y.jsx)(B,{"data-testid":`input-emptyState-icon`,className:`h-7 text-xs w-28 text-right`,value:i.emptyState?.icon??``,onChange:e=>r(`emptyState`,{...i.emptyState||{},icon:e.target.value})})})]})}]}}function xa(e,t){return{key:`userActions`,title:e(`console.objectView.userActions`),collapsible:!0,defaultCollapsed:!0,fields:[$(`inlineEdit`,e(`console.objectView.inlineEdit`),`toggle-inlineEdit`,!0,!1,void 0,Q),$(`addDeleteRecordsInline`,e(`console.objectView.addDeleteRecordsInline`),`toggle-addDeleteRecordsInline`,!0,!1,void 0,Q),{key:`_rowActions`,label:e(`console.objectView.rowActions`),type:`custom`,visibleWhen:da,render:(n,r,i)=>(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.rowActions`),value:`${(i.rowActions||[]).length} actions`,onClick:t}),children:(0,Y.jsx)(`div`,{"data-testid":`row-actions-selector`,className:`pb-2 space-y-0.5 max-h-36 overflow-auto`,children:(0,Y.jsx)(B,{"data-testid":`input-rowActions`,className:`h-7 text-xs w-full`,value:(i.rowActions||[]).join(`, `),placeholder:`edit, delete, duplicate`,onChange:e=>{t(`rowActions`,Xi(e.target.value))}})})})},{key:`_bulkActions`,label:e(`console.objectView.bulkActions`),type:`custom`,visibleWhen:da,render:(n,r,i)=>(0,Y.jsx)(ia,{renderSummary:t=>(0,Y.jsx)(V,{label:e(`console.objectView.bulkActions`),value:`${(i.bulkActions||[]).length} actions`,onClick:t}),children:(0,Y.jsx)(`div`,{"data-testid":`bulk-actions-selector`,className:`pb-2 space-y-0.5 max-h-36 overflow-auto`,children:(0,Y.jsx)(B,{"data-testid":`input-bulkActions`,className:`h-7 text-xs w-full`,value:(i.bulkActions||[]).join(`, `),placeholder:`delete, export, assign`,onChange:e=>{t(`bulkActions`,Xi(e.target.value))}})})})}]}}function Sa(e,t){return{key:`sharing`,title:e(`console.objectView.sharing`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_sharingEnabled`,label:e(`console.objectView.sharingEnabled`),type:`custom`,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.sharingEnabled`),children:(0,Y.jsx)(at,{"data-testid":`toggle-sharing-enabled`,checked:i.sharing?.enabled===!0,onCheckedChange:e=>t(`sharing`,{...i.sharing||{},enabled:e}),className:`scale-75`})})},{key:`_sharingVisibility`,label:e(`console.objectView.sharingVisibility`),type:`custom`,visibleWhen:e=>e.sharing?.enabled===!0,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.sharingVisibility`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-sharing-visibility`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]`,value:i.sharing?.visibility||`private`,onChange:e=>t(`sharing`,{...i.sharing||{},enabled:!0,visibility:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`private`,children:`Private`}),(0,Y.jsx)(`option`,{value:`team`,children:`Team`}),(0,Y.jsx)(`option`,{value:`organization`,children:`Organization`}),(0,Y.jsx)(`option`,{value:`public`,children:`Public`})]})})}]}}function Ca(e,t){return{key:`accessibility`,title:e(`console.objectView.accessibility`),collapsible:!0,defaultCollapsed:!0,fields:[{key:`_ariaLabel`,label:e(`console.objectView.ariaLabel`),type:`custom`,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.ariaLabel`),children:(0,Y.jsx)(B,{"data-testid":`input-aria-label`,className:`h-7 text-xs w-28 text-right`,value:i.aria?.label??``,onChange:e=>t(`aria`,{...i.aria||{},label:e.target.value})})})},{key:`_ariaDescribedBy`,label:e(`console.objectView.ariaDescribedBy`),type:`custom`,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.ariaDescribedBy`),children:(0,Y.jsx)(B,{"data-testid":`input-aria-describedBy`,className:`h-7 text-xs w-28 text-right`,value:i.aria?.describedBy??``,onChange:e=>t(`aria`,{...i.aria||{},describedBy:e.target.value})})})},{key:`_ariaLive`,label:e(`console.objectView.ariaLive`),type:`custom`,render:(n,r,i)=>(0,Y.jsx)(V,{label:e(`console.objectView.ariaLive`),children:(0,Y.jsxs)(`select`,{"data-testid":`select-aria-live`,className:`text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]`,value:i.aria?.live||`off`,onChange:e=>t(`aria`,{...i.aria||{},live:e.target.value}),children:[(0,Y.jsx)(`option`,{value:`off`,children:`Off`}),(0,Y.jsx)(`option`,{value:`polite`,children:`Polite`}),(0,Y.jsx)(`option`,{value:`assertive`,children:`Assertive`})]})})}]}}function $(e,t,n,r=!1,i=!1,a,o){return{key:e,label:t,type:`custom`,disabledWhen:a,visibleWhen:o,render:(e,o,s)=>(0,Y.jsx)(V,{label:t,children:(0,Y.jsx)(at,{"data-testid":n,checked:i?e===!0:r?e!==!1:!!e,disabled:a?a(s):!1,onCheckedChange:e=>o(e),className:`scale-75`})})}}function wa(e,t,n,r,i,a,o,s){return{key:`_${e}`,label:t,type:`custom`,visibleWhen:s,render:(s,c,l)=>(0,Y.jsx)(ia,{renderSummary:n=>(0,Y.jsx)(V,{label:t,value:`${(l[e]||[]).length} ${o}`,onClick:n}),children:(0,Y.jsx)(`div`,{"data-testid":n,className:`pb-2 space-y-0.5 max-h-36 overflow-auto`,children:i.map(t=>(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1`,children:[(0,Y.jsx)(At,{"data-testid":`${r}-${t.value}`,checked:(l[e]||[]).includes(t.value),onCheckedChange:n=>{let r=l[e]||[];a(e,n?[...r,t.value]:r.filter(e=>e!==t.value))},className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`truncate`,children:t.label})]},t.value))})})}}function Ta({open:e,onClose:t,mode:n=`edit`,activeView:r,objectDef:i,onViewUpdate:a,onSave:o,onCreate:s}){let{t:c}=q(),l=(0,J.useRef)(null),u=(0,J.useMemo)(()=>({id:`view_${Date.now()}`,label:c(`console.objectView.newView`),type:`grid`,columns:[],filter:[],sort:[],showSearch:!0,showFilters:!0,showSort:!0}),[]),d=(0,J.useMemo)(()=>({...r}),[n===`create`?`create`:r.id]),{draft:f,isDirty:p,updateField:m,discard:h,undo:g,redo:_,canUndo:v,canRedo:y}=Ot(n===`create`?u:d,{mode:n,onUpdate:a});(0,J.useEffect)(()=>{e&&l.current&&l.current.focus()},[e]);let b=(0,J.useMemo)(()=>ta(i),[i.fields]),x=(0,J.useMemo)(()=>na(f.filter),[f.filter]),S=(0,J.useMemo)(()=>ra(f.sort),[f.sort]),C=(0,J.useMemo)(()=>pa({t:c,fieldOptions:b,objectDef:i,updateField:m,filterGroupValue:x,sortItemsValue:S}),[c,b,i,m,x,S]),w=f.type||`grid`,T=(0,J.useMemo)(()=>({...C,breadcrumb:[c(`console.objectView.page`),Qi[w]||w]}),[C,c,w]),E=(0,J.useCallback)(()=>{n===`create`?s?.(f):o?.(f),h()},[f,o,s,n,h]),D=(0,J.useCallback)(()=>{if(n===`create`){t();return}h()},[h,n,t]),O=c(n===`create`?`console.objectView.createView`:`console.objectView.configureView`);return(0,Y.jsx)(gn,{open:e,onClose:t,schema:T,draft:f,isDirty:p,onFieldChange:m,onSave:E,onDiscard:D,onUndo:g,onRedo:_,canUndo:v,canRedo:y,undoLabel:c(`designer.undo`),redoLabel:c(`designer.redo`),objectDef:i,saveLabel:c(`console.objectView.save`),discardLabel:c(`console.objectView.discard`),panelRef:l,role:`complementary`,ariaLabel:O,tabIndex:-1,testId:`view-config-panel`,closeTitle:c(`console.objectView.closePanel`),footerTestId:`view-config-footer`,saveTestId:`view-config-save`,discardTestId:`view-config-discard`,className:`transition-all overflow-hidden`})}function Ea({objectName:e,objectLabel:t,dataSource:n,onEdit:r,onRefresh:i}){let a=Ln(),{appName:o}=Hn(),s=`/apps/${o}`,{execute:c,loading:l,error:u,runner:f}=d({context:{objectName:e,objectLabel:t||e,baseUrl:s}});return(0,J.useEffect)(()=>{f.registerHandler(`create`,async()=>(r?.(null),{success:!0})),f.registerHandler(`delete`,async r=>{let a=r.params?.recordId||r.recordId;if(!a)return{success:!1,error:`No record ID provided`};try{return await n.delete(e,a),i?.(),R.success(`${t||e} deleted successfully`),{success:!0,reload:!0}}catch(n){return R.error(`Failed to delete ${t||e}`,{description:n.message}),{success:!1,error:n.message}}}),f.registerHandler(`navigate`,async e=>{let t=e.params?.url||e.url;return t&&a(t.startsWith(`/`)?t:`${s}/${t}`),{success:!0}}),f.registerHandler(`refresh`,async()=>(i?.(),{success:!0,reload:!0}))},[f,e,n,r,i,a,s]),{execute:c,create:(0,J.useCallback)(()=>{r?.(null)},[r]),deleteRecord:(0,J.useCallback)(async e=>c({type:`delete`,confirmText:`Are you sure you want to delete this record?`,params:{recordId:e}}),[c]),navigateToView:(0,J.useCallback)(t=>{a(`${s}/${e}/view/${t}`)},[a,s,e]),navigateToRecord:(0,J.useCallback)(t=>{a(`${s}/${e}/record/${encodeURIComponent(t)}`)},[a,s,e]),loading:l,error:u}}function Da({state:e,onOpenChange:t}){let n=()=>{e.resolve?.(!0),t(!1)},r=()=>{e.resolve?.(!1),t(!1)};return(0,Y.jsx)(E,{open:e.open,onOpenChange:e=>{e||r()},children:(0,Y.jsxs)(Pe,{children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)($t,{children:e.options?.title||`Confirm Action`}),(0,Y.jsx)(ze,{children:e.message})]}),(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(ue,{onClick:r,children:e.options?.cancelText||`Cancel`}),(0,Y.jsx)(Le,{onClick:n,children:e.options?.confirmText||`Continue`})]})]})})}function Oa({state:e,onOpenChange:t}){let[n,r]=(0,J.useState)({}),[i,a]=(0,J.useState)({});(0,J.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);r(t),a({})}},[e.open,e.params]);let o=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,s=()=>{let r={};for(let t of e.params)t.required&&o(n[t.name])&&(r[t.name]=!0);if(Object.keys(r).length>0){a(r);return}e.resolve?.(n),t(!1)},c=()=>{e.resolve?.(null),t(!1)},l=(e,t)=>{r(n=>({...n,[e]:t})),a(t=>({...t,[e]:!1}))};return(0,Y.jsx)(Ae,{open:e.open,onOpenChange:e=>{e||c()},children:(0,Y.jsxs)(k,{children:[(0,Y.jsxs)(F,{children:[(0,Y.jsx)(M,{children:`Action Parameters`}),(0,Y.jsx)(Sn,{children:`Please provide the required information to continue.`})]}),(0,Y.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>(0,Y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Y.jsxs)(sn,{htmlFor:e.name,children:[e.label,e.required&&(0,Y.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),e.type===`select`&&e.options?(0,Y.jsxs)(qe,{value:n[e.name]??``,onValueChange:t=>l(e.name,t),children:[(0,Y.jsx)(pt,{id:e.name,className:i[e.name]?`border-destructive`:``,children:(0,Y.jsx)(fn,{placeholder:e.placeholder||`Select ${e.label}`})}),(0,Y.jsx)(Oe,{children:e.options.map(e=>(0,Y.jsx)(S,{value:e.value,children:e.label},e.value))})]}):e.type===`textarea`?(0,Y.jsx)(Ct,{id:e.name,value:n[e.name]??``,onChange:t=>l(e.name,t.target.value),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}):e.type===`number`?(0,Y.jsx)(B,{id:e.name,type:`number`,value:n[e.name]??``,onChange:t=>l(e.name,t.target.value===``?void 0:t.target.valueAsNumber),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}):(0,Y.jsx)(B,{id:e.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(e.type)?e.type:`text`,value:n[e.name]??``,onChange:t=>l(e.name,t.target.value),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}),i[e.name]&&(0,Y.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e.label,` is required`]}),e.helpText&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.helpText})]},e.name))}),(0,Y.jsxs)(Me,{children:[(0,Y.jsx)(I,{variant:`outline`,onClick:c,children:`Cancel`}),(0,Y.jsx)(I,{onClick:s,children:`Confirm`})]})]})})}var ka={grid:St,kanban:je,calendar:on,gallery:_t,timeline:vn,gantt:Et,map:an,chart:Jt},Aa={id:`current-user`,name:`Demo User`};function ja({objectDef:e,recordId:t,dataSource:n,onEdit:r}){let{user:i}=Un(),a=i?{id:i.id,name:i.name,avatar:i.image}:Aa,[o,s]=(0,J.useState)([]);(0,J.useEffect)(()=>{if(!n||!e?.name||!t)return;let r=`${e.name}:${t}`;n.find(`sys_comment`,{$filter:{threadId:r},$orderby:{createdAt:`asc`}}).then(e=>{e.data?.length&&s(e.data.map(e=>({id:e.id,type:`comment`,actor:e.author?.name??`Unknown`,actorAvatarUrl:e.author?.avatar,body:e.content,createdAt:e.createdAt,updatedAt:e.updatedAt,parentId:e.parentId,reactions:e.reactions?Object.entries(e.reactions).map(([e,t])=>({emoji:e,count:t.length,reacted:t.includes(a.id)})):void 0})))}).catch(()=>{})},[n,e?.name,t,a.id]);let c=(0,J.useCallback)(async r=>{let i={id:crypto.randomUUID(),type:`comment`,actor:a.name,actorAvatarUrl:`avatar`in a?a.avatar:void 0,body:r,createdAt:new Date().toISOString()};if(s(e=>[...e,i]),n){let o=`${e.name}:${t}`;n.create(`sys_comment`,{id:i.id,threadId:o,author:a,content:r,mentions:[],createdAt:i.createdAt}).catch(()=>{})}},[a,n,e?.name,t]),l=(0,J.useCallback)(async(r,i)=>{let o={id:crypto.randomUUID(),type:`comment`,actor:a.name,actorAvatarUrl:`avatar`in a?a.avatar:void 0,body:i,createdAt:new Date().toISOString(),parentId:r};if(s(e=>[...e,o].map(e=>e.id===r?{...e,replyCount:(e.replyCount??0)+1}:e)),n){let s=`${e.name}:${t}`;n.create(`sys_comment`,{id:o.id,threadId:s,author:a,content:i,mentions:[],createdAt:o.createdAt,parentId:r}).catch(()=>{})}},[a,n,e?.name,t]),u=(0,J.useCallback)((e,t)=>{s(r=>r.map(r=>{if(r.id!==e)return r;let i=[...r.reactions??[]],o=i.findIndex(e=>e.emoji===t);if(o>=0){let e=i[o];e.reacted?e.count<=1?i.splice(o,1):i[o]={...e,count:e.count-1,reacted:!1}:i[o]={...e,count:e.count+1,reacted:!0}}else i.push({emoji:t,count:1,reacted:!0});let s={...r,reactions:i};return n&&n.update(`sys_comment`,String(e),{$toggleReaction:{emoji:t,userId:a.id}}).catch(()=>{}),s}))},[a.id,n]);return(0,Y.jsxs)(`div`,{className:`h-full bg-background overflow-auto p-3 sm:p-4 lg:p-6`,children:[(0,Y.jsx)($n,{schema:{type:`detail-view`,objectName:e.name,resourceId:t,showBack:!1,showEdit:!0,title:e.label,sections:[{title:`Details`,fields:Object.keys(e.fields||{}).map(t=>({name:t,label:e.fields[t].label||t,type:e.fields[t].type||`text`}))}]},dataSource:n,onEdit:()=>r({id:t})}),(0,Y.jsx)(`div`,{className:`mt-6 border-t pt-6`,children:(0,Y.jsx)(Qn,{config:{position:`bottom`,collapsible:!0,defaultCollapsed:!0,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:o,onAddComment:c,onAddReply:l,onToggleReaction:u})})]})}function Ma({dataSource:e,objects:t,onEdit:n}){let r=Ln(),{objectName:i,viewId:a}=Hn(),[o,s]=Fn(),{showDebug:c,toggleDebug:l}=Hi(),{t:u}=q(),{objectLabel:d,objectDescription:p}=Xn(),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(`edit`),[b,x]=(0,J.useState)(null),S=(0,J.useCallback)(t=>{if(x(t),ae(e=>e+1),e?.updateViewConfig){let n=i,r=t.id;n&&r?e.updateViewConfig(n,r,t).catch(e=>{console.error(`[ViewConfigPanel] Failed to persist view config:`,e)}):console.warn(`[ViewConfigPanel] Cannot persist view config: missing objectName or viewId.`)}else console.warn(`[ViewConfigPanel] dataSource.updateViewConfig is not available. View config saved locally only.`)},[e,i]),C=(0,J.useCallback)(async t=>{try{if(e?.create){let n={objectName:i,...t};await e.create(`sys_view`,n)}_(!1),y(`edit`),ae(e=>e+1)}catch(e){console.error(`[ViewConfigPanel] Failed to create view:`,e)}},[e,i]),[T,E]=(0,J.useState)(void 0),{user:O}=Un(),k=O?.role===`admin`,{can:A}=Yn(),j=t.find(e=>e.name===i);if(!j)return(0,Y.jsx)(`div`,{className:`h-full p-4 flex items-center justify-center`,children:(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,Y.jsx)(St,{className:`h-6 w-6 text-muted-foreground`})}),(0,Y.jsx)(Bt,{children:u(`console.objectView.objectNotFound`)}),(0,Y.jsxs)(ct,{children:[u(`console.objectView.objectNotFoundDescription`,{objectName:i}),` `,u(`console.objectView.objectNotFoundHint`)]})]})});let M=(0,J.useMemo)(()=>{let e=j.listViews||j.list_views||{},t=Object.entries(e).map(([e,t])=>({id:e,...t,type:t.type||`grid`}));return t.length===0&&t.push({id:`all`,label:u(`console.objectView.allRecords`),type:`grid`,columns:j.fields?Object.keys(j.fields).slice(0,5):[]}),t},[j]),N=a||o.get(`view`)||M[0]?.id,P=M.find(e=>e.id===N)||M[0],F=b&&b.id===P?.id?{...P,...b}:P,ee=(0,J.useCallback)((e,t)=>{x(n=>({...n||{},id:P?.id,[e]:t}))},[P?.id]),te=e=>{let t=M.find(t=>t.id===e);t&&(_(!1),a?r(`../${t.id}`,{relative:`path`}):r(`view/${t.id}`))},ne=(0,J.useCallback)(()=>{y(`create`),_(!0)},[]),re=(0,J.useCallback)((e,t)=>{if(e===`settings`){let e=M.find(e=>e.type===t);e&&te(e.id),y(`edit`),_(!0)}},[M,te]),[ie,ae]=(0,J.useState)(0),oe=Ea({objectName:j.name,objectLabel:j.label,dataSource:e,onEdit:n,onRefresh:()=>ae(e=>e+1)}),se=O?{id:O.id,name:O.name,avatar:O.image}:Aa,[ce,le]=(0,J.useState)({open:!1,message:``}),[ue,de]=(0,J.useState)({open:!1,params:[]}),fe=(0,J.useCallback)((e,t)=>new Promise(n=>{le({open:!0,message:e,options:t,resolve:n})}),[]),pe=(0,J.useCallback)(e=>new Promise(t=>{de({open:!0,params:e,resolve:t})}),[]),me=(0,J.useCallback)((e,t)=>{t?.type===`error`?R.error(e):R.success(e)},[]),he=(0,J.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):r(e)},[r]),ge=(0,J.useCallback)(async t=>{try{let n=t.target||t.name,r=t.params||{};typeof e.execute==`function`?await e.execute(j.name,n,r):r.recordId&&Object.keys(r).length>1&&typeof e.update==`function`&&await e.update(j.name,r.recordId,r);let i=t.refreshAfter!==!1;return i&&ae(e=>e+1),{success:!0,reload:i}}catch(e){return{success:!1,error:e.message}}},[e,j.name]),{lastMessage:_e}=Mr({channel:`object:${j.name}`}),{hasConflicts:ve,resolveAllConflicts:ye}=Lr(j.name?`user-${j.name}`:`current-user`);(0,J.useEffect)(()=>{_e&&(ve&&ye(`remote`),ae(e=>e+1))},[_e,ve,ye]),(0,J.useEffect)(()=>{e?.find&&j.name&&e.find(j.name,{limit:0}).then(e=>{typeof e?.total==`number`?E(e.total):Array.isArray(e?.data)?E(e.data.length):Array.isArray(e)&&E(e.length)}).catch(()=>{})},[e,j.name,ie]);let be=(0,J.useMemo)(()=>F?.navigation??j.navigation??{mode:`page`},[F?.navigation,j.navigation]),xe=o.get(`recordId`),Se=(0,J.useCallback)((e,t)=>{if(t===`new_window`){let t=window.location.pathname.replace(/\/view\/.*$/,``);window.open(`${t}/record/${encodeURIComponent(String(e))}`,`_blank`);return}(t===`view`||!t||t===`page`)&&(a?r(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`}):r(`record/${encodeURIComponent(String(e))}`))},[r,a]),L=f({navigation:be,objectName:j.name,onNavigate:Se}),Ce=()=>{L.close();let e=new URLSearchParams(o);e.delete(`recordId`),s(e)};(0,J.useEffect)(()=>{xe&&!L.isOpen?L.open({id:xe}):!xe&&L.isOpen&&L.close()},[xe]);let we=(0,J.useCallback)(({schema:e,dataSource:t,onEdit:n,className:r})=>{let a=`${i}-${F.id}-${ie}`,o=F;if(o.type===`chart`){let e=o.chart||{};return(0,Y.jsx)(_i,{dataSource:t,schema:{type:`object-chart`,objectName:j.name,chartType:e.chartType,xAxisField:e.xAxisField,yAxisFields:e.yAxisFields,aggregation:e.aggregation,series:e.series,config:e.config,filter:e.filter}},a)}return(0,Y.jsx)(Zn,{schema:{...e,rowHeight:o.rowHeight??e.rowHeight,densityMode:o.densityMode??e.densityMode,inlineEdit:o.inlineEdit??o.editRecordsInline??e.inlineEdit,appearance:o.showDescription==null?e.appearance:{showDescription:o.showDescription},showSearch:o.showSearch??e.showSearch,showSort:o.showSort??e.showSort,showFilters:o.showFilters??e.showFilters,showHideFields:o.showHideFields??e.showHideFields,showGroup:o.showGroup??e.showGroup,showColor:o.showColor??e.showColor,showDensity:o.showDensity??e.showDensity,allowExport:o.allowExport??e.allowExport,exportOptions:o.allowExport===!1?void 0:o.exportOptions??e.exportOptions,striped:o.striped??e.striped,bordered:o.bordered??e.bordered,color:o.color??e.color,wrapHeaders:o.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:o.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:o.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:o.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:o.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:o.fieldTextColor??e.fieldTextColor,prefixField:o.prefixField??e.prefixField,showDescription:o.showDescription??e.showDescription,navigation:o.navigation??e.navigation,selection:o.selection??e.selection,pagination:o.pagination??e.pagination,searchableFields:o.searchableFields??e.searchableFields,filterableFields:o.filterableFields??e.filterableFields,resizable:o.resizable??e.resizable,hiddenFields:o.hiddenFields??e.hiddenFields,rowActions:o.rowActions??e.rowActions,bulkActions:o.bulkActions??e.bulkActions,sharing:o.sharing??e.sharing,addRecord:o.addRecord??e.addRecord,conditionalFormatting:o.conditionalFormatting??e.conditionalFormatting,quickFilters:o.quickFilters??e.quickFilters,userFilters:o.userFilters??e.userFilters,showRecordCount:o.showRecordCount??e.showRecordCount,allowPrinting:o.allowPrinting??e.allowPrinting,virtualScroll:o.virtualScroll??e.virtualScroll,emptyState:o.emptyState??e.emptyState,aria:o.aria??e.aria,tabs:e.tabs,...o.filter?.length?{filters:o.filter}:{},...o.sort?.length?{sort:o.sort}:{},options:{kanban:{groupBy:o.kanban?.groupByField||o.kanban?.groupField||`status`,groupField:o.kanban?.groupByField||o.kanban?.groupField||`status`,titleField:o.kanban?.titleField||j.titleField||`name`,cardFields:o.kanban?.columns},calendar:{startDateField:o.calendar?.startDateField||`due_date`,endDateField:o.calendar?.endDateField,titleField:o.calendar?.titleField||`name`,colorField:o.calendar?.colorField,allDayField:o.calendar?.allDayField,defaultView:o.calendar?.defaultView},timeline:{dateField:o.timeline?.dateField||`due_date`,titleField:o.timeline?.titleField||j.titleField||`name`,descriptionField:o.timeline?.descriptionField},map:{locationField:o.map?.locationField,titleField:o.map?.titleField||j.titleField||`name`,latitudeField:o.map?.latitudeField,longitudeField:o.map?.longitudeField,zoom:o.map?.zoom,center:o.map?.center},gallery:{imageField:o.gallery?.imageField||`image`,titleField:o.gallery?.titleField||j.titleField||`name`,subtitleField:o.gallery?.subtitleField},gantt:{startDateField:o.gantt?.startDateField||`start_date`,endDateField:o.gantt?.endDateField||`end_date`,titleField:o.gantt?.titleField||`name`,progressField:o.gantt?.progressField,dependenciesField:o.gantt?.dependenciesField,colorField:o.gantt?.colorField},chart:{chartType:o.chart?.chartType,xAxisField:o.chart?.xAxisField,yAxisFields:o.chart?.yAxisFields,aggregation:o.chart?.aggregation,series:o.chart?.series,config:o.chart?.config}}},className:r,onEdit:n,onRowClick:e=>{L.handleClick(e)},dataSource:t},a)},[F,j,i,ie,L]),Te=(0,J.useMemo)(()=>M.map(e=>e.id===N&&b&&b.id===e.id?{...e,...b}:e),[M,N,b]),Ee=(0,J.useMemo)(()=>({type:`object-view`,objectName:j.name,layout:`page`,showSearch:F?.showSearch!==!1,showFilters:F?.showFilters!==!1,showSort:F?.showSort!==!1,showCreate:!1,showRefresh:!0,allowCreateView:k,viewActions:k?[{type:`settings`},{type:`share`},{type:`duplicate`},{type:`delete`}]:[],onNavigate:(e,t)=>{t===`edit`?n?.({id:e}):t===`view`&&(a?r(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`}):r(`record/${encodeURIComponent(String(e))}`))}}),[j.name,n,F?.showSearch,F?.showFilters,F?.showSort,r,a,k]);return(0,Y.jsxs)(m,{context:{objectName:j.name,user:se},onConfirm:fe,onToast:me,onNavigate:he,onParamCollection:pe,handlers:{api:ge},children:[(0,Y.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-center py-2.5 sm:py-3 px-3 sm:px-4 border-b shrink-0 bg-background z-10`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`bg-primary/10 p-1.5 sm:p-2 rounded-md shrink-0`,children:(0,Y.jsx)(St,{className:`h-4 w-4 text-primary`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`text-base sm:text-lg font-semibold tracking-tight text-foreground truncate`,children:d(j)}),j.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground truncate hidden sm:block max-w-md`,children:p(j)})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:[A(j.name,`create`)&&(0,Y.jsxs)(I,{size:`sm`,onClick:oe.create,className:`shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9`,children:[(0,Y.jsx)(D,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:u(`console.objectView.new`)})]}),j.actions?.some(e=>e.locations?.includes(`list_toolbar`))&&(0,Y.jsx)(h,{schema:{type:`action:bar`,location:`list_toolbar`,actions:j.actions,size:`sm`,variant:`outline`}}),k&&(0,Y.jsxs)(st,{children:[(0,Y.jsx)(Ht,{asChild:!0,children:(0,Y.jsx)(I,{size:`sm`,variant:`ghost`,className:`shadow-none h-8 sm:h-9 px-2`,title:u(`console.objectView.designTools`),children:(0,Y.jsx)(Kt,{className:`h-4 w-4`})})}),(0,Y.jsxs)(Rt,{align:`end`,className:`w-48`,children:[(0,Y.jsxs)(z,{onClick:l,children:[(0,Y.jsx)(Bi,{open:c,onToggle:l,className:`hidden`}),u(`console.objectView.metadataInspector`)]}),(0,Y.jsx)(Zt,{}),(0,Y.jsxs)(z,{onClick:()=>{y(`edit`),_(e=>!e)},children:[(0,Y.jsx)(w,{className:`h-4 w-4 mr-2`}),u(`console.objectView.editView`)]}),(0,Y.jsxs)(z,{onClick:()=>{y(`create`),_(!0)},children:[(0,Y.jsx)(D,{className:`h-4 w-4 mr-2`}),u(`console.objectView.addView`)]})]})]})]})]}),M.length>1&&(0,Y.jsx)(`div`,{className:`border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0`,children:(0,Y.jsx)(ln,{views:M.map(e=>({id:e.id,label:e.label,type:e.type,hasActiveFilters:Array.isArray(e.filter)&&e.filter.length>0,hasActiveSort:Array.isArray(e.sort)&&e.sort.length>0})),activeViewId:N,onViewChange:te,viewTypeIcons:ka,config:{reorderable:!1}})}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-hidden relative flex flex-row`,children:[L.mode===`split`&&L.isOpen?(0,Y.jsx)(Yt,{...L,setIsOpen:e=>{e||Ce()},title:d(j),mainContent:(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`flex-1 relative overflow-auto p-3 sm:p-4`,children:(0,Y.jsx)(Ut,{schema:Ee,dataSource:e,views:Te,activeViewId:N,onViewChange:te,onEdit:e=>n?.(e),onRowClick:e=>{L.handleClick(e)},renderListView:we,onCreateView:ne,onViewAction:re})}),typeof T==`number`&&(0,Y.jsx)(`div`,{"data-testid":`record-count-footer`,className:`border-t px-3 sm:px-4 py-1.5 text-xs text-muted-foreground bg-muted/5 shrink-0`,children:u(`console.objectView.recordCount`,{count:T})})]}),children:t=>(0,Y.jsx)(ja,{objectDef:j,recordId:t.id||t._id,dataSource:e,onEdit:n})}):(0,Y.jsx)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:(0,Y.jsx)(`div`,{className:`flex-1 relative overflow-auto p-3 sm:p-4`,children:(0,Y.jsx)(Ut,{schema:Ee,dataSource:e,views:Te,activeViewId:N,onViewChange:te,onEdit:e=>n?.(e),onRowClick:e=>{L.handleClick(e)},renderListView:we,onCreateView:ne,onViewAction:re})})}),(0,Y.jsx)(Vi,{open:c&&k,sections:[{title:`View Configuration`,data:F},{title:`Object Definition`,data:j}]}),(0,Y.jsx)(`div`,{"data-testid":`view-config-panel-wrapper`,className:`transition-[max-width,opacity] duration-300 ease-in-out overflow-hidden ${g&&k?`max-w-[280px] opacity-100`:`max-w-0 opacity-0`}`,children:(0,Y.jsx)(Ta,{open:g&&k,onClose:()=>{_(!1),y(`edit`)},mode:v,activeView:F,objectDef:j,recordCount:T,onSave:S,onViewUpdate:ee,onCreate:C})})]}),L.mode!==`split`&&(0,Y.jsx)(Yt,{...L,setIsOpen:e=>{e||Ce()},title:j.label,className:L.mode===`drawer`?`w-[90vw] sm:max-w-2xl p-0 overflow-hidden`:void 0,children:t=>(0,Y.jsx)(ja,{objectDef:j,recordId:t.id||t._id,dataSource:e,onEdit:n})})]}),(0,Y.jsx)(Da,{state:ce,onOpenChange:e=>{e||le({open:!1,message:``})}}),(0,Y.jsx)(Oa,{state:ue,onOpenChange:e=>{e||de({open:!1,params:[]})}})]})}function Na({children:e,authUrl:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(void 0),[o,s]=(0,J.useState)(!0);return(0,J.useEffect)(()=>{let e=!1;async function t(){try{let t=new jn({baseUrl:``,autoReconnect:!1});await t.connect();let n=await t.getDiscovery();e||(n?.mode===`preview`?(a({autoLogin:n.previewMode?.autoLogin??!0,simulatedRole:n.previewMode?.simulatedRole??`admin`,simulatedUserName:n.previewMode?.simulatedUserName??`Preview User`,readOnly:n.previewMode?.readOnly??!1,expiresInSeconds:n.previewMode?.expiresInSeconds??0,bannerMessage:n.previewMode?.bannerMessage}),r(!1)):r(n?.services?.auth?.enabled??!0))}catch(t){e||(console.warn(`[ConditionalAuthWrapper] Failed to fetch discovery, defaulting to auth enabled:`,t),r(!0))}finally{e||s(!1)}}return t(),()=>{e=!0}},[]),o?(0,Y.jsx)(Z,{}):i?(0,Y.jsx)(Gn,{authUrl:t,previewMode:i,children:e}):n?(0,Y.jsx)(Gn,{authUrl:t,children:e}):(0,Y.jsx)(Gn,{authUrl:t,enabled:!1,children:e})}function Pa(){let{t:e}=q(),[t,n]=(0,J.useState)(!1),r=(0,J.useMemo)(()=>[{title:e(`console.shortcuts.groups.general`),shortcuts:[{keys:[`⌘`,`K`],description:e(`console.shortcuts.openCommandPalette`)},{keys:[`?`],description:e(`console.shortcuts.showShortcuts`)},{keys:[`Esc`],description:e(`console.shortcuts.closeDialog`)}]},{title:e(`console.shortcuts.groups.navigation`),shortcuts:[{keys:[`B`],description:e(`console.shortcuts.toggleSidebar`)},{keys:[`⌘`,`/`],description:e(`console.shortcuts.focusSearch`)}]},{title:e(`console.shortcuts.groups.dataViews`),shortcuts:[{keys:[`N`],description:e(`console.shortcuts.createRecord`)},{keys:[`R`],description:e(`console.shortcuts.refreshData`)},{keys:[`⌘`,`E`],description:e(`console.shortcuts.editRecord`)}]},{title:e(`console.shortcuts.groups.preferences`),shortcuts:[{keys:[`⌘`,`D`],description:e(`console.shortcuts.toggleDarkMode`)}]}],[e]);return(0,J.useEffect)(()=>{function e(e){let t=e.target;t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable||e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,Y.jsx)(Ae,{open:t,onOpenChange:n,children:(0,Y.jsxs)(k,{className:`sm:max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,Y.jsxs)(F,{children:[(0,Y.jsx)(M,{children:e(`console.shortcuts.title`)}),(0,Y.jsx)(Sn,{children:e(`console.shortcuts.description`)})]}),(0,Y.jsx)(`div`,{className:`space-y-6 pt-2`,children:r.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground mb-3`,children:e.title}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:e.shortcuts.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-sm`,children:e.description}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1`,children:e.keys.map((e,t)=>(0,Y.jsx)(`kbd`,{className:`inline-flex h-6 min-w-[24px] items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground`,children:e},t))})]},t))})]},e.title))})]})})}var Fa=`objectui-onboarding-dismissed`,Ia=[{icon:bt,title:`Navigate Your Apps`,description:`Use the sidebar to browse objects, dashboards, pages, and reports. Switch between apps using the dropdown in the sidebar header.`},{icon:ye,title:`Quick Search`,description:`Press ⌘K (or Ctrl+K) to open the command palette and quickly jump to any object, dashboard, or page.`},{icon:bn,title:`Favorites & Recent`,description:`Star frequently used items to pin them in the sidebar. Recently visited items also appear for quick access.`},{icon:pe,title:`Keyboard Shortcuts`,description:`Press ? to view all keyboard shortcuts. Use them to speed up your workflow with CRUD operations and navigation.`}];function La(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(0);(0,J.useEffect)(()=>{try{if(!localStorage.getItem(Fa)){let e=setTimeout(()=>t(!0),800);return()=>clearTimeout(e)}}catch{}},[]);let i=()=>{t(!1);try{localStorage.setItem(Fa,new Date().toISOString())}catch{}},a=()=>{n<Ia.length-1?r(e=>e+1):i()},o=Ia[n],s=o.icon,c=n===Ia.length-1;return(0,Y.jsx)(Ae,{open:e,onOpenChange:e=>{e||i()},children:(0,Y.jsxs)(k,{className:`sm:max-w-md`,children:[(0,Y.jsxs)(F,{children:[(0,Y.jsxs)(M,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(pe,{className:`h-5 w-5 text-primary`}),`Welcome to ObjectUI`]}),(0,Y.jsx)(Sn,{children:`Let's get you started with a quick tour.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6 text-center`,children:[(0,Y.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full bg-primary/10`,children:(0,Y.jsx)(s,{className:`h-8 w-8 text-primary`})}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold`,children:o.title}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:o.description})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Ia.map((e,t)=>(0,Y.jsx)(`button`,{className:`h-2 w-2 rounded-full transition-colors ${t===n?`bg-primary`:`bg-muted-foreground/30`}`,onClick:()=>r(t),"aria-label":`Go to step ${t+1}`},t))}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,Y.jsx)(I,{variant:`ghost`,size:`sm`,onClick:i,children:`Skip`}),(0,Y.jsxs)(I,{size:`sm`,onClick:a,children:[c?`Get Started`:`Next`,!c&&(0,Y.jsx)(Vt,{className:`ml-1 h-4 w-4`})]})]})]})})}var Ra=0;function za(e=`nav`){return`${e}_${Date.now()}_${++Ra}`}function Ba(e,t){return[...e,t]}function Va(e,t,n){return e.filter(e=>!(e.type===t&&(t===`page`&&e.pageName===n||t===`dashboard`&&e.dashboardName===n))).map(e=>e.children&&e.children.length>0?{...e,children:Va(e.children,t,n)}:e)}function Ha(e,t,n,r){return e.map(e=>{let i=e;return t===`page`&&e.type===`page`&&e.pageName===n?i={...e,pageName:r}:t===`dashboard`&&e.type===`dashboard`&&e.dashboardName===n&&(i={...e,dashboardName:r}),i.children&&i.children.length>0?{...i,children:Ha(i.children,t,n,r)}:i})}function Ua(e,t){return e.length===t.length?e===t?!0:JSON.stringify(e)===JSON.stringify(t):!1}function Wa(){let e=cr(),{apps:t,refresh:n}=or(),r=(0,J.useRef)(e);r.current=e;let i=(0,J.useRef)(n);i.current=n;let a=(0,J.useCallback)(async(e,t)=>{let n=r.current?.getClient();n&&await n.meta.saveItem(`app`,e,t),await i.current?.()},[]),o=(0,J.useCallback)(e=>t.find(t=>t.name===e),[t]),s=(0,J.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Ba(i,{id:za(`nav_page`),type:`page`,label:n||t,pageName:t,icon:`FileText`}),c={...r,navigation:s};try{await a(e,c),R.success(`Navigation updated: added page "${n||t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),c=(0,J.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Ba(i,{id:za(`nav_dash`),type:`dashboard`,label:n||t,dashboardName:t,icon:`LayoutDashboard`}),c={...r,navigation:s};try{await a(e,c),R.success(`Navigation updated: added dashboard "${n||t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),l=(0,J.useCallback)(async(e,t)=>{let n=o(e);if(!n)return;let r=n.navigation??[],i=Va(r,`page`,t);if(Ua(i,r))return;let s={...n,navigation:i};try{await a(e,s),R.success(`Navigation updated: removed page "${t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...n,navigation:r}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),u=(0,J.useCallback)(async(e,t)=>{let n=o(e);if(!n)return;let r=n.navigation??[],i=Va(r,`dashboard`,t);if(Ua(i,r))return;let s={...n,navigation:i};try{await a(e,s),R.success(`Navigation updated: removed dashboard "${t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...n,navigation:r}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),d=(0,J.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Ha(i,`page`,t,n);if(Ua(s,i))return;let c={...r,navigation:s};try{await a(e,c),R.success(`Navigation updated: renamed page "${t}" → "${n}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),f=(0,J.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Ha(i,`dashboard`,t,n);if(Ua(s,i))return;let c={...r,navigation:s};try{await a(e,c),R.success(`Navigation updated: renamed dashboard "${t}" → "${n}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),R.info(`Navigation change undone`)}catch{R.error(`Failed to undo navigation change`)}}}})}catch{R.error(`Failed to update navigation`)}},[o,a]),p=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return{syncPageCreated:s,syncDashboardCreated:c,syncPageDeleted:l,syncDashboardDeleted:u,syncPageRenamed:d,syncDashboardRenamed:f,syncPageCreatedAllApps:(0,J.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await s(t,e,n)}},[t,s]),syncDashboardCreatedAllApps:(0,J.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await c(t,e,n)}},[t,c]),syncPageDeletedAllApps:(0,J.useCallback)(async e=>{for(let n of t){let t=p(n);t&&await l(t,e)}},[t,l]),syncDashboardDeletedAllApps:(0,J.useCallback)(async e=>{for(let n of t){let t=p(n);t&&await u(t,e)}},[t,u]),syncPageRenamedAllApps:(0,J.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await d(t,e,n)}},[t,d]),syncDashboardRenamedAllApps:(0,J.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await f(t,e,n)}},[t,f])}}function Ga(){let{pages:e,dashboards:t,apps:n}=or(),r=cr(),i=(0,J.useRef)(r);i.current=r;let{syncPageCreated:a,syncDashboardCreated:o,syncPageDeleted:s,syncDashboardDeleted:c}=Wa(),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(0),f=(0,J.useRef)(!1),p=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return(0,J.useEffect)(()=>{if(f.current)return;let r=new Set((e??[]).map(e=>e.name).filter(Boolean)),i=new Set((t??[]).map(e=>e.name).filter(Boolean)),m=l.current,h=u.current;if(m===null||h===null){l.current=r,u.current=i;return}let g=[...r].filter(e=>!m.has(e)),_=[...m].filter(e=>!r.has(e)),v=[...i].filter(e=>!h.has(e)),y=[...h].filter(e=>!i.has(e));if(g.length===0&&_.length===0&&v.length===0&&y.length===0){l.current=r,u.current=i;return}let b=++d.current;f.current=!0;let x=!1;return(async()=>{try{for(let e of n){if(x||d.current!==b)break;let t=p(e);if(t){for(let e of g){if(x)break;await a(t,e)}for(let e of _){if(x)break;await s(t,e)}for(let e of v){if(x)break;await o(t,e)}for(let e of y){if(x)break;await c(t,e)}}}}finally{d.current===b&&(l.current=r,u.current=i,f.current=!1)}})(),()=>{x=!0}},[e,t,n,a,o,s,c]),null}function Ka(e){let{theme:t=`system`}=Wr();return(0,Y.jsx)(Tn,{theme:t,className:`toaster group`,icons:{success:(0,Y.jsx)(Ue,{className:`h-4 w-4`}),info:(0,Y.jsx)(nt,{className:`h-4 w-4`}),warning:(0,Y.jsx)(zt,{className:`h-4 w-4`}),error:(0,Y.jsx)(x,{className:`h-4 w-4`}),loading:(0,Y.jsx)(lt,{className:`h-4 w-4 animate-spin`})},toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-primary group-[.toast]:text-primary-foreground`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground`}},...e})}var qa=(0,J.lazy)(()=>W(()=>import(`./RecordDetailView-FkYkjMEZ.js`).then(e=>({default:e.RecordDetailView})),__vite__mapDeps([11,2,5,12,4,1,3,6,13,14,15]))),Ja=(0,J.lazy)(()=>W(()=>import(`./DashboardView-DxTi63mN.js`).then(e=>({default:e.DashboardView})),__vite__mapDeps([16,2,5,12,4,1,3,6,13,14,15]))),Ya=(0,J.lazy)(()=>W(()=>import(`./PageView-CzF68bdQ.js`).then(e=>({default:e.PageView})),__vite__mapDeps([17,2,5,1,3,4,6,15]))),Xa=(0,J.lazy)(()=>W(()=>import(`./ReportView-pQJYBCo1.js`).then(e=>({default:e.ReportView})),__vite__mapDeps([18,2,5,1,3,4,6,13,14,15]))),Za=(0,J.lazy)(()=>W(()=>import(`./SearchResultsPage-DJU7W1Zx.js`).then(e=>({default:e.SearchResultsPage})),__vite__mapDeps([19,2,5,1,3,4,6,15]))),Qa=(0,J.lazy)(()=>W(()=>import(`./CreateAppPage-Do3sVvxx.js`).then(e=>({default:e.CreateAppPage})),__vite__mapDeps([20,2,5,1,3,4,6,15,21]))),$a=(0,J.lazy)(()=>W(()=>import(`./EditAppPage-j0L1x2UT.js`).then(e=>({default:e.EditAppPage})),__vite__mapDeps([22,2,5,1,3,4,6,15,21]))),eo=(0,J.lazy)(()=>W(()=>import(`./PageDesignPage-B62v76Qo.js`).then(e=>({default:e.PageDesignPage})),__vite__mapDeps([23,2,5,1,3,4,6,15,21]))),to=(0,J.lazy)(()=>W(()=>import(`./DashboardDesignPage-B2PH_3Ly.js`).then(e=>({default:e.DashboardDesignPage})),__vite__mapDeps([24,2,5,1,3,4,6,15,21]))),no=(0,J.lazy)(()=>W(()=>import(`./LoginPage-D2CqpSi0.js`).then(e=>({default:e.LoginPage})),__vite__mapDeps([25,5,2,26,3,1,15,4,6]))),ro=(0,J.lazy)(()=>W(()=>import(`./RegisterPage-D7PJIabW.js`).then(e=>({default:e.RegisterPage})),__vite__mapDeps([27,5,2,26,3,1,15,4,6]))),io=(0,J.lazy)(()=>W(()=>import(`./ForgotPasswordPage-Slo6CHvD.js`).then(e=>({default:e.ForgotPasswordPage})),__vite__mapDeps([28,5,2,26,3,1,15,4,6]))),ao=(0,J.lazy)(()=>W(()=>import(`./SystemHubPage-BxKsLijB.js`).then(e=>({default:e.SystemHubPage})),__vite__mapDeps([29,2,5,1,3,4,6,15]))),oo=(0,J.lazy)(()=>W(()=>import(`./AppManagementPage-C3hg63SY.js`).then(e=>({default:e.AppManagementPage})),__vite__mapDeps([30,2,5,1,3,4,6,15]))),so=(0,J.lazy)(()=>W(()=>import(`./UserManagementPage-D2qUebpD.js`).then(e=>({default:e.UserManagementPage})),__vite__mapDeps([31,2,5,32,1,3,4,6]))),co=(0,J.lazy)(()=>W(()=>import(`./OrgManagementPage-BTNWvRHI.js`).then(e=>({default:e.OrgManagementPage})),__vite__mapDeps([33,2,5,32,1,3,4,6]))),lo=(0,J.lazy)(()=>W(()=>import(`./RoleManagementPage-cNU9Z5K1.js`).then(e=>({default:e.RoleManagementPage})),__vite__mapDeps([34,2,5,32,1,3,4,6]))),uo=(0,J.lazy)(()=>W(()=>import(`./PermissionManagementPage-PWrxdXgQ.js`).then(e=>({default:e.PermissionManagementPage})),__vite__mapDeps([35,2,5,32,1,3,4,6]))),fo=(0,J.lazy)(()=>W(()=>import(`./AuditLogPage-BQ8vLOcD.js`).then(e=>({default:e.AuditLogPage})),__vite__mapDeps([36,2,5,32,1,3,4,6]))),po=(0,J.lazy)(()=>W(()=>import(`./ProfilePage-CUo-xIgl.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([37,2,1,3,4,5,6])));function mo({children:e}){return(0,Y.jsx)(lr,{children:(0,Y.jsx)(ho,{children:e})})}function ho({children:e}){let t=cr();return t?(0,Y.jsx)(ar,{adapter:t,children:e}):(0,Y.jsx)(Z,{})}function go(){let[e,t]=(0,J.useState)(`disconnected`),{user:r}=Un(),i=cr(),a=Ln(),o=Pn(),{appName:s}=Hn(),{apps:c,objects:u,loading:f}=or(),p=c.filter(e=>e.active!==!1),m=c.find(e=>e.name===s)||p.find(e=>e.isDefault===!0)||p[0],[h,g]=(0,J.useState)(!1),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(0),{addRecentItem:S}=vr(),{execute:C,runner:w}=d();l({dataSource:i??void 0,onUndo:e=>{R.info(`Undo: ${e.description}`,{duration:4e3}),x(e=>e+1)},onRedo:e=>{R.info(`Redo: ${e.description}`,{duration:3e3}),x(e=>e+1)}}),(0,J.useEffect)(()=>{w.registerHandler(`crud_success`,async e=>(g(!1),x(e=>e+1),R.success(e.params?.message??`Record saved successfully`),{success:!0,reload:!0})),w.registerHandler(`dialog_cancel`,async()=>(g(!1),{success:!0}))},[w]),(0,J.useEffect)(()=>{if(!i)return;let e=i.onConnectionStateChange(e=>{t(e.state),e.error&&console.error(`[Console] Connection error:`,e.error)});return t(i.getConnectionState()),e},[i]);let T=o.pathname.split(`/`).filter(e=>e)[2];(T===`view`||T===`record`||T===`page`||T===`dashboard`||T===`design`)&&(T=``);let E=u.find(e=>e.name===T),D=(0,J.useCallback)(()=>{let e=E?.label||`Record`;C({type:`crud_success`,params:{message:v?`${e} updated successfully`:`${e} created successfully`}})},[C,v,E?.label]),O=(0,J.useCallback)(()=>{C({type:`dialog_cancel`})},[C]);(0,J.useEffect)(()=>{if(!m)return;let e=o.pathname.split(`/`).filter(Boolean),t=e[2];(t===`view`||t===`record`||t===`page`||t===`dashboard`||t===`design`)&&(t=``);let n=`/apps/${m.name}`,r=u;if(t){let e=r.find(e=>e.name===t);e&&S({id:`object:${e.name}`,label:e.label||e.name,href:`${n}/${e.name}`,type:`object`})}else e[2]===`dashboard`&&e[3]?S({id:`dashboard:${e[3]}`,label:e[3].replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),href:`${n}/dashboard/${e[3]}`,type:`dashboard`}):e[2]===`report`&&e[3]&&S({id:`report:${e[3]}`,label:e[3].replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),href:`${n}/report/${e[3]}`,type:`report`})},[o.pathname,S]);let k=e=>{y(e),g(!0)},A=e=>{a(`/apps/${e}`)},j=(0,J.useMemo)(()=>new n({user:r?{name:r.name,email:r.email,role:r.role??`user`}:{},app:m||{},data:v||{}}),[r,m,v]);if(!i||f)return(0,Y.jsx)(Z,{});let M=o.pathname.endsWith(`/create-app`),N=o.pathname.includes(`/system`);return!m&&!M&&!N?(0,Y.jsx)(`div`,{className:`h-screen flex items-center justify-center`,children:(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(Bt,{children:`No Apps Configured`}),(0,Y.jsx)(ct,{children:`No applications have been registered. Create your first app or visit System Settings to configure your environment.`}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-col sm:flex-row items-center gap-3`,children:[(0,Y.jsx)(I,{onClick:()=>a(`/create-app`),"data-testid":`create-first-app-btn`,children:`Create Your First App`}),(0,Y.jsx)(I,{variant:`outline`,onClick:()=>a(`/system`),"data-testid":`go-to-settings-btn`,children:`System Settings`})]})]})}):!m&&(M||N)?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsxs)(Bn,{children:[(0,Y.jsx)(K,{path:`create-app`,element:(0,Y.jsx)(Qa,{})}),(0,Y.jsx)(K,{path:`system`,element:(0,Y.jsx)(ao,{})}),(0,Y.jsx)(K,{path:`system/apps`,element:(0,Y.jsx)(oo,{})}),(0,Y.jsx)(K,{path:`system/users`,element:(0,Y.jsx)(so,{})}),(0,Y.jsx)(K,{path:`system/organizations`,element:(0,Y.jsx)(co,{})}),(0,Y.jsx)(K,{path:`system/roles`,element:(0,Y.jsx)(lo,{})}),(0,Y.jsx)(K,{path:`system/permissions`,element:(0,Y.jsx)(uo,{})}),(0,Y.jsx)(K,{path:`system/audit-log`,element:(0,Y.jsx)(fo,{})}),(0,Y.jsx)(K,{path:`system/profile`,element:(0,Y.jsx)(po,{})})]})}):(0,Y.jsxs)(dr,{user:r?{name:r.name,email:r.email,role:r.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},app:m,data:{},children:[(0,Y.jsx)(Ga,{}),(0,Y.jsxs)(oi,{activeAppName:m.name,activeApp:m,onAppChange:A,objects:u,connectionState:e,children:[(0,Y.jsx)(ci,{apps:c,activeApp:m,objects:u,onAppChange:A}),(0,Y.jsx)(Pa,{}),(0,Y.jsx)(La,{}),(0,Y.jsxs)(_,{dataSource:i||{},children:[(0,Y.jsx)(di,{children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsxs)(Bn,{children:[(0,Y.jsx)(K,{path:`/`,element:(0,Y.jsx)(Nn,{to:_o(m.navigation||[]),replace:!0})}),(0,Y.jsx)(K,{path:`:objectName`,element:(0,Y.jsx)(Ma,{dataSource:i,objects:u,onEdit:k})}),(0,Y.jsx)(K,{path:`:objectName/view/:viewId`,element:(0,Y.jsx)(Ma,{dataSource:i,objects:u,onEdit:k})}),(0,Y.jsx)(K,{path:`:objectName/record/:recordId`,element:(0,Y.jsx)(qa,{dataSource:i,objects:u,onEdit:k},b)}),(0,Y.jsx)(K,{path:`dashboard/:dashboardName`,element:(0,Y.jsx)(Ja,{dataSource:i})}),(0,Y.jsx)(K,{path:`report/:reportName`,element:(0,Y.jsx)(Xa,{dataSource:i})}),(0,Y.jsx)(K,{path:`page/:pageName`,element:(0,Y.jsx)(Ya,{})}),(0,Y.jsx)(K,{path:`design/page/:pageName`,element:(0,Y.jsx)(eo,{})}),(0,Y.jsx)(K,{path:`design/dashboard/:dashboardName`,element:(0,Y.jsx)(to,{})}),(0,Y.jsx)(K,{path:`search`,element:(0,Y.jsx)(Za,{})}),(0,Y.jsx)(K,{path:`create-app`,element:(0,Y.jsx)(Qa,{})}),(0,Y.jsx)(K,{path:`edit-app/:editAppName`,element:(0,Y.jsx)($a,{})}),(0,Y.jsx)(K,{path:`system`,element:(0,Y.jsx)(ao,{})}),(0,Y.jsx)(K,{path:`system/apps`,element:(0,Y.jsx)(oo,{})}),(0,Y.jsx)(K,{path:`system/users`,element:(0,Y.jsx)(so,{})}),(0,Y.jsx)(K,{path:`system/organizations`,element:(0,Y.jsx)(co,{})}),(0,Y.jsx)(K,{path:`system/roles`,element:(0,Y.jsx)(lo,{})}),(0,Y.jsx)(K,{path:`system/permissions`,element:(0,Y.jsx)(uo,{})}),(0,Y.jsx)(K,{path:`system/audit-log`,element:(0,Y.jsx)(fo,{})}),(0,Y.jsx)(K,{path:`system/profile`,element:(0,Y.jsx)(po,{})})]})})}),E&&(0,Y.jsx)(tt,{schema:{type:`object-form`,formType:`modal`,objectName:E.name,mode:v?`edit`:`create`,recordId:v?.id,title:`${v?`Edit`:`Create`} ${E?.label}`,description:v?`Update details for ${E?.label}`:`Add a new ${E?.label} to your database.`,open:h,onOpenChange:g,layout:`vertical`,fields:E.fields?Array.isArray(E.fields)?E.fields.filter(e=>typeof e==`string`?!0:pr(e.visible,j)).map(e=>typeof e==`string`?e:e.name):Object.entries(E.fields).filter(([e,t])=>pr(t.visible,j)).map(([e])=>e):[],onSuccess:D,onCancel:O,showSubmit:!0,showCancel:!0,submitText:`Save Record`,cancelText:`Cancel`},dataSource:i},v?.id||`new`)]})]})]})}function _o(e){if(!e||e.length===0)return``;for(let t of e){if(t.type===`object`)return t.viewName?`${t.objectName}/view/${t.viewName}`:`${t.objectName}`;if(t.type===`page`)return t.pageName?`page/${t.pageName}`:``;if(t.type===`dashboard`)return t.dashboardName?`dashboard/${t.dashboardName}`:``;if(t.type!==`url`&&t.type===`group`&&t.children){let e=_o(t.children);if(e!==``)return e}}return``}function vo(){let{apps:e,loading:t,error:n}=or(),r=Ln(),i=e.filter(e=>e.active!==!1),a=i.find(e=>e.isDefault===!0)||i[0];return t?(0,Y.jsx)(Z,{}):a?(0,Y.jsx)(Nn,{to:`/apps/${a.name}`,replace:!0}):(0,Y.jsx)(`div`,{className:`h-screen flex items-center justify-center`,children:(0,Y.jsxs)(cn,{children:[(0,Y.jsx)(Bt,{children:n?`Failed to Load Configuration`:`No Apps Configured`}),(0,Y.jsx)(ct,{children:n?`There was an error loading the configuration. You can still create an app or access System Settings.`:`No applications have been registered. Create your first app or configure your system.`}),(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-col sm:flex-row items-center gap-3`,children:[(0,Y.jsx)(I,{onClick:()=>r(`/create-app`),"data-testid":`create-first-app-btn`,children:`Create Your First App`}),(0,Y.jsx)(I,{variant:`outline`,onClick:()=>r(`/system`),"data-testid":`go-to-settings-btn`,children:`System Settings`})]})]})})}function yo(){return(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsxs)(Bn,{children:[(0,Y.jsx)(K,{path:`/`,element:(0,Y.jsx)(ao,{})}),(0,Y.jsx)(K,{path:`apps`,element:(0,Y.jsx)(oo,{})}),(0,Y.jsx)(K,{path:`users`,element:(0,Y.jsx)(so,{})}),(0,Y.jsx)(K,{path:`organizations`,element:(0,Y.jsx)(co,{})}),(0,Y.jsx)(K,{path:`roles`,element:(0,Y.jsx)(lo,{})}),(0,Y.jsx)(K,{path:`permissions`,element:(0,Y.jsx)(uo,{})}),(0,Y.jsx)(K,{path:`audit-log`,element:(0,Y.jsx)(fo,{})}),(0,Y.jsx)(K,{path:`profile`,element:(0,Y.jsx)(po,{})})]})})}function bo(){return(0,Y.jsxs)(Ur,{defaultTheme:`system`,storageKey:`object-ui-theme`,children:[(0,Y.jsx)(Ka,{position:`bottom-right`}),(0,Y.jsxs)(Na,{authUrl:`/api/v1/auth`,children:[(0,Y.jsx)(Kn,{}),(0,Y.jsx)(zn,{basename:`/console/`?.replace(/\/$/,``)||`/`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsxs)(Bn,{children:[(0,Y.jsx)(K,{path:`/login`,element:(0,Y.jsx)(no,{})}),(0,Y.jsx)(K,{path:`/register`,element:(0,Y.jsx)(ro,{})}),(0,Y.jsx)(K,{path:`/forgot-password`,element:(0,Y.jsx)(io,{})}),(0,Y.jsx)(K,{path:`/system/*`,element:(0,Y.jsx)(Jn,{fallback:(0,Y.jsx)(Nn,{to:`/login`}),loadingFallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsx)(mo,{children:(0,Y.jsx)(yo,{})})})}),(0,Y.jsx)(K,{path:`/create-app`,element:(0,Y.jsx)(Jn,{fallback:(0,Y.jsx)(Nn,{to:`/login`}),loadingFallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsx)(mo,{children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsx)(Qa,{})})})})}),(0,Y.jsx)(K,{path:`/apps/:appName/*`,element:(0,Y.jsx)(Jn,{fallback:(0,Y.jsx)(Nn,{to:`/login`}),loadingFallback:(0,Y.jsx)(Z,{}),children:(0,Y.jsx)(mo,{children:(0,Y.jsx)(go,{})})})}),(0,Y.jsx)(K,{path:`/`,element:(0,Y.jsx)(mo,{children:(0,Y.jsx)(vo,{})})})]})})})]})]})}async function xo(e){try{let t=await fetch(`/api/v1/i18n/translations/${e}`);if(!t.ok)return console.warn(`[i18n] Failed to load translations for '${e}': HTTP ${t.status}`),{};let n=await t.json();return n?.data?.translations&&typeof n.data.translations==`object`?n.data.translations:n}catch(t){return console.warn(`[i18n] Failed to load translations for '${e}':`,t),{}}}function So(){let e=typeof window<`u`?window.innerWidth:1024;return e<640?35:e<1024?50:60}function Co(){let e=typeof window<`u`?window.innerWidth:1024;return e<640?120:e<1024?200:300}function wo({tasks:e,viewMode:t=`month`,startDate:n,endDate:r,onTaskClick:i,onTaskUpdate:a,onViewChange:o,onAddClick:s,className:c,inlineEdit:l=!1}){let[u,d]=J.useState(new Date),[f,p]=J.useState(typeof window<`u`&&window.innerWidth<640?32:40),[m,h]=J.useState(So()),[g,_]=J.useState(null),[v,x]=J.useState({});J.useEffect(()=>{let e=()=>{p(window.innerWidth<640?32:40),h(So())};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let C=J.useMemo(()=>{let t=n?new Date(n):new Date,i=r?new Date(r):new Date;return!n&&e.length>0&&(t=new Date(Math.min(...e.map(e=>e.start.getTime()))),t.setDate(t.getDate()-7)),!r&&e.length>0&&(i=new Date(Math.max(...e.map(e=>e.end.getTime()))),i.setDate(i.getDate()+14)),t.setHours(0,0,0,0),i.setHours(23,59,59,999),{start:t,end:i}},[n,r,e]),w=J.useMemo(()=>{let e=[],t=new Date(C.start);for(;t<=C.end;)e.push({date:new Date(t),label:t.getDate().toString(),isWeekend:t.getDay()===0||t.getDay()===6}),t.setDate(t.getDate()+1);return e},[C]),T=Co(),E=J.useRef(null),O=J.useRef(null),k=J.useRef(null),A=e=>{E.current&&(E.current.scrollLeft=e.currentTarget.scrollLeft),O.current&&(O.current.scrollTop=e.currentTarget.scrollTop)},j=e=>{C.end.getTime()-C.start.getTime();let t=m,n=1e3*60*60*24,r=e.start.getTime()-C.start.getTime(),i=e.end.getTime()-e.start.getTime();return{left:r/n*t,width:Math.max(i/n*t,t)}};return(0,Y.jsxs)(`div`,{className:H(`flex flex-col h-full bg-background border rounded-lg overflow-hidden min-w-0`,c),children:[(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>s?.(),"aria-label":`Create new task`,children:[(0,Y.jsx)(D,{className:`h-4 w-4 mr-1 sm:mr-2`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`New Task`}),(0,Y.jsx)(`span`,{className:`sm:hidden`,children:`New`})]}),(0,Y.jsx)(`div`,{className:`h-4 w-px bg-border mx-1 sm:mx-2`}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`Previous period`,children:(0,Y.jsx)(ft,{className:`h-4 w-4`})}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`Next period`,children:(0,Y.jsx)(y,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:C.start.toLocaleDateString(void 0,{month:`long`,year:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(qe,{value:t,onValueChange:e=>o?.(e),children:[(0,Y.jsx)(pt,{className:`w-[100px] sm:w-[120px] h-8`,children:(0,Y.jsx)(fn,{})}),(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(S,{value:`day`,children:`Day View`}),(0,Y.jsx)(S,{value:`week`,children:`Week View`}),(0,Y.jsx)(S,{value:`month`,children:`Month View`}),(0,Y.jsx)(S,{value:`quarter`,children:`Quarter View`})]})]}),(0,Y.jsxs)(`div`,{className:`flex bg-muted rounded-md p-1`,children:[(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.max(15,e-10)),"aria-label":`Zoom out`,children:(0,Y.jsx)(De,{className:`h-3 w-3`})}),(0,Y.jsx)(I,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.min(120,e+10)),"aria-label":`Zoom in`,children:(0,Y.jsx)(b,{className:`h-3 w-3`})})]})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm`,style:{width:T,minWidth:T},children:[(0,Y.jsx)(`div`,{className:`flex-1`,children:`Task Name`}),(0,Y.jsx)(`div`,{className:`w-16 sm:w-20 text-right hidden sm:block`,children:`Start`}),(0,Y.jsx)(`div`,{className:`w-16 sm:w-20 text-right hidden sm:block`,children:`End`})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,ref:E,children:(0,Y.jsx)(`div`,{className:`flex h-full`,style:{width:w.length*m},children:w.map((e,t)=>(0,Y.jsxs)(`div`,{className:H(`flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full`,e.isWeekend&&`bg-muted/50`),style:{width:m,minWidth:m},children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-[10px] opacity-70`,children:e.date.toLocaleDateString(void 0,{weekday:`narrow`})})]},t))})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`overflow-hidden border-r bg-card z-10 shadow-sm`,ref:O,style:{width:T,minWidth:T},children:e.map(e=>{let t=l&&g===e.id;return(0,Y.jsxs)(`div`,{className:`flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation`,style:{height:f},onClick:()=>!t&&i?.(e),onDoubleClick:()=>{l&&a&&(_(e.id),x({title:e.title,start:e.start.toLocaleDateString(`en-CA`),end:e.end.toLocaleDateString(`en-CA`),progress:String(e.progress)}))},children:[(0,Y.jsxs)(`div`,{className:`flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:e.color||`#3b82f6`}}),t?(0,Y.jsx)(`input`,{className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:v.title||``,onChange:e=>x(t=>({...t,title:e.target.value})),onKeyDown:t=>{t.key===`Enter`?(a?.(e,{title:v.title,start:new Date(v.start),end:new Date(v.end),progress:Number(v.progress)||0}),_(null)):t.key===`Escape`&&_(null)},onClick:e=>e.stopPropagation(),autoFocus:!0}):(0,Y.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground sm:hidden`,children:[e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}),` → `,e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})]})]})]}),(0,Y.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,children:t?(0,Y.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:v.start||``,onChange:e=>x(t=>({...t,start:e.target.value})),onClick:e=>e.stopPropagation()}):e.start.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})}),(0,Y.jsx)(`div`,{className:`w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block`,children:t?(0,Y.jsx)(`input`,{type:`date`,className:`border rounded px-1 py-0.5 text-xs w-full bg-background`,value:v.end||``,onChange:e=>x(t=>({...t,end:e.target.value})),onClick:e=>e.stopPropagation()}):e.end.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`})})]},e.id)})}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]`,ref:k,onScroll:A,children:(0,Y.jsx)(`div`,{style:{width:w.length*m},children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 flex pointer-events-none z-0`,children:w.map((e,t)=>(0,Y.jsx)(`div`,{className:H(`border-r h-full`,e.isWeekend&&`bg-muted/20`),style:{width:m,minWidth:m}},t))}),e.map(e=>{let t=j(e);return(0,Y.jsx)(`div`,{className:`relative border-b hover:bg-black/5`,style:{height:f},children:(0,Y.jsxs)(`div`,{className:`absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm cursor-pointer hover:brightness-110 flex items-center px-2 group`,style:{left:t.left,width:t.width,backgroundColor:e.color||`#3b82f6`},onClick:()=>i?.(e),children:[e.progress>0&&(0,Y.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm`,style:{width:`${e.progress}%`}}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity`,children:[Math.round(e.progress),`%`]})]})},e.id)}),(0,Y.jsx)(`div`,{className:`absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none`,style:{left:(new Date().getTime()-C.start.getTime())/(1e3*60*60*24)*m},children:(0,Y.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-red-500 -ml-[3px]`})})]})})})]})]})]})}function To(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Eo(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Do(e){let t=null;if(e.startDateField&&e.endDateField)return t={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||`name`,progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},t;if(e.gantt&&(t=e.gantt),t){let e=er.safeParse(t);return e.success||console.warn(`[ObjectGantt] Invalid gantt configuration:`,e.error.format()),t}return null}var Oo=({schema:e,dataSource:t,className:n,onTaskClick:r,onRowClick:i,...o})=>{let[s,c]=(0,J.useState)([]),[l,u]=(0,J.useState)(!0),[d,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),_=To(e),v=(0,J.useMemo)(()=>_,[JSON.stringify(_)]),y=Do(e),b=v?.provider===`value`;(0,J.useEffect)(()=>{(async()=>{try{if(u(!0),o.data&&Array.isArray(o.data)){c(o.data),u(!1);return}if(b&&v?.provider===`value`){c(v.items),u(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(v?.provider===`object`){let n=v.object,r=a(h?.fields);c(p(await t.find(n,{$filter:e.filter,$orderby:Eo(e.sort),...r.length>0?{$expand:r}:{}})))}else v?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectGantt`),c([]));u(!1)}catch(e){m(e),u(!1)}})()},[v,t,b,e.filter,e.sort,h]),(0,J.useEffect)(()=>{!b&&t&&(async()=>{try{if(!t)return;let n=v?.provider===`object`?v.object:e.objectName;if(!n)return;g(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,b,v]);let x=(0,J.useMemo)(()=>{if(!y||!s.length)return[];let{startDateField:e,endDateField:t,titleField:n,progressField:r,dependenciesField:i,colorField:a}=y;return s.map((o,s)=>{let c=o[e],l=o[t],u=o[n]||`Untitled Task`,d=r?o[r]:0,f=i?o[i]:[],p=a?o[a]:void 0;return{id:o.id||o._id||`task-${s}`,title:u,start:c?new Date(c):new Date,end:l?new Date(l):new Date,progress:Math.min(100,Math.max(0,d||0)),dependencies:Array.isArray(f)?f:[],color:p,data:o}}).filter(e=>!isNaN(e.start.getTime())&&!isNaN(e.end.getTime()))},[s,y]),S=f({navigation:e.navigation,objectName:e.objectName,onRowClick:i});return l?(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading Gantt chart...`})})}):d?(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,d.message]})})}):y?(0,Y.jsxs)(`div`,{className:n,children:[(0,Y.jsx)(`div`,{className:`h-[calc(100vh-200px)] min-h-[600px]`,children:(0,Y.jsx)(wo,{tasks:x,onTaskClick:e=>{S.handleClick(e.data),r?.(e.data)},onAddClick:()=>{}})}),S.isOverlay&&(0,Y.jsx)(Yt,{...S,title:`Task Details`,children:e=>(0,Y.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Y.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]}):(0,Y.jsx)(`div`,{className:n,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:`Gantt configuration required. Please specify startDateField, endDateField, and titleField.`})})})},ko=({schema:e})=>{let{dataSource:n}=t()||{};return(0,Y.jsx)(Oo,{schema:e,dataSource:n})};r.register(`object-gantt`,ko,{namespace:`plugin-gantt`,label:`Object Gantt`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]}),r.register(`gantt`,ko,{namespace:`view`,label:`Gantt View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`gantt`,type:`object`,label:`Gantt Config`,description:`startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField`}]});var Ao=10080*60*1e3;function jo(e){let t=e.flatMap(e=>(e.items||[]).flatMap(e=>[e.startDate,e.endDate])),n=Math.min(...t.map(e=>new Date(e).getTime())),r=Math.max(...t.map(e=>new Date(e).getTime()));return{minDate:new Date(n).toISOString().split(`T`)[0],maxDate:new Date(r).toISOString().split(`T`)[0]}}function Mo(e,t,n,r){let i=new Date(e).getTime(),a=new Date(t).getTime(),o=new Date(n).getTime(),s=new Date(r).getTime()-o,c=i-o,l=a-i;return{start:c/s*100,width:l/s*100}}function No(e,t){let n=new Date(e);return t===`short`?n.toLocaleDateString():t===`long`?n.toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):n.toISOString().split(`T`)[0]}var Po=({schema:e,className:t,...n})=>{let{variant:r=`vertical`,items:i=[],dateFormat:a=`short`,onItemClick:o}=e;if(r===`vertical`)return(0,Y.jsx)(Lo,{className:t,...n,children:i.map((e,t)=>(0,Y.jsxs)(zo,{className:H(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,Y.jsx)(Vo,{variant:e.variant||`default`,children:e.icon&&(0,Y.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,Y.jsxs)(Ho,{children:[e.time&&(0,Y.jsx)(Wo,{dateTime:e.time,children:No(e.time,a)}),e.title&&(0,Y.jsx)(Uo,{children:e.title}),e.description&&(0,Y.jsx)(Go,{className:`line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&rt(e.content)]})]},t))});if(r===`horizontal`)return(0,Y.jsx)(Ko,{className:H(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,Y.jsxs)(qo,{className:H(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Y.jsx)(Vo,{variant:e.variant||`default`,children:e.icon&&(0,Y.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,Y.jsxs)(`div`,{className:`mt-4 text-center`,children:[e.time&&(0,Y.jsx)(Wo,{dateTime:e.time,children:No(e.time,a)}),e.title&&(0,Y.jsx)(Uo,{children:e.title}),e.description&&(0,Y.jsx)(Go,{className:`text-center line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&rt(e.content)]})]}),t<i.length-1&&(0,Y.jsx)(`div`,{className:`absolute left-full w-16 border-t-2 border-gray-200 top-3`})]},t))});if(r===`gantt`){let r=jo(i),s=e.minDate||r.minDate,c=e.maxDate||r.maxDate,l=e.timeScale||`month`,u=(()=>{let e=[],t=new Date(s),n=new Date(c);if(l===`month`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})),r.setMonth(r.getMonth()+1)}else if(l===`week`){let r=new Date(t);for(;r<=n;)e.push(`Week ${Math.ceil((r.getTime()-t.getTime())/Ao)+1}`),r.setDate(r.getDate()+7)}else if(l===`day`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})),r.setDate(r.getDate()+1)}return e})();return(0,Y.jsxs)(Jo,{className:H(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:[(0,Y.jsxs)(Yo,{children:[(0,Y.jsx)(Xo,{className:`flex items-center px-2 sm:px-4 py-2 sm:py-3`,children:(0,Y.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:e.rowLabel||`Items`})}),(0,Y.jsx)(Zo,{children:(0,Y.jsx)(`div`,{className:`flex h-full`,children:u.map((e,t)=>(0,Y.jsx)(`div`,{className:`flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center`,children:e},t))})})]}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`div`,{className:`flex`,children:[(0,Y.jsx)(Xo,{children:i.map((e,t)=>(0,Y.jsx)(Qo,{children:(0,Y.jsx)($o,{title:e.label,className:`truncate`,children:e.label})},t))}),(0,Y.jsx)(Zo,{className:`relative`,children:i.map((e,t)=>(0,Y.jsx)(Qo,{className:`relative`,children:(e.items||[]).map((n,r)=>{let i=Mo(n.startDate,n.endDate,s,c);return(0,Y.jsx)(es,{start:i.start,width:i.width,variant:n.variant||`default`,onClick:()=>o?.(n,e,t,r),title:`${n.title||``}\n${No(n.startDate,a)} - ${No(n.endDate,a)}`,children:(0,Y.jsx)(ts,{children:n.title})},r)})},t))})]})})]})}return null};r.register(`timeline`,Po,{namespace:`plugin-timeline`,label:`Timeline`,category:`data-display`,inputs:[{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],label:`Timeline Variant`,defaultValue:`vertical`},{name:`items`,type:`array`,label:`Timeline Items`,description:`For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }`},{name:`dateFormat`,type:`enum`,enum:[`short`,`long`,`iso`],label:`Date Format`,defaultValue:`short`},{name:`timeScale`,type:`enum`,enum:[`day`,`week`,`month`],label:`Time Scale (Gantt only)`,defaultValue:`month`},{name:`rowLabel`,type:`string`,label:`Row Label (Gantt only)`,defaultValue:`Items`},{name:`minDate`,type:`string`,label:`Min Date (Gantt only)`,description:`Override auto-calculated min date (YYYY-MM-DD)`},{name:`maxDate`,type:`string`,label:`Max Date (Gantt only)`,description:`Override auto-calculated max date (YYYY-MM-DD)`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{variant:`vertical`,dateFormat:`short`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`,icon:`🚀`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`,icon:`🎨`},{time:`2024-03-15`,title:`Beta Release`,description:`Released beta version to testers`,variant:`warning`,icon:`⚡`},{time:`2024-04-01`,title:`Launch`,description:`Official product launch`,variant:`success`,icon:`🎉`}]},examples:{vertical:{variant:`vertical`,dateFormat:`long`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`}]},horizontal:{variant:`horizontal`,dateFormat:`short`,items:[{time:`2024-01-01`,title:`Q1`,description:`First quarter`,variant:`default`},{time:`2024-04-01`,title:`Q2`,description:`Second quarter`,variant:`info`},{time:`2024-07-01`,title:`Q3`,description:`Third quarter`,variant:`warning`},{time:`2024-10-01`,title:`Q4`,description:`Fourth quarter`,variant:`success`}]},gantt:{variant:`gantt`,dateFormat:`short`,timeScale:`month`,rowLabel:`Projects`,items:[{label:`Backend Development`,items:[{title:`API Design`,startDate:`2024-01-01`,endDate:`2024-01-31`,variant:`success`},{title:`Implementation`,startDate:`2024-02-01`,endDate:`2024-03-31`,variant:`info`}]},{label:`Frontend Development`,items:[{title:`UI Design`,startDate:`2024-01-15`,endDate:`2024-02-15`,variant:`warning`},{title:`Component Dev`,startDate:`2024-02-15`,endDate:`2024-04-15`,variant:`default`}]},{label:`Testing`,items:[{title:`QA Phase`,startDate:`2024-03-01`,endDate:`2024-04-30`,variant:`danger`}]}]}}});var Fo=On({mapping:On({title:G().optional(),date:G().optional(),description:G().optional(),variant:G().optional()}).optional(),objectName:G().optional(),titleField:G().optional(),dateField:G().optional(),startDateField:G().optional(),endDateField:G().optional(),descriptionField:G().optional(),groupByField:G().optional(),colorField:G().optional(),scale:An([`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional()}),Io=({schema:e,dataSource:t,className:n,onRowClick:r,onItemClick:i,...s})=>{let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(0),[v,y]=(0,J.useState)(null),b=e.timeline;(0,J.useEffect)(()=>{let t=Fo.safeParse(e);t.success||console.warn(`[ObjectTimeline] Invalid timeline configuration:`,t.error.format())},[e]);let x=o(e.bind);(0,J.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||typeof t.getObjectSchema!=`function`||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&y(r)}catch(e){console.warn(`Failed to fetch object def for ObjectTimeline`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,J.useEffect)(()=>{e.objectName&&!x&&!e.items&&!s.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){d(!0);try{let n=a(v?.fields);l(p(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),h(e)}finally{d(!1)}}})()},[e.objectName,t,x,e.items,s.data,g,v]);let S=s.data||x||c,C=e.items;if(!C&&S&&Array.isArray(S)){let t=b?.titleField??e.mapping?.title??e.titleField??`name`,n=b?.startDateField??e.mapping?.date??e.startDateField??e.dateField??`date`,r=b?.endDateField??e.endDateField??n,i=e.mapping?.description??e.descriptionField??`description`,a=e.mapping?.variant??`variant`,o=b?.groupByField??e.groupByField,s=b?.colorField??e.colorField;C=S.map(e=>({title:e[t],time:e[n],startDate:e[n],endDate:e[r],description:e[i],variant:e[a]||`default`,...o?{group:e[o]}:{},...s?{color:e[s]}:{},_data:e}))}let{ref:w,isRefreshing:T,pullDistance:E}=Qe({onRefresh:(0,J.useCallback)(async()=>{_(e=>e+1)},[]),enabled:!!e.objectName&&!!t}),D=f({navigation:e.navigation,objectName:e.objectName,onRowClick:r??i}),O=b?.scale??e.scale,k={...e,items:C||[],className:n||e.className,...O?{timeScale:O}:{},onItemClick:e=>{let t=e._data||e;D.handleClick(t),i?.(t)}};return m?(0,Y.jsxs)(`div`,{className:`p-4 text-red-500`,children:[`Error loading timeline: `,m.message]}):(0,Y.jsxs)(`div`,{ref:w,className:`relative overflow-auto h-full min-w-0`,children:[E>0&&(0,Y.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:E},children:T?`Refreshing…`:`Pull to refresh`}),(0,Y.jsx)(Po,{schema:k}),D.isOverlay&&(0,Y.jsx)(Yt,{...D,title:`Timeline Item`,children:e=>(0,Y.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Y.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},Lo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`ol`,{ref:n,className:H(`relative border-l border-gray-200`,e),...t}));Lo.displayName=`Timeline`;var Ro=We(`ml-6`,{variants:{density:{default:`mb-10`,compact:`mb-3`,comfortable:`mb-6`}},defaultVariants:{density:`default`}}),zo=J.forwardRef(({className:e,density:t,...n},r)=>(0,Y.jsx)(`li`,{ref:r,className:H(Ro({density:t}),e),...n}));zo.displayName=`TimelineItem`;var Bo=We(`absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center`,{variants:{variant:{default:`bg-blue-200 border-blue-400`,success:`bg-emerald-200 border-emerald-500`,warning:`bg-amber-200 border-amber-500`,danger:`bg-red-200 border-red-500`,info:`bg-purple-200 border-purple-500`,todo:`bg-slate-200 border-slate-400`,"in-progress":`bg-blue-200 border-blue-500`,done:`bg-emerald-200 border-emerald-500`}},defaultVariants:{variant:`default`}}),Vo=J.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,Y.jsx)(`div`,{ref:r,className:H(Bo({variant:t}),e),...n}));Vo.displayName=`TimelineMarker`;var Ho=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:e,...t}));Ho.displayName=`TimelineContent`;var Uo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`h3`,{ref:n,className:H(`font-semibold text-lg mb-1`,e),...t}));Uo.displayName=`TimelineTitle`;var Wo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`time`,{ref:n,className:H(`text-sm font-normal text-gray-500 mb-2 block`,e),...t}));Wo.displayName=`TimelineTime`;var Go=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`p`,{ref:n,className:H(`text-base text-gray-700`,e),...t}));Go.displayName=`TimelineDescription`;var Ko=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`relative flex overflow-x-auto py-8`,e),...t}));Ko.displayName=`TimelineHorizontal`;var qo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`flex-shrink-0 w-64 relative`,e),...t}));qo.displayName=`TimelineHorizontalItem`;var Jo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`relative w-full border rounded-lg overflow-hidden`,e),...t}));Jo.displayName=`TimelineGantt`;var Yo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`flex border-b bg-gray-50`,e),...t}));Yo.displayName=`TimelineGanttHeader`;var Xo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`w-48 border-r bg-white`,e),...t}));Xo.displayName=`TimelineGanttRowLabels`;var Zo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`flex-1 overflow-x-auto`,e),...t}));Zo.displayName=`TimelineGanttGrid`;var Qo=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`flex items-center border-b min-h-12`,e),...t}));Qo.displayName=`TimelineGanttRow`;var $o=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`px-4 py-2 font-medium text-sm truncate`,e),...t}));$o.displayName=`TimelineGanttLabel`;var es=J.forwardRef(({className:e,start:t=0,width:n=100,variant:r=`default`,...i},a)=>(0,Y.jsx)(`div`,{ref:a,className:H(`absolute h-8 rounded-md transition-colors cursor-pointer`,{default:`bg-blue-500 hover:bg-blue-600`,success:`bg-green-500 hover:bg-green-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,danger:`bg-red-500 hover:bg-red-600`,info:`bg-purple-500 hover:bg-purple-600`}[r],e),style:{left:`${t}%`,width:`${n}%`},...i}));es.displayName=`TimelineGanttBar`;var ts=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,className:H(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));ts.displayName=`TimelineGanttBarContent`;var ns=({schema:e,...n})=>{let{dataSource:r}=t()||{};return(0,Y.jsx)(Io,{schema:e,dataSource:r,...n})};r.register(`object-timeline`,ns,{namespace:`plugin-timeline`,label:`Object Timeline`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]}),r.register(`timeline`,ns,{namespace:`view`,label:`Timeline View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]});var rs=J.createContext(null);function is(e,t){let n=Array.isArray(e)?e[0]:e?e.x:0,r=Array.isArray(e)?e[1]:e?e.y:0,i=Array.isArray(t)?t[0]:t?t.x:0,a=Array.isArray(t)?t[1]:t?t.y:0;return n===i&&r===a}function as(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!as(e[n],t[n]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!as(e[r],t[r]))return!1;return!0}return!1}function os(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function ss(e,t){let n=t.viewState||t,r={};if(`longitude`in n&&`latitude`in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){let t=e.center.constructor;r.center=new t(n.longitude,n.latitude)}return`zoom`in n&&n.zoom!==e.zoom&&(r.zoom=n.zoom),`bearing`in n&&n.bearing!==e.bearing&&(r.bearing=n.bearing),`pitch`in n&&n.pitch!==e.pitch&&(r.pitch=n.pitch),n.padding&&e.padding&&!as(n.padding,e.padding)&&(r.padding=n.padding),r}var cs=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function ls(e){if(!e)return null;if(typeof e==`string`||(`toJS`in e&&(e=e.toJS()),!e.layers))return e;let t={};for(let n of e.layers)t[n.id]=n;let n=e.layers.map(e=>{let n=null;`interactive`in e&&(n=Object.assign({},e),delete n.interactive);let r=t[e.ref];if(r){n||=Object.assign({},e),delete n.ref;for(let e of cs)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var us={version:8,sources:{},layers:[]},ds={mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,click:`onClick`,dblclick:`onDblClick`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,mouseout:`onMouseOut`,contextmenu:`onContextMenu`,touchstart:`onTouchStart`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchcancel:`onTouchCancel`},fs={movestart:`onMoveStart`,move:`onMove`,moveend:`onMoveEnd`,dragstart:`onDragStart`,drag:`onDrag`,dragend:`onDragEnd`,zoomstart:`onZoomStart`,zoom:`onZoom`,zoomend:`onZoomEnd`,rotatestart:`onRotateStart`,rotate:`onRotate`,rotateend:`onRotateEnd`,pitchstart:`onPitchStart`,pitch:`onPitch`,pitchend:`onPitchEnd`},ps={wheel:`onWheel`,boxzoomstart:`onBoxZoomStart`,boxzoomend:`onBoxZoomEnd`,boxzoomcancel:`onBoxZoomCancel`,resize:`onResize`,load:`onLoad`,render:`onRender`,idle:`onIdle`,remove:`onRemove`,data:`onData`,styledata:`onStyleData`,sourcedata:`onSourceData`,error:`onError`},ms=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],hs=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],gs=class e{constructor(e,t,n){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=e=>{let t=this.props[ps[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||os(this._map.transform);let t=this.props[fs[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=os(e),ss(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[ds[e.type]];t&&(this.props.interactiveLayerIds&&e.type!==`mouseover`&&e.type!==`mouseout`&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._MapClass=e,this.props=t,this._initialize(n)}get map(){return this._map}setProps(e){let t=this.props;this.props=e;let n=this._updateSettings(e,t),r=this._updateSize(e),i=this._updateViewState(e);this._updateStyle(e,t),this._updateStyleComponents(e),this._updateHandlers(e,t),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){let r=e.savedMaps.pop();if(!r)return null;let i=r.map,a=i.getContainer();for(n.className=a.className;a.childNodes.length>0;)n.appendChild(a.childNodes[0]);i._container=n;let o=i._resizeObserver;o&&(o.disconnect(),o.observe(n)),r.setProps({...t,styleDiffing:!1}),i.resize();let{initialViewState:s}=t;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s)),i.isStyleLoaded()?i.fire(`load`):i.once(`style.load`,()=>i.fire(`load`)),i._update(),r}_initialize(e){let{props:t}=this,{mapStyle:n=us}=t,r={...t,...t.initialViewState,container:e,style:ls(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),t.gl){let e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}let a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),t.cursor&&(a.getCanvas().style.cursor=t.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on(`style.load`,()=>{this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:a.getProjection?.(),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on(`sourcedata`,()=>{this._updateStyleComponents(this.props)});for(let e in ds)a.on(e,this._onPointerEvent);for(let e in fs)a.on(e,this._onCameraEvent);for(let e in ps)a.on(e,this._onEvent);this._map=a}recycle(){this.map.getContainer().querySelector(`[mapboxgl-children]`)?.remove(),e.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){let e=this._map;e.style&&(e._frame&&=(e._frame.cancel(),null),e._render())}_updateSize(e){let{viewState:t}=e;if(t){let e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e){let t=this._map,n=t.transform;if(!t.isMoving()){let r=ss(n,e);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(e,t){let n=this._map,r=!1;for(let i of ms)i in e&&!as(e[i],t[i])&&(r=!0,n[`set${i[0].toUpperCase()}${i.slice(1)}`]?.call(n,e[i]));return r}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||``),e.mapStyle!==t.mapStyle){let{mapStyle:t=us,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(ls(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style._loaded&&(e&&!as(e,a.light)&&(a.light=e,i.setLight(e)),t&&!as(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!as(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!as(r,a.terrain)&&(!r||i.getSource(r.source))&&(a.terrain=r,i.setTerrain(r)))}_updateHandlers(e,t){let n=this._map;for(let r of hs){let i=e[r]??!0;as(i,t[r]??!0)||(i?n[r].enable(i):n[r].disable())}}_queryRenderedFeatures(e){let t=this._map,{interactiveLayerIds:n=[]}=this.props;try{return t.queryRenderedFeatures(e,{layers:n.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(e){let{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){let t=e.type,n=this._hoveredFeatures?.length>0,r=this._queryRenderedFeatures(e.point),i=r.length>0;!i&&n&&(e.type=`mouseleave`,this._onPointerEvent(e)),this._hoveredFeatures=r,i&&!n&&(e.type=`mouseenter`,this._onPointerEvent(e)),e.type=t}else this._hoveredFeatures=null}};gs.savedMaps=[];var _s=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function vs(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of ys(t))!(e in n)&&!_s.includes(e)&&(n[e]=t[e].bind(t));return n}function ys(e){let t=new Set,n=e;for(;n;){for(let r of Object.getOwnPropertyNames(n))r[0]!==`_`&&typeof e[r]==`function`&&r!==`fire`&&r!==`setEventedParent`&&t.add(r);n=Object.getPrototypeOf(n)}return Array.from(t)}var bs=typeof document<`u`?J.useLayoutEffect:J.useEffect;function xs(e,t){let{RTLTextPlugin:n,maxParallelImageRequests:r,workerCount:i,workerUrl:a}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()===`unavailable`){let{pluginUrl:t,lazy:r=!0}=typeof n==`string`?{pluginUrl:n}:n;e.setRTLTextPlugin(t,e=>{e&&console.error(e)},r)}r!==void 0&&e.setMaxParallelImageRequests(r),i!==void 0&&e.setWorkerCount(i),a!==void 0&&e.setWorkerUrl(a)}var Ss=J.createContext(null);function Cs(t,n){let r=(0,J.useContext)(rs),[i,a]=(0,J.useState)(null),o=(0,J.useRef)(),{current:s}=(0,J.useRef)({mapLib:null,map:null});(0,J.useEffect)(()=>{let n=t.mapLib,i=!0,c;return Promise.resolve(n||W(()=>import(`./maplibre-gl-DsUGuDud.js`).then(t=>e(t.default,1)),__vite__mapDeps([38,2]))).then(e=>{if(!i)return;if(!e)throw Error(`Invalid mapLib`);let n=`Map`in e?e:e.default;if(!n.Map)throw Error(`Invalid mapLib`);xs(n,t),t.reuseMaps&&(c=gs.reuse(t,o.current)),c||=new gs(n.Map,t,o.current),s.map=vs(c),s.mapLib=n,a(c),r?.onMapMount(s.map,t.id)}).catch(e=>{let{onError:n}=t;n?n({type:`error`,target:null,originalEvent:null,error:e}):console.error(e)}),()=>{i=!1,c&&(r?.onMapUnmount(t.id),t.reuseMaps?c.recycle():c.destroy())}},[]),bs(()=>{i&&i.setProps(t)}),(0,J.useImperativeHandle)(n,()=>s.map,[i]);let c=(0,J.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]),l={height:`100%`};return J.createElement(`div`,{id:t.id,ref:o,style:c},i&&J.createElement(Ss.Provider,{value:s},J.createElement(`div`,{"mapboxgl-children":``,style:l},t.children)))}var ws=J.forwardRef(Cs),Ts=e(O(),1),Es=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function Ds(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!Es.test(e)?n[e]=`${r}px`:n[e]=r}}function Os(e,t){if(e===t)return null;let n=ks(e),r=ks(t),i=[];for(let e of r)n.has(e)||i.push(e);for(let e of n)r.has(e)||i.push(e);return i.length===0?null:i}function ks(e){return new Set(e?e.trim().split(/\s+/):[])}var As=(0,J.memo)((0,J.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,J.useContext)(Ss),i=(0,J.useRef)({props:e}),a=(0,J.useMemo)(()=>{let t=!1;J.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,J.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,J.useEffect)(()=>{Ds(a.getElement(),l)},[l]),(0,J.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!is(a.getOffset(),c)&&a.setOffset(c),a.isDraggable()!==u&&a.setDraggable(u),a.getRotation()!==f&&a.setRotation(f),a.getRotationAlignment()!==p&&a.setRotationAlignment(p),a.getPitchAlignment()!==m&&a.setPitchAlignment(m),a.getPopup()!==d&&a.setPopup(d);let g=Os(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,Ts.createPortal)(e.children,a.getElement())})),js=(0,J.memo)((0,J.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,J.useContext)(Ss),i=(0,J.useMemo)(()=>document.createElement(`div`),[]),a=(0,J.useRef)({props:e}),o=(0,J.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,J.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,J.useEffect)(()=>{Ds(o.getElement(),e.style)},[e.style]),(0,J.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!as(t.offset,e.offset)&&o.setOffset(e.offset),(t.anchor!==e.anchor||t.maxWidth!==e.maxWidth)&&(o.options.anchor=e.anchor,o.setMaxWidth(e.maxWidth));let n=Os(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,Ts.createPortal)(e.children,i)}));function Ms(e,t,n,r){let i=(0,J.useContext)(Ss),a=(0,J.useMemo)(()=>e(i),[]);return(0,J.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function Ns(e){let t=Ms(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,J.useEffect)(()=>{Ds(t._container,e.style)},[e.style]),null}(0,J.memo)(Ns);function Ps(e){let t=Ms(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,J.useEffect)(()=>{Ds(t._controlContainer,e.style)},[e.style]),null}(0,J.memo)(Ps);function Fs(e,t){let n=(0,J.useRef)({props:e}),r=Ms(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,J.useImperativeHandle)(t,()=>r,[]),(0,J.useEffect)(()=>{Ds(r._container,e.style)},[e.style]),null}(0,J.memo)((0,J.forwardRef)(Fs));function Is(e){let t=Ms(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,J.useEffect)(()=>{Ds(t._container,e.style)},[e.style]),null}var Ls=(0,J.memo)(Is);function Rs(e){let t=Ms(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,J.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,J.useEffect)(()=>{Ds(t._container,i)},[i]),null}(0,J.memo)(Rs);function zs(e){let t=Ms(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,J.useEffect)(()=>{Ds(t._container,e.style)},[e.style]),null}(0,J.memo)(zs);function Bs(e){let t=Ms(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,J.useEffect)(()=>{Ds(t._container,e.style)},[e.style]),null}(0,J.memo)(Bs);var Vs=On({latitudeField:G().optional(),longitudeField:G().optional(),locationField:G().optional(),titleField:G().optional(),descriptionField:G().optional(),zoom:kn().optional(),center:Mn([kn(),kn()]).optional()});function Hs(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function Us(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function Ws(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||`name`,descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let t=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?t=e.filter.map:e.map&&(t=e.map),t){let e=Vs.safeParse(t);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),t}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0]}}function Gs(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function Ks(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var qs=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:o,onDelete:s,enableClustering:c,clusterRadius:l=50,...u})=>{let[d,m]=(0,J.useState)([]),[h,g]=(0,J.useState)(!0),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(``),T=Hs(e),E=(0,J.useMemo)(()=>T,[JSON.stringify(T)]),D=Ws(e),O=E?.provider===`value`;(0,J.useEffect)(()=>{(async()=>{try{if(g(!0),u.data){let e=u.data;if(Array.isArray(e)){m(e),g(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),g(!1);return}}if(O&&E?.provider===`value`){m(E.items),g(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(E?.provider===`object`){let n=E.object,r=a(y?.fields);m(p(await t.find(n,{$filter:e.filter,$orderby:Us(e.sort),...r.length>0?{$expand:r}:{}})))}else E?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));g(!1)}catch(e){v(e),g(!1)}})()},[E,t,O,e.filter,e.sort,y]),(0,J.useEffect)(()=>{!O&&t&&(async()=>{try{if(!t)return;let n=E?.provider===`object`?E.object:e.objectName;if(!n)return;b(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,O,E]);let{markers:k,invalidCount:A}=(0,J.useMemo)(()=>{let e=0;return{markers:d.map((t,n)=>{let r=Gs(t,D);if(!r)return e++,null;let i=D.titleField?t[D.titleField]:`Marker`,a=D.descriptionField?t[D.descriptionField]:void 0,[o,s]=r;return!isFinite(o)||!isFinite(s)||o<-90||o>90||s<-180||s>180?(e++,null):{id:t.id||t._id||`marker-${n}`,title:i,description:a,coordinates:[s,o],data:t}}).filter(e=>e!==null),invalidCount:e}},[d,D]),j=(0,J.useMemo)(()=>k.find(e=>e.id===x),[k,x]),[M,N]=(0,J.useState)(D.zoom||3),P=f({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),F=(0,J.useMemo)(()=>{if(!C.trim())return k;let e=C.toLowerCase();return k.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[k,C]),ee=(0,J.useMemo)(()=>c??(e.enableClustering||F.length>100)?Ks(F,M,l):F.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[F,M,c,l,e]),te=(0,J.useMemo)(()=>{if(!F.length)return{longitude:D.center?.[1]||0,latitude:D.center?.[0]||0,zoom:D.zoom||2};let e=F.map(e=>e.coordinates[0]),t=F.map(e=>e.coordinates[1]),n=Math.min(...e),r=Math.max(...e),i=Math.min(...t),a=Math.max(...t);return{longitude:(n+r)/2,latitude:(i+a)/2,zoom:D.zoom||3}},[F,D]);return h?(0,Y.jsx)(`div`,{className:H(`min-w-0 overflow-hidden`,n),children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):_?(0,Y.jsx)(`div`,{className:H(`min-w-0 overflow-hidden`,n),children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Y.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,_.message]})})}):(0,Y.jsxs)(`div`,{className:H(`min-w-0 overflow-hidden`,n),children:[A>0&&(0,Y.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${A} record${A===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),k.length>0&&(0,Y.jsx)(`div`,{className:`mb-2`,children:(0,Y.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`Search locations…`,className:`w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),(0,Y.jsx)(`div`,{className:`relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full`,children:(0,Y.jsxs)(ws,{initialViewState:te,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>N(Math.round(e.viewState.zoom)),children:[(0,Y.jsx)(Ls,{position:`top-right`,showCompass:!0,showZoom:!0}),ee.map(e=>e.isCluster?(0,Y.jsx)(As,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md`,style:{width:Math.min(48,24+e.markers.length*2),height:Math.min(48,24+e.markers.length*2)},title:`${e.markers.length} markers`,children:e.markers.length})},e.id):(0,Y.jsx)(As,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];S(n.id),P.handleClick(n.data),r?.(n.data)},children:(0,Y.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),j&&(0,Y.jsx)(js,{longitude:j.coordinates[0],latitude:j.coordinates[1],anchor:`top`,onClose:()=>S(null),closeOnClick:!1,children:(0,Y.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Y.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:j.title}),j.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j.description}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[o&&(0,Y.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>o(j.data),children:`Edit`}),s&&(0,Y.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>s(j.data),children:`Delete`})]})]})})]})}),P.isOverlay&&(0,Y.jsx)(Yt,{...P,title:`Location Details`,children:e=>(0,Y.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Y.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},Js=({schema:e,...n})=>{let{dataSource:r}=t()||{};return(0,Y.jsx)(qs,{schema:e,dataSource:r,...n})};console.log(`Registering object-map...`),r.register(`object-map`,Js,{namespace:`plugin-map`,label:`Object Map`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]}),r.register(`map`,Js,{namespace:`view`,label:`Map View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]});var Ys=J.lazy(()=>W(()=>import(`./MarkdownImpl-B0Iew7iJ.js`),__vite__mapDeps([39,2,3])));r.register(`markdown`,({schema:e})=>(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fe,{className:`w-full h-[200px]`}),children:(0,Y.jsx)(Ys,{content:e.content||``,className:e.className})}),{namespace:`plugin-markdown`,label:`Markdown`,category:`plugin`,inputs:[{name:`content`,type:`string`,label:`Markdown Content`,required:!0,inputType:`textarea`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{content:`# Hello World
|
|
3
|
-
|
|
4
|
-
This is a **markdown** component with *formatting* support.
|
|
5
|
-
|
|
6
|
-
- Item 1
|
|
7
|
-
- Item 2
|
|
8
|
-
- Item 3`}});async function Xs(){tr.createRoot(document.getElementById(`root`)).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(wt,{pwa:{enabled:!0,name:`ObjectUI Console`,shortName:`Console`},children:(0,Y.jsx)(Wn,{loadLanguage:xo,children:(0,Y.jsx)(bo,{})})})}))}Xs();export{Vr as a,or as c,Hi as i,Da as n,X as o,Vi as r,cr as s,Oa as t};
|